Update other graphics apis to match missing vertex shader inputs merging
This commit is contained in:
@@ -67,6 +67,11 @@ void DynamicBuffer::Dispose()
|
||||
Data.Resize(0);
|
||||
}
|
||||
|
||||
GPUVertexLayout* DynamicVertexBuffer::GetLayout() const
|
||||
{
|
||||
return _layout ? _layout : (GetBuffer() ? GetBuffer()->GetVertexLayout() : nullptr);
|
||||
}
|
||||
|
||||
void DynamicVertexBuffer::SetLayout(GPUVertexLayout* layout)
|
||||
{
|
||||
_layout = layout;
|
||||
|
||||
@@ -144,6 +144,8 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
// Gets the vertex buffer layout.
|
||||
GPUVertexLayout* GetLayout() const;
|
||||
// Sets the vertex buffer layout.
|
||||
void SetLayout(GPUVertexLayout* layout);
|
||||
|
||||
|
||||
@@ -208,12 +208,10 @@ GPUVertexLayout* GPUVertexLayout::Get(const Span<GPUVertexLayout*>& layouts)
|
||||
return result;
|
||||
}
|
||||
|
||||
GPUVertexLayout* GPUVertexLayout::Merge(GPUVertexLayout* base, const GPUVertexLayout* reference)
|
||||
GPUVertexLayout* GPUVertexLayout::Merge(GPUVertexLayout* base, GPUVertexLayout* reference)
|
||||
{
|
||||
if (!reference || !base || base == reference)
|
||||
return base;
|
||||
GPUVertexLayout* result = base;
|
||||
if (base && reference)
|
||||
GPUVertexLayout* result = base ? base : reference;
|
||||
if (base && reference && base != reference)
|
||||
{
|
||||
bool anyMissing = false;
|
||||
const Elements& baseElements = base->GetElements();
|
||||
|
||||
@@ -75,7 +75,7 @@ public:
|
||||
/// <param name="base">The list of vertex buffers for the layout.</param>
|
||||
/// <param name="reference">The list of reference inputs.</param>
|
||||
/// <returns>Vertex layout object. Doesn't need to be cleared as it's cached for an application lifetime.</returns>
|
||||
static GPUVertexLayout* Merge(GPUVertexLayout* base, const GPUVertexLayout* reference);
|
||||
static GPUVertexLayout* Merge(GPUVertexLayout* base, GPUVertexLayout* reference);
|
||||
|
||||
public:
|
||||
// [GPUResource]
|
||||
|
||||
@@ -26,8 +26,8 @@ ID3D11InputLayout* GPUShaderProgramVSDX11::GetInputLayout(GPUVertexLayoutDX11* v
|
||||
vertexLayout = (GPUVertexLayoutDX11*)Layout;
|
||||
if (vertexLayout && vertexLayout->InputElementsCount)
|
||||
{
|
||||
auto actualLayout = (GPUVertexLayoutDX11*)GPUVertexLayout::Merge(vertexLayout, Layout);
|
||||
LOG_DIRECTX_RESULT(vertexLayout->GetDevice()->GetDevice()->CreateInputLayout(actualLayout->InputElements, actualLayout->InputElementsCount, Bytecode.Get(), Bytecode.Length(), &inputLayout));
|
||||
auto mergedVertexLayout = (GPUVertexLayoutDX11*)GPUVertexLayout::Merge(vertexLayout, Layout);
|
||||
LOG_DIRECTX_RESULT(vertexLayout->GetDevice()->GetDevice()->CreateInputLayout(mergedVertexLayout->InputElements, mergedVertexLayout->InputElementsCount, Bytecode.Get(), Bytecode.Length(), &inputLayout));
|
||||
}
|
||||
_cache.Add(vertexLayout, inputLayout);
|
||||
}
|
||||
|
||||
@@ -49,8 +49,6 @@ bool GPUPipelineStateDX12::IsValid() const
|
||||
ID3D12PipelineState* GPUPipelineStateDX12::GetState(GPUTextureViewDX12* depth, int32 rtCount, GPUTextureViewDX12** rtHandles, GPUVertexLayoutDX12* vertexLayout)
|
||||
{
|
||||
ASSERT(depth || rtCount);
|
||||
if (!vertexLayout)
|
||||
vertexLayout = VertexLayout;
|
||||
|
||||
// Prepare key
|
||||
GPUPipelineStateKeyDX12 key;
|
||||
@@ -85,6 +83,7 @@ ID3D12PipelineState* GPUPipelineStateDX12::GetState(GPUTextureViewDX12* depth, i
|
||||
_desc.SampleDesc.Quality = key.MSAA == MSAALevel::None ? 0 : GPUDeviceDX12::GetMaxMSAAQuality((int32)key.MSAA);
|
||||
_desc.SampleMask = D3D12_DEFAULT_SAMPLE_MASK;
|
||||
_desc.DSVFormat = RenderToolsDX::ToDxgiFormat(PixelFormatExtensions::FindDepthStencilFormat(key.DepthFormat));
|
||||
vertexLayout = (GPUVertexLayoutDX12*)GPUVertexLayout::Merge(vertexLayout, VertexLayout);
|
||||
_desc.InputLayout.pInputElementDescs = vertexLayout ? vertexLayout->InputElements : nullptr;
|
||||
_desc.InputLayout.NumElements = vertexLayout ? vertexLayout->InputElementsCount : 0;
|
||||
|
||||
|
||||
@@ -205,8 +205,6 @@ PipelineLayoutVulkan* GPUPipelineStateVulkan::GetLayout()
|
||||
VkPipeline GPUPipelineStateVulkan::GetState(RenderPassVulkan* renderPass, GPUVertexLayoutVulkan* vertexLayout)
|
||||
{
|
||||
ASSERT(renderPass);
|
||||
if (!vertexLayout)
|
||||
vertexLayout = VertexShaderLayout;
|
||||
|
||||
// Try reuse cached version
|
||||
VkPipeline pipeline = VK_NULL_HANDLE;
|
||||
@@ -224,6 +222,7 @@ VkPipeline GPUPipelineStateVulkan::GetState(RenderPassVulkan* renderPass, GPUVer
|
||||
PROFILE_CPU_NAMED("Create Pipeline");
|
||||
|
||||
// Bind vertex input
|
||||
vertexLayout = (GPUVertexLayoutVulkan*)GPUVertexLayout::Merge(vertexLayout, VertexShaderLayout);
|
||||
_desc.pVertexInputState = vertexLayout ? &vertexLayout->CreateInfo : nullptr;
|
||||
|
||||
// Update description to match the pipeline
|
||||
|
||||
Reference in New Issue
Block a user