removed min component from lineardepth mipchain

This commit is contained in:
turanszkij
2020-03-24 23:53:51 +00:00
parent fbb990f207
commit ffc85620a1
11 changed files with 68 additions and 125 deletions
+7 -16
View File
@@ -229,22 +229,16 @@ void RenderPath3D::ResizeBuffers()
desc.Format = FORMAT_R32_FLOAT;
desc.Width = wiRenderer::GetInternalResolution().x;
desc.Height = wiRenderer::GetInternalResolution().y;
desc.MipLevels = 6;
device->CreateTexture(&desc, nullptr, &rtLinearDepth);
device->SetName(&rtLinearDepth, "rtLinearDepth");
desc.Width = (desc.Width + 1) / 2;
desc.Height = (desc.Height + 1) / 2;
desc.MipLevels = 5;
desc.Format = FORMAT_R32G32_FLOAT;
device->CreateTexture(&desc, nullptr, &rtLinearDepth_minmax);
device->SetName(&rtLinearDepth_minmax, "rtLinearDepth_minmax");
for (uint32_t i = 0; i < desc.MipLevels; ++i)
{
int subresource_index;
subresource_index = device->CreateSubresource(&rtLinearDepth_minmax, SRV, 0, 1, i, 1);
subresource_index = device->CreateSubresource(&rtLinearDepth, SRV, 0, 1, i, 1);
assert(subresource_index == i);
subresource_index = device->CreateSubresource(&rtLinearDepth_minmax, UAV, 0, 1, i, 1);
subresource_index = device->CreateSubresource(&rtLinearDepth, UAV, 0, 1, i, 1);
assert(subresource_index == i);
}
}
@@ -422,7 +416,7 @@ void RenderPath3D::RenderShadows(CommandList cmd) const
void RenderPath3D::RenderLinearDepth(CommandList cmd) const
{
wiRenderer::Postprocess_Lineardepth(depthBuffer_Copy, rtLinearDepth, rtLinearDepth_minmax, cmd);
wiRenderer::Postprocess_Lineardepth(depthBuffer_Copy, rtLinearDepth, cmd);
}
void RenderPath3D::RenderAO(CommandList cmd) const
{
@@ -436,7 +430,6 @@ void RenderPath3D::RenderAO(CommandList cmd) const
wiRenderer::Postprocess_SSAO(
depthBuffer_Copy,
rtLinearDepth,
rtLinearDepth_minmax,
rtAO,
cmd,
getAORange(),
@@ -447,7 +440,6 @@ void RenderPath3D::RenderAO(CommandList cmd) const
case AO_HBAO:
wiRenderer::Postprocess_HBAO(
rtLinearDepth,
rtLinearDepth_minmax,
rtAO,
cmd,
getAOPower()
@@ -456,7 +448,6 @@ void RenderPath3D::RenderAO(CommandList cmd) const
case AO_MSAO:
wiRenderer::Postprocess_MSAO(
rtLinearDepth,
rtLinearDepth_minmax,
rtAO,
cmd,
getAOPower()
@@ -469,7 +460,7 @@ void RenderPath3D::RenderSSR(const Texture& gbuffer1, const Texture& gbuffer2, C
{
if (getSSREnabled())
{
wiRenderer::Postprocess_SSR(rtSceneCopy, depthBuffer_Copy, rtLinearDepth_minmax, gbuffer1, gbuffer2, rtSSR, cmd);
wiRenderer::Postprocess_SSR(rtSceneCopy, depthBuffer_Copy, rtLinearDepth, gbuffer1, gbuffer2, rtSSR, cmd);
}
}
void RenderPath3D::DownsampleDepthBuffer(CommandList cmd) const
@@ -632,7 +623,7 @@ void RenderPath3D::RenderTransparents(const RenderPass& renderpass_transparent,
if (getVolumeLightsEnabled() && wiRenderer::IsRequestedVolumetricLightRendering())
{
device->EventBegin("Contribute Volumetric Lights", cmd);
wiRenderer::Postprocess_Upsample_Bilateral(rtVolumetricLights, rtLinearDepth, rtLinearDepth_minmax,
wiRenderer::Postprocess_Upsample_Bilateral(rtVolumetricLights, rtLinearDepth,
*renderpass_transparent.desc.attachments[0].texture, cmd, true, 1.5f);
device->EventEnd(cmd);
}
@@ -697,7 +688,7 @@ void RenderPath3D::RenderPostprocessChain(const Texture& srcSceneRT, const Textu
if (getDepthOfFieldEnabled())
{
wiRenderer::Postprocess_DepthOfField(rt_first == nullptr ? *rt_read : *rt_first, *rt_write, rtLinearDepth, rtLinearDepth_minmax, cmd, getDepthOfFieldFocus(), getDepthOfFieldStrength(), getDepthOfFieldAspect());
wiRenderer::Postprocess_DepthOfField(rt_first == nullptr ? *rt_read : *rt_first, *rt_write, rtLinearDepth, cmd, getDepthOfFieldFocus(), getDepthOfFieldStrength(), getDepthOfFieldAspect());
rt_first = nullptr;
std::swap(rt_read, rt_write);
+1 -2
View File
@@ -80,8 +80,7 @@ protected:
wiGraphics::Texture depthBuffer; // used for depth-testing, can be MSAA
wiGraphics::Texture depthBuffer_Copy; // used for shader resource, single sample
wiGraphics::Texture depthBuffer_Reflection; // used for reflection, single sample
wiGraphics::Texture rtLinearDepth; // linear depth result
wiGraphics::Texture rtLinearDepth_minmax; // linear depth result (halfres minmax, mipchain)
wiGraphics::Texture rtLinearDepth; // linear depth result + mipchain (max filter)
wiGraphics::Texture smallDepth; // downsampled depth buffer
wiGraphics::RenderPass renderpass_occlusionculling;
+3 -4
View File
@@ -4,8 +4,7 @@
TEXTURE2D(input, float4, TEXSLOT_ONDEMAND0);
TEXTURE2D(neighborhood_mindepth_maxcoc, float2, TEXSLOT_ONDEMAND1);
TEXTURE2D(texture_lineardepth_minmax, float2, TEXSLOT_ONDEMAND2);
STRUCTUREDBUFFER(tiles, uint, TEXSLOT_ONDEMAND3);
STRUCTUREDBUFFER(tiles, uint, TEXSLOT_ONDEMAND2);
RWTEXTURE2D(output_presort, float3, 0);
RWTEXTURE2D(output_prefilter, float3, 1);
@@ -32,7 +31,7 @@ void main(uint3 Gid : SV_GroupID, uint3 GTid : SV_GroupThreadID)
#else
const float mindepth = neighborhood_mindepth_maxcoc[2 * pixel / DEPTHOFFIELD_TILESIZE].x;
const float center_depth = texture_lineardepth_minmax[pixel].g;
const float center_depth = texture_lineardepth.Load(uint3(pixel, 1));
const float coc = min(dof_maxcoc, dof_scale * abs(1 - dof_focus / (center_depth * g_xCamera_ZFarP)));
const float alpha = SampleAlpha(coc);
const float2 depthcmp = DepthCmp2(center_depth, mindepth);
@@ -56,7 +55,7 @@ void main(uint3 Gid : SV_GroupID, uint3 GTid : SV_GroupThreadID)
{
const float offsetCoc = disc[i].z;
const float2 uv2 = uv + ringScale * disc[i].xy;
const float depth = texture_lineardepth_minmax.SampleLevel(sampler_point_clamp, uv2, 0).g;
const float depth = texture_lineardepth.SampleLevel(sampler_point_clamp, uv2, 1);
const float3 color = max(0, input.SampleLevel(sampler_linear_clamp, uv2, 0).rgb);
const float weight = saturate(abs(depth - center_depth) * g_xCamera_ZFarP * 2);
prefilter += lerp(color, center_color, weight);
+2 -3
View File
@@ -1,8 +1,7 @@
#include "globals.hlsli"
#include "ShaderInterop_Postprocess.h"
TEXTURE2D(texture_lineardepth_minmax, float2, TEXSLOT_ONDEMAND0);
TEXTURE2D(texture_horizontalpass, float, TEXSLOT_ONDEMAND1);
TEXTURE2D(texture_horizontalpass, float, TEXSLOT_ONDEMAND0);
RWTEXTURE2D(output, unorm float, 0);
@@ -90,7 +89,7 @@ void main(uint3 Gid : SV_GroupID, uint groupIndex : SV_GroupIndex)
{
const uint2 pixel = tile_start + hbao_direction * (i - TILE_BORDER);
const float2 uv = (pixel + 0.5f) * xPPResolution_rcp;
const float z = texture_lineardepth_minmax[tile_start + hbao_direction * (i - TILE_BORDER)].g * g_xCamera_ZFarP;
const float z = texture_lineardepth.Load(uint3(tile_start + hbao_direction * (i - TILE_BORDER), 1)) * g_xCamera_ZFarP;
const float2 xy = (hbao_uv_to_view_A * uv + hbao_uv_to_view_B) * z;
cache[i] = float2(horizontal ? xy.x : xy.y, z);
}
+15 -25
View File
@@ -4,14 +4,13 @@
TEXTURE2D(input, float, TEXSLOT_ONDEMAND0);
RWTEXTURE2D(output_fullres, float, 0);
RWTEXTURE2D(output_minmax_mip0, float2, 1);
RWTEXTURE2D(output_minmax_mip1, float2, 2);
RWTEXTURE2D(output_minmax_mip2, float2, 3);
RWTEXTURE2D(output_minmax_mip3, float2, 4);
RWTEXTURE2D(output_minmax_mip4, float2, 5);
RWTEXTURE2D(output_mip0, float, 0);
RWTEXTURE2D(output_mip1, float, 1);
RWTEXTURE2D(output_mip2, float, 2);
RWTEXTURE2D(output_mip3, float, 3);
RWTEXTURE2D(output_mip4, float, 4);
RWTEXTURE2D(output_mip5, float, 5);
groupshared float tile_min[POSTPROCESS_LINEARDEPTH_BLOCKSIZE][POSTPROCESS_LINEARDEPTH_BLOCKSIZE];
groupshared float tile_max[POSTPROCESS_LINEARDEPTH_BLOCKSIZE][POSTPROCESS_LINEARDEPTH_BLOCKSIZE];
[numthreads(POSTPROCESS_LINEARDEPTH_BLOCKSIZE, POSTPROCESS_LINEARDEPTH_BLOCKSIZE, 1)]
@@ -23,52 +22,43 @@ void main(uint3 DTid : SV_DispatchThreadID, uint3 GTid : SV_GroupThreadID)
getLinearDepth(input[clamp(DTid.xy * 2 + uint2(0, 1), 0, lineardepth_inputresolution - 1)]),
getLinearDepth(input[clamp(DTid.xy * 2 + uint2(1, 1), 0, lineardepth_inputresolution - 1)])
) * g_xCamera_ZFarP_rcp;
output_fullres[DTid.xy * 2 + uint2(0, 0)] = lineardepths.x;
output_fullres[DTid.xy * 2 + uint2(1, 0)] = lineardepths.y;
output_fullres[DTid.xy * 2 + uint2(0, 1)] = lineardepths.z;
output_fullres[DTid.xy * 2 + uint2(1, 1)] = lineardepths.w;
output_mip0[DTid.xy * 2 + uint2(0, 0)] = lineardepths.x;
output_mip0[DTid.xy * 2 + uint2(1, 0)] = lineardepths.y;
output_mip0[DTid.xy * 2 + uint2(0, 1)] = lineardepths.z;
output_mip0[DTid.xy * 2 + uint2(1, 1)] = lineardepths.w;
float mindepth = min(lineardepths.x, min(lineardepths.y, min(lineardepths.z, lineardepths.w)));
float maxdepth = max(lineardepths.x, max(lineardepths.y, max(lineardepths.z, lineardepths.w)));
tile_min[GTid.x][GTid.y] = mindepth;
tile_max[GTid.x][GTid.y] = maxdepth;
output_minmax_mip0[DTid.xy] = float2(mindepth, maxdepth);
output_mip1[DTid.xy] = maxdepth;
GroupMemoryBarrierWithGroupSync();
if (GTid.x % 2 == 0 && GTid.y % 2 == 0)
{
mindepth = min(tile_min[GTid.x][GTid.y], min(tile_min[GTid.x + 1][GTid.y], min(tile_min[GTid.x][GTid.y + 1], tile_min[GTid.x + 1][GTid.y+ 1])));
maxdepth = max(tile_max[GTid.x][GTid.y], max(tile_max[GTid.x + 1][GTid.y], max(tile_max[GTid.x][GTid.y + 1], tile_max[GTid.x + 1][GTid.y+ 1])));
tile_min[GTid.x][GTid.y] = mindepth;
tile_max[GTid.x][GTid.y] = maxdepth;
output_minmax_mip1[DTid.xy / 2] = float2(mindepth, maxdepth);
output_mip2[DTid.xy / 2] = maxdepth;
}
GroupMemoryBarrierWithGroupSync();
if (GTid.x % 4 == 0 && GTid.y % 4 == 0)
{
mindepth = min(tile_min[GTid.x][GTid.y], min(tile_min[GTid.x + 2][GTid.y], min(tile_min[GTid.x][GTid.y + 2], tile_min[GTid.x + 2][GTid.y + 2])));
maxdepth = max(tile_max[GTid.x][GTid.y], max(tile_max[GTid.x + 2][GTid.y], max(tile_max[GTid.x][GTid.y + 2], tile_max[GTid.x + 2][GTid.y + 2])));
tile_min[GTid.x][GTid.y] = mindepth;
tile_max[GTid.x][GTid.y] = maxdepth;
output_minmax_mip2[DTid.xy / 4] = float2(mindepth, maxdepth);
output_mip3[DTid.xy / 4] = maxdepth;
}
GroupMemoryBarrierWithGroupSync();
if (GTid.x % 8 == 0 && GTid.y % 8 == 0)
{
mindepth = min(tile_min[GTid.x][GTid.y], min(tile_min[GTid.x + 4][GTid.y], min(tile_min[GTid.x][GTid.y + 4], tile_min[GTid.x + 4][GTid.y + 4])));
maxdepth = max(tile_max[GTid.x][GTid.y], max(tile_max[GTid.x + 4][GTid.y], max(tile_max[GTid.x][GTid.y + 4], tile_max[GTid.x + 4][GTid.y + 4])));
tile_min[GTid.x][GTid.y] = mindepth;
tile_max[GTid.x][GTid.y] = maxdepth;
output_minmax_mip3[DTid.xy / 8] = float2(mindepth, maxdepth);
output_mip4[DTid.xy / 8] = maxdepth;
}
GroupMemoryBarrierWithGroupSync();
if (GTid.x % 16 == 0 && GTid.y % 16 == 0)
{
mindepth = min(tile_min[GTid.x][GTid.y], min(tile_min[GTid.x + 8][GTid.y], min(tile_min[GTid.x][GTid.y + 8], tile_min[GTid.x + 8][GTid.y + 8])));
maxdepth = max(tile_max[GTid.x][GTid.y], max(tile_max[GTid.x + 8][GTid.y], max(tile_max[GTid.x][GTid.y + 8], tile_max[GTid.x + 8][GTid.y + 8])));
output_minmax_mip4[DTid.xy / 16] = float2(mindepth, maxdepth);
output_mip5[DTid.xy / 16] = maxdepth;
}
}
+1 -10
View File
@@ -3,7 +3,6 @@
// Define this to use reduced precision, but faster depth buffer:
#define USE_LINEARDEPTH
TEXTURE2D(texture_lineardepth_minmax, float2, TEXSLOT_ONDEMAND0);
RWTEXTURE2D(output, unorm float, 0);
@@ -15,14 +14,6 @@ groupshared float tile_Z[TILE_SIZE*TILE_SIZE];
[numthreads(POSTPROCESS_BLOCKSIZE, POSTPROCESS_BLOCKSIZE, 1)]
void main(uint3 DTid : SV_DispatchThreadID, uint3 Gid : SV_GroupID, uint3 GTid : SV_GroupThreadID, uint groupIndex : SV_GroupIndex)
{
[branch]
if (texture_lineardepth_minmax.Load(uint3(Gid.xy, log2(POSTPROCESS_BLOCKSIZE))).r == 1.0f)
{
// early exit when tile min (mip3) is the farplane
output[DTid.xy] = 1;
return;
}
const int2 tile_upperleft = Gid.xy * POSTPROCESS_BLOCKSIZE - TILE_BORDER;
for (uint t = groupIndex; t < TILE_SIZE * TILE_SIZE; t += POSTPROCESS_BLOCKSIZE * POSTPROCESS_BLOCKSIZE)
{
@@ -111,7 +102,7 @@ void main(uint3 DTid : SV_DispatchThreadID, uint3 Gid : SV_GroupID, uint3 GTid :
{
#ifdef USE_LINEARDEPTH
const float ray_depth_real = vProjectedCoord.w; // .w is also linear depth, could be also written as getLinearDepth(vProjectedCoord.z)
const float ray_depth_sample = texture_lineardepth_minmax.SampleLevel(sampler_point_clamp, vProjectedCoord.xy, 0).g * g_xCamera_ZFarP;
const float ray_depth_sample = texture_lineardepth.SampleLevel(sampler_point_clamp, vProjectedCoord.xy, 0) * g_xCamera_ZFarP;
const float depth_fix = 1 - saturate(abs(ray_depth_real - ray_depth_sample) * 0.2f); // too much depth difference cancels the effect
ao += (ray_depth_sample < ray_depth_real) * depth_fix;
#else
+2 -3
View File
@@ -3,7 +3,6 @@
#include "ShaderInterop_Postprocess.h"
TEXTURE2D(input, float4, TEXSLOT_ONDEMAND0);
TEXTURE2D(texture_lineardepth_minmax, float2, TEXSLOT_ONDEMAND1);
RWTEXTURE2D(texture_raytrace, float4, 0);
RWTEXTURE2D(texture_mask, float2, 1);
@@ -193,13 +192,13 @@ bool ScreenSpaceRayTrace(float3 csOrig, float3 csDir, float jitter, float roughn
}
// A simple HZB approach based on roughness
level += min(raytraceHZBBias / 10.0f, 5.0f) * roughness;
level += min(raytraceHZBBias / 10.0f, 6.0f) * roughness;
hitPixel = permute ? PQk.yx : PQk.xy;
hitPixel *= xPPResolution_rcp;
#ifdef USE_LINEARDEPTH
sceneZMax = texture_lineardepth_minmax.SampleLevel(sampler_point_clamp, hitPixel, level).g * g_xCamera_ZFarP;
sceneZMax = texture_lineardepth.SampleLevel(sampler_point_clamp, hitPixel, level) * g_xCamera_ZFarP;
#else
sceneZMax = getLinearDepth(texture_depth.SampleLevel(sampler_point_clamp, hitPixel, 0).r);
#endif
+7 -20
View File
@@ -6,7 +6,6 @@
#endif // UPSAMPLE_FORMAT
TEXTURE2D(input, UPSAMPLE_FORMAT, TEXSLOT_ONDEMAND0);
TEXTURE2D(lineardepth_minmax, float2, TEXSLOT_ONDEMAND1);
// Note: this post process can be either a pixel shader or compute shader, depending on use case
@@ -34,26 +33,14 @@ void main(uint3 DTid : SV_DispatchThreadID)
const float2 uv11 = uv00 + lowres_texel_size;
const float4 lineardepth_highres = texture_lineardepth.SampleLevel(sampler_point_clamp, uv, 0).xxxx;
const float2 lineardepth_lowres_minmax_00 = lineardepth_minmax.SampleLevel(sampler_point_clamp, uv00, lowres_depthchain_mip);
const float2 lineardepth_lowres_minmax_10 = lineardepth_minmax.SampleLevel(sampler_point_clamp, uv10, lowres_depthchain_mip);
const float2 lineardepth_lowres_minmax_01 = lineardepth_minmax.SampleLevel(sampler_point_clamp, uv01, lowres_depthchain_mip);
const float2 lineardepth_lowres_minmax_11 = lineardepth_minmax.SampleLevel(sampler_point_clamp, uv11, lowres_depthchain_mip);
const float4 lineardepth_lowres_min = float4(
lineardepth_lowres_minmax_00.x,
lineardepth_lowres_minmax_10.x,
lineardepth_lowres_minmax_01.x,
lineardepth_lowres_minmax_11.x
);
const float4 lineardepth_lowres_max = float4(
lineardepth_lowres_minmax_00.y,
lineardepth_lowres_minmax_10.y,
lineardepth_lowres_minmax_01.y,
lineardepth_lowres_minmax_11.y
);
const float4 lineardepth_lowres = float4(
texture_lineardepth.SampleLevel(sampler_point_clamp, uv00, lowres_depthchain_mip),
texture_lineardepth.SampleLevel(sampler_point_clamp, uv10, lowres_depthchain_mip),
texture_lineardepth.SampleLevel(sampler_point_clamp, uv01, lowres_depthchain_mip),
texture_lineardepth.SampleLevel(sampler_point_clamp, uv11, lowres_depthchain_mip)
);
const float4 depth_diff_min = abs(lineardepth_highres - lineardepth_lowres_min);
const float4 depth_diff_max = abs(lineardepth_highres - lineardepth_lowres_max);
const float4 depth_diff = max(depth_diff_min, depth_diff_max) * g_xCamera_ZFarP;
const float4 depth_diff = abs(lineardepth_highres - lineardepth_lowres) * g_xCamera_ZFarP;
const float accum_diff = dot(depth_diff, float4(1, 1, 1, 1));
UPSAMPLE_FORMAT color;
+27 -33
View File
@@ -8788,7 +8788,6 @@ void Postprocess_Blur_Bilateral(
void Postprocess_SSAO(
const Texture& depthbuffer,
const Texture& lineardepth,
const Texture& lineardepth_minmax,
const Texture& output,
CommandList cmd,
float range,
@@ -8809,6 +8808,7 @@ void Postprocess_SSAO(
if (saved_desc.Width != lineardepth_desc.Width || saved_desc.Height != lineardepth_desc.Height)
{
saved_desc = lineardepth_desc; // <- this must already have SRV and UAV request flags set up!
saved_desc.MipLevels = 1;
TextureDesc desc = saved_desc;
desc.Format = FORMAT_R8_UNORM;
@@ -8821,7 +8821,7 @@ void Postprocess_SSAO(
device->BindComputeShader(&computeShaders[CSTYPE_POSTPROCESS_SSAO], cmd);
device->BindResource(CS, &depthbuffer, TEXSLOT_DEPTH, cmd);
device->BindResource(CS, &lineardepth_minmax, TEXSLOT_ONDEMAND0, cmd);
device->BindResource(CS, &lineardepth, TEXSLOT_LINEARDEPTH, cmd);
const TextureDesc& desc = temp0.GetDesc();
@@ -8851,15 +8851,14 @@ void Postprocess_SSAO(
device->Barrier(&GPUBarrier::Memory(), 1, cmd);
device->UnbindUAVs(0, arraysize(uavs), cmd);
Postprocess_Blur_Bilateral(temp0, lineardepth_minmax, temp1, temp0, cmd, 1.2f, -1, -1, true);
Postprocess_Upsample_Bilateral(temp0, lineardepth, lineardepth_minmax, output, cmd);
Postprocess_Blur_Bilateral(temp0, lineardepth, temp1, temp0, cmd, 1.2f, -1, -1, true);
Postprocess_Upsample_Bilateral(temp0, lineardepth, output, cmd);
wiProfiler::EndRange(prof_range);
device->EventEnd(cmd);
}
void Postprocess_HBAO(
const Texture& lineardepth,
const Texture& lineardepth_minmax,
const Texture& output,
CommandList cmd,
float power
@@ -8878,6 +8877,7 @@ void Postprocess_HBAO(
if (saved_desc.Width != lineardepth_desc.Width || saved_desc.Height != lineardepth_desc.Height)
{
saved_desc = lineardepth_desc; // <- this must already have SRV and UAV request flags set up!
saved_desc.MipLevels = 1;
TextureDesc desc = saved_desc;
desc.Format = FORMAT_R8_UNORM;
@@ -8889,7 +8889,7 @@ void Postprocess_HBAO(
device->BindComputeShader(&computeShaders[CSTYPE_POSTPROCESS_HBAO], cmd);
device->BindResource(CS, &lineardepth_minmax, TEXSLOT_ONDEMAND0, cmd);
device->BindResource(CS, &lineardepth, TEXSLOT_LINEARDEPTH, cmd);
const TextureDesc& desc = temp0.GetDesc();
@@ -8965,15 +8965,14 @@ void Postprocess_HBAO(
device->UnbindResources(TEXSLOT_ONDEMAND1, 1, cmd);
}
Postprocess_Blur_Bilateral(temp0, lineardepth_minmax, temp1, temp0, cmd, 1.2f, -1, -1, true);
Postprocess_Upsample_Bilateral(temp0, lineardepth, lineardepth_minmax, output, cmd);
Postprocess_Blur_Bilateral(temp0, lineardepth, temp1, temp0, cmd, 1.2f, -1, -1, true);
Postprocess_Upsample_Bilateral(temp0, lineardepth, output, cmd);
wiProfiler::EndRange(prof_range);
device->EventEnd(cmd);
}
void Postprocess_MSAO(
const Texture& lineardepth,
const Texture& lineardepth_minmax,
const Texture& output,
CommandList cmd,
float power
@@ -9009,6 +9008,7 @@ void Postprocess_MSAO(
if (saved_desc.Width != lineardepth_desc.Width || saved_desc.Height != lineardepth_desc.Height)
{
saved_desc = lineardepth_desc; // <- this must already have SRV and UAV request flags set up!
saved_desc.MipLevels = 1;
const uint32_t bufferWidth = saved_desc.Width;
const uint32_t bufferWidth1 = (bufferWidth + 1) / 2;
@@ -9385,7 +9385,7 @@ void Postprocess_MSAO(
void Postprocess_SSR(
const Texture& input,
const Texture& depthbuffer,
const Texture& lineardepth_minmax,
const Texture& lineardepth,
const Texture& gbuffer1,
const Texture& gbuffer2,
const Texture& output,
@@ -9451,10 +9451,10 @@ void Postprocess_SSR(
device->BindComputeShader(&computeShaders[CSTYPE_POSTPROCESS_SSR_RAYTRACE], cmd);
device->BindResource(CS, &depthbuffer, TEXSLOT_DEPTH, cmd);
device->BindResource(CS, &lineardepth, TEXSLOT_LINEARDEPTH, cmd);
device->BindResource(CS, &gbuffer1, TEXSLOT_GBUFFER1, cmd);
device->BindResource(CS, &gbuffer2, TEXSLOT_GBUFFER2, cmd);
device->BindResource(CS, &input, TEXSLOT_ONDEMAND0, cmd);
device->BindResource(CS, &lineardepth_minmax, TEXSLOT_ONDEMAND1, cmd);
const GPUResource* uavs[] = {
&texture_raytrace,
@@ -9710,7 +9710,6 @@ void Postprocess_DepthOfField(
const Texture& input,
const Texture& output,
const Texture& lineardepth,
const Texture& lineardepth_minmax,
CommandList cmd,
float focus,
float scale,
@@ -9926,7 +9925,6 @@ void Postprocess_DepthOfField(
const GPUResource* res[] = {
&input,
&texture_neighborhoodmax,
&lineardepth_minmax
};
device->BindResources(CS, res, TEXSLOT_ONDEMAND0, arraysize(res), cmd);
@@ -9936,15 +9934,15 @@ void Postprocess_DepthOfField(
};
device->BindUAVs(CS, uavs, 0, arraysize(uavs), cmd);
device->BindResource(CS, &buffer_tiles_earlyexit, TEXSLOT_ONDEMAND3, cmd);
device->BindResource(CS, &buffer_tiles_earlyexit, TEXSLOT_ONDEMAND2, cmd);
device->BindComputeShader(&computeShaders[CSTYPE_POSTPROCESS_DEPTHOFFIELD_PREPASS_EARLYEXIT], cmd);
device->DispatchIndirect(&buffer_tile_statistics, INDIRECT_OFFSET_EARLYEXIT, cmd);
device->BindResource(CS, &buffer_tiles_cheap, TEXSLOT_ONDEMAND3, cmd);
device->BindResource(CS, &buffer_tiles_cheap, TEXSLOT_ONDEMAND2, cmd);
device->BindComputeShader(&computeShaders[CSTYPE_POSTPROCESS_DEPTHOFFIELD_PREPASS], cmd);
device->DispatchIndirect(&buffer_tile_statistics, INDIRECT_OFFSET_CHEAP, cmd);
device->BindResource(CS, &buffer_tiles_expensive, TEXSLOT_ONDEMAND3, cmd);
device->BindResource(CS, &buffer_tiles_expensive, TEXSLOT_ONDEMAND2, cmd);
device->BindComputeShader(&computeShaders[CSTYPE_POSTPROCESS_DEPTHOFFIELD_PREPASS], cmd);
device->DispatchIndirect(&buffer_tile_statistics, INDIRECT_OFFSET_EXPENSIVE, cmd);
@@ -10491,8 +10489,7 @@ void Postprocess_TemporalAA(
}
void Postprocess_Lineardepth(
const Texture& input,
const Texture& output_fullres,
const Texture& output_minmax,
const Texture& output,
CommandList cmd
)
{
@@ -10500,11 +10497,11 @@ void Postprocess_Lineardepth(
device->EventBegin("Postprocess_Lineardepth", cmd);
const TextureDesc& desc = output_minmax.GetDesc();
const TextureDesc& desc = output.GetDesc();
PostProcessCB cb;
cb.xPPResolution.x = desc.Width;
cb.xPPResolution.y = desc.Height;
cb.xPPResolution.x = desc.Width / 2; // downsample res
cb.xPPResolution.y = desc.Height / 2; // downsample res
cb.xPPResolution_rcp.x = 1.0f / cb.xPPResolution.x;
cb.xPPResolution_rcp.y = 1.0f / cb.xPPResolution.y;
cb.xPPParams0.x = (float)input.GetDesc().Width;
@@ -10516,12 +10513,12 @@ void Postprocess_Lineardepth(
device->BindResource(CS, &input, TEXSLOT_ONDEMAND0, cmd);
device->BindUAV(CS, &output_fullres, 0, cmd);
device->BindUAV(CS, &output_minmax, 1, cmd, 0);
device->BindUAV(CS, &output_minmax, 2, cmd, 1);
device->BindUAV(CS, &output_minmax, 3, cmd, 2);
device->BindUAV(CS, &output_minmax, 4, cmd, 3);
device->BindUAV(CS, &output_minmax, 5, cmd, 4);
device->BindUAV(CS, &output, 0, cmd, 0);
device->BindUAV(CS, &output, 1, cmd, 1);
device->BindUAV(CS, &output, 2, cmd, 2);
device->BindUAV(CS, &output, 3, cmd, 3);
device->BindUAV(CS, &output, 4, cmd, 4);
device->BindUAV(CS, &output, 5, cmd, 5);
device->BindComputeShader(&computeShaders[CSTYPE_POSTPROCESS_LINEARDEPTH], cmd);
device->Dispatch(
@@ -10680,7 +10677,6 @@ void Postprocess_Chromatic_Aberration(
void Postprocess_Upsample_Bilateral(
const Texture& input,
const Texture& lineardepth,
const Texture& lineardepth_minmax,
const Texture& output,
CommandList cmd,
bool pixelshader,
@@ -10699,10 +10695,10 @@ void Postprocess_Upsample_Bilateral(
cb.xPPResolution_rcp.x = 1.0f / cb.xPPResolution.x;
cb.xPPResolution_rcp.y = 1.0f / cb.xPPResolution.y;
cb.xPPParams0.x = threshold;
cb.xPPParams0.y = cb.xPPResolution_rcp.x * (float)desc.Width / (float)input.GetDesc().Width;
cb.xPPParams0.z = cb.xPPResolution_rcp.y * (float)desc.Height / (float)input.GetDesc().Height;
cb.xPPParams0.y = 1.0f / (float)input.GetDesc().Width;
cb.xPPParams0.z = 1.0f / (float)input.GetDesc().Height;
// select mip from lowres depth mipchain:
cb.xPPParams0.w = floorf(std::max(0.0f, log2f(std::max((float)desc.Width / (float)input.GetDesc().Width, (float)desc.Height / (float)input.GetDesc().Height)) - 1));
cb.xPPParams0.w = floorf(std::max(1.0f, log2f(std::max((float)desc.Width / (float)input.GetDesc().Width, (float)desc.Height / (float)input.GetDesc().Height))));
device->UpdateBuffer(&constantBuffers[CBTYPE_POSTPROCESS], &cb, cmd);
if (pixelshader)
@@ -10712,7 +10708,6 @@ void Postprocess_Upsample_Bilateral(
device->BindConstantBuffer(PS, &constantBuffers[CBTYPE_POSTPROCESS], CB_GETBINDSLOT(PostProcessCB), cmd);
device->BindResource(PS, &input, TEXSLOT_ONDEMAND0, cmd);
device->BindResource(PS, &lineardepth_minmax, TEXSLOT_ONDEMAND1, cmd);
device->BindResource(PS, &lineardepth, TEXSLOT_LINEARDEPTH, cmd);
device->Draw(3, 0, cmd);
@@ -10748,7 +10743,6 @@ void Postprocess_Upsample_Bilateral(
device->BindConstantBuffer(CS, &constantBuffers[CBTYPE_POSTPROCESS], CB_GETBINDSLOT(PostProcessCB), cmd);
device->BindResource(CS, &input, TEXSLOT_ONDEMAND0, cmd);
device->BindResource(CS, &lineardepth_minmax, TEXSLOT_ONDEMAND1, cmd);
device->BindResource(CS, &lineardepth, TEXSLOT_LINEARDEPTH, cmd);
const GPUResource* uavs[] = {
+2 -8
View File
@@ -191,7 +191,6 @@ namespace wiRenderer
void Postprocess_SSAO(
const wiGraphics::Texture& depthbuffer,
const wiGraphics::Texture& lineardepth,
const wiGraphics::Texture& lineardepth_minmax,
const wiGraphics::Texture& output,
wiGraphics::CommandList cmd,
float range = 1.0f,
@@ -200,14 +199,12 @@ namespace wiRenderer
);
void Postprocess_HBAO(
const wiGraphics::Texture& lineardepth,
const wiGraphics::Texture& lineardepth_minmax,
const wiGraphics::Texture& output,
wiGraphics::CommandList cmd,
float power = 2.0f
);
void Postprocess_MSAO(
const wiGraphics::Texture& lineardepth,
const wiGraphics::Texture& lineardepth_minmax,
const wiGraphics::Texture& output,
wiGraphics::CommandList cmd,
float power = 2.0f
@@ -215,7 +212,7 @@ namespace wiRenderer
void Postprocess_SSR(
const wiGraphics::Texture& input,
const wiGraphics::Texture& depthbuffer,
const wiGraphics::Texture& lineardepth_minmax,
const wiGraphics::Texture& lineardepth,
const wiGraphics::Texture& gbuffer1,
const wiGraphics::Texture& gbuffer2,
const wiGraphics::Texture& output,
@@ -239,7 +236,6 @@ namespace wiRenderer
const wiGraphics::Texture& input,
const wiGraphics::Texture& output,
const wiGraphics::Texture& lineardepth,
const wiGraphics::Texture& lineardepth_minmax,
wiGraphics::CommandList cmd,
float focus = 10.0f,
float scale = 1.0f,
@@ -284,8 +280,7 @@ namespace wiRenderer
);
void Postprocess_Lineardepth(
const wiGraphics::Texture& input,
const wiGraphics::Texture& output_fullres,
const wiGraphics::Texture& output_minmax,
const wiGraphics::Texture& output,
wiGraphics::CommandList cmd
);
void Postprocess_Sharpen(
@@ -313,7 +308,6 @@ namespace wiRenderer
void Postprocess_Upsample_Bilateral(
const wiGraphics::Texture& input,
const wiGraphics::Texture& lineardepth,
const wiGraphics::Texture& lineardepth_minmax,
const wiGraphics::Texture& output,
wiGraphics::CommandList cmd,
bool is_pixelshader = false,
+1 -1
View File
@@ -9,7 +9,7 @@ namespace wiVersion
// minor features, major updates
const int minor = 38;
// minor bug fixes, alterations, refactors, updates
const int revision = 26;
const int revision = 27;
long GetVersion()