Add renderer backpack scene integration test

This commit is contained in:
2026-03-26 22:28:11 +08:00
parent 5735e769b0
commit 8bdb1f34c7
6 changed files with 435 additions and 7 deletions

View File

@@ -155,7 +155,7 @@ void D3D12Device::Shutdown() {
bool D3D12Device::CreateDXGIFactory(bool enableDebugLayer) {
UINT dxgiFactoryFlags = 0;
if (enableDebugLayer) {
if (enableDebugLayer) {
ID3D12Debug* debugController = nullptr;
if (SUCCEEDED(D3D12GetDebugInterface(IID_PPV_ARGS(&debugController)))) {
debugController->EnableDebugLayer();
@@ -342,7 +342,15 @@ RHITexture* D3D12Device::CreateTexture(const TextureDesc& desc) {
}
d3d12Desc.Layout = D3D12_TEXTURE_LAYOUT_UNKNOWN;
if (texture->Initialize(m_device.Get(), d3d12Desc)) {
const bool isDepthFormat = format == Format::D24_UNorm_S8_UInt ||
format == Format::D32_Float ||
format == Format::D16_UNorm;
const D3D12_RESOURCE_STATES initialState =
isDepthFormat ? D3D12_RESOURCE_STATE_DEPTH_WRITE : D3D12_RESOURCE_STATE_COMMON;
if (texture->Initialize(m_device.Get(), d3d12Desc, initialState)) {
if (isDepthFormat) {
texture->SetState(ResourceStates::DepthWrite);
}
return texture;
}
delete texture;

View File

@@ -91,7 +91,7 @@ RHI::GraphicsPipelineDesc CreatePipelineDesc(RHI::RHIType backendType, RHI::RHIP
pipelineDesc.topologyType = static_cast<uint32_t>(RHI::PrimitiveTopologyType::Triangle);
pipelineDesc.renderTargetCount = 1;
pipelineDesc.renderTargetFormats[0] = static_cast<uint32_t>(RHI::Format::R8G8B8A8_UNorm);
pipelineDesc.depthStencilFormat = static_cast<uint32_t>(RHI::Format::Unknown);
pipelineDesc.depthStencilFormat = static_cast<uint32_t>(RHI::Format::D24_UNorm_S8_UInt);
pipelineDesc.sampleCount = 1;
pipelineDesc.rasterizerState.fillMode = static_cast<uint32_t>(RHI::FillMode::Solid);
@@ -99,8 +99,9 @@ RHI::GraphicsPipelineDesc CreatePipelineDesc(RHI::RHIType backendType, RHI::RHIP
pipelineDesc.rasterizerState.frontFace = static_cast<uint32_t>(RHI::FrontFace::CounterClockwise);
pipelineDesc.rasterizerState.depthClipEnable = true;
pipelineDesc.depthStencilState.depthTestEnable = false;
pipelineDesc.depthStencilState.depthWriteEnable = false;
pipelineDesc.depthStencilState.depthTestEnable = true;
pipelineDesc.depthStencilState.depthWriteEnable = true;
pipelineDesc.depthStencilState.depthFunc = static_cast<uint32_t>(RHI::ComparisonFunc::Less);
pipelineDesc.depthStencilState.stencilEnable = false;
RHI::InputElementDesc position = {};
@@ -152,8 +153,10 @@ RHI::GraphicsPipelineDesc CreatePipelineDesc(RHI::RHIType backendType, RHI::RHIP
const Resources::Texture* FindMaterialTexture(const Resources::Material& material) {
static const char* kTextureNames[] = {
"baseColorTexture",
"_BaseColorTexture",
"_MainTex",
"albedoTexture",
"mainTexture",
"texture"
};
@@ -592,7 +595,8 @@ bool BuiltinForwardPipeline::DrawVisibleObject(
commandList->SetGraphicsDescriptorSets(kDescriptorFirstSet, 3, descriptorSets, m_pipelineLayout);
if (cachedMesh->indexBufferView != nullptr && section.indexCount > 0) {
commandList->DrawIndexed(section.indexCount, 1, section.startIndex, static_cast<int32_t>(section.baseVertex), 0);
// MeshLoader flattens section indices into a single global index buffer.
commandList->DrawIndexed(section.indexCount, 1, section.startIndex, 0, 0);
} else if (section.vertexCount > 0) {
commandList->Draw(section.vertexCount, 1, section.baseVertex, 0);
}