| 382 | } |
| 383 | |
| 384 | void 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 | |
| 424 | void Skybox::RenderEnvironmentMap(ID3D12GraphicsCommandList* cmdList, const Float4x4& view, |
| 425 | const Float4x4& projection, const Texture* environmentMap, Float3 scale) |
nothing calls this directly
no test coverage detected