mirror of
https://github.com/brl/mutter.git
synced 2024-11-09 15:37:00 -05:00
cogl: Eliminate _cogl_gl_util_get_texture_target_string
Its results are effectively constant now. Fold them into the callers and remove the function. https://gitlab.gnome.org/GNOME/mutter/merge_requests/546
This commit is contained in:
parent
e71f44dbd6
commit
2b9cd50e84
@ -233,14 +233,9 @@ add_layer_declaration_cb (CoglPipelineLayer *layer,
|
||||
void *user_data)
|
||||
{
|
||||
CoglPipelineShaderState *shader_state = user_data;
|
||||
const char *target_string;
|
||||
|
||||
_cogl_gl_util_get_texture_target_string (COGL_TEXTURE_TYPE_2D,
|
||||
&target_string, NULL);
|
||||
|
||||
g_string_append_printf (shader_state->header,
|
||||
"uniform sampler%s cogl_sampler%i;\n",
|
||||
target_string,
|
||||
"uniform sampler2D cogl_sampler%i;\n",
|
||||
layer->index);
|
||||
|
||||
return TRUE;
|
||||
@ -410,17 +405,12 @@ ensure_texture_lookup_generated (CoglPipelineShaderState *shader_state,
|
||||
{
|
||||
int unit_index = _cogl_pipeline_layer_get_unit_index (layer);
|
||||
CoglPipelineSnippetData snippet_data;
|
||||
const char *target_string, *tex_coord_swizzle;
|
||||
|
||||
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
|
||||
|
||||
if (shader_state->unit_state[unit_index].sampled)
|
||||
return;
|
||||
|
||||
_cogl_gl_util_get_texture_target_string (COGL_TEXTURE_TYPE_2D,
|
||||
&target_string,
|
||||
&tex_coord_swizzle);
|
||||
|
||||
shader_state->unit_state[unit_index].sampled = TRUE;
|
||||
|
||||
g_string_append_printf (shader_state->header,
|
||||
@ -451,20 +441,18 @@ ensure_texture_lookup_generated (CoglPipelineShaderState *shader_state,
|
||||
{
|
||||
g_string_append_printf (shader_state->header,
|
||||
"vec4\n"
|
||||
"cogl_real_texture_lookup%i (sampler%s tex,\n"
|
||||
"cogl_real_texture_lookup%i (sampler2D tex,\n"
|
||||
" vec4 coords)\n"
|
||||
"{\n"
|
||||
" return ",
|
||||
layer->index,
|
||||
target_string);
|
||||
layer->index);
|
||||
|
||||
if (G_UNLIKELY (COGL_DEBUG_ENABLED (COGL_DEBUG_DISABLE_TEXTURING)))
|
||||
g_string_append (shader_state->header,
|
||||
"vec4 (1.0, 1.0, 1.0, 1.0);\n");
|
||||
else
|
||||
g_string_append_printf (shader_state->header,
|
||||
"texture%s (tex, coords.%s);\n",
|
||||
target_string, tex_coord_swizzle);
|
||||
g_string_append (shader_state->header,
|
||||
"texture2D (tex, coords.st);\n");
|
||||
|
||||
g_string_append (shader_state->header, "}\n");
|
||||
}
|
||||
@ -483,8 +471,7 @@ ensure_texture_lookup_generated (CoglPipelineShaderState *shader_state,
|
||||
snippet_data.return_variable = "cogl_texel";
|
||||
snippet_data.arguments = "cogl_sampler, cogl_tex_coord";
|
||||
snippet_data.argument_declarations =
|
||||
g_strdup_printf ("sampler%s cogl_sampler, vec4 cogl_tex_coord",
|
||||
target_string);
|
||||
g_strdup ("sampler2D cogl_sampler, vec4 cogl_tex_coord");
|
||||
snippet_data.source_buf = shader_state->header;
|
||||
|
||||
_cogl_pipeline_snippet_generate_code (&snippet_data);
|
||||
|
@ -169,14 +169,9 @@ add_layer_declaration_cb (CoglPipelineLayer *layer,
|
||||
void *user_data)
|
||||
{
|
||||
CoglPipelineShaderState *shader_state = user_data;
|
||||
const char *target_string;
|
||||
|
||||
_cogl_gl_util_get_texture_target_string (COGL_TEXTURE_TYPE_2D,
|
||||
&target_string, NULL);
|
||||
|
||||
g_string_append_printf (shader_state->header,
|
||||
"uniform sampler%s cogl_sampler%i;\n",
|
||||
target_string,
|
||||
"uniform sampler2D cogl_sampler%i;\n",
|
||||
layer->index);
|
||||
|
||||
return TRUE;
|
||||
|
@ -85,11 +85,6 @@ _cogl_gl_util_clear_gl_errors (CoglContext *ctx);
|
||||
gboolean
|
||||
_cogl_gl_util_catch_out_of_memory (CoglContext *ctx, CoglError **error);
|
||||
|
||||
void
|
||||
_cogl_gl_util_get_texture_target_string (CoglTextureType texture_type,
|
||||
const char **target_string_out,
|
||||
const char **swizzle_out);
|
||||
|
||||
/* Parses a GL version number stored in a string. @version_string must
|
||||
* point to the beginning of the version number (ie, it can't point to
|
||||
* the "OpenGL ES" part on GLES). The version number can be followed
|
||||
|
@ -127,39 +127,6 @@ _cogl_gl_util_catch_out_of_memory (CoglContext *ctx, CoglError **error)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void
|
||||
_cogl_gl_util_get_texture_target_string (CoglTextureType texture_type,
|
||||
const char **target_string_out,
|
||||
const char **swizzle_out)
|
||||
{
|
||||
const char *target_string, *tex_coord_swizzle;
|
||||
|
||||
switch (texture_type)
|
||||
{
|
||||
#if 0 /* TODO */
|
||||
case COGL_TEXTURE_TYPE_1D:
|
||||
target_string = "1D";
|
||||
tex_coord_swizzle = "s";
|
||||
break;
|
||||
#endif
|
||||
|
||||
case COGL_TEXTURE_TYPE_2D:
|
||||
target_string = "2D";
|
||||
tex_coord_swizzle = "st";
|
||||
break;
|
||||
|
||||
default:
|
||||
target_string = "Unknown";
|
||||
tex_coord_swizzle = NULL;
|
||||
g_assert_not_reached ();
|
||||
}
|
||||
|
||||
if (target_string_out)
|
||||
*target_string_out = target_string;
|
||||
if (swizzle_out)
|
||||
*swizzle_out = tex_coord_swizzle;
|
||||
}
|
||||
|
||||
gboolean
|
||||
_cogl_gl_util_parse_gl_version (const char *version_string,
|
||||
int *major_out,
|
||||
|
Loading…
Reference in New Issue
Block a user