internal/graphicsdriver/directx: rename structs for a new DirectX 11 implementation

Updates #2613
This commit is contained in:
Hajime Hoshi 2023-03-26 00:28:57 +09:00
parent d6525a2782
commit 902d7244eb
5 changed files with 1340 additions and 1334 deletions

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -23,17 +23,13 @@ import (
"github.com/hajimehoshi/ebiten/v2/internal/graphicsdriver" "github.com/hajimehoshi/ebiten/v2/internal/graphicsdriver"
) )
type Image struct { type image12 struct {
graphics *Graphics graphics *graphics12
id graphicsdriver.ImageID id graphicsdriver.ImageID
width int width int
height int height int
screen bool screen bool
*image12
}
type image12 struct {
states [frameCount]_D3D12_RESOURCE_STATES states [frameCount]_D3D12_RESOURCE_STATES
texture *_ID3D12Resource texture *_ID3D12Resource
stencil *_ID3D12Resource stencil *_ID3D12Resource
@ -43,16 +39,16 @@ type image12 struct {
uploadingStagingBuffers []*_ID3D12Resource uploadingStagingBuffers []*_ID3D12Resource
} }
func (i *Image) ID() graphicsdriver.ImageID { func (i *image12) ID() graphicsdriver.ImageID {
return i.id return i.id
} }
func (i *Image) Dispose() { func (i *image12) Dispose() {
// Dipose the images later as this image might still be used. // Dipose the images later as this image might still be used.
i.graphics.removeImage(i) i.graphics.removeImage(i)
} }
func (i *Image) disposeImpl() { func (i *image12) disposeImpl() {
if i.dsvDescriptorHeap != nil { if i.dsvDescriptorHeap != nil {
i.dsvDescriptorHeap.Release() i.dsvDescriptorHeap.Release()
i.dsvDescriptorHeap = nil i.dsvDescriptorHeap = nil
@ -71,11 +67,11 @@ func (i *Image) disposeImpl() {
} }
} }
func (*Image) IsInvalidated() bool { func (*image12) IsInvalidated() bool {
return false return false
} }
func (i *Image) ReadPixels(buf []byte, x, y, width, height int) error { func (i *image12) ReadPixels(buf []byte, x, y, width, height int) error {
if i.screen { if i.screen {
return errors.New("directx: Pixels cannot be called on the screen") return errors.New("directx: Pixels cannot be called on the screen")
} }
@ -152,7 +148,7 @@ func (i *Image) ReadPixels(buf []byte, x, y, width, height int) error {
return nil return nil
} }
func (i *Image) WritePixels(args []*graphicsdriver.WritePixelsArgs) error { func (i *image12) WritePixels(args []*graphicsdriver.WritePixelsArgs) error {
if i.screen { if i.screen {
return errors.New("directx: WritePixels cannot be called on the screen") return errors.New("directx: WritePixels cannot be called on the screen")
} }
@ -247,21 +243,21 @@ func (i *Image) WritePixels(args []*graphicsdriver.WritePixelsArgs) error {
return nil return nil
} }
func (i *Image) resource() *_ID3D12Resource { func (i *image12) resource() *_ID3D12Resource {
if i.screen { if i.screen {
return i.graphics.renderTargets[i.graphics.frameIndex] return i.graphics.renderTargets[i.graphics.frameIndex]
} }
return i.texture return i.texture
} }
func (i *Image) state() _D3D12_RESOURCE_STATES { func (i *image12) state() _D3D12_RESOURCE_STATES {
if i.screen { if i.screen {
return i.states[i.graphics.frameIndex] return i.states[i.graphics.frameIndex]
} }
return i.states[0] return i.states[0]
} }
func (i *Image) setState(newState _D3D12_RESOURCE_STATES) { func (i *image12) setState(newState _D3D12_RESOURCE_STATES) {
if i.screen { if i.screen {
i.states[i.graphics.frameIndex] = newState i.states[i.graphics.frameIndex] = newState
return return
@ -269,7 +265,7 @@ func (i *Image) setState(newState _D3D12_RESOURCE_STATES) {
i.states[0] = newState i.states[0] = newState
} }
func (i *Image) transiteState(newState _D3D12_RESOURCE_STATES) (_D3D12_RESOURCE_BARRIER_Transition, bool) { func (i *image12) transiteState(newState _D3D12_RESOURCE_STATES) (_D3D12_RESOURCE_BARRIER_Transition, bool) {
if i.state() == newState { if i.state() == newState {
return _D3D12_RESOURCE_BARRIER_Transition{}, false return _D3D12_RESOURCE_BARRIER_Transition{}, false
} }
@ -288,14 +284,14 @@ func (i *Image) transiteState(newState _D3D12_RESOURCE_STATES) (_D3D12_RESOURCE_
}, true }, true
} }
func (i *Image) internalSize() (int, int) { func (i *image12) internalSize() (int, int) {
if i.screen { if i.screen {
return i.width, i.height return i.width, i.height
} }
return graphics.InternalImageSize(i.width), graphics.InternalImageSize(i.height) return graphics.InternalImageSize(i.width), graphics.InternalImageSize(i.height)
} }
func (i *Image) setAsRenderTarget(drawCommandList *_ID3D12GraphicsCommandList, device *_ID3D12Device, useStencil bool) error { func (i *image12) setAsRenderTarget(drawCommandList *_ID3D12GraphicsCommandList, device *_ID3D12Device, useStencil bool) error {
if err := i.ensureRenderTargetView(device); err != nil { if err := i.ensureRenderTargetView(device); err != nil {
return err return err
} }
@ -337,7 +333,7 @@ func (i *Image) setAsRenderTarget(drawCommandList *_ID3D12GraphicsCommandList, d
return nil return nil
} }
func (i *Image) ensureRenderTargetView(device *_ID3D12Device) error { func (i *image12) ensureRenderTargetView(device *_ID3D12Device) error {
if i.screen { if i.screen {
return nil return nil
} }
@ -366,7 +362,7 @@ func (i *Image) ensureRenderTargetView(device *_ID3D12Device) error {
return nil return nil
} }
func (i *Image) ensureDepthStencilView(device *_ID3D12Device) error { func (i *image12) ensureDepthStencilView(device *_ID3D12Device) error {
if i.screen { if i.screen {
return fmt.Errorf("directx: stencils are not available on the screen framebuffer") return fmt.Errorf("directx: stencils are not available on the screen framebuffer")
} }
@ -424,7 +420,7 @@ func (i *Image) ensureDepthStencilView(device *_ID3D12Device) error {
return nil return nil
} }
func (i *Image) releaseUploadingStagingBuffers() { func (i *image12) releaseUploadingStagingBuffers() {
for idx, buf := range i.uploadingStagingBuffers { for idx, buf := range i.uploadingStagingBuffers {
buf.Release() buf.Release()
i.uploadingStagingBuffers[idx] = nil i.uploadingStagingBuffers[idx] = nil

View File

@ -178,7 +178,7 @@ func (p *pipelineStates) initialize(device *_ID3D12Device) (ferr error) {
return nil return nil
} }
func (p *pipelineStates) drawTriangles(device *_ID3D12Device, commandList *_ID3D12GraphicsCommandList, frameIndex int, screen bool, srcs [graphics.ShaderImageCount]*Image, shader *Shader, dstRegions []graphicsdriver.DstRegion, uniforms []uint32, blend graphicsdriver.Blend, indexOffset int, evenOdd bool) error { func (p *pipelineStates) drawTriangles(device *_ID3D12Device, commandList *_ID3D12GraphicsCommandList, frameIndex int, screen bool, srcs [graphics.ShaderImageCount]*image12, shader *Shader, dstRegions []graphicsdriver.DstRegion, uniforms []uint32, blend graphicsdriver.Blend, indexOffset int, evenOdd bool) error {
idx := len(p.constantBuffers[frameIndex]) idx := len(p.constantBuffers[frameIndex])
if idx >= numDescriptorsPerFrame { if idx >= numDescriptorsPerFrame {
return fmt.Errorf("directx: too many constant buffers") return fmt.Errorf("directx: too many constant buffers")

View File

@ -37,7 +37,7 @@ type pipelineStateKey struct {
} }
type Shader struct { type Shader struct {
graphics *Graphics graphics *graphics12
id graphicsdriver.ShaderID id graphicsdriver.ShaderID
uniformTypes []shaderir.Type uniformTypes []shaderir.Type
uniformOffsets []int uniformOffsets []int