Removing the need for multiview

This commit is contained in:
2025-07-04 23:19:10 +02:00
parent b2cb8b42e4
commit bcdcc47eb3
3 changed files with 96 additions and 78 deletions
+2 -2
View File
@@ -70,11 +70,11 @@ struct VertexOutput
float3 localPos : LOCALPOS;
};
[shader("vertex")]
VertexOutput vertMain(uint vertexIndex : SV_VertexID, uint viewIndex : SV_ViewID)
VertexOutput vertMain(uint vertexIndex : SV_VertexID)
{
VertexOutput output;
output.localPos = vertices[vertexIndex];
output.svPos = mul(pViewParams.projection, mul(pViewParams.view[viewIndex], float4(output.localPos, 1)));
output.svPos = mul(pViewParams.projection, mul(pViewParams.view[vertexIndex / 6], float4(output.localPos, 1)));
return output;
}
+32 -13
View File
@@ -131,11 +131,19 @@ void EnvironmentLoader::import(EnvironmentImportArgs args, PEnvironmentMapAsset
.height = SOURCE_RESOLUTION,
.usage = Gfx::SE_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | Gfx::SE_IMAGE_USAGE_SAMPLED_BIT,
});
Array<Gfx::OTextureView> cubeViews;
cubeViews.add(cubeMap->createTextureView(0, 1, 0, 1));
cubeViews.add(cubeMap->createTextureView(0, 1, 1, 1));
cubeViews.add(cubeMap->createTextureView(0, 1, 2, 1));
cubeViews.add(cubeMap->createTextureView(0, 1, 3, 1));
cubeViews.add(cubeMap->createTextureView(0, 1, 4, 1));
cubeViews.add(cubeMap->createTextureView(0, 1, 5, 1));
for(uint32 i = 0; i < 6; ++i) {
Gfx::ORenderPass cubeRenderPass = graphics->createRenderPass(
Gfx::RenderTargetLayout{
.colorAttachments =
{
Gfx::RenderTargetAttachment(cubeMap->getDefaultView(), Gfx::SE_IMAGE_LAYOUT_UNDEFINED, Gfx::SE_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL,
Gfx::RenderTargetAttachment(cubeViews[i], Gfx::SE_IMAGE_LAYOUT_UNDEFINED, Gfx::SE_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL,
Gfx::SE_ATTACHMENT_LOAD_OP_DONT_CARE, Gfx::SE_ATTACHMENT_STORE_OP_STORE),
},
},
@@ -153,7 +161,7 @@ void EnvironmentLoader::import(EnvironmentImportArgs args, PEnvironmentMapAsset
.size = {SOURCE_RESOLUTION, SOURCE_RESOLUTION},
.offset = {0, 0},
},
"EnvironmentRenderPass", {0b111111}, {0b111111});
"EnvironmentRenderPass");
cubeRenderPipeline = graphics->createGraphicsPipeline(Gfx::LegacyPipelineCreateInfo{
.vertexShader = cubeRenderVertex,
.fragmentShader = cubeRenderFrag,
@@ -169,9 +177,17 @@ void EnvironmentLoader::import(EnvironmentImportArgs args, PEnvironmentMapAsset
renderCommand->bindPipeline(cubeRenderPipeline);
renderCommand->bindDescriptor({set});
renderCommand->setViewport(cubeRenderViewport);
renderCommand->draw(36, 1, 0, 0);
renderCommand->draw(6, 1, i*6, 0);
graphics->executeCommands(std::move(renderCommand));
graphics->endRenderPass();
}
set = cubeRenderLayout->allocateDescriptorSet();
set->updateConstants("view", 0, captureViews);
set->updateConstants("projection", 0, &captureProjection);
set->updateSampler("sampler", 0, cubeSampler);
set->updateTexture("cubeMap", 0, cubeMap->getDefaultView());
set->writeChanges();
Gfx::OTextureCube convolutedMap = graphics->createTextureCube(TextureCreateInfo{
.format = Gfx::SE_FORMAT_R32G32B32A32_SFLOAT,
@@ -179,9 +195,17 @@ void EnvironmentLoader::import(EnvironmentImportArgs args, PEnvironmentMapAsset
.height = CONVOLUTED_RESOLUTION,
.usage = Gfx::SE_IMAGE_USAGE_COLOR_ATTACHMENT_BIT,
});
Array<Gfx::OTextureView> convolutedViews;
convolutedViews.add(cubeMap->createTextureView(0, 1, 0, 1));
convolutedViews.add(cubeMap->createTextureView(0, 1, 1, 1));
convolutedViews.add(cubeMap->createTextureView(0, 1, 2, 1));
convolutedViews.add(cubeMap->createTextureView(0, 1, 3, 1));
convolutedViews.add(cubeMap->createTextureView(0, 1, 4, 1));
convolutedViews.add(cubeMap->createTextureView(0, 1, 5, 1));
for(uint32 i = 0; i < 6; ++i) {
Gfx::ORenderPass convolutionPass = graphics->createRenderPass(
Gfx::RenderTargetLayout{
.colorAttachments = {Gfx::RenderTargetAttachment(convolutedMap->getDefaultView(), Gfx::SE_IMAGE_LAYOUT_UNDEFINED,
.colorAttachments = {Gfx::RenderTargetAttachment(convolutedViews[i], Gfx::SE_IMAGE_LAYOUT_UNDEFINED,
Gfx::SE_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL,
Gfx::SE_ATTACHMENT_LOAD_OP_DONT_CARE, Gfx::SE_ATTACHMENT_STORE_OP_STORE)},
},
@@ -190,7 +214,7 @@ void EnvironmentLoader::import(EnvironmentImportArgs args, PEnvironmentMapAsset
.size = {CONVOLUTED_RESOLUTION, CONVOLUTED_RESOLUTION},
.offset = {0, 0},
},
"EnvironmentRenderPass", {0b111111}, {0b111111});
"EnvironmentRenderPass");
convolutionPipeline = graphics->createGraphicsPipeline(Gfx::LegacyPipelineCreateInfo{
.vertexShader = cubeRenderVertex,
.fragmentShader = convolutionFrag,
@@ -202,22 +226,17 @@ void EnvironmentLoader::import(EnvironmentImportArgs args, PEnvironmentMapAsset
},
});
set = cubeRenderLayout->allocateDescriptorSet();
set->updateConstants("view", 0, captureViews);
set->updateConstants("projection", 0, &captureProjection);
set->updateSampler("sampler", 0, cubeSampler);
set->updateTexture("cubeMap", 0, cubeMap->getDefaultView());
set->writeChanges();
graphics->beginRenderPass(convolutionPass);
Gfx::ORenderCommand cmd = graphics->createRenderCommand("ConvolutionPass");
cmd->bindPipeline(convolutionPipeline);
cmd->bindDescriptor({set});
cmd->setViewport(convolutionViewport);
cmd->draw(36, 1, 0, 0);
cmd->draw(6, 1, i*6, 0);
graphics->executeCommands(std::move(cmd));
graphics->endRenderPass();
}
asset->skybox = std::move(cubeMap);
asset->irradianceMap = std::move(convolutedMap);
graphics->waitDeviceIdle();
-1
View File
@@ -905,7 +905,6 @@ void Graphics::createDevice(GraphicsInitializer initializer) {
// required for spirv_1_4
initializer.deviceExtensions.add(VK_KHR_SHADER_FLOAT_CONTROLS_EXTENSION_NAME);
}
initializer.deviceExtensions.add(VK_KHR_MULTIVIEW_EXTENSION_NAME);
#ifdef __APPLE__
initializer.deviceExtensions.add("VK_KHR_portability_subset");
#endif