D3D12: Fix Quad test screenshot and update texture
- Fix SetGraphicsRootDescriptorTable call order (SetRootSignature before SetPipelineState) - Rename texture earth_d.jpg -> earth.png - Fix vertex order for TriangleStrip quad rendering - Add integration test README - Add debug logging to D3D12Screenshot - Remove obsolete run.bat
This commit is contained in:
@@ -95,8 +95,6 @@ bool LoadTexture(const char* filename, D3D12Texture& texture, D3D12ShaderResourc
|
||||
return false;
|
||||
}
|
||||
|
||||
Log("[INFO] Loaded texture %s: %dx%d", filename, width, height);
|
||||
|
||||
allocator.Reset();
|
||||
commandList->Reset(allocator.GetCommandAllocator(), nullptr);
|
||||
|
||||
@@ -112,9 +110,8 @@ bool LoadTexture(const char* filename, D3D12Texture& texture, D3D12ShaderResourc
|
||||
queue.WaitForIdle();
|
||||
|
||||
texture.SetName(filename);
|
||||
stbi_image_free(pixels);
|
||||
|
||||
srvHeap.Initialize(device, DescriptorHeapType::CBV_SRV_UAV, 1);
|
||||
srvHeap.Initialize(device, DescriptorHeapType::CBV_SRV_UAV, 1, true);
|
||||
D3D12_SHADER_RESOURCE_VIEW_DESC srvDesc = D3D12ShaderResourceView::CreateDesc(Format::R8G8B8A8_UNorm, D3D12_SRV_DIMENSION_TEXTURE2D);
|
||||
srv.InitializeAt(device, texture.GetResource(), srvHeap.GetCPUDescriptorHandleForHeapStart(), &srvDesc);
|
||||
|
||||
@@ -263,8 +260,8 @@ bool InitD3D12() {
|
||||
Vertex vertices[] = {
|
||||
{ { -0.5f, -0.5f, 0.0f, 1.0f }, { 0.0f, 1.0f, 0.0f, 0.0f } },
|
||||
{ { -0.5f, 0.5f, 0.0f, 1.0f }, { 0.0f, 0.0f, 0.0f, 0.0f } },
|
||||
{ { 0.5f, 0.5f, 0.0f, 1.0f }, { 1.0f, 0.0f, 0.0f, 0.0f } },
|
||||
{ { 0.5f, -0.5f, 0.0f, 1.0f }, { 1.0f, 1.0f, 0.0f, 0.0f } },
|
||||
{ { 0.5f, 0.5f, 0.0f, 1.0f }, { 1.0f, 0.0f, 0.0f, 0.0f } },
|
||||
};
|
||||
|
||||
if (!gVertexBuffer.InitializeWithData(device, gCommandList.GetCommandList(), vertices, sizeof(vertices), D3D12_RESOURCE_STATE_VERTEX_AND_CONSTANT_BUFFER)) {
|
||||
@@ -274,7 +271,7 @@ bool InitD3D12() {
|
||||
gVertexBuffer.SetStride(sizeof(Vertex));
|
||||
gVertexBuffer.SetBufferType(BufferType::Vertex);
|
||||
|
||||
if (!LoadTexture("Res/Image/earth_d.jpg", gDiffuseTexture, gDiffuseSRV, device, gSRVHeap, gCommandList.GetCommandList(), gCommandAllocator, gCommandQueue)) {
|
||||
if (!LoadTexture("Res/Image/earth.png", gDiffuseTexture, gDiffuseSRV, device, gSRVHeap, gCommandList.GetCommandList(), gCommandAllocator, gCommandQueue)) {
|
||||
Log("[ERROR] Failed to load texture");
|
||||
return false;
|
||||
}
|
||||
@@ -384,24 +381,22 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine
|
||||
|
||||
BeginRender();
|
||||
|
||||
gCommandList.SetRootSignature(gRootSignature.GetRootSignature());
|
||||
gCommandList.SetPipelineState(gPipelineState.GetPipelineState());
|
||||
|
||||
ID3D12DescriptorHeap* heaps[] = { gSRVHeap.GetDescriptorHeap() };
|
||||
gCommandList.SetDescriptorHeaps(1, heaps);
|
||||
gCommandList.SetGraphicsRootDescriptorTable(0, gSRVHeap.GetGPUDescriptorHandleForHeapStart());
|
||||
|
||||
gCommandList.SetPipelineState(gPipelineState.GetPipelineState());
|
||||
gCommandList.SetRootSignature(gRootSignature.GetRootSignature());
|
||||
gCommandList.SetPrimitiveTopology(PrimitiveTopology::TriangleList);
|
||||
gCommandList.SetPrimitiveTopology(PrimitiveTopology::TriangleStrip);
|
||||
gCommandList.SetVertexBuffer(0, gVertexBuffer.GetResource(), 0, gVertexBuffer.GetStride());
|
||||
gCommandList.Draw(4, 1, 0, 0);
|
||||
|
||||
frameCount++;
|
||||
|
||||
if (frameCount >= targetFrameCount) {
|
||||
Log("[INFO] Reached target frame count %d - taking screenshot!", targetFrameCount);
|
||||
ExecuteCommandList();
|
||||
WaitForGPU();
|
||||
Log("[INFO] GPU idle, taking screenshot...");
|
||||
|
||||
|
||||
bool screenshotResult = D3D12Screenshot::Capture(
|
||||
gDevice,
|
||||
gCommandQueue,
|
||||
|
||||
Reference in New Issue
Block a user