shader: flesh is_shad out of vrend_shader_samplertypeconv()

Analogous to previous commit there's a single user that cares about it.
Let that one use amplertype_is_shadow() and drop the function argument.

Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
macos/master
Emil Velikov 6 years ago committed by Emil Velikov
parent beceb6106a
commit 4e764b66fa
  1. 12
      src/vrend_blitter.c
  2. 21
      src/vrend_shader.c
  3. 2
      src/vrend_shader.h

@ -171,7 +171,6 @@ static GLuint blit_build_frag_tex_col(struct vrend_blitter_ctx *blit_ctx,
{ {
GLuint fs_id; GLuint fs_id;
char shader_buf[4096]; char shader_buf[4096];
int is_shad;
const char *twm; const char *twm;
const char *ext_str = ""; const char *ext_str = "";
char dest_swizzle_snippet[DEST_SWIZZLE_SNIPPET_SIZE] = "texel"; char dest_swizzle_snippet[DEST_SWIZZLE_SNIPPET_SIZE] = "texel";
@ -218,7 +217,7 @@ static GLuint blit_build_frag_tex_col(struct vrend_blitter_ctx *blit_ctx,
FS_TEXFETCH_COL_GL, FS_TEXFETCH_COL_GL,
ext_str, vec4_type_for_tgsi_ret(tgsi_ret), ext_str, vec4_type_for_tgsi_ret(tgsi_ret),
vrend_shader_samplerreturnconv(tgsi_ret), vrend_shader_samplerreturnconv(tgsi_ret),
vrend_shader_samplertypeconv(blit_ctx->use_gles, tgsi_tex_target, &is_shad), twm, vrend_shader_samplertypeconv(blit_ctx->use_gles, tgsi_tex_target), twm,
dest_swizzle_snippet); dest_swizzle_snippet);
fs_id = glCreateShader(GL_FRAGMENT_SHADER); fs_id = glCreateShader(GL_FRAGMENT_SHADER);
@ -239,7 +238,6 @@ static GLuint blit_build_frag_tex_col_msaa(struct vrend_blitter_ctx *blit_ctx,
{ {
GLuint fs_id; GLuint fs_id;
char shader_buf[4096]; char shader_buf[4096];
int is_shad;
const char *twm; const char *twm;
const char *ivec; const char *ivec;
char dest_swizzle_snippet[DEST_SWIZZLE_SNIPPET_SIZE] = "texel"; char dest_swizzle_snippet[DEST_SWIZZLE_SNIPPET_SIZE] = "texel";
@ -270,7 +268,7 @@ static GLuint blit_build_frag_tex_col_msaa(struct vrend_blitter_ctx *blit_ctx,
: FS_TEXFETCH_COL_MSAA_GL, : FS_TEXFETCH_COL_MSAA_GL,
ext_str, vec4_type_for_tgsi_ret(tgsi_ret), ext_str, vec4_type_for_tgsi_ret(tgsi_ret),
vrend_shader_samplerreturnconv(tgsi_ret), vrend_shader_samplerreturnconv(tgsi_ret),
vrend_shader_samplertypeconv(blit_ctx->use_gles, tgsi_tex_target, &is_shad), vrend_shader_samplertypeconv(blit_ctx->use_gles, tgsi_tex_target),
nr_samples, ivec, twm, dest_swizzle_snippet); nr_samples, ivec, twm, dest_swizzle_snippet);
VREND_DEBUG(dbg_blit, NULL, "-- Blit FS shader MSAA -----------------\n" VREND_DEBUG(dbg_blit, NULL, "-- Blit FS shader MSAA -----------------\n"
@ -290,7 +288,6 @@ static GLuint blit_build_frag_tex_writedepth(struct vrend_blitter_ctx *blit_ctx,
{ {
GLuint fs_id; GLuint fs_id;
char shader_buf[4096]; char shader_buf[4096];
int is_shad;
const char *twm; const char *twm;
switch (tgsi_tex_target) { switch (tgsi_tex_target) {
@ -330,7 +327,7 @@ static GLuint blit_build_frag_tex_writedepth(struct vrend_blitter_ctx *blit_ctx,
snprintf(shader_buf, 4096, blit_ctx->use_gles ? FS_TEXFETCH_DS_GLES snprintf(shader_buf, 4096, blit_ctx->use_gles ? FS_TEXFETCH_DS_GLES
: FS_TEXFETCH_DS_GL, : FS_TEXFETCH_DS_GL,
vrend_shader_samplertypeconv(blit_ctx->use_gles, tgsi_tex_target, &is_shad), twm); vrend_shader_samplertypeconv(blit_ctx->use_gles, tgsi_tex_target), twm);
fs_id = glCreateShader(GL_FRAGMENT_SHADER); fs_id = glCreateShader(GL_FRAGMENT_SHADER);
@ -346,7 +343,6 @@ static GLuint blit_build_frag_blit_msaa_depth(struct vrend_blitter_ctx *blit_ctx
{ {
GLuint fs_id; GLuint fs_id;
char shader_buf[4096]; char shader_buf[4096];
int is_shad;
const char *twm; const char *twm;
const char *ivec; const char *ivec;
@ -368,7 +364,7 @@ static GLuint blit_build_frag_blit_msaa_depth(struct vrend_blitter_ctx *blit_ctx
snprintf(shader_buf, 4096, blit_ctx->use_gles ? snprintf(shader_buf, 4096, blit_ctx->use_gles ?
(is_array ? FS_TEXFETCH_DS_MSAA_ARRAY_GLES : FS_TEXFETCH_DS_MSAA_GLES) (is_array ? FS_TEXFETCH_DS_MSAA_ARRAY_GLES : FS_TEXFETCH_DS_MSAA_GLES)
: FS_TEXFETCH_DS_MSAA_GL, : FS_TEXFETCH_DS_MSAA_GL,
vrend_shader_samplertypeconv(blit_ctx->use_gles, tgsi_tex_target, &is_shad), ivec, twm); vrend_shader_samplertypeconv(blit_ctx->use_gles, tgsi_tex_target), ivec, twm);
fs_id = glCreateShader(GL_FRAGMENT_SHADER); fs_id = glCreateShader(GL_FRAGMENT_SHADER);

@ -5348,7 +5348,7 @@ char vrend_shader_samplerreturnconv(enum tgsi_return_type type)
} }
} }
const char *vrend_shader_samplertypeconv(bool use_gles, int sampler_type, int *is_shad) const char *vrend_shader_samplertypeconv(bool use_gles, int sampler_type)
{ {
switch (sampler_type) { switch (sampler_type) {
case TGSI_TEXTURE_BUFFER: return "Buffer"; case TGSI_TEXTURE_BUFFER: return "Buffer";
@ -5362,13 +5362,11 @@ const char *vrend_shader_samplertypeconv(bool use_gles, int sampler_type, int *i
case TGSI_TEXTURE_RECT: return use_gles ? "2D" : "2DRect"; case TGSI_TEXTURE_RECT: return use_gles ? "2D" : "2DRect";
case TGSI_TEXTURE_SHADOW1D: case TGSI_TEXTURE_SHADOW1D:
if (!use_gles) { if (!use_gles) {
*is_shad = 1;
return "1DShadow"; return "1DShadow";
} }
/* fallthrough */ /* fallthrough */
case TGSI_TEXTURE_SHADOW2D: *is_shad = 1; return "2DShadow"; case TGSI_TEXTURE_SHADOW2D: return "2DShadow";
case TGSI_TEXTURE_SHADOWRECT: case TGSI_TEXTURE_SHADOWRECT:
*is_shad = 1;
return (!use_gles) ? "2DRectShadow" : "2DShadow"; return (!use_gles) ? "2DRectShadow" : "2DShadow";
case TGSI_TEXTURE_1D_ARRAY: case TGSI_TEXTURE_1D_ARRAY:
if (!use_gles) if (!use_gles)
@ -5377,14 +5375,13 @@ const char *vrend_shader_samplertypeconv(bool use_gles, int sampler_type, int *i
case TGSI_TEXTURE_2D_ARRAY: return "2DArray"; case TGSI_TEXTURE_2D_ARRAY: return "2DArray";
case TGSI_TEXTURE_SHADOW1D_ARRAY: case TGSI_TEXTURE_SHADOW1D_ARRAY:
if (!use_gles) { if (!use_gles) {
*is_shad = 1;
return "1DArrayShadow"; return "1DArrayShadow";
} }
/* fallthrough */ /* fallthrough */
case TGSI_TEXTURE_SHADOW2D_ARRAY: *is_shad = 1; return "2DArrayShadow"; case TGSI_TEXTURE_SHADOW2D_ARRAY: return "2DArrayShadow";
case TGSI_TEXTURE_SHADOWCUBE: *is_shad = 1; return "CubeShadow"; case TGSI_TEXTURE_SHADOWCUBE: return "CubeShadow";
case TGSI_TEXTURE_CUBE_ARRAY: return "CubeArray"; case TGSI_TEXTURE_CUBE_ARRAY: return "CubeArray";
case TGSI_TEXTURE_SHADOWCUBE_ARRAY: *is_shad = 1; return "CubeArrayShadow"; case TGSI_TEXTURE_SHADOWCUBE_ARRAY: return "CubeArrayShadow";
case TGSI_TEXTURE_2D_MSAA: return "2DMS"; case TGSI_TEXTURE_2D_MSAA: return "2DMS";
case TGSI_TEXTURE_2D_ARRAY_MSAA: return "2DMSArray"; case TGSI_TEXTURE_2D_ARRAY_MSAA: return "2DMSArray";
default: return NULL; default: return NULL;
@ -5430,7 +5427,7 @@ static void emit_sampler_decl(struct dump_ctx *ctx,
const struct vrend_shader_sampler *sampler) const struct vrend_shader_sampler *sampler)
{ {
char ptc; char ptc;
int is_shad = 0; bool is_shad;
const char *sname, *precision, *stc; const char *sname, *precision, *stc;
sname = tgsi_proc_to_prefix(ctx->prog_type); sname = tgsi_proc_to_prefix(ctx->prog_type);
@ -5438,7 +5435,8 @@ static void emit_sampler_decl(struct dump_ctx *ctx,
precision = (ctx->cfg->use_gles) ? "highp " : " "; precision = (ctx->cfg->use_gles) ? "highp " : " ";
ptc = vrend_shader_samplerreturnconv(sampler->tgsi_sampler_return); ptc = vrend_shader_samplerreturnconv(sampler->tgsi_sampler_return);
stc = vrend_shader_samplertypeconv(ctx->cfg->use_gles, sampler->tgsi_sampler_type, &is_shad); stc = vrend_shader_samplertypeconv(ctx->cfg->use_gles, sampler->tgsi_sampler_type);
is_shad = samplertype_is_shadow(sampler->tgsi_sampler_type);
/* GLES does not support 1D textures -- we use a 2D texture and set the parameter set to 0.5 */ /* GLES does not support 1D textures -- we use a 2D texture and set the parameter set to 0.5 */
if (ctx->cfg->use_gles && sampler->tgsi_sampler_type == TGSI_TEXTURE_1D) if (ctx->cfg->use_gles && sampler->tgsi_sampler_type == TGSI_TEXTURE_1D)
@ -5590,7 +5588,6 @@ static void emit_image_decl(struct dump_ctx *ctx,
const struct vrend_shader_image *image) const struct vrend_shader_image *image)
{ {
char ptc; char ptc;
int is_shad = 0;
const char *sname, *stc, *formatstr; const char *sname, *stc, *formatstr;
enum tgsi_return_type itype; enum tgsi_return_type itype;
const char *volatile_str = image->vflag ? "volatile " : ""; const char *volatile_str = image->vflag ? "volatile " : "";
@ -5599,7 +5596,7 @@ static void emit_image_decl(struct dump_ctx *ctx,
formatstr = get_internalformat_string(image->decl.Format, &itype); formatstr = get_internalformat_string(image->decl.Format, &itype);
ptc = vrend_shader_samplerreturnconv(itype); ptc = vrend_shader_samplerreturnconv(itype);
sname = tgsi_proc_to_prefix(ctx->prog_type); sname = tgsi_proc_to_prefix(ctx->prog_type);
stc = vrend_shader_samplertypeconv(ctx->cfg->use_gles, image->decl.Resource, &is_shad); stc = vrend_shader_samplertypeconv(ctx->cfg->use_gles, image->decl.Resource);
if (!image->decl.Writable) if (!image->decl.Writable)
access = "readonly "; access = "readonly ";

@ -160,7 +160,7 @@ bool vrend_convert_shader(struct vrend_context *rctx,
struct vrend_shader_info *sinfo, struct vrend_shader_info *sinfo,
struct vrend_strarray *shader); struct vrend_strarray *shader);
const char *vrend_shader_samplertypeconv(bool use_gles, int sampler_type, int *is_shad); const char *vrend_shader_samplertypeconv(bool use_gles, int sampler_type);
char vrend_shader_samplerreturnconv(enum tgsi_return_type type); char vrend_shader_samplerreturnconv(enum tgsi_return_type type);

Loading…
Cancel
Save