Skip to content

Commit

Permalink
Merge pull request #136 from zeux/master
Browse files Browse the repository at this point in the history
Fix texelFetch & sampler2DMS support
  • Loading branch information
aras-p committed Oct 31, 2016
2 parents bde3cfa + 40804e7 commit 800d8ad
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/glsl/glsl_optimizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ initialize_mesa_context(struct gl_context *ctx, glslopt_target api)
{
default:
case kGlslTargetOpenGL:
ctx->Const.GLSLVersion = 140;
ctx->Const.GLSLVersion = 150;
break;
case kGlslTargetOpenGLES20:
ctx->Extensions.OES_standard_derivatives = true;
Expand Down
11 changes: 9 additions & 2 deletions src/glsl/ir_print_glsl_visitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -830,7 +830,7 @@ void ir_print_glsl_visitor::visit(ir_texture *ir)
sampler_uv_dim += 1;
if (is_array)
sampler_uv_dim += 1;
const bool is_proj = (uv_dim > sampler_uv_dim);
const bool is_proj = ((ir->op == ir_tex || ir->op == ir_txb || ir->op == ir_txl || ir->op == ir_txd) && uv_dim > sampler_uv_dim);
const bool is_lod = (ir->op == ir_txl);

if (is_lod && state->es_shader && state->language_version < 300 && state->stage == MESA_SHADER_FRAGMENT)
Expand Down Expand Up @@ -872,7 +872,7 @@ void ir_print_glsl_visitor::visit(ir_texture *ir)
}
else
{
if (ir->op == ir_txf)
if (ir->op == ir_txf || ir->op == ir_txf_ms)
buffer.asprintf_append ("texelFetch");
else
buffer.asprintf_append ("texture");
Expand Down Expand Up @@ -923,6 +923,13 @@ void ir_print_glsl_visitor::visit(ir_texture *ir)
ir->lod_info.lod->accept(this);
}

// sample index
if (ir->op == ir_txf_ms)
{
buffer.asprintf_append (", ");
ir->lod_info.sample_index->accept(this);
}

// grad
if (ir->op == ir_txd)
{
Expand Down
7 changes: 7 additions & 0 deletions tests/fragment/texelFetchMSAA-in.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#version 150
uniform sampler2DMS tex;
in vec2 uv;
out vec4 color;
void main() {
color = texelFetch(tex, ivec2(uv), 3);
}
15 changes: 15 additions & 0 deletions tests/fragment/texelFetchMSAA-out.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#version 150
uniform sampler2DMS tex;
in vec2 uv;
out vec4 color;
void main ()
{
color = texelFetch (tex, ivec2(uv), 3);
}


// stats: 1 alu 1 tex 0 flow
// inputs: 1
// #0: uv (high float) 2x1 [-1]
// textures: 1
// #0: tex (high other) 0x0 [-1]

0 comments on commit 800d8ad

Please sign in to comment.