mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-09-21 13:15:57 +00:00
Fix handling of slice offsets for 3D textures
* There were inconsistencies that could lead to off-by-one or missampling in some cases when applying a slight offset to ensure we sample the selected slice of the texture.
This commit is contained in:
@@ -88,7 +88,7 @@ uvec4 SampleTextureUInt4(int type, vec2 pos, float slice, int mipLevel, int samp
|
||||
}
|
||||
else // if (type == RESTYPE_TEX3D)
|
||||
{
|
||||
col = texelFetch(texUInt3D, ivec3(pos * texRes.xy, slice), mipLevel);
|
||||
col = texelFetch(texUInt3D, ivec3(pos * texRes.xy, slice + 0.001f), mipLevel);
|
||||
}
|
||||
|
||||
return col;
|
||||
@@ -166,7 +166,7 @@ ivec4 SampleTextureSInt4(int type, vec2 pos, float slice, int mipLevel, int samp
|
||||
}
|
||||
else // if (type == RESTYPE_TEX3D)
|
||||
{
|
||||
col = texelFetch(texSInt3D, ivec3(pos * texRes.xy, slice), mipLevel);
|
||||
col = texelFetch(texSInt3D, ivec3(pos * texRes.xy, slice + 0.001f), mipLevel);
|
||||
}
|
||||
|
||||
return col;
|
||||
@@ -281,7 +281,7 @@ vec4 SampleTextureFloat4(int type, vec2 pos, float slice, int mipLevel, int samp
|
||||
}
|
||||
else if(type == RESTYPE_TEX3D)
|
||||
{
|
||||
col = textureLod(tex3D, vec3(pos, slice / texRes.z), float(mipLevel));
|
||||
col = textureLod(tex3D, vec3(pos, (slice + 0.001f) / texRes.z), float(mipLevel));
|
||||
}
|
||||
else if(type == RESTYPE_TEXCUBE)
|
||||
{
|
||||
|
||||
@@ -84,7 +84,7 @@ uvec4 SampleTextureUInt4(int type, vec2 pos, float slice, int mipLevel, int samp
|
||||
}
|
||||
else // if (type == RESTYPE_TEX3D)
|
||||
{
|
||||
col = texelFetch(texUInt3D, ivec3(pos * texRes.xy, slice), mipLevel);
|
||||
col = texelFetch(texUInt3D, ivec3(pos * texRes.xy, slice + 0.001f), mipLevel);
|
||||
}
|
||||
|
||||
return col;
|
||||
@@ -150,7 +150,7 @@ ivec4 SampleTextureSInt4(int type, vec2 pos, float slice, int mipLevel, int samp
|
||||
}
|
||||
else // if (type == RESTYPE_TEX3D)
|
||||
{
|
||||
col = texelFetch(texSInt3D, ivec3(pos * texRes.xy, slice), mipLevel);
|
||||
col = texelFetch(texSInt3D, ivec3(pos * texRes.xy, slice + 0.001f), mipLevel);
|
||||
}
|
||||
|
||||
return col;
|
||||
@@ -258,7 +258,7 @@ vec4 SampleTextureFloat4(int type, vec2 pos, float slice, int mipLevel, int samp
|
||||
}
|
||||
else if(type == RESTYPE_TEX3D)
|
||||
{
|
||||
col = textureLod(tex3D, vec3(pos, slice / texRes.z), float(mipLevel));
|
||||
col = textureLod(tex3D, vec3(pos, (slice + 0.001f) / texRes.z), float(mipLevel));
|
||||
}
|
||||
else if(type == RESTYPE_TEXCUBE)
|
||||
{
|
||||
|
||||
@@ -44,7 +44,7 @@ vec4 SampleTextureFloat4(int type, vec2 pos, float slice, int mipLevel, int samp
|
||||
}
|
||||
else if(type == RESTYPE_TEX3D)
|
||||
{
|
||||
col = textureLod(tex3D, vec3(pos, slice / texRes.z), float(mipLevel));
|
||||
col = textureLod(tex3D, vec3(pos, (slice + 0.001f) / texRes.z), float(mipLevel));
|
||||
}
|
||||
else if(type == RESTYPE_TEX2DMS)
|
||||
{
|
||||
@@ -96,7 +96,7 @@ uvec4 SampleTextureUInt4(int type, vec2 pos, float slice, int mipLevel, int samp
|
||||
}
|
||||
else if(type == RESTYPE_TEX3D)
|
||||
{
|
||||
col = texelFetch(texUInt3D, ivec3(pos * texRes.xy, slice), mipLevel);
|
||||
col = texelFetch(texUInt3D, ivec3(pos * texRes.xy, slice + 0.001f), mipLevel);
|
||||
}
|
||||
else if(type == RESTYPE_TEX2DMS)
|
||||
{
|
||||
@@ -133,7 +133,7 @@ ivec4 SampleTextureSInt4(int type, vec2 pos, float slice, int mipLevel, int samp
|
||||
}
|
||||
else if(type == RESTYPE_TEX3D)
|
||||
{
|
||||
col = texelFetch(texSInt3D, ivec3(pos * texRes.xy, slice), mipLevel);
|
||||
col = texelFetch(texSInt3D, ivec3(pos * texRes.xy, slice + 0.001f), mipLevel);
|
||||
}
|
||||
else if(type == RESTYPE_TEX2DMS)
|
||||
{
|
||||
|
||||
@@ -61,7 +61,7 @@ uint4 SampleTextureUInt4(uint type, float2 uv, float slice, float mip, int sampl
|
||||
if(type == RESTYPE_TEX1D)
|
||||
col = texDisplayUIntTex1DArray.Load(int3(uv.x*texRes.x, slice, mip));
|
||||
else if(type == RESTYPE_TEX3D)
|
||||
col = texDisplayUIntTex3D.Load(int4(uv.xy*texRes.xy, slice*texRes.z, mip));
|
||||
col = texDisplayUIntTex3D.Load(int4(uv.xy*texRes.xy, slice + 0.001f, mip));
|
||||
else if(type == RESTYPE_TEX2D)
|
||||
col = texDisplayUIntTex2DArray.Load(int4(uv.xy*texRes.xy, slice, mip));
|
||||
else if(type == RESTYPE_TEX2D_MS)
|
||||
@@ -81,7 +81,7 @@ int4 SampleTextureInt4(uint type, float2 uv, float slice, float mip, int sample,
|
||||
if(type == RESTYPE_TEX1D)
|
||||
col = texDisplayIntTex1DArray.Load(int3(uv.x*texRes.x, slice, mip));
|
||||
else if(type == RESTYPE_TEX3D)
|
||||
col = texDisplayIntTex3D.Load(int4(uv.xy*texRes.xy, slice*texRes.z, mip));
|
||||
col = texDisplayIntTex3D.Load(int4(uv.xy*texRes.xy, slice + 0.001f, mip));
|
||||
else if(type == RESTYPE_TEX2D)
|
||||
col = texDisplayIntTex2DArray.Load(int4(uv.xy*texRes.xy, slice, mip));
|
||||
else if(type == RESTYPE_TEX2D_MS)
|
||||
@@ -108,9 +108,9 @@ float4 SampleTextureFloat4(uint type, bool linearSample, float2 uv, float slice,
|
||||
else if(type == RESTYPE_TEX3D)
|
||||
{
|
||||
if(linearSample)
|
||||
col = texDisplayTex3D.SampleLevel(linearSampler, float3(uv.xy, slice), mip);
|
||||
col = texDisplayTex3D.SampleLevel(linearSampler, float3(uv.xy, (slice + 0.001f) / texRes.z), mip);
|
||||
else
|
||||
col = texDisplayTex3D.Load(int4(uv.xy*texRes.xy, slice*texRes.z, mip));
|
||||
col = texDisplayTex3D.Load(int4(uv.xy*texRes.xy, slice + 0.001f, mip));
|
||||
}
|
||||
else if(type == RESTYPE_DEPTH)
|
||||
{
|
||||
|
||||
@@ -1817,7 +1817,7 @@ bool D3D11DebugManager::GetHistogram(ResourceId texid, uint32_t sliceFace, uint3
|
||||
}
|
||||
|
||||
if(details.texType == eTexType_3D)
|
||||
cdata.HistogramSlice = float(sliceFace) / float(details.texDepth) + 0.001f;
|
||||
cdata.HistogramSlice = float(sliceFace);
|
||||
|
||||
ID3D11Buffer *cbuf = MakeCBuffer(&cdata, sizeof(cdata));
|
||||
|
||||
@@ -1918,7 +1918,7 @@ bool D3D11DebugManager::GetMinMax(ResourceId texid, uint32_t sliceFace, uint32_t
|
||||
}
|
||||
|
||||
if(details.texType == eTexType_3D)
|
||||
cdata.HistogramSlice = float(sliceFace) / float(details.texDepth) + 0.001f;
|
||||
cdata.HistogramSlice = float(sliceFace);
|
||||
|
||||
ID3D11Buffer *cbuf = MakeCBuffer(&cdata, sizeof(cdata));
|
||||
|
||||
@@ -3414,7 +3414,7 @@ bool D3D11DebugManager::RenderTexture(TextureDisplay cfg, bool blendAlpha)
|
||||
if(details.texType == eTexType_3D)
|
||||
{
|
||||
pixelData.OutputDisplayFormat = RESTYPE_TEX3D;
|
||||
pixelData.Slice = (float(cfg.sliceFace) / float(details.texDepth)) + 0.001f;
|
||||
pixelData.Slice = float(cfg.sliceFace);
|
||||
}
|
||||
else if(details.texType == eTexType_1D)
|
||||
{
|
||||
|
||||
@@ -7981,7 +7981,7 @@ bool D3D12DebugManager::RenderTextureInternal(D3D12_CPU_DESCRIPTOR_HANDLE rtv, T
|
||||
pixelData.Slice = float(RDCCLAMP(cfg.sliceFace, 0U, uint32_t(resourceDesc.DepthOrArraySize - 1)));
|
||||
|
||||
if(resourceDesc.Dimension == D3D12_RESOURCE_DIMENSION_TEXTURE3D)
|
||||
pixelData.Slice = (float(cfg.sliceFace) / float(resourceDesc.DepthOrArraySize)) + 0.001f;
|
||||
pixelData.Slice = float(cfg.sliceFace);
|
||||
|
||||
vector<D3D12_RESOURCE_BARRIER> barriers;
|
||||
int resType = 0;
|
||||
|
||||
Reference in New Issue
Block a user