fixed undefined behavior in volumetric cloud and aerial perspective cubemap capture

This commit is contained in:
Turánszki János
2026-02-08 14:21:11 +01:00
parent 8beff1fd7f
commit d1856f0e7f
4 changed files with 5 additions and 9 deletions
@@ -1720,10 +1720,10 @@ struct AerialPerspectiveCapturePushConstants
uint2 resolution;
float2 resolution_rcp;
int texture_input;
int texture_output;
float padding0;
float padding1;
float padding2;
};
struct VolumetricCloudCapturePushConstants
@@ -1731,15 +1731,15 @@ struct VolumetricCloudCapturePushConstants
uint2 resolution;
float2 resolution_rcp;
int texture_input;
int texture_output;
int maxStepCount;
float LODMin;
float shadowSampleCount;
float groundContributionSampleCount;
float padding0;
float padding1;
float padding2;
};
@@ -95,7 +95,6 @@ void RenderAerialPerspective(uint3 DTid, float2 uv, float depth, float3 depthWor
[numthreads(POSTPROCESS_BLOCKSIZE, POSTPROCESS_BLOCKSIZE, 1)]
void main(uint3 DTid : SV_DispatchThreadID)
{
TextureCube input = bindless_cubemaps[descriptor_index(capture.texture_input)];
RWTexture2DArray<float4> output = bindless_rwtextures2DArray[descriptor_index(capture.texture_output)];
const float2 uv = (DTid.xy + 0.5) * capture.resolution_rcp;
@@ -113,7 +112,7 @@ void main(uint3 DTid : SV_DispatchThreadID)
const float depth = texture_input_depth.SampleLevel(sampler_point_clamp, N, 0).r;
#endif // MSAA
float4 composite = input.SampleLevel(sampler_linear_clamp, N, 0);
float4 composite = output[uint3(DTid.xy, DTid.z)];
// Ignore skybox
if (depth == 0.0)
@@ -724,7 +724,6 @@ void RenderClouds(uint3 DTid, float2 uv, float depth, float3 depthWorldPosition,
[numthreads(POSTPROCESS_BLOCKSIZE, POSTPROCESS_BLOCKSIZE, 1)]
void main(uint3 DTid : SV_DispatchThreadID)
{
TextureCube input = bindless_cubemaps[descriptor_index(capture.texture_input)];
RWTexture2DArray<float4> output = bindless_rwtextures2DArray[descriptor_index(capture.texture_output)];
const float2 uv = (DTid.xy + 0.5) * capture.resolution_rcp;
@@ -751,7 +750,7 @@ void main(uint3 DTid : SV_DispatchThreadID)
float2 cloudDepth = 0;
RenderClouds(DTid, uv, depth, depthWorldPosition, rayOrigin, rayDirection, cloudColor, cloudDepth);
float4 composite = input.SampleLevel(sampler_linear_clamp, N, 0);
float4 composite = output[uint3(DTid.xy, DTid.z)];
// Output
output[uint3(DTid.xy, DTid.z)] = float4(composite.rgb * (1.0 - cloudColor.a) + cloudColor.rgb, composite.a * (1.0 - cloudColor.a));
-2
View File
@@ -9361,7 +9361,6 @@ void RefreshEnvProbes(const Visibility& vis, CommandList cmd)
push.resolution.y = desc.height;
push.resolution_rcp.x = 1.0f / push.resolution.x;
push.resolution_rcp.y = 1.0f / push.resolution.y;
push.texture_input = device->GetDescriptorIndex(&envrenderingColorBuffer, SubresourceType::SRV);
push.texture_output = device->GetDescriptorIndex(&envrenderingColorBuffer, SubresourceType::UAV);
device->PushConstants(&push, sizeof(push), cmd);
@@ -9425,7 +9424,6 @@ void RefreshEnvProbes(const Visibility& vis, CommandList cmd)
push.resolution.y = desc.height;
push.resolution_rcp.x = 1.0f / push.resolution.x;
push.resolution_rcp.y = 1.0f / push.resolution.y;
push.texture_input = device->GetDescriptorIndex(&envrenderingColorBuffer, SubresourceType::SRV);
push.texture_output = device->GetDescriptorIndex(&envrenderingColorBuffer, SubresourceType::UAV);
if (probe.IsRealTime())