MCPcopy Create free account
hub / github.com/TheRealMJP/DeferredTexturing / RenderCommon

Method RenderCommon

SampleFramework12/v1.00/Graphics/Skybox.cpp:384–422  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

382}
383
384void Skybox::RenderCommon(ID3D12GraphicsCommandList* cmdList, const Texture* environmentMap,
385 const Float4x4& view, const Float4x4& projection, Float3 scale)
386{
387 // Set the constants
388 vsConstantBuffer.Data.View = view;
389 vsConstantBuffer.Data.Projection = projection;
390 vsConstantBuffer.Upload();
391
392 psConstantBuffer.Data.Scale = scale;
393 psConstantBuffer.Upload();
394
395 // Set pipeline state
396 cmdList->SetPipelineState(pipelineState);
397 cmdList->SetGraphicsRootSignature(rootSignature);
398 cmdList->IASetPrimitiveTopology(D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
399
400 // Bind descriptors and constant buffers
401 D3D12_CPU_DESCRIPTOR_HANDLE psResources[1] = { environmentMap->SRV.CPUHandle };
402
403 DX12::BindShaderResources(cmdList, 0, ArraySize_(psResources), psResources, CmdListMode::Graphics, ShaderResourceType::SRV_UAV_CBV);
404 vsConstantBuffer.SetAsGfxRootParameter(cmdList, 1);
405 psConstantBuffer.SetAsGfxRootParameter(cmdList, 2);
406
407 // Set vertex/index buffers
408 D3D12_VERTEX_BUFFER_VIEW vbView = { };
409 vbView.BufferLocation = vertexBuffer.GPUAddress;
410 vbView.SizeInBytes = uint32(vertexBuffer.Size);
411 vbView.StrideInBytes = sizeof(Float3);
412 cmdList->IASetVertexBuffers(0, 1, &vbView);
413
414 D3D12_INDEX_BUFFER_VIEW ibView = { };
415 ibView.BufferLocation = indexBuffer.GPUAddress;
416 ibView.SizeInBytes = uint32(indexBuffer.Size);
417 ibView.Format = DXGI_FORMAT_R16_UINT;
418 cmdList->IASetIndexBuffer(&ibView);
419
420 // Draw
421 cmdList->DrawIndexedInstanced(NumIndices, 1, 0, 0, 0);
422}
423
424void Skybox::RenderEnvironmentMap(ID3D12GraphicsCommandList* cmdList, const Float4x4& view,
425 const Float4x4& projection, const Texture* environmentMap, Float3 scale)

Callers

nothing calls this directly

Calls 3

BindShaderResourcesFunction · 0.85
UploadMethod · 0.80
SetAsGfxRootParameterMethod · 0.80

Tested by

no test coverage detected