mirror of
https://github.com/MobileGL-Dev/MobileGL
synced 2026-09-09 04:38:30 +09:00
[Fix] (MG_Util/ShaderTranspiler/SpvcSession): use proper usage bit to select the right code path. Fix bugs along the way
This commit is contained in:
@@ -1075,7 +1075,8 @@ namespace MobileGL::MG_Backend::DirectGLES {
|
||||
String source;
|
||||
auto& spirvCode = shaderSpirvs[index];
|
||||
|
||||
MG_Util::ShaderTranspiler::SpvcSession spvcSession(spirvCode);
|
||||
MG_Util::ShaderTranspiler::SpvcSession spvcSession(spirvCode,
|
||||
MG_Util::ShaderTranspiler::SessionUsageBit::Transpile);
|
||||
|
||||
spvc_compiler_options options;
|
||||
spvcSession.CreateOptions(&options);
|
||||
|
||||
@@ -464,7 +464,7 @@ namespace MobileGL::MG_State::GLState {
|
||||
MGLOG_D("ProgramObject %u: GenerateBinary - parsing SPIR-V meta data for module %zu "
|
||||
"(shaderType=%u, wordCount=%zu)",
|
||||
m_externalIndex, i, shaderType, spv.size());
|
||||
SpvcSession session(spv);
|
||||
SpvcSession session(spv, SessionUsageBit::Reflection);
|
||||
auto result = session.ParseMetaData();
|
||||
if (result < 0) {
|
||||
MGLOG_D("ProgramObject %u: GenerateBinary - SpvcSession::ParseMetaData failed for module %zu, "
|
||||
|
||||
@@ -191,7 +191,7 @@ TEST_F(ProgramTest, CompileAndLink) {
|
||||
String source;
|
||||
auto& spirvCode = shaderSpirvs[index];
|
||||
|
||||
MG_Util::ShaderTranspiler::SpvcSession spvcSession(spirvCode);
|
||||
MG_Util::ShaderTranspiler::SpvcSession spvcSession(spirvCode, MG_Util::ShaderTranspiler::SessionUsageBit::Transpile);
|
||||
|
||||
spvc_compiler_options options;
|
||||
spvcSession.CreateOptions(&options);
|
||||
@@ -926,7 +926,7 @@ TEST_F(ProgramTest, CompileAndLinkWithExplicitVertexIn) {
|
||||
char* pSrcVertIn = nullptr;
|
||||
const char* needle = "layout(location = 2) in vec2 UV0;";
|
||||
for (auto spirv : spirvs) {
|
||||
MG_Util::ShaderTranspiler::SpvcSession spvcSession(spirv);
|
||||
MG_Util::ShaderTranspiler::SpvcSession spvcSession(spirv, MG_Util::ShaderTranspiler::SessionUsageBit::Transpile);
|
||||
spvc_compiler_options options;
|
||||
spvcSession.CreateOptions(&options);
|
||||
|
||||
@@ -987,7 +987,7 @@ TEST_F(ProgramTest, CompileAndLinkWithExplicitFragmentOut) {
|
||||
char* pSrcfragOut = nullptr;
|
||||
const char* needle = "layout(location = 7) out vec4 fragColor;";
|
||||
// for (auto spirv: spirvs) {
|
||||
MG_Util::ShaderTranspiler::SpvcSession spvcSession(fragSpirv);
|
||||
MG_Util::ShaderTranspiler::SpvcSession spvcSession(fragSpirv, MG_Util::ShaderTranspiler::SessionUsageBit::Transpile);
|
||||
spvc_compiler_options options;
|
||||
spvcSession.CreateOptions(&options);
|
||||
|
||||
@@ -1209,7 +1209,7 @@ TEST_F(ProgramTest, CompileShaderWithSamplerAsVarName) {
|
||||
auto programObject = MG_State::pGLContext->GetCurrentProgram();
|
||||
auto& spirvs = programObject->GetGeneratedSpirv();
|
||||
auto& fragSpirv = spirvs[programObject->GetShaderIndexByStage(ShaderStage::Fragment)];
|
||||
MG_Util::ShaderTranspiler::SpvcSession spvcSession(fragSpirv);
|
||||
MG_Util::ShaderTranspiler::SpvcSession spvcSession(fragSpirv, MG_Util::ShaderTranspiler::SessionUsageBit::Transpile);
|
||||
spvc_compiler_options options;
|
||||
spvcSession.CreateOptions(&options);
|
||||
|
||||
|
||||
@@ -153,7 +153,7 @@ TEST_F(ProgramUtilTest, CompileFragmentShaderWithDiscard) {
|
||||
|
||||
Vector<SpvcSession> sessions(spirvs.size());
|
||||
for (SizeT i = 0; i < spirvs.size(); ++i) {
|
||||
sessions[i] = SpvcSession(spirvs[i]);
|
||||
sessions[i] = SpvcSession(spirvs[i], SessionUsageBit::Transpile);
|
||||
}
|
||||
|
||||
for (SizeT i = 0; i < spirvs.size(); ++i) {
|
||||
@@ -278,7 +278,7 @@ TEST_F(ProgramUtilTest, DecompProgram) {
|
||||
|
||||
Vector<SpvcSession> sessions(spirvs.size());
|
||||
for (SizeT i = 0; i < spirvs.size(); ++i) {
|
||||
sessions[i] = SpvcSession(spirvs[i]);
|
||||
sessions[i] = SpvcSession(spirvs[i], SessionUsageBit::Transpile);
|
||||
}
|
||||
|
||||
for (SizeT i = 0; i < spirvs.size(); ++i) {
|
||||
@@ -439,7 +439,7 @@ TEST_F(ProgramUtilTest, CompileAndLinkBlitProgram) {
|
||||
auto spirvs = bin_res.value();
|
||||
Vector<SpvcSession> sessions(spirvs.size());
|
||||
for (SizeT i = 0; i < spirvs.size(); ++i) {
|
||||
sessions[i] = SpvcSession(spirvs[i]);
|
||||
sessions[i] = SpvcSession(spirvs[i], SessionUsageBit::Transpile);
|
||||
}
|
||||
|
||||
for (SizeT i = 0; i < spirvs.size(); ++i) {
|
||||
|
||||
@@ -286,7 +286,7 @@ namespace MobileGL {
|
||||
for (uint32_t i = 0; i < bindingCount; ++i) {
|
||||
auto* binding = bindings[i];
|
||||
if (binding->descriptor_type != SPV_REFLECT_DESCRIPTOR_TYPE_UNIFORM_BUFFER) continue;
|
||||
if (strcmp(binding->name, GLOBAL_UBO_NAME) != 0) continue;
|
||||
if (strcmp(binding->type_description->type_name, GLOBAL_UBO_NAME) != 0) continue;
|
||||
|
||||
auto& block = binding->block;
|
||||
metadata.globalUboSize = block.size;
|
||||
|
||||
@@ -73,7 +73,7 @@ namespace MobileGL {
|
||||
SpvcSession() {}
|
||||
|
||||
explicit SpvcSession(const Vector<unsigned int>& spirv,
|
||||
Flags<SessionUsageBit> usage = SessionUsageBit::Reflection | SessionUsageBit::Transpile);
|
||||
Flags<SessionUsageBit> usage);
|
||||
|
||||
SpvcSession(SpvcSession&) = delete;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user