Move build_vec4 to glslang_util.c

This commit is contained in:
twinaphex 2020-08-03 18:34:33 +02:00
parent cce2ac6904
commit 86d302099e
4 changed files with 22 additions and 29 deletions

View File

@ -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);
}

View File

@ -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

View File

@ -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<float *>(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<float *>
(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<float *>(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<float *>(push_constant_buffer.data() + refl[index].push_constant_offset),
width,
height);

View File

@ -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<float *>(data + refl[index].ubo_offset),
width,
height);
if (refl[index].push_constant)
build_vec4(
glslang_build_vec4(
reinterpret_cast<float *>(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<float *>(data + refl.ubo_offset),
width,
height);
if (refl.push_constant)
build_vec4(
glslang_build_vec4(
reinterpret_cast<float *>
(push.buffer.data() + (refl.push_constant_offset >> 2)),
width,