Update replay proxy to use new serialisation mechanism

This commit is contained in:
baldurk
2017-11-07 19:30:36 +00:00
parent 9388d2b71b
commit b992e95f94
28 changed files with 1585 additions and 3127 deletions
@@ -856,7 +856,7 @@ void D3D11PipelineStateViewer::setShaderState(const D3D11Pipe::Shader &stage, QL
{
shader->setText(QFormatStr("%1() - %2")
.arg(shaderDetails->EntryPoint)
.arg(QFileInfo(shaderDetails->DebugInfo.files[0].first).fileName()));
.arg(QFileInfo(shaderDetails->DebugInfo.files[0].Filename).fileName()));
}
int vs = 0;
@@ -2549,7 +2549,7 @@ void D3D11PipelineStateViewer::exportHTML(QXmlStreamWriter &xml, const D3D11Pipe
{
shadername = QFormatStr("%1() - %2")
.arg(shaderDetails->EntryPoint)
.arg(QFileInfo(shaderDetails->DebugInfo.files[0].first).fileName());
.arg(QFileInfo(shaderDetails->DebugInfo.files[0].Filename).fileName());
}
xml.writeStartElement(lit("p"));
@@ -926,7 +926,7 @@ void D3D12PipelineStateViewer::setShaderState(const D3D12Pipe::Shader &stage, QL
{
shader->setText(QFormatStr("%1() - %2")
.arg(shaderDetails->EntryPoint)
.arg(QFileInfo(shaderDetails->DebugInfo.files[0].first).fileName()));
.arg(QFileInfo(shaderDetails->DebugInfo.files[0].Filename).fileName()));
}
int vs = 0;
@@ -2378,7 +2378,7 @@ void D3D12PipelineStateViewer::exportHTML(QXmlStreamWriter &xml, const D3D12Pipe
{
shadername = QFormatStr("%1() - %2")
.arg(shaderDetails->EntryPoint)
.arg(QFileInfo(shaderDetails->DebugInfo.files[0].first).fileName());
.arg(QFileInfo(shaderDetails->DebugInfo.files[0].Filename).fileName());
}
xml.writeStartElement(lit("p"));
@@ -550,18 +550,18 @@ bool PipelineStateViewer::PrepareShaderEditing(const ShaderReflection *shaderDet
for(auto &s : shaderDetails->DebugInfo.files)
{
QString filename = s.first;
QString filename = s.Filename;
if(uniqueFiles.contains(filename.toLower()))
{
qWarning() << lit("Duplicate full filename") << QString(s.first);
qWarning() << lit("Duplicate full filename") << filename;
continue;
}
uniqueFiles.push_back(filename.toLower());
files[filename] = s.second;
files[filename] = s.Contents;
}
mainfile = shaderDetails->DebugInfo.files[0].first;
mainfile = shaderDetails->DebugInfo.files[0].Filename;
return true;
}
@@ -1278,7 +1278,7 @@ void VulkanPipelineStateViewer::setShaderState(const VKPipe::Shader &stage,
if(!shaderDetails->DebugInfo.files.isEmpty())
shader->setText(entryFunc + lit("() - ") +
QFileInfo(shaderDetails->DebugInfo.files[0].first).fileName());
QFileInfo(shaderDetails->DebugInfo.files[0].Filename).fileName());
}
int vs = 0;
@@ -2595,7 +2595,7 @@ void VulkanPipelineStateViewer::exportHTML(QXmlStreamWriter &xml, const VKPipe::
else if(!shaderDetails->DebugInfo.files.isEmpty())
shadername = QFormatStr("%1() - %2")
.arg(entryFunc)
.arg(QFileInfo(shaderDetails->DebugInfo.files[0].first).fileName());
.arg(QFileInfo(shaderDetails->DebugInfo.files[0].Filename).fileName());
}
xml.writeStartElement(lit("p"));
+14 -14
View File
@@ -364,10 +364,10 @@ void ShaderViewer::debugShader(const ShaderBindpointMapping *bind, const ShaderR
int fileIdx = 0;
QWidget *sel = NULL;
for(auto &f : shader->DebugInfo.files)
for(const ShaderSourceFile &f : shader->DebugInfo.files)
{
QString name = QFileInfo(f.first).fileName();
QString text = f.second;
QString name = QFileInfo(f.Filename).fileName();
QString text = f.Contents;
ScintillaEdit *scintilla = AddFileScintilla(name, text);
@@ -1135,13 +1135,13 @@ void ShaderViewer::updateDebugging()
{
for(int i = 0; i < m_Trace->cbuffers.count(); i++)
{
for(int j = 0; j < m_Trace->cbuffers[i].count(); j++)
for(int j = 0; j < m_Trace->cbuffers[i].members.count(); j++)
{
if(m_Trace->cbuffers[i][j].rows > 0 || m_Trace->cbuffers[i][j].columns > 0)
if(m_Trace->cbuffers[i].members[j].rows > 0 || m_Trace->cbuffers[i].members[j].columns > 0)
{
RDTreeWidgetItem *node =
new RDTreeWidgetItem({m_Trace->cbuffers[i][j].name, lit("cbuffer"),
stringRep(m_Trace->cbuffers[i][j], false)});
new RDTreeWidgetItem({m_Trace->cbuffers[i].members[j].name, lit("cbuffer"),
stringRep(m_Trace->cbuffers[i].members[j], false)});
node->setTag(QVariant::fromValue(VariableTag(VariableCategory::Constants, j, i)));
ui->constants->addTopLevelItem(node);
@@ -1251,9 +1251,9 @@ void ShaderViewer::updateDebugging()
{
RDTreeWidgetItem *node =
new RDTreeWidgetItem({QFormatStr("x%1").arg(i), lit("indexable"), QString()});
for(int t = 0; t < state.indexableTemps[i].count(); t++)
node->addChild(
new RDTreeWidgetItem({state.indexableTemps[i][t].name, lit("indexable"), QString()}));
for(int t = 0; t < state.indexableTemps[i].members.count(); t++)
node->addChild(new RDTreeWidgetItem(
{state.indexableTemps[i].members[t].name, lit("indexable"), QString()}));
ui->variables->addTopLevelItem(node);
}
@@ -1278,11 +1278,11 @@ void ShaderViewer::updateDebugging()
{
RDTreeWidgetItem *node = ui->variables->topLevelItem(v++);
for(int t = 0; t < state.indexableTemps[i].count(); t++)
for(int t = 0; t < state.indexableTemps[i].members.count(); t++)
{
RDTreeWidgetItem *child = node->child(t);
child->setText(2, stringRep(state.indexableTemps[i][t], false));
child->setText(2, stringRep(state.indexableTemps[i].members[t], false));
child->setTag(QVariant::fromValue(VariableTag(VariableCategory::IndexTemporaries, t, i)));
}
}
@@ -1928,11 +1928,11 @@ const rdcarray<ShaderVariable> *ShaderViewer::GetVariableList(VariableCategory v
case VariableCategory::Unknown: vars = NULL; break;
case VariableCategory::Temporaries: vars = &state.registers; break;
case VariableCategory::IndexTemporaries:
vars = arrayIdx < state.indexableTemps.count() ? &state.indexableTemps[arrayIdx] : NULL;
vars = arrayIdx < state.indexableTemps.count() ? &state.indexableTemps[arrayIdx].members : NULL;
break;
case VariableCategory::Inputs: vars = &m_Trace->inputs; break;
case VariableCategory::Constants:
vars = arrayIdx < m_Trace->cbuffers.count() ? &m_Trace->cbuffers[arrayIdx] : NULL;
vars = arrayIdx < m_Trace->cbuffers.count() ? &m_Trace->cbuffers[arrayIdx].members : NULL;
break;
case VariableCategory::Outputs: vars = &state.outputs; break;
}
+6
View File
@@ -882,6 +882,12 @@ different to the above, and lets the UI make decisions e.g. to flip rendering of
with software rendering, or with some functionality disabled due to lack of support.
)");
bool degraded;
DOCUMENT(R"(``True`` if the driver mutates shader reflection structures from event to event.
Currently this is only true for OpenGL where the superfluous indirect in the binding model must be
worked around by re-sorting bindings.
)");
bool shadersMutable;
};
DECLARE_REFLECTION_STRUCT(APIProperties);
+32 -6
View File
@@ -203,7 +203,7 @@ struct ShaderDebugState
DOCUMENT(
"Indexable temporary variables for this shader as a list of :class:`ShaderValue` lists.");
rdcarray<rdcarray<ShaderVariable> > indexableTemps;
rdcarray<ShaderVariable> indexableTemps;
DOCUMENT(R"(The next instruction to be executed after this state. The initial state before any
shader execution happened will have ``nextInstruction == 0``.)");
@@ -228,7 +228,7 @@ struct ShaderDebugTrace
Each entry in this list corresponds to a constant block with the same index in the
:data:`ShaderBindpointMapping.ConstantBlocks` list, which can be used to look up the metadata.
)");
rdcarray<rdcarray<ShaderVariable> > cbuffers;
rdcarray<ShaderVariable> cbuffers;
DOCUMENT(R"(A list of :class:`ShaderDebugState` states representing the state after each
instruction was executed
@@ -451,16 +451,42 @@ able to be read from and written to arbitrarily.
DECLARE_REFLECTION_STRUCT(ShaderResource);
DOCUMENT("Contains a single flag used at compile-time on a shader.");
struct ShaderCompileFlag
{
DOCUMENT("The name of the compile flag.");
rdcstr Name;
DOCUMENT("The value of the compile flag.");
rdcstr Value;
};
DECLARE_REFLECTION_STRUCT(ShaderCompileFlag);
DOCUMENT("Contains the information about the compilation environment of a shader");
struct ShaderCompileFlags
{
DOCUMENT(R"(A list of tuples, where each tuple is a pair of flagName, flagValue.
DOCUMENT(R"(A list of :class:`ShaderCompileFlag`.
Each entry is an API or compiler specific flag used to compile this shader originally.
)");
rdcarray<rdcpair<rdcstr, rdcstr> > flags;
rdcarray<ShaderCompileFlag> flags;
};
DECLARE_REFLECTION_STRUCT(ShaderCompileFlags);
DOCUMENT("Contains a source file available in a debug-compiled shader.");
struct ShaderSourceFile
{
DOCUMENT("The filename of this source file.");
rdcstr Filename;
DOCUMENT("The actual contents of the file.");
rdcstr Contents;
};
DECLARE_REFLECTION_STRUCT(ShaderSourceFile);
DOCUMENT(R"(Contains the information about a shader contained within API-specific debugging
information attached to the shader.
@@ -472,11 +498,11 @@ struct ShaderDebugChunk
DOCUMENT("A :class:`ShaderCompileFlags` containing the flags used to compile this shader.");
ShaderCompileFlags compileFlags;
DOCUMENT(R"(A list of tuples, where each tuple is a pair of filename, source code.
DOCUMENT(R"(A list of :class:`ShaderSourceFile`.
The first entry in the list is always the file where the entry point is.
)");
rdcarray<rdcpair<rdcstr, rdcstr> > files;
rdcarray<ShaderSourceFile> files;
};
DECLARE_REFLECTION_STRUCT(ShaderDebugChunk);
+6 -5
View File
@@ -137,10 +137,10 @@ public:
}
vector<ResourceId> GetTextures() { return {m_TextureID}; }
TextureDescription GetTexture(ResourceId id) { return m_Proxy->GetTexture(m_TextureID); }
byte *GetTextureData(ResourceId tex, uint32_t arrayIdx, uint32_t mip,
const GetTextureDataParams &params, size_t &dataSize)
void GetTextureData(ResourceId tex, uint32_t arrayIdx, uint32_t mip,
const GetTextureDataParams &params, bytebuf &data)
{
return m_Proxy->GetTextureData(m_TextureID, arrayIdx, mip, params, dataSize);
m_Proxy->GetTextureData(m_TextureID, arrayIdx, mip, params, data);
}
// handle a couple of operations ourselves to return a simple fake log
@@ -170,10 +170,11 @@ public:
bool IsRenderOutput(ResourceId id) { return false; }
ResourceId GetLiveID(ResourceId id) { return id; }
vector<GPUCounter> EnumerateCounters() { return vector<GPUCounter>(); }
void DescribeCounter(GPUCounter counterID, CounterDescription &desc)
CounterDescription DescribeCounter(GPUCounter counterID)
{
RDCEraseEl(desc);
CounterDescription desc = {};
desc.counterID = counterID;
return desc;
}
vector<CounterResult> FetchCounters(const vector<GPUCounter> &counters)
{
File diff suppressed because it is too large Load Diff
+81 -89
View File
@@ -37,6 +37,7 @@ enum ReplayProxyPacket
eReplayProxy_ReplayLog = eReplayProxy_First,
eReplayProxy_GetAPIProperties,
eReplayProxy_GetPassEvents,
eReplayProxy_GetTextures,
@@ -56,8 +57,7 @@ enum ReplayProxyPacket
eReplayProxy_IsRenderOutput,
eReplayProxy_NeedRemapForFetch,
eReplayProxy_FreeResource,
eReplayProxy_HasResolver,
eReplayProxy_FreeTargetResource,
eReplayProxy_FetchCounters,
eReplayProxy_EnumerateCounters,
@@ -68,10 +68,6 @@ enum ReplayProxyPacket
eReplayProxy_InitPostVSVec,
eReplayProxy_GetPostVS,
eReplayProxy_InitStackResolver,
eReplayProxy_HasStackResolver,
eReplayProxy_GetAddressDetails,
eReplayProxy_BuildTargetShader,
eReplayProxy_ReplaceResource,
eReplayProxy_RemoveReplacement,
@@ -82,40 +78,36 @@ enum ReplayProxyPacket
eReplayProxy_RenderOverlay,
eReplayProxy_GetAPIProperties,
eReplayProxy_PixelHistory,
eReplayProxy_DisassembleShader,
eReplayProxy_GetISATargets,
eReplayProxy_GetDisassemblyTargets,
};
// This class implements IReplayDriver and StackResolver. On the local machine where the UI
// is, this can then act like a full local replay by farming out over the network to a remote
// replay where necessary to implement some functions, and using a local proxy where necessary.
#define IMPLEMENT_FUNCTION_PROXIED(rettype, name, ...) \
rettype name(__VA_ARGS__); \
template <typename ParamSerialiser, typename ReturnSerialiser> \
rettype CONCAT(Proxied_, name)(ParamSerialiser & paramser, ReturnSerialiser & retser, \
##__VA_ARGS__);
// This class implements IReplayDriver. On the local machine where the UI is, this can then act like
// a full local replay by farming out over the network to a remote replay where necessary to
// implement some functions, and using a local proxy where necessary.
//
// This class is also used on the remote replay just so we can re-use the serialisation logic
// across the network before and after implementing the IRemoteDriver parts.
class ReplayProxy : public IReplayDriver, Callstack::StackResolver
// This class is also used on the remote replay just so we can re-use the serialisation logic across
// the network before and after implementing the IRemoteDriver parts.
class ReplayProxy : public IReplayDriver
{
public:
ReplayProxy(Network::Socket *sock, IReplayDriver *proxy)
: m_Socket(sock), m_Proxy(proxy), m_Remote(NULL), m_RemoteServer(false)
ReplayProxy(ReadSerialiser &reader, WriteSerialiser &writer, IReplayDriver *proxy)
: m_Reader(reader), m_Writer(writer), m_Proxy(proxy), m_Remote(NULL), m_RemoteServer(false)
{
m_FromReplaySerialiser = NULL;
m_ToReplaySerialiser = new Serialiser(NULL, Serialiser::WRITING, false);
m_RemoteHasResolver = false;
GetAPIProperties();
}
ReplayProxy(Network::Socket *sock, IRemoteDriver *remote)
: m_Socket(sock), m_Proxy(NULL), m_Remote(remote), m_RemoteServer(true)
ReplayProxy(ReadSerialiser &reader, WriteSerialiser &writer, IRemoteDriver *remote)
: m_Reader(reader), m_Writer(writer), m_Proxy(NULL), m_Remote(remote), m_RemoteServer(true)
{
m_ToReplaySerialiser = NULL;
m_FromReplaySerialiser = new Serialiser(NULL, Serialiser::WRITING, false);
m_RemoteHasResolver = false;
RDCEraseEl(m_APIProps);
}
@@ -123,7 +115,7 @@ public:
bool IsRemoteProxy() { return !m_RemoteServer; }
void Shutdown() { delete this; }
void ReadLogInitialisation() {}
void ReadLogInitialisation(RDCFile *rdc) {}
vector<WindowingSystem> GetSupportedWindowSystems()
{
if(m_Proxy)
@@ -387,79 +379,82 @@ public:
return ResourceId();
}
bool Tick(int type, Serialiser *incomingPacket);
bool Tick(int type);
vector<ResourceId> GetBuffers();
BufferDescription GetBuffer(ResourceId id);
vector<ResourceId> GetTextures();
TextureDescription GetTexture(ResourceId id);
APIProperties GetAPIProperties();
vector<DebugMessage> GetDebugMessages();
void SavePipelineState();
const D3D11Pipe::State &GetD3D11PipelineState() { return m_D3D11PipelineState; }
const D3D12Pipe::State &GetD3D12PipelineState() { return m_D3D12PipelineState; }
const GLPipe::State &GetGLPipelineState() { return m_GLPipelineState; }
const VKPipe::State &GetVulkanPipelineState() { return m_VulkanPipelineState; }
void ReplayLog(uint32_t endEventID, ReplayLogType replayType);
IMPLEMENT_FUNCTION_PROXIED(std::vector<ResourceId>, GetBuffers);
IMPLEMENT_FUNCTION_PROXIED(BufferDescription, GetBuffer, ResourceId id);
vector<uint32_t> GetPassEvents(uint32_t eventID);
IMPLEMENT_FUNCTION_PROXIED(std::vector<ResourceId>, GetTextures);
IMPLEMENT_FUNCTION_PROXIED(TextureDescription, GetTexture, ResourceId id);
vector<EventUsage> GetUsage(ResourceId id);
FrameRecord GetFrameRecord();
IMPLEMENT_FUNCTION_PROXIED(APIProperties, GetAPIProperties);
bool IsRenderOutput(ResourceId id);
IMPLEMENT_FUNCTION_PROXIED(std::vector<DebugMessage>, GetDebugMessages);
ResourceId GetLiveID(ResourceId id);
IMPLEMENT_FUNCTION_PROXIED(void, SavePipelineState);
IMPLEMENT_FUNCTION_PROXIED(void, ReplayLog, uint32_t endEventID, ReplayLogType replayType);
vector<GPUCounter> EnumerateCounters();
void DescribeCounter(GPUCounter counterID, CounterDescription &desc);
vector<CounterResult> FetchCounters(const vector<GPUCounter> &counterID);
IMPLEMENT_FUNCTION_PROXIED(std::vector<uint32_t>, GetPassEvents, uint32_t eventID);
void FillCBufferVariables(ResourceId shader, string entryPoint, uint32_t cbufSlot,
vector<ShaderVariable> &outvars, const vector<byte> &data);
IMPLEMENT_FUNCTION_PROXIED(std::vector<EventUsage>, GetUsage, ResourceId id);
IMPLEMENT_FUNCTION_PROXIED(FrameRecord, GetFrameRecord);
void GetBufferData(ResourceId buff, uint64_t offset, uint64_t len, vector<byte> &retData);
byte *GetTextureData(ResourceId tex, uint32_t arrayIdx, uint32_t mip,
const GetTextureDataParams &params, size_t &dataSize);
IMPLEMENT_FUNCTION_PROXIED(bool, IsRenderOutput, ResourceId id);
void InitPostVSBuffers(uint32_t eventID);
void InitPostVSBuffers(const vector<uint32_t> &passEvents);
MeshFormat GetPostVSBuffers(uint32_t eventID, uint32_t instID, MeshDataStage stage);
IMPLEMENT_FUNCTION_PROXIED(ResourceId, GetLiveID, ResourceId id);
ResourceId RenderOverlay(ResourceId texid, CompType typeHint, DebugOverlay overlay,
uint32_t eventID, const vector<uint32_t> &passEvents);
IMPLEMENT_FUNCTION_PROXIED(std::vector<GPUCounter>, EnumerateCounters);
IMPLEMENT_FUNCTION_PROXIED(CounterDescription, DescribeCounter, GPUCounter counterID);
IMPLEMENT_FUNCTION_PROXIED(std::vector<CounterResult>, FetchCounters,
const std::vector<GPUCounter> &counterID);
ShaderReflection *GetShader(ResourceId shader, string entryPoint);
IMPLEMENT_FUNCTION_PROXIED(void, FillCBufferVariables, ResourceId shader, std::string entryPoint,
uint32_t cbufSlot, std::vector<ShaderVariable> &outvars,
const std::vector<byte> &data);
vector<string> GetDisassemblyTargets();
string DisassembleShader(ResourceId pipeline, const ShaderReflection *refl, const string &target);
IMPLEMENT_FUNCTION_PROXIED(void, GetBufferData, ResourceId buff, uint64_t offset, uint64_t len,
std::vector<byte> &retData);
IMPLEMENT_FUNCTION_PROXIED(void, GetTextureData, ResourceId tex, uint32_t arrayIdx, uint32_t mip,
const GetTextureDataParams &params, bytebuf &data);
bool HasCallstacks();
void InitCallstackResolver();
Callstack::StackResolver *GetCallstackResolver();
// implementing Callstack::StackResolver
Callstack::AddressDetails GetAddr(uint64_t addr);
IMPLEMENT_FUNCTION_PROXIED(void, InitPostVSBuffers, uint32_t eventID);
IMPLEMENT_FUNCTION_PROXIED(void, InitPostVSBuffers, const std::vector<uint32_t> &passEvents);
IMPLEMENT_FUNCTION_PROXIED(MeshFormat, GetPostVSBuffers, uint32_t eventID, uint32_t instID,
MeshDataStage stage);
void FreeTargetResource(ResourceId id);
IMPLEMENT_FUNCTION_PROXIED(ResourceId, RenderOverlay, ResourceId texid, CompType typeHint,
DebugOverlay overlay, uint32_t eventID,
const std::vector<uint32_t> &passEvents);
vector<PixelModification> PixelHistory(vector<EventUsage> events, ResourceId target, uint32_t x,
uint32_t y, uint32_t slice, uint32_t mip,
uint32_t sampleIdx, CompType typeHint);
ShaderDebugTrace DebugVertex(uint32_t eventID, uint32_t vertid, uint32_t instid, uint32_t idx,
uint32_t instOffset, uint32_t vertOffset);
ShaderDebugTrace DebugPixel(uint32_t eventID, uint32_t x, uint32_t y, uint32_t sample,
uint32_t primitive);
ShaderDebugTrace DebugThread(uint32_t eventID, const uint32_t groupid[3],
const uint32_t threadid[3]);
IMPLEMENT_FUNCTION_PROXIED(ShaderReflection *, GetShader, ResourceId shader,
std::string entryPoint);
void BuildTargetShader(string source, string entry, const ShaderCompileFlags &compileFlags,
ShaderStage type, ResourceId *id, string *errors);
void ReplaceResource(ResourceId from, ResourceId to);
void RemoveReplacement(ResourceId id);
IMPLEMENT_FUNCTION_PROXIED(std::vector<std::string>, GetDisassemblyTargets);
IMPLEMENT_FUNCTION_PROXIED(std::string, DisassembleShader, ResourceId pipeline,
const ShaderReflection *refl, const std::string &target);
IMPLEMENT_FUNCTION_PROXIED(void, FreeTargetResource, ResourceId id);
IMPLEMENT_FUNCTION_PROXIED(std::vector<PixelModification>, PixelHistory,
std::vector<EventUsage> events, ResourceId target, uint32_t x,
uint32_t y, uint32_t slice, uint32_t mip, uint32_t sampleIdx,
CompType typeHint);
IMPLEMENT_FUNCTION_PROXIED(ShaderDebugTrace, DebugVertex, uint32_t eventID, uint32_t vertid,
uint32_t instid, uint32_t idx, uint32_t instOffset, uint32_t vertOffset);
IMPLEMENT_FUNCTION_PROXIED(ShaderDebugTrace, DebugPixel, uint32_t eventID, uint32_t x, uint32_t y,
uint32_t sample, uint32_t primitive);
IMPLEMENT_FUNCTION_PROXIED(ShaderDebugTrace, DebugThread, uint32_t eventID,
const uint32_t groupid[3], const uint32_t threadid[3]);
IMPLEMENT_FUNCTION_PROXIED(void, BuildTargetShader, std::string source, std::string entry,
const ShaderCompileFlags &compileFlags, ShaderStage type,
ResourceId *id, std::string *errors);
IMPLEMENT_FUNCTION_PROXIED(void, ReplaceResource, ResourceId from, ResourceId to);
IMPLEMENT_FUNCTION_PROXIED(void, RemoveReplacement, ResourceId id);
void FileChanged() {}
// will never be used
@@ -488,12 +483,10 @@ public:
}
private:
bool SendReplayCommand(ReplayProxyPacket type);
void EnsureTexCached(ResourceId texid, uint32_t arrayIdx, uint32_t mip);
void RemapProxyTextureIfNeeded(TextureDescription &tex, GetTextureDataParams &params);
void EnsureBufCached(ResourceId bufid);
bool NeedRemapForFetch(const ResourceFormat &format);
IMPLEMENT_FUNCTION_PROXIED(bool, NeedRemapForFetch, const ResourceFormat &format);
struct TextureCacheEntry
{
@@ -546,16 +539,15 @@ private:
}
};
map<ShaderReflKey, ShaderReflection *> m_ShaderReflectionCache;
std::map<ShaderReflKey, ShaderReflection *> m_ShaderReflectionCache;
Network::Socket *m_Socket;
Serialiser *m_FromReplaySerialiser;
Serialiser *m_ToReplaySerialiser;
ReadSerialiser &m_Reader;
WriteSerialiser &m_Writer;
IReplayDriver *m_Proxy;
IRemoteDriver *m_Remote;
bool m_RemoteServer;
bool m_RemoteHasResolver;
bool m_IsErrored = false;
APIProperties m_APIProps;
+37 -43
View File
@@ -579,11 +579,12 @@ ShaderDebug::State D3D11DebugManager::CreateShaderDebugState(ShaderDebugTrace &t
FillCBufferVariables(dxbc->m_CBuffers[i].variables, vars, true,
cbufData[dxbc->m_CBuffers[i].reg]);
trace.cbuffers[i] = vars;
trace.cbuffers[i].members = vars;
for(size_t c = 0; c < trace.cbuffers[i].size(); c++)
trace.cbuffers[i][c].name = StringFormat::Fmt("cb%u[%u] (%s)", dxbc->m_CBuffers[i].reg,
(uint32_t)c, trace.cbuffers[i][c].name.c_str());
for(size_t c = 0; c < trace.cbuffers[i].members.size(); c++)
trace.cbuffers[i].members[c].name =
StringFormat::Fmt("cb%u[%u] (%s)", dxbc->m_CBuffers[i].reg, (uint32_t)c,
trace.cbuffers[i].members[c].name.c_str());
}
initialState.Init();
@@ -2859,8 +2860,8 @@ void D3D11DebugManager::PickPixel(ResourceId texture, uint32_t x, uint32_t y, ui
m_pImmediateContext->Unmap(m_DebugRender.PickPixelStageTex, 0);
}
byte *D3D11DebugManager::GetTextureData(ResourceId tex, uint32_t arrayIdx, uint32_t mip,
const GetTextureDataParams &params, size_t &dataSize)
void D3D11DebugManager::GetTextureData(ResourceId tex, uint32_t arrayIdx, uint32_t mip,
const GetTextureDataParams &params, bytebuf &data)
{
D3D11RenderStateTracker tracker(m_WrappedContext);
@@ -2869,7 +2870,6 @@ byte *D3D11DebugManager::GetTextureData(ResourceId tex, uint32_t arrayIdx, uint3
uint32_t subresource = 0;
uint32_t mips = 0;
dataSize = 0;
size_t bytesize = 0;
if(WrappedID3D11Texture1D::m_TextureList.find(tex) != WrappedID3D11Texture1D::m_TextureList.end())
@@ -2890,11 +2890,11 @@ byte *D3D11DebugManager::GetTextureData(ResourceId tex, uint32_t arrayIdx, uint3
mips = desc.MipLevels ? desc.MipLevels : CalcNumMips(desc.Width, 1, 1);
if(mip >= mips || arrayIdx >= desc.ArraySize)
return NULL;
return;
if(params.remap)
if(params.remap != RemapTexture::NoRemap)
{
RDCASSERT(params.remap == eRemap_RGBA8);
RDCASSERT(params.remap == RemapTexture::RGBA8);
desc.Format =
IsSRGBFormat(desc.Format) ? DXGI_FORMAT_R8G8B8A8_UNORM_SRGB : DXGI_FORMAT_R8G8B8A8_UNORM;
@@ -2910,14 +2910,14 @@ byte *D3D11DebugManager::GetTextureData(ResourceId tex, uint32_t arrayIdx, uint3
if(FAILED(hr))
{
RDCERR("Couldn't create staging texture to retrieve data. HRESULT: %s", ToStr(hr).c_str());
return NULL;
return;
}
bytesize = GetByteSize(desc.Width, 1, 1, desc.Format, mip);
if(params.remap)
if(params.remap != RemapTexture::NoRemap)
{
RDCASSERT(params.remap == eRemap_RGBA8);
RDCASSERT(params.remap == RemapTexture::RGBA8);
subresource = mip;
@@ -2933,7 +2933,7 @@ byte *D3D11DebugManager::GetTextureData(ResourceId tex, uint32_t arrayIdx, uint3
{
RDCERR("Couldn't create target texture to downcast texture. HRESULT: %s", ToStr(hr).c_str());
SAFE_RELEASE(d);
return NULL;
return;
}
D3D11_RENDER_TARGET_VIEW_DESC rtvDesc;
@@ -2948,7 +2948,7 @@ byte *D3D11DebugManager::GetTextureData(ResourceId tex, uint32_t arrayIdx, uint3
RDCERR("Couldn't create target rtv to downcast texture. HRESULT: %s", ToStr(hr).c_str());
SAFE_RELEASE(d);
SAFE_RELEASE(rtTex);
return NULL;
return;
}
ID3D11RenderTargetView *rtv = wrappedrtv;
@@ -3029,11 +3029,11 @@ byte *D3D11DebugManager::GetTextureData(ResourceId tex, uint32_t arrayIdx, uint3
mips = desc.MipLevels ? desc.MipLevels : CalcNumMips(desc.Width, desc.Height, 1);
if(mip >= mips || arrayIdx >= desc.ArraySize)
return NULL;
return;
if(params.remap)
if(params.remap != RemapTexture::NoRemap)
{
RDCASSERT(params.remap == eRemap_RGBA8);
RDCASSERT(params.remap == RemapTexture::RGBA8);
desc.Format = (IsSRGBFormat(desc.Format) || wrapTex->m_RealDescriptor)
? DXGI_FORMAT_R8G8B8A8_UNORM_SRGB
@@ -3050,14 +3050,14 @@ byte *D3D11DebugManager::GetTextureData(ResourceId tex, uint32_t arrayIdx, uint3
if(FAILED(hr))
{
RDCERR("Couldn't create staging texture to retrieve data. HRESULT: %s", ToStr(hr).c_str());
return NULL;
return;
}
bytesize = GetByteSize(desc.Width, desc.Height, 1, desc.Format, mip);
if(params.remap)
if(params.remap != RemapTexture::NoRemap)
{
RDCASSERT(params.remap == eRemap_RGBA8);
RDCASSERT(params.remap == RemapTexture::RGBA8);
subresource = mip;
@@ -3073,7 +3073,7 @@ byte *D3D11DebugManager::GetTextureData(ResourceId tex, uint32_t arrayIdx, uint3
{
RDCERR("Couldn't create target texture to downcast texture. HRESULT: %s", ToStr(hr).c_str());
SAFE_RELEASE(d);
return NULL;
return;
}
D3D11_RENDER_TARGET_VIEW_DESC rtvDesc;
@@ -3088,7 +3088,7 @@ byte *D3D11DebugManager::GetTextureData(ResourceId tex, uint32_t arrayIdx, uint3
RDCERR("Couldn't create target rtv to downcast texture. HRESULT: %s", ToStr(hr).c_str());
SAFE_RELEASE(d);
SAFE_RELEASE(rtTex);
return NULL;
return;
}
ID3D11RenderTargetView *rtv = wrappedrtv;
@@ -3148,7 +3148,7 @@ byte *D3D11DebugManager::GetTextureData(ResourceId tex, uint32_t arrayIdx, uint3
{
RDCERR("Couldn't create target texture to resolve texture. HRESULT: %s", ToStr(hr).c_str());
SAFE_RELEASE(d);
return NULL;
return;
}
m_pImmediateContext->ResolveSubresource(resolveTex, arrayIdx, wrapTex, arrayIdx, desc.Format);
@@ -3184,11 +3184,11 @@ byte *D3D11DebugManager::GetTextureData(ResourceId tex, uint32_t arrayIdx, uint3
mips = desc.MipLevels ? desc.MipLevels : CalcNumMips(desc.Width, desc.Height, desc.Depth);
if(mip >= mips)
return NULL;
return;
if(params.remap)
if(params.remap != RemapTexture::NoRemap)
{
RDCASSERT(params.remap == eRemap_RGBA8);
RDCASSERT(params.remap == RemapTexture::RGBA8);
desc.Format =
IsSRGBFormat(desc.Format) ? DXGI_FORMAT_R8G8B8A8_UNORM_SRGB : DXGI_FORMAT_R8G8B8A8_UNORM;
@@ -3203,14 +3203,14 @@ byte *D3D11DebugManager::GetTextureData(ResourceId tex, uint32_t arrayIdx, uint3
if(FAILED(hr))
{
RDCERR("Couldn't create staging texture to retrieve data. HRESULT: %s", ToStr(hr).c_str());
return NULL;
return;
}
bytesize = GetByteSize(desc.Width, desc.Height, desc.Depth, desc.Format, mip);
if(params.remap)
if(params.remap != RemapTexture::NoRemap)
{
RDCASSERT(params.remap == eRemap_RGBA8);
RDCASSERT(params.remap == RemapTexture::RGBA8);
subresource = mip;
@@ -3226,7 +3226,7 @@ byte *D3D11DebugManager::GetTextureData(ResourceId tex, uint32_t arrayIdx, uint3
{
RDCERR("Couldn't create target texture to downcast texture. HRESULT: %s", ToStr(hr).c_str());
SAFE_RELEASE(d);
return NULL;
return;
}
D3D11_RENDER_TARGET_VIEW_DESC rtvDesc;
@@ -3252,7 +3252,7 @@ byte *D3D11DebugManager::GetTextureData(ResourceId tex, uint32_t arrayIdx, uint3
RDCERR("Couldn't create target rtv to downcast texture. HRESULT: %s", ToStr(hr).c_str());
SAFE_RELEASE(d);
SAFE_RELEASE(rtTex);
return NULL;
return;
}
rtv = wrappedrtv;
@@ -3302,8 +3302,7 @@ byte *D3D11DebugManager::GetTextureData(ResourceId tex, uint32_t arrayIdx, uint3
else
{
RDCERR("Trying to get texture data for unknown ID %llu!", tex);
dataSize = 0;
return new byte[0];
return;
}
MapIntercept intercept;
@@ -3311,13 +3310,10 @@ byte *D3D11DebugManager::GetTextureData(ResourceId tex, uint32_t arrayIdx, uint3
D3D11_MAPPED_SUBRESOURCE mapped = {0};
HRESULT hr = m_pImmediateContext->Map(dummyTex, subresource, D3D11_MAP_READ, 0, &mapped);
byte *ret = NULL;
if(SUCCEEDED(hr))
{
ret = new byte[bytesize];
dataSize = bytesize;
intercept.InitWrappedResource(dummyTex, subresource, ret);
data.resize(bytesize);
intercept.InitWrappedResource(dummyTex, subresource, data.data());
intercept.SetD3D(mapped);
intercept.CopyFromD3D();
@@ -3325,8 +3321,8 @@ byte *D3D11DebugManager::GetTextureData(ResourceId tex, uint32_t arrayIdx, uint3
// copy it into the beginning.
if(intercept.numSlices > 1 && arrayIdx > 0 && (int)arrayIdx < intercept.numSlices)
{
byte *dst = ret;
byte *src = ret + intercept.app.DepthPitch * arrayIdx;
byte *dst = data.data();
byte *src = data.data() + intercept.app.DepthPitch * arrayIdx;
for(int row = 0; row < intercept.numRows; row++)
{
@@ -3343,8 +3339,6 @@ byte *D3D11DebugManager::GetTextureData(ResourceId tex, uint32_t arrayIdx, uint3
}
SAFE_RELEASE(dummyTex);
return ret;
}
ResourceId D3D11DebugManager::ApplyCustomShader(ResourceId shader, ResourceId texid, uint32_t mip,
+5 -4
View File
@@ -75,8 +75,9 @@ vector<GPUCounter> D3D11DebugManager::EnumerateCounters()
return ret;
}
void D3D11DebugManager::DescribeCounter(GPUCounter counterID, CounterDescription &desc)
CounterDescription D3D11DebugManager::DescribeCounter(GPUCounter counterID)
{
CounterDescription desc = {};
desc.counterID = counterID;
/////AMD//////
@@ -84,9 +85,7 @@ void D3D11DebugManager::DescribeCounter(GPUCounter counterID, CounterDescription
{
if(m_pAMDCounters)
{
desc = m_pAMDCounters->GetCounterDescription(counterID);
return;
return m_pAMDCounters->GetCounterDescription(counterID);
}
}
@@ -202,6 +201,8 @@ void D3D11DebugManager::DescribeCounter(GPUCounter counterID, CounterDescription
desc.unit = CounterUnit::Absolute;
break;
}
return desc;
}
struct GPUTimer
+3 -3
View File
@@ -133,8 +133,8 @@ public:
void GetBufferData(ResourceId buff, uint64_t offset, uint64_t length, vector<byte> &retData);
void GetBufferData(ID3D11Buffer *buff, uint64_t offset, uint64_t length, vector<byte> &retData);
byte *GetTextureData(ResourceId tex, uint32_t arrayIdx, uint32_t mip,
const GetTextureDataParams &params, size_t &dataSize);
void GetTextureData(ResourceId tex, uint32_t arrayIdx, uint32_t mip,
const GetTextureDataParams &params, bytebuf &data);
void FillCBufferVariables(const vector<DXBC::CBufferVariable> &invars,
vector<ShaderVariable> &outvars, bool flattenVec4s,
@@ -156,7 +156,7 @@ public:
static void PostDeviceShutdownCounters();
vector<GPUCounter> EnumerateCounters();
void DescribeCounter(GPUCounter counterID, CounterDescription &desc);
CounterDescription DescribeCounter(GPUCounter counterID);
vector<CounterResult> FetchCounters(const vector<GPUCounter> &counters);
vector<CounterResult> FetchCountersAMD(const vector<GPUCounter> &counters);
+6 -5
View File
@@ -385,6 +385,7 @@ APIProperties D3D11Replay::GetAPIProperties()
ret.pipelineType = GraphicsAPI::D3D11;
ret.localRenderer = GraphicsAPI::D3D11;
ret.degraded = m_WARP;
ret.shadersMutable = false;
return ret;
}
@@ -1433,10 +1434,10 @@ void D3D11Replay::GetBufferData(ResourceId buff, uint64_t offset, uint64_t len,
m_pDevice->GetDebugManager()->GetBufferData(buff, offset, len, retData);
}
byte *D3D11Replay::GetTextureData(ResourceId tex, uint32_t arrayIdx, uint32_t mip,
const GetTextureDataParams &params, size_t &dataSize)
void D3D11Replay::GetTextureData(ResourceId tex, uint32_t arrayIdx, uint32_t mip,
const GetTextureDataParams &params, bytebuf &data)
{
return m_pDevice->GetDebugManager()->GetTextureData(tex, arrayIdx, mip, params, dataSize);
m_pDevice->GetDebugManager()->GetTextureData(tex, arrayIdx, mip, params, data);
}
void D3D11Replay::ReplaceResource(ResourceId from, ResourceId to)
@@ -1454,9 +1455,9 @@ vector<GPUCounter> D3D11Replay::EnumerateCounters()
return m_pDevice->GetDebugManager()->EnumerateCounters();
}
void D3D11Replay::DescribeCounter(GPUCounter counterID, CounterDescription &desc)
CounterDescription D3D11Replay::DescribeCounter(GPUCounter counterID)
{
m_pDevice->GetDebugManager()->DescribeCounter(counterID, desc);
return m_pDevice->GetDebugManager()->DescribeCounter(counterID);
}
vector<CounterResult> D3D11Replay::FetchCounters(const vector<GPUCounter> &counters)
+3 -3
View File
@@ -109,8 +109,8 @@ public:
MeshFormat GetPostVSBuffers(uint32_t eventID, uint32_t instID, MeshDataStage stage);
void GetBufferData(ResourceId buff, uint64_t offset, uint64_t len, vector<byte> &retData);
byte *GetTextureData(ResourceId tex, uint32_t arrayIdx, uint32_t mip,
const GetTextureDataParams &params, size_t &dataSize);
void GetTextureData(ResourceId tex, uint32_t arrayIdx, uint32_t mip,
const GetTextureDataParams &params, bytebuf &data);
void BuildTargetShader(string source, string entry, const ShaderCompileFlags &compileFlags,
ShaderStage type, ResourceId *id, string *errors);
@@ -118,7 +118,7 @@ public:
void RemoveReplacement(ResourceId id);
vector<GPUCounter> EnumerateCounters();
void DescribeCounter(GPUCounter counterID, CounterDescription &desc);
CounterDescription DescribeCounter(GPUCounter counterID);
vector<CounterResult> FetchCounters(const vector<GPUCounter> &counters);
ResourceId CreateProxyTexture(const TextureDescription &templateTex);
+1
View File
@@ -70,6 +70,7 @@ APIProperties D3D12Replay::GetAPIProperties()
ret.pipelineType = GraphicsAPI::D3D12;
ret.localRenderer = GraphicsAPI::D3D12;
ret.degraded = false;
ret.shadersMutable = false;
return ret;
}
+1
View File
@@ -136,6 +136,7 @@ APIProperties GLReplay::GetAPIProperties()
ret.pipelineType = GraphicsAPI::OpenGL;
ret.localRenderer = GraphicsAPI::OpenGL;
ret.degraded = m_Degraded;
ret.shadersMutable = true;
return ret;
}
+12 -12
View File
@@ -567,14 +567,14 @@ void State::Init()
{
if(indexTempSizes[i] > 0)
{
indexableTemps[i].resize(indexTempSizes[i]);
indexableTemps[i].members.resize(indexTempSizes[i]);
for(uint32_t t = 0; t < indexTempSizes[i]; t++)
{
char buf[64] = {0};
StringFormat::snprintf(buf, 63, "x%u[%u]", i, t);
indexableTemps[i][t] = ShaderVariable(buf, 0l, 0l, 0l, 0l);
indexableTemps[i].members[t] = ShaderVariable(buf, 0l, 0l, 0l, 0l);
}
}
}
@@ -646,10 +646,10 @@ void State::SetDst(const ASMOperand &dstoper, const ASMOperation &op, const Shad
RDCASSERT(indices[0] < (uint32_t)indexableTemps.size());
if(indices[0] < (uint32_t)indexableTemps.size())
{
RDCASSERT(indices[1] < (uint32_t)indexableTemps[indices[0]].size());
if(indices[1] < (uint32_t)indexableTemps[indices[0]].size())
RDCASSERT(indices[1] < (uint32_t)indexableTemps[indices[0]].members.size());
if(indices[1] < (uint32_t)indexableTemps[indices[0]].members.size())
{
v = &indexableTemps[indices[0]][indices[1]];
v = &indexableTemps[indices[0]].members[indices[1]];
}
}
}
@@ -839,10 +839,10 @@ ShaderVariable State::GetSrc(const ASMOperand &oper, const ASMOperation &op) con
RDCASSERT(indices[0] < (uint32_t)indexableTemps.size());
if(indices[0] < (uint32_t)indexableTemps.size())
{
RDCASSERT(indices[1] < (uint32_t)indexableTemps[indices[0]].size());
if(indices[1] < (uint32_t)indexableTemps[indices[0]].size())
RDCASSERT(indices[1] < (uint32_t)indexableTemps[indices[0]].members.size());
if(indices[1] < (uint32_t)indexableTemps[indices[0]].members.size())
{
v = s = indexableTemps[indices[0]][indices[1]];
v = s = indexableTemps[indices[0]].members[indices[1]];
}
}
}
@@ -943,11 +943,11 @@ ShaderVariable State::GetSrc(const ASMOperand &oper, const ASMOperation &op) con
if(cb >= 0 && cb < trace->cbuffers.count())
{
RDCASSERTMSG("Out of bounds cbuffer lookup",
indices[1] < (uint32_t)trace->cbuffers[cb].count(), indices[1],
trace->cbuffers[cb].count());
indices[1] < (uint32_t)trace->cbuffers[cb].members.count(), indices[1],
trace->cbuffers[cb].members.count());
if(indices[1] < (uint32_t)trace->cbuffers[cb].size())
v = s = trace->cbuffers[cb][indices[1]];
if(indices[1] < (uint32_t)trace->cbuffers[cb].members.count())
v = s = trace->cbuffers[cb].members[indices[1]];
else
v = s = ShaderVariable("", 0U, 0U, 0U, 0U);
}
@@ -1427,8 +1427,8 @@ uint32_t DecodeFlags(const ShaderCompileFlags &compileFlags)
{
uint32_t ret = 0;
if(!compileFlags.flags.empty() && compileFlags.flags[0].first == "compileFlags")
ret = atoi(compileFlags.flags[0].second.c_str());
if(!compileFlags.flags.empty() && compileFlags.flags[0].Name == "compileFlags")
ret = atoi(compileFlags.flags[0].Value.c_str());
return ret;
}
@@ -215,8 +215,8 @@ void MakeShaderReflection(DXBC::DXBCFile *dxbc, ShaderReflection *refl,
refl->DebugInfo.files.resize(dxbc->m_DebugInfo->Files.size());
for(size_t i = 0; i < dxbc->m_DebugInfo->Files.size(); i++)
{
refl->DebugInfo.files[i].first = dxbc->m_DebugInfo->Files[i].first;
refl->DebugInfo.files[i].second = dxbc->m_DebugInfo->Files[i].second;
refl->DebugInfo.files[i].Filename = dxbc->m_DebugInfo->Files[i].first;
refl->DebugInfo.files[i].Contents = dxbc->m_DebugInfo->Files[i].second;
}
string entry = dxbc->m_DebugInfo->GetEntryFunction();
@@ -235,8 +235,8 @@ void MakeShaderReflection(DXBC::DXBCFile *dxbc, ShaderReflection *refl,
// positives, and so we want to bias towards leaving [0] in place.
for(size_t i = 0; i < refl->DebugInfo.files.size(); i++)
{
const char *c = strstr(refl->DebugInfo.files[i].first.c_str(), entry.c_str());
const char *end = refl->DebugInfo.files[i].first.end();
const char *c = strstr(refl->DebugInfo.files[i].Filename.c_str(), entry.c_str());
const char *end = refl->DebugInfo.files[i].Filename.end();
// no substring match? continue
if(c == NULL)
@@ -3918,8 +3918,8 @@ void SPVModule::MakeReflection(ShaderStage stage, const string &entryPoint,
for(size_t i = 0; i < sourceFiles.size(); i++)
{
reflection.DebugInfo.files[i].first = sourceFiles[i].first;
reflection.DebugInfo.files[i].second = sourceFiles[i].second;
reflection.DebugInfo.files[i].Filename = sourceFiles[i].first;
reflection.DebugInfo.files[i].Contents = sourceFiles[i].second;
}
}
+4 -1
View File
@@ -74,8 +74,9 @@ vector<GPUCounter> VulkanReplay::EnumerateCounters()
return ret;
}
void VulkanReplay::DescribeCounter(GPUCounter counterID, CounterDescription &desc)
CounterDescription VulkanReplay::DescribeCounter(GPUCounter counterID)
{
CounterDescription desc = {};
desc.counterID = counterID;
// 6839CB5B-FBD2-4550-B606-8C65157C684C
desc.uuid.bytes[0] = 0x6839CB5B;
@@ -185,6 +186,8 @@ void VulkanReplay::DescribeCounter(GPUCounter counterID, CounterDescription &des
desc.unit = CounterUnit::Absolute;
break;
}
return desc;
}
struct VulkanGPUTimerCallback : public VulkanDrawcallCallback
+17 -17
View File
@@ -653,6 +653,7 @@ APIProperties VulkanReplay::GetAPIProperties()
ret.pipelineType = GraphicsAPI::Vulkan;
ret.localRenderer = GraphicsAPI::Vulkan;
ret.degraded = false;
ret.shadersMutable = false;
return ret;
}
@@ -4298,16 +4299,15 @@ MeshFormat VulkanReplay::GetPostVSBuffers(uint32_t eventID, uint32_t instID, Mes
return GetDebugManager()->GetPostVSBuffers(eventID, instID, stage);
}
byte *VulkanReplay::GetTextureData(ResourceId tex, uint32_t arrayIdx, uint32_t mip,
const GetTextureDataParams &params, size_t &dataSize)
void VulkanReplay::GetTextureData(ResourceId tex, uint32_t arrayIdx, uint32_t mip,
const GetTextureDataParams &params, bytebuf &data)
{
bool wasms = false;
if(m_pDriver->m_CreationInfo.m_Image.find(tex) == m_pDriver->m_CreationInfo.m_Image.end())
{
RDCERR("Trying to get texture data for unknown ID %llu!", tex);
dataSize = 0;
return new byte[0];
return;
}
VulkanCreationInfo::Image &imInfo = m_pDriver->m_CreationInfo.m_Image[tex];
@@ -4366,22 +4366,22 @@ byte *VulkanReplay::GetTextureData(ResourceId tex, uint32_t arrayIdx, uint32_t m
wasms = true;
}
if(params.remap)
if(params.remap != RemapTexture::NoRemap)
{
int renderFlags = 0;
// force readback texture to RGBA8 unorm
if(params.remap == eRemap_RGBA8)
if(params.remap == RemapTexture::RGBA8)
{
imCreateInfo.format =
IsSRGBFormat(imCreateInfo.format) ? VK_FORMAT_R8G8B8A8_SRGB : VK_FORMAT_R8G8B8A8_UNORM;
}
else if(params.remap == eRemap_RGBA16)
else if(params.remap == RemapTexture::RGBA16)
{
imCreateInfo.format = VK_FORMAT_R16G16B16A16_SFLOAT;
renderFlags = eTexDisplay_F16Render;
}
else if(params.remap == eRemap_RGBA32)
else if(params.remap == RemapTexture::RGBA32)
{
imCreateInfo.format = VK_FORMAT_R32G32B32A32_SFLOAT;
renderFlags = eTexDisplay_F32Render;
@@ -4884,6 +4884,8 @@ byte *VulkanReplay::GetTextureData(ResourceId tex, uint32_t arrayIdx, uint32_t m
copyregion[i].imageExtent.depth = RDCMAX(1U, copyregion[i].imageExtent.depth >> mip);
}
uint32_t dataSize = 0;
// for most combined depth-stencil images this will be large enough for both to be copied
// separately, but for D24S8 we need to add extra space since they won't be copied packed
dataSize = GetByteSize(imInfo.extent.width, imInfo.extent.height, imInfo.extent.depth,
@@ -4891,7 +4893,7 @@ byte *VulkanReplay::GetTextureData(ResourceId tex, uint32_t arrayIdx, uint32_t m
if(imCreateInfo.format == VK_FORMAT_D24_UNORM_S8_UINT)
{
dataSize = AlignUp(dataSize, (size_t)4);
dataSize = AlignUp(dataSize, 4U);
dataSize += GetByteSize(imInfo.extent.width, imInfo.extent.height, imInfo.extent.depth,
VK_FORMAT_S8_UINT, mip);
}
@@ -4935,7 +4937,7 @@ byte *VulkanReplay::GetTextureData(ResourceId tex, uint32_t arrayIdx, uint32_t m
vt->CmdCopyImageToBuffer(Unwrap(cmd), srcImage, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL,
readbackBuf, 2, copyregion);
}
else if(imInfo.type == VK_IMAGE_TYPE_3D && params.remap)
else if(imInfo.type == VK_IMAGE_TYPE_3D && params.remap != RemapTexture::NoRemap)
{
// copy in each slice from the 2D array we created to render out the 3D texture
for(uint32_t i = 0; i < imCreateInfo.arrayLayers; i++)
@@ -4997,7 +4999,7 @@ byte *VulkanReplay::GetTextureData(ResourceId tex, uint32_t arrayIdx, uint32_t m
RDCASSERT(pData != NULL);
byte *ret = new byte[dataSize];
data.resize(dataSize);
if(isDepth && isStencil)
{
@@ -5009,7 +5011,7 @@ byte *VulkanReplay::GetTextureData(ResourceId tex, uint32_t arrayIdx, uint32_t m
uint16_t *dSrc = (uint16_t *)pData;
uint8_t *sSrc = (uint8_t *)(pData + copyregion[1].bufferOffset);
uint16_t *dDst = (uint16_t *)ret;
uint16_t *dDst = (uint16_t *)data.data();
uint16_t *sDst = dDst + 1; // interleaved, next pixel
for(size_t i = 0; i < pixelCount; i++)
@@ -5033,7 +5035,7 @@ byte *VulkanReplay::GetTextureData(ResourceId tex, uint32_t arrayIdx, uint32_t m
uint32_t *dSrc = (uint32_t *)pData;
uint8_t *sSrc = (uint8_t *)(pData + copyregion[1].bufferOffset);
uint32_t *dst = (uint32_t *)ret;
uint32_t *dst = (uint32_t *)data.data();
for(size_t i = 0; i < pixelCount; i++)
{
@@ -5050,7 +5052,7 @@ byte *VulkanReplay::GetTextureData(ResourceId tex, uint32_t arrayIdx, uint32_t m
uint32_t *dSrc = (uint32_t *)pData;
uint8_t *sSrc = (uint8_t *)(pData + copyregion[1].bufferOffset);
uint32_t *dDst = (uint32_t *)ret;
uint32_t *dDst = (uint32_t *)data.data();
uint32_t *sDst = dDst + 1; // interleaved, next pixel
for(size_t i = 0; i < pixelCount; i++)
@@ -5071,7 +5073,7 @@ byte *VulkanReplay::GetTextureData(ResourceId tex, uint32_t arrayIdx, uint32_t m
}
else
{
memcpy(ret, pData, dataSize);
memcpy(data.data(), pData, dataSize);
}
vt->UnmapMemory(Unwrap(dev), readbackMem);
@@ -5097,8 +5099,6 @@ byte *VulkanReplay::GetTextureData(ResourceId tex, uint32_t arrayIdx, uint32_t m
delete[] tmpView;
vt->DestroyRenderPass(Unwrap(dev), tmpRP, NULL);
}
return ret;
}
void VulkanReplay::BuildCustomShader(string source, string entry,
+3 -3
View File
@@ -182,7 +182,7 @@ public:
ResourceId GetLiveID(ResourceId id);
vector<GPUCounter> EnumerateCounters();
void DescribeCounter(GPUCounter counterID, CounterDescription &desc);
CounterDescription DescribeCounter(GPUCounter counterID);
vector<CounterResult> FetchCounters(const vector<GPUCounter> &counters);
bool GetMinMax(ResourceId texid, uint32_t sliceFace, uint32_t mip, uint32_t sample,
@@ -194,8 +194,8 @@ public:
MeshFormat GetPostVSBuffers(uint32_t eventID, uint32_t instID, MeshDataStage stage);
void GetBufferData(ResourceId buff, uint64_t offset, uint64_t len, vector<byte> &retData);
byte *GetTextureData(ResourceId tex, uint32_t arrayIdx, uint32_t mip,
const GetTextureDataParams &params, size_t &dataSize);
void GetTextureData(ResourceId tex, uint32_t arrayIdx, uint32_t mip,
const GetTextureDataParams &params, bytebuf &data);
void ReplaceResource(ResourceId from, ResourceId to);
void RemoveReplacement(ResourceId id);
+18
View File
@@ -211,6 +211,15 @@ void DoSerialise(SerialiserType &ser, ShaderResource &el)
SIZE_CHECK(80);
}
template <typename SerialiserType>
void DoSerialise(SerialiserType &ser, ShaderCompileFlag &el)
{
SERIALISE_MEMBER(Name);
SERIALISE_MEMBER(Value);
SIZE_CHECK(32);
}
template <typename SerialiserType>
void DoSerialise(SerialiserType &ser, ShaderCompileFlags &el)
{
@@ -219,6 +228,15 @@ void DoSerialise(SerialiserType &ser, ShaderCompileFlags &el)
SIZE_CHECK(16);
}
template <typename SerialiserType>
void DoSerialise(SerialiserType &ser, ShaderSourceFile &el)
{
SERIALISE_MEMBER(Filename);
SERIALISE_MEMBER(Contents);
SIZE_CHECK(32);
}
template <typename SerialiserType>
void DoSerialise(SerialiserType &ser, ShaderDebugChunk &el)
{
+10 -21
View File
@@ -285,11 +285,7 @@ rdcarray<GPUCounter> ReplayController::EnumerateCounters()
CounterDescription ReplayController::DescribeCounter(GPUCounter counterID)
{
CounterDescription ret;
m_pDevice->DescribeCounter(counterID, ret);
return ret;
return m_pDevice->DescribeCounter(counterID);
}
rdcarray<BufferDescription> ReplayController::GetBuffers()
@@ -378,13 +374,7 @@ bytebuf ReplayController::GetTextureData(ResourceId tex, uint32_t arrayIdx, uint
return ret;
}
size_t sz = 0;
byte *bytes = m_pDevice->GetTextureData(liveId, arrayIdx, mip, GetTextureDataParams(), sz);
if(sz != 0 && bytes != NULL)
ret.assign(bytes, sz);
SAFE_DELETE_ARRAY(bytes);
m_pDevice->GetTextureData(liveId, arrayIdx, mip, GetTextureDataParams(), ret);
return ret;
}
@@ -641,14 +631,14 @@ bool ReplayController::SaveTexture(const TextureSave &saveData, const char *path
params.forDiskSave = true;
params.typeHint = sd.typeHint;
params.resolve = resolveSamples;
params.remap = downcast ? eRemap_RGBA8 : eRemap_None;
params.remap = downcast ? RemapTexture::RGBA8 : RemapTexture::NoRemap;
params.blackPoint = sd.comp.blackPoint;
params.whitePoint = sd.comp.whitePoint;
size_t datasize = 0;
byte *bytes = m_pDevice->GetTextureData(liveid, slice, mip, params, datasize);
bytebuf data;
m_pDevice->GetTextureData(liveid, slice, mip, params, data);
if(bytes == NULL)
if(data.empty())
{
RDCERR("Couldn't get bytes for mip %u, slice %u", mip, slice);
@@ -660,6 +650,8 @@ bool ReplayController::SaveTexture(const TextureSave &saveData, const char *path
if(td.depth == 1)
{
byte *bytes = new byte[data.size()];
memcpy(bytes, data.data(), data.size());
subdata.push_back(bytes);
continue;
}
@@ -686,17 +678,16 @@ bool ReplayController::SaveTexture(const TextureSave &saveData, const char *path
if(numSlices == 1)
{
byte *depthslice = new byte[mipSlicePitch];
byte *b = bytes + mipSlicePitch * sliceOffset;
byte *b = data.data() + mipSlicePitch * sliceOffset;
memcpy(depthslice, b, slicePitch);
subdata.push_back(depthslice);
delete[] bytes;
continue;
}
s += (d - 1);
byte *b = bytes;
byte *b = data.data();
// add each depth slice as a separate subdata
for(uint32_t di = 0; di < d; di++)
@@ -709,8 +700,6 @@ bool ReplayController::SaveTexture(const TextureSave &saveData, const char *path
b += mipSlicePitch;
}
delete[] bytes;
}
}
+28
View File
@@ -24,6 +24,34 @@
#include "replay_driver.h"
#include "maths/formatpacking.h"
#include "serialise/serialiser.h"
template <>
std::string DoStringise(const RemapTexture &el)
{
BEGIN_ENUM_STRINGISE(RemapTexture);
{
STRINGISE_ENUM_CLASS(NoRemap)
STRINGISE_ENUM_CLASS(RGBA8)
STRINGISE_ENUM_CLASS(RGBA16)
STRINGISE_ENUM_CLASS(RGBA32)
STRINGISE_ENUM_CLASS(D32S8)
}
END_ENUM_STRINGISE();
}
template <typename SerialiserType>
void DoSerialise(SerialiserType &ser, GetTextureDataParams &el)
{
SERIALISE_MEMBER(forDiskSave);
SERIALISE_MEMBER(typeHint);
SERIALISE_MEMBER(resolve);
SERIALISE_MEMBER(remap);
SERIALISE_MEMBER(blackPoint);
SERIALISE_MEMBER(whitePoint);
}
INSTANTIATE_SERIALISE_TYPE(GetTextureDataParams);
DrawcallDescription *SetupDrawcallPointers(vector<DrawcallDescription *> *drawcallTable,
rdcarray<DrawcallDescription> &draws,
+17 -11
View File
@@ -36,21 +36,25 @@ struct FrameRecord
rdcarray<DrawcallDescription> drawcallList;
};
enum RemapTextureEnum
DECLARE_REFLECTION_STRUCT(FrameRecord);
enum class RemapTexture : uint32_t
{
eRemap_None,
eRemap_RGBA8,
eRemap_RGBA16,
eRemap_RGBA32,
eRemap_D32S8
NoRemap,
RGBA8,
RGBA16,
RGBA32,
D32S8
};
DECLARE_REFLECTION_ENUM(RemapTexture);
struct GetTextureDataParams
{
bool forDiskSave;
CompType typeHint;
bool resolve;
RemapTextureEnum remap;
RemapTexture remap;
float blackPoint;
float whitePoint;
@@ -58,13 +62,15 @@ struct GetTextureDataParams
: forDiskSave(false),
typeHint(CompType::Typeless),
resolve(false),
remap(eRemap_None),
remap(RemapTexture::NoRemap),
blackPoint(0.0f),
whitePoint(1.0f)
{
}
};
DECLARE_REFLECTION_STRUCT(GetTextureDataParams);
class RDCFile;
// these two interfaces define what an API driver implementation must provide
@@ -122,8 +128,8 @@ public:
virtual void GetBufferData(ResourceId buff, uint64_t offset, uint64_t len,
vector<byte> &retData) = 0;
virtual byte *GetTextureData(ResourceId tex, uint32_t arrayIdx, uint32_t mip,
const GetTextureDataParams &params, size_t &dataSize) = 0;
virtual void GetTextureData(ResourceId tex, uint32_t arrayIdx, uint32_t mip,
const GetTextureDataParams &params, bytebuf &data) = 0;
virtual void BuildTargetShader(string source, string entry, const ShaderCompileFlags &compileFlags,
ShaderStage type, ResourceId *id, string *errors) = 0;
@@ -132,7 +138,7 @@ public:
virtual void FreeTargetResource(ResourceId id) = 0;
virtual vector<GPUCounter> EnumerateCounters() = 0;
virtual void DescribeCounter(GPUCounter counterID, CounterDescription &desc) = 0;
virtual CounterDescription DescribeCounter(GPUCounter counterID) = 0;
virtual vector<CounterResult> FetchCounters(const vector<GPUCounter> &counterID) = 0;
virtual void FillCBufferVariables(ResourceId shader, string entryPoint, uint32_t cbufSlot,