Skip to content

Commit

Permalink
[tzsl] added texsize(id) which is equivalent to GLSL's textureSize(..…
Browse files Browse the repository at this point in the history
…., 0). also added post_render graph to quad_renderer. it works but note that post_render should definitely depend on the main pass, which it doesnt
  • Loading branch information
harrand committed Dec 8, 2024
1 parent 91c8cea commit cfee87d
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
1 change: 1 addition & 0 deletions include/tz/ren/quad.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ namespace tz::ren
return {std::begin(default_targets), std::end(default_targets)};
}();
std::span<const tz::gpu::resource_handle> extra_resources = {};
tz::gpu::graph_handle post_render = tz::nullhand;
/// Any extra optional flags to specify?
quad_renderer_flag flags = static_cast<quad_renderer_flag>(0);
/// Custom fragment shader. Unless @ref quad_renderer_flag::custom_fragment_shader is specified, this value is ignored and a default fragment shader is used.
Expand Down
4 changes: 4 additions & 0 deletions src/tz/ren/quad.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,10 @@ namespace tz::ren

ren.graph = tz::gpu::create_graph();
tz::gpu::graph_add_pass(ren.graph, ren.main_pass);
if(info.post_render != tz::nullhand)
{
tz::gpu::graph_add_subgraph(ren.graph, info.post_render);
}
if(info.flags & quad_renderer_flag::graph_present_after)
{
tz::gpu::graph_add_pass(ren.graph, tz::gpu::present_pass);
Expand Down
2 changes: 1 addition & 1 deletion tools/tzslc/tzsl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ namespace tzslc
{
ret = "#pragma shader_stage(" + *beg + ")" + stage_define;
}
return ret + "\n" + "layout(binding = 1) uniform sampler2D tz_textures[];\n#define sample(id, uv) texture(tz_textures[id], uv)";
return ret + "\n" + "layout(binding = 1) uniform sampler2D tz_textures[];\n#define sample(id, uv) texture(tz_textures[id], uv)\n#define texsize(id) textureSize(tz_textures[id], 0)\n";
});

tzslc_assert(stage_specifier_count == 1, "Unexpected number of shader stage specifiers. Expected 1, got %zu", stage_specifier_count);
Expand Down

0 comments on commit cfee87d

Please sign in to comment.