mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-08-26 08:26:50 +00:00
Allow cbuffer previewer to apply custom format to non-buffer-backed CBs
* This in particular means push constants and specialization constants on vulkan but also applies to root-value cbuffers on D3D12. * GL bare uniforms are not feasible to expose in this way.
This commit is contained in:
@@ -107,6 +107,7 @@ void ConstantBufferPreviewer::OnEventChanged(uint32_t eventId)
|
||||
m_cbuffer = cb.resourceId;
|
||||
uint64_t offset = cb.byteOffset;
|
||||
uint64_t size = cb.byteSize;
|
||||
bytebuf inlineData = cb.inlineData;
|
||||
|
||||
ResourceId prevShader = m_shader;
|
||||
|
||||
@@ -136,26 +137,24 @@ void ConstantBufferPreviewer::OnEventChanged(uint32_t eventId)
|
||||
|
||||
if(!m_formatOverride.type.members.empty())
|
||||
{
|
||||
m_Ctx.Replay().AsyncInvoke([this, offset, size, wasEmpty](IReplayController *r) {
|
||||
bytebuf data;
|
||||
if(size > 0)
|
||||
data = r->GetBufferData(m_cbuffer, offset, size);
|
||||
rdcarray<ShaderVariable> vars = applyFormatOverride(data);
|
||||
GUIInvoke::call(this, [this, vars, wasEmpty] {
|
||||
RDTreeViewExpansionState state;
|
||||
ui->variables->saveExpansion(state, 0);
|
||||
setVariables(vars);
|
||||
if(wasEmpty)
|
||||
{
|
||||
// Expand before resizing so that collapsed data will already be visible when expanded
|
||||
ui->variables->expandAll();
|
||||
for(int i = 0; i < 3; i++)
|
||||
ui->variables->resizeColumnToContents(i);
|
||||
ui->variables->collapseAll();
|
||||
}
|
||||
ui->variables->applyExpansion(state, 0);
|
||||
if(!inlineData.empty() && m_cbuffer == ResourceId())
|
||||
{
|
||||
setVariablesPreserveExpansion(applyFormatOverride(inlineData), wasEmpty);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_Ctx.Replay().AsyncInvoke([this, offset, size, wasEmpty](IReplayController *r) {
|
||||
bytebuf data;
|
||||
|
||||
if(size > 0 && m_cbuffer != ResourceId())
|
||||
data = r->GetBufferData(m_cbuffer, offset, size);
|
||||
|
||||
rdcarray<ShaderVariable> vars = applyFormatOverride(data);
|
||||
|
||||
GUIInvoke::call(this,
|
||||
[this, vars, wasEmpty] { setVariablesPreserveExpansion(vars, wasEmpty); });
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -327,6 +326,26 @@ void ConstantBufferPreviewer::setVariables(const rdcarray<ShaderVariable> &vars)
|
||||
ui->variables->endUpdate();
|
||||
}
|
||||
|
||||
void ConstantBufferPreviewer::setVariablesPreserveExpansion(const rdcarray<ShaderVariable> &vars,
|
||||
bool wasEmpty)
|
||||
{
|
||||
RDTreeViewExpansionState state;
|
||||
ui->variables->saveExpansion(state, 0);
|
||||
|
||||
setVariables(vars);
|
||||
|
||||
if(wasEmpty)
|
||||
{
|
||||
// Expand before resizing so that collapsed data will already be visible when expanded
|
||||
ui->variables->expandAll();
|
||||
for(int i = 0; i < 3; i++)
|
||||
ui->variables->resizeColumnToContents(i);
|
||||
ui->variables->collapseAll();
|
||||
}
|
||||
|
||||
ui->variables->applyExpansion(state, 0);
|
||||
}
|
||||
|
||||
void ConstantBufferPreviewer::updateLabels()
|
||||
{
|
||||
QString bufName = m_Ctx.GetResourceName(m_cbuffer);
|
||||
|
||||
Reference in New Issue
Block a user