Skip to content

Commit

Permalink
gi: enable GLSL extensions using macros rather than generate new code
Browse files Browse the repository at this point in the history
  • Loading branch information
pablode committed Aug 3, 2024
1 parent 14ce229 commit b96e0ef
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 17 deletions.
2 changes: 1 addition & 1 deletion src/gi/impl/Gi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1196,7 +1196,7 @@ namespace gtl
.nextEventEstimation = nextEventEstimation,
.progressiveAccumulation = params.progressiveAccumulation,
.reorderInvocations = s_deviceFeatures.rayTracingInvocationReorder,
.shaderClockExts = clockCyclesAov
.shaderClockExt = clockCyclesAov
};

std::vector<uint8_t> spv;
Expand Down
10 changes: 2 additions & 8 deletions src/gi/impl/GlslShaderGen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,18 +74,12 @@ namespace gtl
GiGlslStitcher stitcher;
stitcher.appendVersion();

if (params.shaderClockExts)
if (params.shaderClockExt)
{
stitcher.appendRequiredExtension("GL_EXT_shader_explicit_arithmetic_types_int64");
stitcher.appendRequiredExtension("GL_ARB_shader_clock");
stitcher.appendDefine("REQUIRE_CLOCK");
}
if (params.reorderInvocations)
{
stitcher.appendRequiredExtension("GL_NV_shader_invocation_reorder");
// For hit shader invocation reordering hint
stitcher.appendRequiredExtension("GL_EXT_buffer_reference");
stitcher.appendRequiredExtension("GL_EXT_buffer_reference_uvec2");

uint32_t reoderHintValueCount = params.materialCount + 1/* no hit */;
int32_t reorderHintBitCount = 0;

Expand Down
2 changes: 1 addition & 1 deletion src/gi/impl/GlslShaderGen.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ namespace gtl
bool nextEventEstimation;
bool progressiveAccumulation;
bool reorderInvocations;
bool shaderClockExts;
bool shaderClockExt;
};

struct MissShaderParams
Expand Down
5 changes: 0 additions & 5 deletions src/gi/impl/GlslStitcher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,6 @@ namespace gtl
m_source << "#define " << name << " " << value << "\n";
}

void GiGlslStitcher::appendRequiredExtension(std::string_view name)
{
m_source << "#extension " << name << ": require\n";
}

void GiGlslStitcher::appendString(std::string_view value)
{
m_source << value;
Expand Down
2 changes: 0 additions & 2 deletions src/gi/impl/GlslStitcher.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ namespace gtl
void appendDefine(std::string_view name, int32_t value);
void appendDefine(std::string_view name, float value);

void appendRequiredExtension(std::string_view name);

void appendString(std::string_view value);

bool appendSourceFile(fs::path path);
Expand Down
9 changes: 9 additions & 0 deletions src/gi/shaders/rp_main.rgen
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,17 @@
#extension GL_EXT_shader_explicit_arithmetic_types_int16: require
#extension GL_EXT_shader_explicit_arithmetic_types_int64: require
#extension GL_EXT_buffer_reference: require

#ifdef REORDER_INVOCATIONS
#extension GL_NV_shader_invocation_reorder: require
// For hit shader invocation reordering hint
#extension GL_EXT_buffer_reference: require
#extension GL_EXT_buffer_reference_uvec2: require
#endif

#ifdef REQUIRE_CLOCK
#extension GL_EXT_shader_explicit_arithmetic_types_int64: require
#extension GL_ARB_shader_clock: require
#endif

#include "rp_main_payload.glsl"
Expand Down

0 comments on commit b96e0ef

Please sign in to comment.