mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-07-20 22:41:36 +00:00
Pass selected slice/face and sample idx to custom vis shaders. Refs #304
This commit is contained in:
@@ -58,6 +58,8 @@ There are several constant parameters available, each detailed below with the va
|
||||
uvec4 TexDim;
|
||||
uint SelectedMip;
|
||||
uint TextureType;
|
||||
uint SelectedSliceFace;
|
||||
int SelectedSample;
|
||||
} RENDERDOC;
|
||||
|
||||
In this way you can access the properties as ``RENDERDOC.TexDim`` insetad of ``RENDERDOC_TexDim``.
|
||||
@@ -89,6 +91,28 @@ Selected Mip level
|
||||
|
||||
This variable will be filled out with the selected mip level in the UI.
|
||||
|
||||
Selected Slice/Face
|
||||
```````````````````
|
||||
|
||||
.. highlight:: c++
|
||||
.. code:: c++
|
||||
|
||||
uint RENDERDOC_SelectedSliceFace;
|
||||
|
||||
This variable will be filled out with the selected texture array slice (or cubemap face) in the UI.
|
||||
|
||||
Selected Multisample sample
|
||||
```````````````````````````
|
||||
|
||||
.. highlight:: c++
|
||||
.. code:: c++
|
||||
|
||||
int RENDERDOC_SelectedSample;
|
||||
|
||||
This variable will be filled out with the selected multisample sample index as chosen in the UI. If the UI has 'average value' selected, this variable will be negative and with an absolute value equal to the number of samples.
|
||||
|
||||
So for example in a 4x MSAA texture, the valid values are ``0``, ``1``, ``2``, ``3`` to select a sample, or ``-4`` for 'average value'.
|
||||
|
||||
Current texture type
|
||||
````````````````````
|
||||
|
||||
|
||||
@@ -131,10 +131,10 @@ public:
|
||||
m_Proxy->BuildCustomShader(source, entry, compileFlags, type, id, errors);
|
||||
}
|
||||
void FreeCustomShader(ResourceId id) { m_Proxy->FreeTargetResource(id); }
|
||||
ResourceId ApplyCustomShader(ResourceId shader, ResourceId texid, uint32_t mip,
|
||||
FormatComponentType typeHint)
|
||||
ResourceId ApplyCustomShader(ResourceId shader, ResourceId texid, uint32_t mip, uint32_t arrayIdx,
|
||||
uint32_t sampleIdx, FormatComponentType typeHint)
|
||||
{
|
||||
return m_Proxy->ApplyCustomShader(shader, m_TextureID, mip, typeHint);
|
||||
return m_Proxy->ApplyCustomShader(shader, m_TextureID, mip, arrayIdx, sampleIdx, typeHint);
|
||||
}
|
||||
vector<ResourceId> GetTextures() { return m_Proxy->GetTextures(); }
|
||||
FetchTexture GetTexture(ResourceId id) { return m_Proxy->GetTexture(m_TextureID); }
|
||||
|
||||
@@ -320,14 +320,15 @@ public:
|
||||
m_Proxy->FreeTargetResource(id);
|
||||
}
|
||||
|
||||
ResourceId ApplyCustomShader(ResourceId shader, ResourceId texid, uint32_t mip,
|
||||
FormatComponentType typeHint)
|
||||
ResourceId ApplyCustomShader(ResourceId shader, ResourceId texid, uint32_t mip, uint32_t arrayIdx,
|
||||
uint32_t sampleIdx, FormatComponentType typeHint)
|
||||
{
|
||||
if(m_Proxy)
|
||||
{
|
||||
EnsureTexCached(texid, 0, mip);
|
||||
texid = m_ProxyTextureIds[texid];
|
||||
ResourceId customResourceId = m_Proxy->ApplyCustomShader(shader, texid, mip, typeHint);
|
||||
ResourceId customResourceId =
|
||||
m_Proxy->ApplyCustomShader(shader, texid, mip, arrayIdx, sampleIdx, typeHint);
|
||||
m_LocalTextures.insert(customResourceId);
|
||||
m_ProxyTextureIds[customResourceId] = customResourceId;
|
||||
return customResourceId;
|
||||
|
||||
@@ -2982,6 +2982,7 @@ byte *D3D11DebugManager::GetTextureData(ResourceId id, uint32_t arrayIdx, uint32
|
||||
}
|
||||
|
||||
ResourceId D3D11DebugManager::ApplyCustomShader(ResourceId shader, ResourceId texid, uint32_t mip,
|
||||
uint32_t arrayIdx, uint32_t sampleIdx,
|
||||
FormatComponentType typeHint)
|
||||
{
|
||||
TextureShaderDetails details = GetShaderDetails(texid, typeHint, false);
|
||||
@@ -3032,13 +3033,13 @@ ResourceId D3D11DebugManager::ApplyCustomShader(ResourceId shader, ResourceId te
|
||||
disp.HDRMul = -1.0f;
|
||||
disp.linearDisplayAsGamma = false;
|
||||
disp.mip = mip;
|
||||
disp.sampleIdx = 0;
|
||||
disp.sampleIdx = sampleIdx;
|
||||
disp.overlay = eTexOverlay_None;
|
||||
disp.rangemin = 0.0f;
|
||||
disp.rangemax = 1.0f;
|
||||
disp.rawoutput = false;
|
||||
disp.scale = 1.0f;
|
||||
disp.sliceFace = 0;
|
||||
disp.sliceFace = arrayIdx;
|
||||
|
||||
SetOutputDimensions(RDCMAX(1U, details.texWidth >> mip), RDCMAX(1U, details.texHeight >> mip));
|
||||
|
||||
|
||||
@@ -3298,11 +3298,13 @@ bool D3D11DebugManager::RenderTexture(TextureDisplay cfg, bool blendAlpha)
|
||||
TextureShaderDetails details =
|
||||
GetShaderDetails(cfg.texid, cfg.typeHint, cfg.rawoutput ? true : false);
|
||||
|
||||
pixelData.SampleIdx = (int)RDCCLAMP(cfg.sampleIdx, 0U, details.sampleCount - 1);
|
||||
int sampleIdx = (int)RDCCLAMP(cfg.sampleIdx, 0U, details.sampleCount - 1);
|
||||
|
||||
// hacky resolve
|
||||
if(cfg.sampleIdx == ~0U)
|
||||
pixelData.SampleIdx = -int(details.sampleCount);
|
||||
sampleIdx = -int(details.sampleCount);
|
||||
|
||||
pixelData.SampleIdx = sampleIdx;
|
||||
|
||||
if(details.texFmt == DXGI_FORMAT_UNKNOWN)
|
||||
return false;
|
||||
@@ -3418,6 +3420,36 @@ bool D3D11DebugManager::RenderTexture(TextureDisplay cfg, bool blendAlpha)
|
||||
var.name.c_str());
|
||||
}
|
||||
}
|
||||
else if(var.name == "RENDERDOC_SelectedSliceFace")
|
||||
{
|
||||
if(var.type.descriptor.rows == 1 && var.type.descriptor.cols == 1 &&
|
||||
var.type.descriptor.type == DXBC::VARTYPE_UINT)
|
||||
{
|
||||
uint32_t *d = (uint32_t *)(byteData + var.descriptor.offset);
|
||||
|
||||
d[0] = cfg.sliceFace;
|
||||
}
|
||||
else
|
||||
{
|
||||
RDCWARN("Custom shader: Variable recognised but type wrong, expected uint: %s",
|
||||
var.name.c_str());
|
||||
}
|
||||
}
|
||||
else if(var.name == "RENDERDOC_SelectedSample")
|
||||
{
|
||||
if(var.type.descriptor.rows == 1 && var.type.descriptor.cols == 1 &&
|
||||
var.type.descriptor.type == DXBC::VARTYPE_INT)
|
||||
{
|
||||
int32_t *d = (int32_t *)(byteData + var.descriptor.offset);
|
||||
|
||||
d[0] = cfg.sampleIdx;
|
||||
}
|
||||
else
|
||||
{
|
||||
RDCWARN("Custom shader: Variable recognised but type wrong, expected int: %s",
|
||||
var.name.c_str());
|
||||
}
|
||||
}
|
||||
else if(var.name == "RENDERDOC_TextureType")
|
||||
{
|
||||
if(var.type.descriptor.rows == 1 && var.type.descriptor.cols == 1 &&
|
||||
|
||||
@@ -194,8 +194,8 @@ public:
|
||||
ResourceId RenderOverlay(ResourceId texid, FormatComponentType typeHint,
|
||||
TextureDisplayOverlay overlay, uint32_t eventID,
|
||||
const vector<uint32_t> &passEvents);
|
||||
ResourceId ApplyCustomShader(ResourceId shader, ResourceId texid, uint32_t mip,
|
||||
FormatComponentType typeHint);
|
||||
ResourceId ApplyCustomShader(ResourceId shader, ResourceId texid, uint32_t mip, uint32_t arrayIdx,
|
||||
uint32_t sampleIdx, FormatComponentType typeHint);
|
||||
|
||||
// don't need to differentiate arrays as we treat everything
|
||||
// as an array (potentially with only one element).
|
||||
|
||||
@@ -1581,9 +1581,11 @@ ResourceId D3D11Replay::RenderOverlay(ResourceId texid, FormatComponentType type
|
||||
}
|
||||
|
||||
ResourceId D3D11Replay::ApplyCustomShader(ResourceId shader, ResourceId texid, uint32_t mip,
|
||||
uint32_t arrayIdx, uint32_t sampleIdx,
|
||||
FormatComponentType typeHint)
|
||||
{
|
||||
return m_pDevice->GetDebugManager()->ApplyCustomShader(shader, texid, mip, typeHint);
|
||||
return m_pDevice->GetDebugManager()->ApplyCustomShader(shader, texid, mip, arrayIdx, sampleIdx,
|
||||
typeHint);
|
||||
}
|
||||
|
||||
bool D3D11Replay::IsRenderOutput(ResourceId id)
|
||||
|
||||
@@ -155,8 +155,8 @@ public:
|
||||
|
||||
void BuildCustomShader(string source, string entry, const uint32_t compileFlags,
|
||||
ShaderStageType type, ResourceId *id, string *errors);
|
||||
ResourceId ApplyCustomShader(ResourceId shader, ResourceId texid, uint32_t mip,
|
||||
FormatComponentType typeHint);
|
||||
ResourceId ApplyCustomShader(ResourceId shader, ResourceId texid, uint32_t mip, uint32_t arrayIdx,
|
||||
uint32_t sampleIdx, FormatComponentType typeHint);
|
||||
|
||||
bool IsRenderOutput(ResourceId id);
|
||||
|
||||
|
||||
@@ -475,6 +475,7 @@ ResourceId D3D12Replay::RenderOverlay(ResourceId texid, FormatComponentType type
|
||||
}
|
||||
|
||||
ResourceId D3D12Replay::ApplyCustomShader(ResourceId shader, ResourceId texid, uint32_t mip,
|
||||
uint32_t arrayIdx, uint32_t sampleIdx,
|
||||
FormatComponentType typeHint)
|
||||
{
|
||||
return ResourceId();
|
||||
|
||||
@@ -150,8 +150,8 @@ public:
|
||||
|
||||
void BuildCustomShader(string source, string entry, const uint32_t compileFlags,
|
||||
ShaderStageType type, ResourceId *id, string *errors);
|
||||
ResourceId ApplyCustomShader(ResourceId shader, ResourceId texid, uint32_t mip,
|
||||
FormatComponentType typeHint);
|
||||
ResourceId ApplyCustomShader(ResourceId shader, ResourceId texid, uint32_t mip, uint32_t arrayIdx,
|
||||
uint32_t sampleIdx, FormatComponentType typeHint);
|
||||
|
||||
bool IsRenderOutput(ResourceId id);
|
||||
|
||||
|
||||
@@ -1475,6 +1475,20 @@ bool GLReplay::RenderTextureInternal(TextureDisplay cfg, bool blendAlpha)
|
||||
if(loc >= 0)
|
||||
gl.glProgramUniform1ui(customProg, loc, cfg.mip);
|
||||
|
||||
loc = gl.glGetUniformLocation(customProg, "RENDERDOC_SelectedSliceFace");
|
||||
if(loc >= 0)
|
||||
gl.glProgramUniform1ui(customProg, loc, cfg.sliceFace);
|
||||
|
||||
loc = gl.glGetUniformLocation(customProg, "RENDERDOC_SelectedSample");
|
||||
if(loc >= 0)
|
||||
{
|
||||
if(cfg.sampleIdx == ~0U)
|
||||
gl.glProgramUniform1i(customProg, loc, -texDetails.samples);
|
||||
else
|
||||
gl.glProgramUniform1i(customProg, loc,
|
||||
(int)RDCCLAMP(cfg.sampleIdx, 0U, (uint32_t)texDetails.samples - 1));
|
||||
}
|
||||
|
||||
loc = gl.glGetUniformLocation(customProg, "RENDERDOC_TextureType");
|
||||
if(loc >= 0)
|
||||
gl.glProgramUniform1ui(customProg, loc, resType);
|
||||
|
||||
@@ -2611,6 +2611,7 @@ void GLReplay::BuildCustomShader(string source, string entry, const uint32_t com
|
||||
}
|
||||
|
||||
ResourceId GLReplay::ApplyCustomShader(ResourceId shader, ResourceId texid, uint32_t mip,
|
||||
uint32_t arrayIdx, uint32_t sampleIdx,
|
||||
FormatComponentType typeHint)
|
||||
{
|
||||
if(shader == ResourceId() || texid == ResourceId())
|
||||
@@ -2647,13 +2648,13 @@ ResourceId GLReplay::ApplyCustomShader(ResourceId shader, ResourceId texid, uint
|
||||
disp.HDRMul = -1.0f;
|
||||
disp.linearDisplayAsGamma = false;
|
||||
disp.mip = mip;
|
||||
disp.sampleIdx = 0;
|
||||
disp.sampleIdx = sampleIdx;
|
||||
disp.overlay = eTexOverlay_None;
|
||||
disp.rangemin = 0.0f;
|
||||
disp.rangemax = 1.0f;
|
||||
disp.rawoutput = false;
|
||||
disp.scale = 1.0f;
|
||||
disp.sliceFace = 0;
|
||||
disp.sliceFace = arrayIdx;
|
||||
|
||||
RenderTextureInternal(disp, false);
|
||||
|
||||
|
||||
@@ -194,8 +194,8 @@ public:
|
||||
|
||||
ResourceId RenderOverlay(ResourceId id, FormatComponentType typeHint, TextureDisplayOverlay overlay,
|
||||
uint32_t eventID, const vector<uint32_t> &passEvents);
|
||||
ResourceId ApplyCustomShader(ResourceId shader, ResourceId texid, uint32_t mip,
|
||||
FormatComponentType typeHint);
|
||||
ResourceId ApplyCustomShader(ResourceId shader, ResourceId texid, uint32_t mip, uint32_t arrayIdx,
|
||||
uint32_t sampleIdx, FormatComponentType typeHint);
|
||||
|
||||
ResourceId CreateProxyTexture(const FetchTexture &templateTex);
|
||||
void SetProxyTextureData(ResourceId texid, uint32_t arrayIdx, uint32_t mip, byte *data,
|
||||
|
||||
@@ -1226,10 +1226,14 @@ bool VulkanReplay::RenderTextureInternal(TextureDisplay cfg, VkRenderPassBeginIn
|
||||
|
||||
data->Scale = cfg.scale * mipScale;
|
||||
|
||||
data->SampleIdx = cfg.sampleIdx;
|
||||
int sampleIdx = (int)RDCCLAMP(cfg.sampleIdx, 0U, (uint32_t)SampleCount(iminfo.samples));
|
||||
|
||||
sampleIdx = cfg.sampleIdx;
|
||||
|
||||
if(cfg.sampleIdx == ~0U)
|
||||
data->SampleIdx = -SampleCount(iminfo.samples);
|
||||
sampleIdx = -SampleCount(iminfo.samples);
|
||||
|
||||
data->SampleIdx = sampleIdx;
|
||||
|
||||
data->OutputRes.x = (float)m_DebugWidth;
|
||||
data->OutputRes.y = (float)m_DebugHeight;
|
||||
@@ -1273,7 +1277,8 @@ bool VulkanReplay::RenderTextureInternal(TextureDisplay cfg, VkRenderPassBeginIn
|
||||
Vec4u texDim;
|
||||
uint32_t selectedMip;
|
||||
uint32_t texType;
|
||||
uint32_t padding[2];
|
||||
uint32_t selectedSliceFace;
|
||||
int32_t selectedSample;
|
||||
};
|
||||
|
||||
CustomTexDisplayUBOData *customData = (CustomTexDisplayUBOData *)data;
|
||||
@@ -1283,7 +1288,8 @@ bool VulkanReplay::RenderTextureInternal(TextureDisplay cfg, VkRenderPassBeginIn
|
||||
customData->texDim.z = iminfo.extent.depth;
|
||||
customData->texDim.w = iminfo.mipLevels;
|
||||
customData->selectedMip = cfg.mip;
|
||||
customData->padding[0] = customData->padding[1] = 0;
|
||||
customData->selectedSliceFace = cfg.sliceFace;
|
||||
customData->selectedSample = sampleIdx;
|
||||
customData->texType = (uint32_t)textype;
|
||||
}
|
||||
|
||||
@@ -5357,6 +5363,7 @@ void VulkanReplay::FreeCustomShader(ResourceId id)
|
||||
}
|
||||
|
||||
ResourceId VulkanReplay::ApplyCustomShader(ResourceId shader, ResourceId texid, uint32_t mip,
|
||||
uint32_t arrayIdx, uint32_t sampleIdx,
|
||||
FormatComponentType typeHint)
|
||||
{
|
||||
if(shader == ResourceId() || texid == ResourceId())
|
||||
@@ -5383,13 +5390,13 @@ ResourceId VulkanReplay::ApplyCustomShader(ResourceId shader, ResourceId texid,
|
||||
disp.HDRMul = -1.0f;
|
||||
disp.linearDisplayAsGamma = false;
|
||||
disp.mip = mip;
|
||||
disp.sampleIdx = 0;
|
||||
disp.sampleIdx = sampleIdx;
|
||||
disp.overlay = eTexOverlay_None;
|
||||
disp.rangemin = 0.0f;
|
||||
disp.rangemax = 1.0f;
|
||||
disp.rawoutput = false;
|
||||
disp.scale = 1.0f;
|
||||
disp.sliceFace = 0;
|
||||
disp.sliceFace = arrayIdx;
|
||||
|
||||
VkClearValue clearval = {{{0.0f, 0.0f, 0.0f, 1.0f}}};
|
||||
VkRenderPassBeginInfo rpbegin = {
|
||||
|
||||
@@ -196,8 +196,8 @@ public:
|
||||
ResourceId RenderOverlay(ResourceId cfg, FormatComponentType typeHint,
|
||||
TextureDisplayOverlay overlay, uint32_t eventID,
|
||||
const vector<uint32_t> &passEvents);
|
||||
ResourceId ApplyCustomShader(ResourceId shader, ResourceId texid, uint32_t mip,
|
||||
FormatComponentType typeHint);
|
||||
ResourceId ApplyCustomShader(ResourceId shader, ResourceId texid, uint32_t mip, uint32_t arrayIdx,
|
||||
uint32_t sampleIdx, FormatComponentType typeHint);
|
||||
|
||||
ResourceId CreateProxyTexture(const FetchTexture &templateTex);
|
||||
void SetProxyTextureData(ResourceId texid, uint32_t arrayIdx, uint32_t mip, byte *data,
|
||||
|
||||
@@ -166,6 +166,7 @@ public:
|
||||
virtual void BuildCustomShader(string source, string entry, const uint32_t compileFlags,
|
||||
ShaderStageType type, ResourceId *id, string *errors) = 0;
|
||||
virtual ResourceId ApplyCustomShader(ResourceId shader, ResourceId texid, uint32_t mip,
|
||||
uint32_t arrayIdx, uint32_t sampleIdx,
|
||||
FormatComponentType typeHint) = 0;
|
||||
virtual void FreeCustomShader(ResourceId id) = 0;
|
||||
|
||||
|
||||
@@ -566,7 +566,8 @@ void ReplayOutput::DisplayTex()
|
||||
if(m_RenderData.texDisplay.CustomShader != ResourceId())
|
||||
{
|
||||
m_CustomShaderResourceId = m_pDevice->ApplyCustomShader(
|
||||
m_RenderData.texDisplay.CustomShader, texDisplay.texid, texDisplay.mip, texDisplay.typeHint);
|
||||
m_RenderData.texDisplay.CustomShader, texDisplay.texid, texDisplay.mip,
|
||||
texDisplay.sliceFace, texDisplay.sampleIdx, texDisplay.typeHint);
|
||||
|
||||
texDisplay.texid = m_pDevice->GetLiveID(m_CustomShaderResourceId);
|
||||
texDisplay.typeHint = eCompType_None;
|
||||
|
||||
Reference in New Issue
Block a user