mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2025-02-05 23:44:31 +01:00
internal/graphicsdriver/directx: bug fix: wrong offsets
* Wrong offsets were speicified when creating a constant buffer view and a shader resource view. * Wrong root descriptor tables were speicified. For one draw command, one descriptor table for a constant buffer and textures should be used. Updates #2198 Closes #2201
This commit is contained in:
parent
ddaef29bc9
commit
4a17f6159a
@ -593,7 +593,7 @@ func (g *Graphics) End(present bool) error {
|
|||||||
|
|
||||||
// Release vertices and indices buffers when too many ones were created.
|
// Release vertices and indices buffers when too many ones were created.
|
||||||
// This is needed espciallly for testings, where present is always false.
|
// This is needed espciallly for testings, where present is always false.
|
||||||
if len(g.vertices[g.frameIndex]) >= 16 {
|
if len(g.vertices[g.frameIndex]) >= numDescriptorsPerFrame {
|
||||||
if err := g.waitForCommandQueue(); err != nil {
|
if err := g.waitForCommandQueue(); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -23,7 +23,7 @@ import (
|
|||||||
"github.com/hajimehoshi/ebiten/v2/internal/graphicsdriver"
|
"github.com/hajimehoshi/ebiten/v2/internal/graphicsdriver"
|
||||||
)
|
)
|
||||||
|
|
||||||
const numDescriptorsPerFrame = 256
|
const numDescriptorsPerFrame = 16
|
||||||
|
|
||||||
func operationToBlend(c graphicsdriver.Operation, alpha bool) _D3D12_BLEND {
|
func operationToBlend(c graphicsdriver.Operation, alpha bool) _D3D12_BLEND {
|
||||||
switch c {
|
switch c {
|
||||||
@ -389,7 +389,8 @@ func (p *pipelineStates) useGraphicsPipelineState(device *iD3D12Device, commandL
|
|||||||
p.constantBuffers[frameIndex][idx] = cb
|
p.constantBuffers[frameIndex][idx] = cb
|
||||||
|
|
||||||
h := p.shaderDescriptorHeap.GetCPUDescriptorHandleForHeapStart()
|
h := p.shaderDescriptorHeap.GetCPUDescriptorHandleForHeapStart()
|
||||||
h.Offset(int32(frameIndex*numDescriptorsPerFrame+numConstantBufferAndSourceTextures*idx), p.shaderDescriptorSize)
|
offset := int32(numConstantBufferAndSourceTextures * (frameIndex*numDescriptorsPerFrame + idx))
|
||||||
|
h.Offset(offset, p.shaderDescriptorSize)
|
||||||
device.CreateConstantBufferView(&_D3D12_CONSTANT_BUFFER_VIEW_DESC{
|
device.CreateConstantBufferView(&_D3D12_CONSTANT_BUFFER_VIEW_DESC{
|
||||||
BufferLocation: cb.GetGPUVirtualAddress(),
|
BufferLocation: cb.GetGPUVirtualAddress(),
|
||||||
SizeInBytes: bufferSize,
|
SizeInBytes: bufferSize,
|
||||||
@ -397,7 +398,8 @@ func (p *pipelineStates) useGraphicsPipelineState(device *iD3D12Device, commandL
|
|||||||
}
|
}
|
||||||
|
|
||||||
h := p.shaderDescriptorHeap.GetCPUDescriptorHandleForHeapStart()
|
h := p.shaderDescriptorHeap.GetCPUDescriptorHandleForHeapStart()
|
||||||
h.Offset(int32(frameIndex*numDescriptorsPerFrame+numConstantBufferAndSourceTextures*idx), p.shaderDescriptorSize)
|
offset := int32(numConstantBufferAndSourceTextures * (frameIndex*numDescriptorsPerFrame + idx))
|
||||||
|
h.Offset(offset, p.shaderDescriptorSize)
|
||||||
for _, src := range srcs {
|
for _, src := range srcs {
|
||||||
h.Offset(1, p.shaderDescriptorSize)
|
h.Offset(1, p.shaderDescriptorSize)
|
||||||
if src == nil {
|
if src == nil {
|
||||||
@ -437,9 +439,8 @@ func (p *pipelineStates) useGraphicsPipelineState(device *iD3D12Device, commandL
|
|||||||
|
|
||||||
// Match the indices with rootParams in graphicsPipelineState.
|
// Match the indices with rootParams in graphicsPipelineState.
|
||||||
gh := p.shaderDescriptorHeap.GetGPUDescriptorHandleForHeapStart()
|
gh := p.shaderDescriptorHeap.GetGPUDescriptorHandleForHeapStart()
|
||||||
gh.Offset(int32(frameIndex*numDescriptorsPerFrame+numConstantBufferAndSourceTextures*idx), p.shaderDescriptorSize)
|
gh.Offset(offset, p.shaderDescriptorSize)
|
||||||
commandList.SetGraphicsRootDescriptorTable(0, gh)
|
commandList.SetGraphicsRootDescriptorTable(0, gh)
|
||||||
gh.Offset(1, p.shaderDescriptorSize)
|
|
||||||
commandList.SetGraphicsRootDescriptorTable(1, gh)
|
commandList.SetGraphicsRootDescriptorTable(1, gh)
|
||||||
commandList.SetGraphicsRootDescriptorTable(2, p.samplerDescriptorHeap.GetGPUDescriptorHandleForHeapStart())
|
commandList.SetGraphicsRootDescriptorTable(2, p.samplerDescriptorHeap.GetGPUDescriptorHandleForHeapStart())
|
||||||
|
|
||||||
@ -456,21 +457,21 @@ func (p *pipelineStates) ensureRootSignature(device *iD3D12Device) (rootSignatur
|
|||||||
NumDescriptors: 1,
|
NumDescriptors: 1,
|
||||||
BaseShaderRegister: 0,
|
BaseShaderRegister: 0,
|
||||||
RegisterSpace: 0,
|
RegisterSpace: 0,
|
||||||
OffsetInDescriptorsFromTableStart: _D3D12_DESCRIPTOR_RANGE_OFFSET_APPEND,
|
OffsetInDescriptorsFromTableStart: 0,
|
||||||
}
|
}
|
||||||
srv := _D3D12_DESCRIPTOR_RANGE{
|
srv := _D3D12_DESCRIPTOR_RANGE{
|
||||||
RangeType: _D3D12_DESCRIPTOR_RANGE_TYPE_SRV, // t0
|
RangeType: _D3D12_DESCRIPTOR_RANGE_TYPE_SRV, // t0
|
||||||
NumDescriptors: graphics.ShaderImageNum,
|
NumDescriptors: graphics.ShaderImageNum,
|
||||||
BaseShaderRegister: 0,
|
BaseShaderRegister: 0,
|
||||||
RegisterSpace: 0,
|
RegisterSpace: 0,
|
||||||
OffsetInDescriptorsFromTableStart: _D3D12_DESCRIPTOR_RANGE_OFFSET_APPEND,
|
OffsetInDescriptorsFromTableStart: 1,
|
||||||
}
|
}
|
||||||
sampler := _D3D12_DESCRIPTOR_RANGE{
|
sampler := _D3D12_DESCRIPTOR_RANGE{
|
||||||
RangeType: _D3D12_DESCRIPTOR_RANGE_TYPE_SAMPLER, // s0
|
RangeType: _D3D12_DESCRIPTOR_RANGE_TYPE_SAMPLER, // s0
|
||||||
NumDescriptors: 1,
|
NumDescriptors: 1,
|
||||||
BaseShaderRegister: 0,
|
BaseShaderRegister: 0,
|
||||||
RegisterSpace: 0,
|
RegisterSpace: 0,
|
||||||
OffsetInDescriptorsFromTableStart: _D3D12_DESCRIPTOR_RANGE_OFFSET_APPEND,
|
OffsetInDescriptorsFromTableStart: 0,
|
||||||
}
|
}
|
||||||
|
|
||||||
rootParams := [...]_D3D12_ROOT_PARAMETER{
|
rootParams := [...]_D3D12_ROOT_PARAMETER{
|
||||||
|
Loading…
Reference in New Issue
Block a user