2021-05-20 04:58:32 +03:00
|
|
|
// Copyright 2021 yuzu Emulator Project
|
|
|
|
// Licensed under GPLv2 or any later version
|
|
|
|
// Refer to the license.txt file included.
|
|
|
|
|
|
|
|
#include "shader_recompiler/backend/bindings.h"
|
|
|
|
#include "shader_recompiler/backend/glsl/emit_context.h"
|
|
|
|
#include "shader_recompiler/frontend/ir/program.h"
|
2021-05-26 02:55:40 +03:00
|
|
|
#include "shader_recompiler/profile.h"
|
2021-05-20 04:58:32 +03:00
|
|
|
|
|
|
|
namespace Shader::Backend::GLSL {
|
2021-05-27 04:18:17 +03:00
|
|
|
namespace {
|
|
|
|
std::string_view InterpDecorator(Interpolation interp) {
|
|
|
|
switch (interp) {
|
|
|
|
case Interpolation::Smooth:
|
|
|
|
return "";
|
|
|
|
case Interpolation::Flat:
|
|
|
|
return "flat";
|
|
|
|
case Interpolation::NoPerspective:
|
|
|
|
return "noperspective";
|
|
|
|
}
|
|
|
|
throw InvalidArgument("Invalid interpolation {}", interp);
|
|
|
|
}
|
2021-05-28 05:28:33 +03:00
|
|
|
|
2021-06-01 06:07:13 +03:00
|
|
|
std::string_view InputArrayDecorator(Stage stage) {
|
2021-05-31 20:28:53 +03:00
|
|
|
switch (stage) {
|
|
|
|
case Stage::Geometry:
|
2021-06-01 06:07:13 +03:00
|
|
|
case Stage::TessellationControl:
|
|
|
|
case Stage::TessellationEval:
|
|
|
|
return "[]";
|
|
|
|
default:
|
|
|
|
return "";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string OutputDecorator(Stage stage, u32 size) {
|
|
|
|
switch (stage) {
|
|
|
|
case Stage::TessellationControl:
|
|
|
|
return fmt::format("[{}]", size);
|
2021-05-31 20:28:53 +03:00
|
|
|
default:
|
|
|
|
return "";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-05-29 08:53:32 +03:00
|
|
|
std::string_view SamplerType(TextureType type, bool is_depth) {
|
|
|
|
if (is_depth) {
|
|
|
|
switch (type) {
|
|
|
|
case TextureType::Color1D:
|
|
|
|
return "sampler1DShadow";
|
|
|
|
case TextureType::ColorArray1D:
|
|
|
|
return "sampler1DArrayShadow";
|
|
|
|
case TextureType::Color2D:
|
|
|
|
return "sampler2DShadow";
|
|
|
|
case TextureType::ColorArray2D:
|
|
|
|
return "sampler2DArrayShadow";
|
|
|
|
case TextureType::ColorCube:
|
|
|
|
return "samplerCubeShadow";
|
|
|
|
case TextureType::ColorArrayCube:
|
|
|
|
return "samplerCubeArrayShadow";
|
|
|
|
default:
|
|
|
|
fmt::print("Texture type: {}", type);
|
|
|
|
throw NotImplementedException("Texture type: {}", type);
|
|
|
|
}
|
|
|
|
}
|
2021-05-28 05:28:33 +03:00
|
|
|
switch (type) {
|
2021-05-29 08:06:29 +03:00
|
|
|
case TextureType::Color1D:
|
|
|
|
return "sampler1D";
|
|
|
|
case TextureType::ColorArray1D:
|
|
|
|
return "sampler1DArray";
|
2021-05-28 05:28:33 +03:00
|
|
|
case TextureType::Color2D:
|
|
|
|
return "sampler2D";
|
|
|
|
case TextureType::ColorArray2D:
|
|
|
|
return "sampler2DArray";
|
|
|
|
case TextureType::Color3D:
|
|
|
|
return "sampler3D";
|
2021-05-28 20:54:09 +03:00
|
|
|
case TextureType::ColorCube:
|
|
|
|
return "samplerCube";
|
2021-05-29 08:06:29 +03:00
|
|
|
case TextureType::ColorArrayCube:
|
|
|
|
return "samplerCubeArray";
|
|
|
|
case TextureType::Buffer:
|
|
|
|
return "samplerBuffer";
|
2021-05-28 05:28:33 +03:00
|
|
|
default:
|
2021-05-28 20:54:09 +03:00
|
|
|
fmt::print("Texture type: {}", type);
|
2021-05-28 05:28:33 +03:00
|
|
|
throw NotImplementedException("Texture type: {}", type);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-06-01 06:07:13 +03:00
|
|
|
std::string_view GetTessMode(TessPrimitive primitive) {
|
|
|
|
switch (primitive) {
|
|
|
|
case TessPrimitive::Triangles:
|
|
|
|
return "triangles";
|
|
|
|
case TessPrimitive::Quads:
|
|
|
|
return "quads";
|
|
|
|
case TessPrimitive::Isolines:
|
|
|
|
return "isolines";
|
|
|
|
}
|
|
|
|
throw InvalidArgument("Invalid tessellation primitive {}", primitive);
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string_view GetTessSpacing(TessSpacing spacing) {
|
|
|
|
switch (spacing) {
|
|
|
|
case TessSpacing::Equal:
|
|
|
|
return "equal_spacing";
|
|
|
|
case TessSpacing::FractionalOdd:
|
|
|
|
return "fractional_odd_spacing";
|
|
|
|
case TessSpacing::FractionalEven:
|
|
|
|
return "fractional_even_spacing";
|
|
|
|
}
|
|
|
|
throw InvalidArgument("Invalid tessellation spacing {}", spacing);
|
|
|
|
}
|
|
|
|
|
2021-05-31 20:28:53 +03:00
|
|
|
std::string_view InputPrimitive(InputTopology topology) {
|
|
|
|
switch (topology) {
|
|
|
|
case InputTopology::Points:
|
|
|
|
return "points";
|
|
|
|
case InputTopology::Lines:
|
|
|
|
return "lines";
|
|
|
|
case InputTopology::LinesAdjacency:
|
|
|
|
return "lines_adjacency";
|
|
|
|
case InputTopology::Triangles:
|
|
|
|
return "triangles";
|
|
|
|
case InputTopology::TrianglesAdjacency:
|
|
|
|
return "triangles_adjacency";
|
|
|
|
}
|
|
|
|
throw InvalidArgument("Invalid input topology {}", topology);
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string_view OutputPrimitive(OutputTopology topology) {
|
|
|
|
switch (topology) {
|
|
|
|
case OutputTopology::PointList:
|
|
|
|
return "points";
|
|
|
|
case OutputTopology::LineStrip:
|
|
|
|
return "line_strip";
|
|
|
|
case OutputTopology::TriangleStrip:
|
|
|
|
return "triangle_strip";
|
|
|
|
}
|
|
|
|
throw InvalidArgument("Invalid output topology {}", topology);
|
|
|
|
}
|
2021-06-01 06:07:13 +03:00
|
|
|
|
|
|
|
void SetupOutPerVertex(Stage stage, const Info& info, std::string& header) {
|
|
|
|
if (stage != Stage::VertexA && stage != Stage::VertexB && stage != Stage::Geometry) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
header += "out gl_PerVertex{";
|
|
|
|
if (info.stores_position) {
|
|
|
|
header += "vec4 gl_Position;";
|
|
|
|
}
|
|
|
|
if (info.stores_point_size) {
|
|
|
|
header += "float gl_PointSize;";
|
|
|
|
}
|
|
|
|
if (info.stores_clip_distance) {
|
|
|
|
header += "float gl_ClipDistance[];";
|
|
|
|
}
|
2021-06-01 07:07:14 +03:00
|
|
|
header += "};\n";
|
2021-06-01 06:07:13 +03:00
|
|
|
}
|
2021-05-27 04:18:17 +03:00
|
|
|
} // namespace
|
2021-05-20 04:58:32 +03:00
|
|
|
|
2021-05-28 03:31:03 +03:00
|
|
|
EmitContext::EmitContext(IR::Program& program, Bindings& bindings, const Profile& profile_,
|
|
|
|
const RuntimeInfo& runtime_info_)
|
|
|
|
: info{program.info}, profile{profile_}, runtime_info{runtime_info_} {
|
2021-05-22 03:56:46 +03:00
|
|
|
SetupExtensions(header);
|
2021-05-26 07:16:20 +03:00
|
|
|
stage = program.stage;
|
|
|
|
switch (program.stage) {
|
|
|
|
case Stage::VertexA:
|
|
|
|
case Stage::VertexB:
|
2021-05-28 05:28:33 +03:00
|
|
|
stage_name = "vs";
|
2021-05-26 07:16:20 +03:00
|
|
|
break;
|
|
|
|
case Stage::TessellationControl:
|
2021-06-01 06:07:13 +03:00
|
|
|
stage_name = "tsc";
|
|
|
|
header += fmt::format("layout(vertices={})out;\n", program.invocations);
|
|
|
|
break;
|
2021-05-26 07:16:20 +03:00
|
|
|
case Stage::TessellationEval:
|
2021-06-01 06:07:13 +03:00
|
|
|
stage_name = "tse";
|
|
|
|
header += fmt::format("layout({},{},{})in;\n", GetTessMode(runtime_info.tess_primitive),
|
|
|
|
GetTessSpacing(runtime_info.tess_spacing),
|
|
|
|
runtime_info.tess_clockwise ? "cw" : "ccw");
|
2021-05-26 07:16:20 +03:00
|
|
|
break;
|
|
|
|
case Stage::Geometry:
|
2021-05-28 05:28:33 +03:00
|
|
|
stage_name = "gs";
|
2021-06-01 06:07:13 +03:00
|
|
|
header += fmt::format("layout({})in;layout({},max_vertices={})out;\n",
|
2021-05-31 20:28:53 +03:00
|
|
|
InputPrimitive(runtime_info.input_topology),
|
|
|
|
OutputPrimitive(program.output_topology), program.output_vertices);
|
2021-05-26 07:16:20 +03:00
|
|
|
break;
|
|
|
|
case Stage::Fragment:
|
2021-05-28 05:28:33 +03:00
|
|
|
stage_name = "fs";
|
2021-05-26 07:16:20 +03:00
|
|
|
break;
|
|
|
|
case Stage::Compute:
|
2021-05-28 05:28:33 +03:00
|
|
|
stage_name = "cs";
|
2021-05-21 06:38:38 +03:00
|
|
|
header += fmt::format("layout(local_size_x={},local_size_y={},local_size_z={}) in;\n",
|
|
|
|
program.workgroup_size[0], program.workgroup_size[1],
|
|
|
|
program.workgroup_size[2]);
|
2021-05-26 07:16:20 +03:00
|
|
|
break;
|
2021-05-21 06:38:38 +03:00
|
|
|
}
|
2021-06-01 06:07:13 +03:00
|
|
|
SetupOutPerVertex(stage, info, header);
|
2021-05-26 07:16:20 +03:00
|
|
|
for (size_t index = 0; index < info.input_generics.size(); ++index) {
|
|
|
|
const auto& generic{info.input_generics[index]};
|
|
|
|
if (generic.used) {
|
2021-06-01 06:07:13 +03:00
|
|
|
header += fmt::format("layout(location={}){} in vec4 in_attr{}{};", index,
|
|
|
|
InterpDecorator(generic.interpolation), index,
|
|
|
|
InputArrayDecorator(stage));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for (size_t index = 0; index < info.uses_patches.size(); ++index) {
|
|
|
|
if (!info.uses_patches[index]) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (stage == Stage::TessellationControl) {
|
|
|
|
header += fmt::format("layout(location={})patch out vec4 patch{};", index, index);
|
|
|
|
} else {
|
|
|
|
header += fmt::format("layout(location={})patch in vec4 patch{};", index, index);
|
2021-05-26 07:16:20 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
for (size_t index = 0; index < info.stores_frag_color.size(); ++index) {
|
|
|
|
if (!info.stores_frag_color[index]) {
|
|
|
|
continue;
|
|
|
|
}
|
2021-05-28 20:54:09 +03:00
|
|
|
header += fmt::format("layout(location={})out vec4 frag_color{};", index, index);
|
2021-05-26 07:16:20 +03:00
|
|
|
}
|
|
|
|
for (size_t index = 0; index < info.stores_generics.size(); ++index) {
|
2021-05-31 05:42:52 +03:00
|
|
|
// TODO: Properly resolve attribute issues
|
2021-06-01 06:07:13 +03:00
|
|
|
const auto declaration{fmt::format("layout(location={}) out vec4 out_attr{}{};", index,
|
|
|
|
index, OutputDecorator(stage, program.invocations))};
|
2021-05-31 05:42:52 +03:00
|
|
|
if (info.stores_generics[index] || stage == Stage::VertexA || stage == Stage::VertexB) {
|
|
|
|
header += declaration;
|
2021-05-26 07:16:20 +03:00
|
|
|
}
|
|
|
|
}
|
2021-06-01 07:07:14 +03:00
|
|
|
header += "\n";
|
2021-05-28 05:28:33 +03:00
|
|
|
DefineConstantBuffers(bindings);
|
|
|
|
DefineStorageBuffers(bindings);
|
2021-05-27 04:18:17 +03:00
|
|
|
SetupImages(bindings);
|
2021-05-28 05:28:33 +03:00
|
|
|
DefineHelperFunctions();
|
2021-05-20 04:58:32 +03:00
|
|
|
}
|
|
|
|
|
2021-05-28 20:54:09 +03:00
|
|
|
void EmitContext::SetupExtensions(std::string&) {
|
2021-05-31 02:13:22 +03:00
|
|
|
// TODO: track this usage
|
|
|
|
header += "#extension GL_ARB_sparse_texture2 : enable\n";
|
|
|
|
header += "#extension GL_EXT_texture_shadow_lod : enable\n";
|
2021-05-22 03:56:46 +03:00
|
|
|
if (info.uses_int64) {
|
|
|
|
header += "#extension GL_ARB_gpu_shader_int64 : enable\n";
|
|
|
|
}
|
2021-05-25 01:35:37 +03:00
|
|
|
if (info.uses_int64_bit_atomics) {
|
|
|
|
header += "#extension GL_NV_shader_atomic_int64 : enable\n";
|
|
|
|
}
|
|
|
|
if (info.uses_atomic_f32_add) {
|
|
|
|
header += "#extension GL_NV_shader_atomic_float : enable\n";
|
|
|
|
}
|
|
|
|
if (info.uses_atomic_f16x2_add || info.uses_atomic_f16x2_min || info.uses_atomic_f16x2_max) {
|
|
|
|
header += "#extension NV_shader_atomic_fp16_vector : enable\n";
|
|
|
|
}
|
2021-05-25 08:52:02 +03:00
|
|
|
if (info.uses_fp16) {
|
2021-05-26 02:55:40 +03:00
|
|
|
if (profile.support_gl_nv_gpu_shader_5) {
|
|
|
|
header += "#extension GL_NV_gpu_shader5 : enable\n";
|
|
|
|
}
|
|
|
|
if (profile.support_gl_amd_gpu_shader_half_float) {
|
|
|
|
header += "#extension GL_AMD_gpu_shader_half_float : enable\n";
|
|
|
|
}
|
2021-05-25 08:52:02 +03:00
|
|
|
}
|
2021-05-29 04:24:52 +03:00
|
|
|
if (info.uses_subgroup_invocation_id || info.uses_subgroup_mask || info.uses_subgroup_vote ||
|
|
|
|
info.uses_subgroup_shuffles || info.uses_fswzadd) {
|
|
|
|
header += "#extension GL_ARB_shader_ballot : enable\n";
|
2021-05-30 07:08:39 +03:00
|
|
|
header += "#extension GL_ARB_shader_group_vote : enable\n";
|
2021-05-30 07:53:26 +03:00
|
|
|
if (!info.uses_int64) {
|
|
|
|
header += "#extension GL_ARB_gpu_shader_int64 : enable\n";
|
|
|
|
}
|
2021-05-29 04:24:52 +03:00
|
|
|
}
|
2021-05-31 20:28:53 +03:00
|
|
|
if (info.stores_viewport_index) {
|
|
|
|
header += "#extension GL_ARB_shader_viewport_layer_array : enable\n";
|
|
|
|
header += "#extension GL_NV_viewport_array2 : enable\n";
|
|
|
|
}
|
2021-05-22 03:56:46 +03:00
|
|
|
}
|
|
|
|
|
2021-05-28 05:28:33 +03:00
|
|
|
void EmitContext::DefineConstantBuffers(Bindings& bindings) {
|
2021-05-20 04:58:32 +03:00
|
|
|
if (info.constant_buffer_descriptors.empty()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
for (const auto& desc : info.constant_buffer_descriptors) {
|
2021-05-28 20:54:09 +03:00
|
|
|
header += fmt::format(
|
|
|
|
"layout(std140,binding={}) uniform {}_cbuf_{}{{vec4 {}_cbuf{}[{}];}};",
|
2021-05-28 05:28:33 +03:00
|
|
|
bindings.uniform_buffer, stage_name, desc.index, stage_name, desc.index, 4 * 1024);
|
|
|
|
bindings.uniform_buffer += desc.count;
|
2021-05-21 06:38:38 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-05-28 05:28:33 +03:00
|
|
|
void EmitContext::DefineStorageBuffers(Bindings& bindings) {
|
2021-05-21 06:38:38 +03:00
|
|
|
if (info.storage_buffers_descriptors.empty()) {
|
|
|
|
return;
|
|
|
|
}
|
2021-05-31 03:02:44 +03:00
|
|
|
u32 index{};
|
2021-05-21 06:38:38 +03:00
|
|
|
for (const auto& desc : info.storage_buffers_descriptors) {
|
2021-05-31 03:02:44 +03:00
|
|
|
header += fmt::format("layout(std430,binding={}) buffer {}_ssbo_{}{{uint {}_ssbo{}[];}};",
|
|
|
|
bindings.storage_buffer, stage_name, bindings.storage_buffer,
|
|
|
|
stage_name, index);
|
2021-05-28 05:28:33 +03:00
|
|
|
bindings.storage_buffer += desc.count;
|
2021-05-31 03:02:44 +03:00
|
|
|
index += desc.count;
|
2021-05-20 04:58:32 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-05-25 01:35:37 +03:00
|
|
|
void EmitContext::DefineHelperFunctions() {
|
2021-05-30 21:31:59 +03:00
|
|
|
if (info.uses_global_increment || info.uses_shared_increment) {
|
2021-05-28 20:54:09 +03:00
|
|
|
header += "uint CasIncrement(uint op_a,uint op_b){return(op_a>=op_b)?0u:(op_a+1u);}\n";
|
2021-05-25 01:35:37 +03:00
|
|
|
}
|
2021-05-30 21:31:59 +03:00
|
|
|
if (info.uses_global_decrement || info.uses_shared_decrement) {
|
2021-05-28 20:54:09 +03:00
|
|
|
header +=
|
2021-05-25 01:35:37 +03:00
|
|
|
"uint CasDecrement(uint op_a,uint op_b){return(op_a==0||op_a>op_b)?op_b:(op_a-1u);}\n";
|
|
|
|
}
|
2021-05-25 08:35:30 +03:00
|
|
|
if (info.uses_atomic_f32_add) {
|
2021-05-28 20:54:09 +03:00
|
|
|
header += "uint CasFloatAdd(uint op_a,float op_b){return "
|
|
|
|
"floatBitsToUint(uintBitsToFloat(op_a)+op_b);}\n";
|
2021-05-25 08:35:30 +03:00
|
|
|
}
|
|
|
|
if (info.uses_atomic_f32x2_add) {
|
2021-05-28 20:54:09 +03:00
|
|
|
header += "uint CasFloatAdd32x2(uint op_a,vec2 op_b){return "
|
|
|
|
"packHalf2x16(unpackHalf2x16(op_a)+op_b);}\n";
|
2021-05-25 08:35:30 +03:00
|
|
|
}
|
|
|
|
if (info.uses_atomic_f32x2_min) {
|
2021-05-28 20:54:09 +03:00
|
|
|
header += "uint CasFloatMin32x2(uint op_a,vec2 op_b){return "
|
|
|
|
"packHalf2x16(min(unpackHalf2x16(op_a),op_b));}\n";
|
2021-05-25 08:35:30 +03:00
|
|
|
}
|
|
|
|
if (info.uses_atomic_f32x2_max) {
|
2021-05-28 20:54:09 +03:00
|
|
|
header += "uint CasFloatMax32x2(uint op_a,vec2 op_b){return "
|
|
|
|
"packHalf2x16(max(unpackHalf2x16(op_a),op_b));}\n";
|
2021-05-25 08:35:30 +03:00
|
|
|
}
|
2021-05-25 08:52:02 +03:00
|
|
|
if (info.uses_atomic_f16x2_add) {
|
2021-05-28 20:54:09 +03:00
|
|
|
header += "uint CasFloatAdd16x2(uint op_a,f16vec2 op_b){return "
|
|
|
|
"packFloat2x16(unpackFloat2x16(op_a)+op_b);}\n";
|
2021-05-25 08:52:02 +03:00
|
|
|
}
|
|
|
|
if (info.uses_atomic_f16x2_min) {
|
2021-05-28 20:54:09 +03:00
|
|
|
header += "uint CasFloatMin16x2(uint op_a,f16vec2 op_b){return "
|
|
|
|
"packFloat2x16(min(unpackFloat2x16(op_a),op_b));}\n";
|
2021-05-25 08:52:02 +03:00
|
|
|
}
|
|
|
|
if (info.uses_atomic_f16x2_max) {
|
2021-05-28 20:54:09 +03:00
|
|
|
header += "uint CasFloatMax16x2(uint op_a,f16vec2 op_b){return "
|
|
|
|
"packFloat2x16(max(unpackFloat2x16(op_a),op_b));}\n";
|
2021-05-25 08:52:02 +03:00
|
|
|
}
|
2021-05-26 05:13:50 +03:00
|
|
|
if (info.uses_atomic_s32_min) {
|
2021-05-28 20:54:09 +03:00
|
|
|
header += "uint CasMinS32(uint op_a,uint op_b){return uint(min(int(op_a),int(op_b)));}";
|
2021-05-26 05:13:50 +03:00
|
|
|
}
|
|
|
|
if (info.uses_atomic_s32_max) {
|
2021-05-28 20:54:09 +03:00
|
|
|
header += "uint CasMaxS32(uint op_a,uint op_b){return uint(max(int(op_a),int(op_b)));}";
|
2021-05-26 05:13:50 +03:00
|
|
|
}
|
2021-05-25 01:35:37 +03:00
|
|
|
}
|
|
|
|
|
2021-05-27 04:18:17 +03:00
|
|
|
void EmitContext::SetupImages(Bindings& bindings) {
|
|
|
|
image_buffer_bindings.reserve(info.image_buffer_descriptors.size());
|
|
|
|
for (const auto& desc : info.image_buffer_descriptors) {
|
|
|
|
throw NotImplementedException("image_buffer_descriptors");
|
|
|
|
image_buffer_bindings.push_back(bindings.image);
|
|
|
|
bindings.image += desc.count;
|
|
|
|
}
|
|
|
|
image_bindings.reserve(info.image_descriptors.size());
|
|
|
|
for (const auto& desc : info.image_descriptors) {
|
|
|
|
throw NotImplementedException("image_bindings");
|
|
|
|
|
|
|
|
image_bindings.push_back(bindings.image);
|
|
|
|
bindings.image += desc.count;
|
|
|
|
}
|
|
|
|
texture_buffer_bindings.reserve(info.texture_buffer_descriptors.size());
|
|
|
|
for (const auto& desc : info.texture_buffer_descriptors) {
|
|
|
|
texture_buffer_bindings.push_back(bindings.texture);
|
2021-05-31 08:12:52 +03:00
|
|
|
const auto sampler_type{SamplerType(TextureType::Buffer, false)};
|
|
|
|
const auto indices{bindings.texture + desc.count};
|
|
|
|
for (u32 index = bindings.texture; index < indices; ++index) {
|
|
|
|
header += fmt::format("layout(binding={}) uniform {} tex{};", bindings.texture,
|
|
|
|
sampler_type, index);
|
|
|
|
}
|
2021-05-27 04:18:17 +03:00
|
|
|
bindings.texture += desc.count;
|
|
|
|
}
|
|
|
|
texture_bindings.reserve(info.texture_descriptors.size());
|
|
|
|
for (const auto& desc : info.texture_descriptors) {
|
2021-05-29 08:53:32 +03:00
|
|
|
const auto sampler_type{SamplerType(desc.type, desc.is_depth)};
|
2021-05-27 04:18:17 +03:00
|
|
|
texture_bindings.push_back(bindings.texture);
|
|
|
|
const auto indices{bindings.texture + desc.count};
|
|
|
|
for (u32 index = bindings.texture; index < indices; ++index) {
|
2021-05-28 20:54:09 +03:00
|
|
|
header += fmt::format("layout(binding={}) uniform {} tex{};", bindings.texture,
|
|
|
|
sampler_type, index);
|
2021-05-27 04:18:17 +03:00
|
|
|
}
|
|
|
|
bindings.texture += desc.count;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-05-20 04:58:32 +03:00
|
|
|
} // namespace Shader::Backend::GLSL
|