diff --git a/gfx/drivers_shader/glslang_util.c b/gfx/drivers_shader/glslang_util.c index 0dc505c093..e8169cda70 100644 --- a/gfx/drivers_shader/glslang_util.c +++ b/gfx/drivers_shader/glslang_util.c @@ -333,3 +333,11 @@ enum glslang_format glslang_find_format(const char *fmt) return SLANG_FORMAT_UNKNOWN; } + +void glslang_build_vec4(float *data, unsigned width, unsigned height) +{ + data[0] = (float)(width); + data[1] = (float)(height); + data[2] = 1.0f / (float)(width); + data[3] = 1.0f / (float)(height); +} diff --git a/gfx/drivers_shader/glslang_util.h b/gfx/drivers_shader/glslang_util.h index 6116435087..c489dfe65d 100644 --- a/gfx/drivers_shader/glslang_util.h +++ b/gfx/drivers_shader/glslang_util.h @@ -83,6 +83,8 @@ enum slang_texture_semantic slang_name_to_texture_semantic_array( const char *name, const char **names, unsigned *index); +void glslang_build_vec4(float *data, unsigned width, unsigned height); + RETRO_END_DECLS #endif diff --git a/gfx/drivers_shader/shader_gl_core.cpp b/gfx/drivers_shader/shader_gl_core.cpp index e97369625a..c8665ae66a 100644 --- a/gfx/drivers_shader/shader_gl_core.cpp +++ b/gfx/drivers_shader/shader_gl_core.cpp @@ -276,15 +276,6 @@ static unsigned num_miplevels(unsigned width, unsigned height) return levels; } - -static void build_vec4(float *data, unsigned width, unsigned height) -{ - data[0] = float(width); - data[1] = float(height); - data[2] = 1.0f / float(width); - data[3] = 1.0f / float(height); -} - struct Texture { gl_core_filter_chain_texture texture; @@ -1103,14 +1094,14 @@ void Pass::build_semantic_vec4(uint8_t *data, slang_semantic semantic, if (refl->location.ubo_vertex >= 0 || refl->location.ubo_fragment >= 0) { float v4[4]; - build_vec4(v4, width, height); + glslang_build_vec4(v4, width, height); if (refl->location.ubo_vertex >= 0) glUniform4fv(refl->location.ubo_vertex, 1, v4); if (refl->location.ubo_fragment >= 0) glUniform4fv(refl->location.ubo_fragment, 1, v4); } else - build_vec4( + glslang_build_vec4( reinterpret_cast(data + refl->ubo_offset), width, height); @@ -1122,14 +1113,14 @@ void Pass::build_semantic_vec4(uint8_t *data, slang_semantic semantic, refl->location.push_fragment >= 0) { float v4[4]; - build_vec4(v4, width, height); + glslang_build_vec4(v4, width, height); if (refl->location.push_vertex >= 0) glUniform4fv(refl->location.push_vertex, 1, v4); if (refl->location.push_fragment >= 0) glUniform4fv(refl->location.push_fragment, 1, v4); } else - build_vec4( + glslang_build_vec4( reinterpret_cast (push_constant_buffer.data() + refl->push_constant_offset), width, @@ -1254,14 +1245,14 @@ void Pass::build_semantic_texture_array_vec4(uint8_t *data, slang_texture_semant if (refl[index].location.ubo_vertex >= 0 || refl[index].location.ubo_fragment >= 0) { float v4[4]; - build_vec4(v4, width, height); + glslang_build_vec4(v4, width, height); if (refl[index].location.ubo_vertex >= 0) glUniform4fv(refl[index].location.ubo_vertex, 1, v4); if (refl[index].location.ubo_fragment >= 0) glUniform4fv(refl[index].location.ubo_fragment, 1, v4); } else - build_vec4( + glslang_build_vec4( reinterpret_cast(data + refl[index].ubo_offset), width, height); @@ -1272,14 +1263,14 @@ void Pass::build_semantic_texture_array_vec4(uint8_t *data, slang_texture_semant if (refl[index].location.push_vertex >= 0 || refl[index].location.push_fragment >= 0) { float v4[4]; - build_vec4(v4, width, height); + glslang_build_vec4(v4, width, height); if (refl[index].location.push_vertex >= 0) glUniform4fv(refl[index].location.push_vertex, 1, v4); if (refl[index].location.push_fragment >= 0) glUniform4fv(refl[index].location.push_fragment, 1, v4); } else - build_vec4( + glslang_build_vec4( reinterpret_cast(push_constant_buffer.data() + refl[index].push_constant_offset), width, height); diff --git a/gfx/drivers_shader/shader_vulkan.cpp b/gfx/drivers_shader/shader_vulkan.cpp index 51e069df86..f6456b1a1d 100644 --- a/gfx/drivers_shader/shader_vulkan.cpp +++ b/gfx/drivers_shader/shader_vulkan.cpp @@ -478,14 +478,6 @@ static void build_identity_matrix(float *data) data[15] = 1.0f; } -static void build_vec4(float *data, unsigned width, unsigned height) -{ - data[0] = float(width); - data[1] = float(height); - data[2] = 1.0f / float(width); - data[3] = 1.0f / float(height); -} - static VkFormat glslang_format_to_vk(glslang_format fmt) { #undef FMT @@ -2037,13 +2029,13 @@ void Pass::build_semantic_texture_array_vec4(uint8_t *data, slang_texture_semant return; if (data && refl[index].uniform) - build_vec4( + glslang_build_vec4( reinterpret_cast(data + refl[index].ubo_offset), width, height); if (refl[index].push_constant) - build_vec4( + glslang_build_vec4( reinterpret_cast(push.buffer.data() + (refl[index].push_constant_offset >> 2)), width, height); @@ -2061,13 +2053,13 @@ void Pass::build_semantic_vec4(uint8_t *data, slang_semantic semantic, auto &refl = reflection.semantics[semantic]; if (data && refl.uniform) - build_vec4( + glslang_build_vec4( reinterpret_cast(data + refl.ubo_offset), width, height); if (refl.push_constant) - build_vec4( + glslang_build_vec4( reinterpret_cast (push.buffer.data() + (refl.push_constant_offset >> 2)), width,