mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-08-23 15:06:32 +00:00
Add a backend query to check shader encodings BuildTargetShader allows
* This will allow the backend to specify both the native format (e.g. SPIR-V, DXBC) as well as a language it might be able to internally compile (GLSL or HLSL). * The caller will then able to decide for itself whether it wants to compile to native format and pass that down, or pass the language down and let it be built internally. * Currently BuildTargetShader still only accepts shader source.
This commit is contained in:
@@ -279,6 +279,8 @@ void CaptureContext::LoadCaptureThreaded(const QString &captureFile, const QStri
|
||||
|
||||
m_APIProps = r->GetAPIProperties();
|
||||
|
||||
m_TargetEncodings = r->GetTargetShaderEncodings();
|
||||
|
||||
m_PostloadProgress = 0.2f;
|
||||
|
||||
m_Drawcalls = &r->GetDrawcalls();
|
||||
|
||||
@@ -107,6 +107,7 @@ public:
|
||||
CaptureModifications GetCaptureModifications() override { return m_CaptureMods; }
|
||||
const FrameDescription &FrameInfo() override { return m_FrameInfo; }
|
||||
const APIProperties &APIProps() override { return m_APIProps; }
|
||||
rdcarray<ShaderEncoding> TargetShaderEncodings() { return m_TargetEncodings; }
|
||||
uint32_t CurSelectedEvent() override { return m_SelectedEventID; }
|
||||
uint32_t CurEvent() override { return m_EventID; }
|
||||
const DrawcallDescription *CurSelectedDrawcall() override
|
||||
@@ -292,6 +293,7 @@ private:
|
||||
const rdcarray<DrawcallDescription> *m_Drawcalls;
|
||||
rdcarray<DrawcallDescription> m_EmptyDraws;
|
||||
|
||||
rdcarray<ShaderEncoding> m_TargetEncodings;
|
||||
APIProperties m_APIProps;
|
||||
FrameDescription m_FrameInfo;
|
||||
const DrawcallDescription *m_FirstDrawcall = NULL;
|
||||
|
||||
@@ -1184,6 +1184,15 @@ the UI which aren't reflected in the capture file on disk.
|
||||
)");
|
||||
virtual const APIProperties &APIProps() = 0;
|
||||
|
||||
DOCUMENT(R"(Retrieve the list of :class:`~renderdoc.ShaderEncoding` that are available for
|
||||
building target shaders for the currently loaded capture. See
|
||||
:meth:`~renderdoc.ReplayController.BuildTargetShader`.
|
||||
|
||||
:return: The available encodings.
|
||||
:rtype: ``list`` of :class:`~renderdoc.ShaderEncoding`
|
||||
)");
|
||||
virtual rdcarray<ShaderEncoding> TargetShaderEncodings() = 0;
|
||||
|
||||
DOCUMENT(R"(Retrieve the currently selected :data:`eventId <renderdoc.APIEvent.eventId>`.
|
||||
|
||||
In most cases, prefer using :meth:`CurEvent`. See :meth:`CaptureViewer.OnSelectedEventChanged` for more
|
||||
|
||||
@@ -265,6 +265,7 @@ TEMPLATE_ARRAY_INSTANTIATE(rdcarray, ShaderResource)
|
||||
TEMPLATE_ARRAY_INSTANTIATE(rdcarray, ShaderSampler)
|
||||
TEMPLATE_ARRAY_INSTANTIATE(rdcarray, ShaderSourceFile)
|
||||
TEMPLATE_ARRAY_INSTANTIATE(rdcarray, ShaderVariable)
|
||||
TEMPLATE_ARRAY_INSTANTIATE(rdcarray, ShaderEncoding)
|
||||
TEMPLATE_ARRAY_INSTANTIATE(rdcarray, RegisterRange)
|
||||
TEMPLATE_ARRAY_INSTANTIATE(rdcarray, LocalVariableMapping)
|
||||
TEMPLATE_ARRAY_INSTANTIATE(rdcarray, SigParameter)
|
||||
|
||||
@@ -64,6 +64,7 @@ struct CaptureContextInvoker : ICaptureContext
|
||||
}
|
||||
virtual const FrameDescription &FrameInfo() override { return m_Ctx.FrameInfo(); }
|
||||
virtual const APIProperties &APIProps() override { return m_Ctx.APIProps(); }
|
||||
virtual rdcarray<ShaderEncoding> TargetShaderEncodings() { return m_Ctx.TargetShaderEncodings(); }
|
||||
virtual uint32_t CurSelectedEvent() override { return m_Ctx.CurSelectedEvent(); }
|
||||
virtual uint32_t CurEvent() override { return m_Ctx.CurEvent(); }
|
||||
virtual const DrawcallDescription *CurSelectedDrawcall() override
|
||||
|
||||
@@ -892,6 +892,21 @@ The language used is native to the API's renderer - HLSL for D3D based renderers
|
||||
const ShaderCompileFlags &flags,
|
||||
ShaderStage type) = 0;
|
||||
|
||||
DOCUMENT(R"(Retrieve the list of supported :class:`ShaderEncoding` which can be build using
|
||||
:meth:`BuildTargetShader`.
|
||||
|
||||
The list is sorted in priority order, so if the caller has a shader in a form but could
|
||||
compile/translate it to another, prefer to satisfy the first encoding before later encodings.
|
||||
|
||||
This typically means the 'native' encoding is listed first, and then subsequent encodings are
|
||||
compiled internally - so compiling externally could be preferable as it allows better customisation
|
||||
of the compile process or using alternate/updated tools.
|
||||
|
||||
:return: The list of target shader encodings available.
|
||||
:rtype: ``list`` of :class:`ShaderEncoding`
|
||||
)");
|
||||
virtual rdcarray<ShaderEncoding> GetTargetShaderEncodings() = 0;
|
||||
|
||||
DOCUMENT(R"(Replace one resource with another for subsequent replay and analysis work.
|
||||
|
||||
This is commonly used for modifying the capture by selectively replacing resources with newly
|
||||
|
||||
@@ -245,6 +245,7 @@ public:
|
||||
void BuildTargetShader(string source, string entry, const ShaderCompileFlags &compileFlags,
|
||||
ShaderStage type, ResourceId *id, string *errors)
|
||||
{
|
||||
rdcarray<ShaderEncoding> GetTargetShaderEncodings() { return {}; }
|
||||
}
|
||||
void ReplaceResource(ResourceId from, ResourceId to) {}
|
||||
void RemoveReplacement(ResourceId id) {}
|
||||
|
||||
@@ -960,6 +960,31 @@ void ReplayProxy::FreeTargetResource(ResourceId id)
|
||||
PROXY_FUNCTION(FreeTargetResource, id);
|
||||
}
|
||||
|
||||
template <typename ParamSerialiser, typename ReturnSerialiser>
|
||||
rdcarray<ShaderEncoding> ReplayProxy::Proxied_GetTargetShaderEncodings(ParamSerialiser ¶mser,
|
||||
ReturnSerialiser &retser)
|
||||
{
|
||||
const ReplayProxyPacket packet = eReplayProxy_GetTargetShaderEncodings;
|
||||
rdcarray<ShaderEncoding> ret;
|
||||
|
||||
{
|
||||
BEGIN_PARAMS();
|
||||
END_PARAMS();
|
||||
}
|
||||
|
||||
if(paramser.IsReading() && !paramser.IsErrored() && !m_IsErrored)
|
||||
ret = m_Remote->GetTargetShaderEncodings();
|
||||
|
||||
SERIALISE_RETURN(ret);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
rdcarray<ShaderEncoding> ReplayProxy::GetTargetShaderEncodings()
|
||||
{
|
||||
PROXY_FUNCTION(GetTargetShaderEncodings);
|
||||
}
|
||||
|
||||
template <typename ParamSerialiser, typename ReturnSerialiser>
|
||||
void ReplayProxy::Proxied_BuildTargetShader(ParamSerialiser ¶mser, ReturnSerialiser &retser,
|
||||
std::string source, std::string entry,
|
||||
@@ -2098,6 +2123,7 @@ bool ReplayProxy::Tick(int type)
|
||||
break;
|
||||
case eReplayProxy_DisassembleShader: DisassembleShader(ResourceId(), NULL, ""); break;
|
||||
case eReplayProxy_GetDisassemblyTargets: GetDisassemblyTargets(); break;
|
||||
case eReplayProxy_GetTargetShaderEncodings: GetTargetShaderEncodings(); break;
|
||||
default: RDCERR("Unexpected command %u", type); return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -93,6 +93,7 @@ enum ReplayProxyPacket
|
||||
|
||||
eReplayProxy_DisassembleShader,
|
||||
eReplayProxy_GetDisassemblyTargets,
|
||||
eReplayProxy_GetTargetShaderEncodings,
|
||||
};
|
||||
|
||||
#define IMPLEMENT_FUNCTION_PROXIED(rettype, name, ...) \
|
||||
@@ -496,6 +497,7 @@ public:
|
||||
IMPLEMENT_FUNCTION_PROXIED(void, BuildTargetShader, std::string source, std::string entry,
|
||||
const ShaderCompileFlags &compileFlags, ShaderStage type,
|
||||
ResourceId *id, std::string *errors);
|
||||
IMPLEMENT_FUNCTION_PROXIED(rdcarray<ShaderEncoding>, GetTargetShaderEncodings);
|
||||
IMPLEMENT_FUNCTION_PROXIED(void, ReplaceResource, ResourceId from, ResourceId to);
|
||||
IMPLEMENT_FUNCTION_PROXIED(void, RemoveReplacement, ResourceId id);
|
||||
|
||||
|
||||
@@ -178,6 +178,10 @@ public:
|
||||
|
||||
void BuildTargetShader(string source, string entry, const ShaderCompileFlags &compileFlags,
|
||||
ShaderStage type, ResourceId *id, string *errors);
|
||||
rdcarray<ShaderEncoding> GetTargetShaderEncodings()
|
||||
{
|
||||
return {ShaderEncoding::DXBC, ShaderEncoding::HLSL};
|
||||
}
|
||||
void ReplaceResource(ResourceId from, ResourceId to);
|
||||
void RemoveReplacement(ResourceId id);
|
||||
|
||||
|
||||
@@ -138,6 +138,10 @@ public:
|
||||
|
||||
void BuildTargetShader(string source, string entry, const ShaderCompileFlags &compileFlags,
|
||||
ShaderStage type, ResourceId *id, string *errors);
|
||||
rdcarray<ShaderEncoding> GetTargetShaderEncodings()
|
||||
{
|
||||
return {ShaderEncoding::DXBC, ShaderEncoding::HLSL};
|
||||
}
|
||||
void ReplaceResource(ResourceId from, ResourceId to);
|
||||
void RemoveReplacement(ResourceId id);
|
||||
|
||||
|
||||
@@ -180,6 +180,7 @@ public:
|
||||
|
||||
void BuildTargetShader(string source, string entry, const ShaderCompileFlags &compileFlags,
|
||||
ShaderStage type, ResourceId *id, string *errors);
|
||||
rdcarray<ShaderEncoding> GetTargetShaderEncodings() { return {ShaderEncoding::GLSL}; }
|
||||
void BuildCustomShader(string source, string entry, const ShaderCompileFlags &compileFlags,
|
||||
ShaderStage type, ResourceId *id, string *errors);
|
||||
void FreeCustomShader(ResourceId id);
|
||||
|
||||
@@ -267,6 +267,10 @@ public:
|
||||
|
||||
void BuildTargetShader(string source, string entry, const ShaderCompileFlags &compileFlags,
|
||||
ShaderStage type, ResourceId *id, string *errors);
|
||||
rdcarray<ShaderEncoding> GetTargetShaderEncodings()
|
||||
{
|
||||
return {ShaderEncoding::SPIRV, ShaderEncoding::GLSL};
|
||||
}
|
||||
void BuildCustomShader(string source, string entry, const ShaderCompileFlags &compileFlags,
|
||||
ShaderStage type, ResourceId *id, string *errors);
|
||||
void FreeCustomShader(ResourceId id);
|
||||
|
||||
@@ -1771,6 +1771,11 @@ void ReplayController::Shutdown()
|
||||
delete this;
|
||||
}
|
||||
|
||||
rdcarray<ShaderEncoding> ReplayController::GetTargetShaderEncodings()
|
||||
{
|
||||
return m_pDevice->GetTargetShaderEncodings();
|
||||
}
|
||||
|
||||
rdcpair<ResourceId, rdcstr> ReplayController::BuildTargetShader(
|
||||
const char *entry, const char *source, const ShaderCompileFlags &compileFlags, ShaderStage type)
|
||||
{
|
||||
|
||||
@@ -151,6 +151,7 @@ public:
|
||||
void FreeCustomShader(ResourceId id);
|
||||
|
||||
rdcpair<ResourceId, rdcstr> BuildTargetShader(const char *entry, const char *source,
|
||||
rdcarray<ShaderEncoding> GetTargetShaderEncodings();
|
||||
const ShaderCompileFlags &compileFlags,
|
||||
ShaderStage type);
|
||||
void ReplaceResource(ResourceId from, ResourceId to);
|
||||
|
||||
@@ -139,6 +139,7 @@ public:
|
||||
|
||||
virtual void BuildTargetShader(string source, string entry, const ShaderCompileFlags &compileFlags,
|
||||
ShaderStage type, ResourceId *id, string *errors) = 0;
|
||||
virtual rdcarray<ShaderEncoding> GetTargetShaderEncodings() = 0;
|
||||
virtual void ReplaceResource(ResourceId from, ResourceId to) = 0;
|
||||
virtual void RemoveReplacement(ResourceId id) = 0;
|
||||
virtual void FreeTargetResource(ResourceId id) = 0;
|
||||
|
||||
Reference in New Issue
Block a user