mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-11-10 04:57:26 +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
42d5d91829
commit
b3267a7126
@ -758,7 +758,7 @@ func (g *Graphics) End(present bool) error {
|
||||
|
||||
// Release vertices and indices buffers when too many ones were created.
|
||||
// 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 {
|
||||
return err
|
||||
}
|
||||
|
@ -23,7 +23,7 @@ import (
|
||||
"github.com/hajimehoshi/ebiten/v2/internal/graphicsdriver"
|
||||
)
|
||||
|
||||
const numDescriptorsPerFrame = 256
|
||||
const numDescriptorsPerFrame = 16
|
||||
|
||||
func operationToBlend(c graphicsdriver.Operation, alpha bool) _D3D12_BLEND {
|
||||
switch c {
|
||||
@ -402,7 +402,8 @@ func (p *pipelineStates) useGraphicsPipelineState(device *_ID3D12Device, command
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
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{
|
||||
BufferLocation: cb.GetGPUVirtualAddress(),
|
||||
SizeInBytes: bufferSize,
|
||||
@ -422,7 +423,8 @@ func (p *pipelineStates) useGraphicsPipelineState(device *_ID3D12Device, command
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
h.Offset(int32(frameIndex*numDescriptorsPerFrame+numConstantBufferAndSourceTextures*idx), p.shaderDescriptorSize)
|
||||
offset := int32(numConstantBufferAndSourceTextures * (frameIndex*numDescriptorsPerFrame + idx))
|
||||
h.Offset(offset, p.shaderDescriptorSize)
|
||||
for _, src := range srcs {
|
||||
h.Offset(1, p.shaderDescriptorSize)
|
||||
if src == nil {
|
||||
@ -459,9 +461,8 @@ func (p *pipelineStates) useGraphicsPipelineState(device *_ID3D12Device, command
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
gh.Offset(int32(frameIndex*numDescriptorsPerFrame+numConstantBufferAndSourceTextures*idx), p.shaderDescriptorSize)
|
||||
gh.Offset(offset, p.shaderDescriptorSize)
|
||||
commandList.SetGraphicsRootDescriptorTable(0, gh)
|
||||
gh.Offset(1, p.shaderDescriptorSize)
|
||||
commandList.SetGraphicsRootDescriptorTable(1, gh)
|
||||
sh, err := p.samplerDescriptorHeap.GetGPUDescriptorHandleForHeapStart()
|
||||
if err != nil {
|
||||
@ -482,21 +483,21 @@ func (p *pipelineStates) ensureRootSignature(device *_ID3D12Device) (rootSignatu
|
||||
NumDescriptors: 1,
|
||||
BaseShaderRegister: 0,
|
||||
RegisterSpace: 0,
|
||||
OffsetInDescriptorsFromTableStart: _D3D12_DESCRIPTOR_RANGE_OFFSET_APPEND,
|
||||
OffsetInDescriptorsFromTableStart: 0,
|
||||
}
|
||||
srv := _D3D12_DESCRIPTOR_RANGE{
|
||||
RangeType: _D3D12_DESCRIPTOR_RANGE_TYPE_SRV, // t0
|
||||
NumDescriptors: graphics.ShaderImageCount,
|
||||
BaseShaderRegister: 0,
|
||||
RegisterSpace: 0,
|
||||
OffsetInDescriptorsFromTableStart: _D3D12_DESCRIPTOR_RANGE_OFFSET_APPEND,
|
||||
OffsetInDescriptorsFromTableStart: 1,
|
||||
}
|
||||
sampler := _D3D12_DESCRIPTOR_RANGE{
|
||||
RangeType: _D3D12_DESCRIPTOR_RANGE_TYPE_SAMPLER, // s0
|
||||
NumDescriptors: 1,
|
||||
BaseShaderRegister: 0,
|
||||
RegisterSpace: 0,
|
||||
OffsetInDescriptorsFromTableStart: _D3D12_DESCRIPTOR_RANGE_OFFSET_APPEND,
|
||||
OffsetInDescriptorsFromTableStart: 0,
|
||||
}
|
||||
|
||||
rootParams := [...]_D3D12_ROOT_PARAMETER{
|
||||
|
Loading…
Reference in New Issue
Block a user