question

$$ANON_USER$$ avatar image
0 Votes"
$$ANON_USER$$ asked ·

Input Layout of UWP Directx12 example app.

 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 }"

windows-uwp
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

$$ANON_USER$$ avatar image
0 Votes"
$$ANON_USER$$ answered ·

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

· 1 ·
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hello, I'm glad you found a solution. You can describe your solution in detail and accept it as an answer, which will help more people who encounter the same problem.

0 Votes 0 ·