gl_shader_cache: Update commentary for shared memory

Remove false commentary. Not dividing by 4 the size of shared memory is
not a hack; it describes the number of integers, not bytes.

While we are at it sort the generated code to put preprocessor lines on
the top.
master
ReinUsesLisp 2019-12-20 22:51:19 +07:00
parent 486c6a5316
commit 1e16023d60
No known key found for this signature in database
GPG Key ID: 2DFC508897B39CFE
1 changed files with 6 additions and 9 deletions

@ -264,28 +264,25 @@ CachedProgram BuildShader(const Device& device, u64 unique_identifier, ShaderTyp
"#extension GL_NV_shader_thread_group : require\n" "#extension GL_NV_shader_thread_group : require\n"
"#extension GL_NV_shader_thread_shuffle : require\n"; "#extension GL_NV_shader_thread_shuffle : require\n";
} }
source += '\n';
if (shader_type == ShaderType::Geometry) { if (shader_type == ShaderType::Geometry) {
const auto [glsl_topology, max_vertices] = GetPrimitiveDescription(variant.primitive_mode); const auto [glsl_topology, max_vertices] = GetPrimitiveDescription(variant.primitive_mode);
source += fmt::format("#define MAX_VERTEX_INPUT {}\n", max_vertices); source += fmt::format("#define MAX_VERTEX_INPUT {}\n", max_vertices);
source += fmt::format("layout ({}) in;\n\n", glsl_topology); source += fmt::format("layout ({}) in;\n", glsl_topology);
} }
if (shader_type == ShaderType::Compute) { if (shader_type == ShaderType::Compute) {
if (variant.local_memory_size > 0) {
source += fmt::format("#define LOCAL_MEMORY_SIZE {}\n",
Common::AlignUp(variant.local_memory_size, 4) / 4);
}
source += source +=
fmt::format("layout (local_size_x = {}, local_size_y = {}, local_size_z = {}) in;\n", fmt::format("layout (local_size_x = {}, local_size_y = {}, local_size_z = {}) in;\n",
variant.block_x, variant.block_y, variant.block_z); variant.block_x, variant.block_y, variant.block_z);
if (variant.shared_memory_size > 0) { if (variant.shared_memory_size > 0) {
// TODO(Rodrigo): We should divide by four here, but having a larger shared memory pool // shared_memory_size is described in number of words
// avoids out of bound stores. Find out why shared memory size is being invalid.
source += fmt::format("shared uint smem[{}];\n", variant.shared_memory_size); source += fmt::format("shared uint smem[{}];\n", variant.shared_memory_size);
} }
if (variant.local_memory_size > 0) {
source += fmt::format("#define LOCAL_MEMORY_SIZE {}\n",
Common::AlignUp(variant.local_memory_size, 4) / 4);
}
} }
source += '\n'; source += '\n';