Input Layout of UWP Directx12 example app.

Anonymous
2020-05-29T21:51:02.343+00:00
void Sample3DSceneRenderer::CreateDeviceDependentResources()
{
//...... .....

    auto createPipelineStateTask = (createPSTask && createVSTask).then([this]() {

        static const D3D12_INPUT_ELEMENT_DESC inputLayout[] =
        {
            { "POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0, D3D12_INPUT_CLASSIFICATION_PER_VERTEX_DATA, 0 },
            { "COLOR", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 12, D3D12_INPUT_CLASSIFICATION_PER_VERTEX_DATA, 0 },
        };

        D3D12_GRAPHICS_PIPELINE_STATE_DESC state = {};
        state.InputLayout = { inputLayout, _countof(inputLayout) };
        state.pRootSignature = m_rootSignature.Get();
        state.VS = CD3DX12_SHADER_BYTECODE(&m_vertexShader[0], m_vertexShader.size());
        state.PS = CD3DX12_SHADER_BYTECODE(&m_pixelShader[0], m_pixelShader.size());
        state.RasterizerState = CD3DX12_RASTERIZER_DESC(D3D12_DEFAULT);
        state.BlendState = CD3DX12_BLEND_DESC(D3D12_DEFAULT);
        state.DepthStencilState = CD3DX12_DEPTH_STENCIL_DESC(D3D12_DEFAULT);
        state.SampleMask = UINT_MAX;
        state.PrimitiveTopologyType = D3D12_PRIMITIVE_TOPOLOGY_TYPE_TRIANGLE;
        state.NumRenderTargets = 1;
        state.RTVFormats[0] = m_deviceResources->GetBackBufferFormat();
        state.DSVFormat = m_deviceResources->GetDepthBufferFormat();
        state.SampleDesc.Count = 1;

        DX::ThrowIfFailed(m_deviceResources->GetD3DDevice()->CreateGraphicsPipelineState(&state, IID_PPV_ARGS(&m_pipelineState)));

        // Shader data can be deleted once the pipeline state is created.
        m_vertexShader.clear();
        m_pixelShader.clear();
    });

How is a 12 byte offset determined in the DirectX12 app as generated by Visual Studio?

"{ "COLOR", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, -->12 <--, D3D12_INPUT_CLASSIFICATION_PER_VERTEX_DATA, 0 }"

Universal Windows Platform (UWP)
0 comments No comments
{count} votes

Accepted answer
  1. Anonymous
    2020-05-30T20:38:19.323+00:00

    OK. For the size of position float counted at the C++ structure. I think I get that now.


0 additional answers

Sort by: Most helpful