aboutsummaryrefslogtreecommitdiff
path: root/mesalib/src/mesa/state_tracker
diff options
context:
space:
mode:
Diffstat (limited to 'mesalib/src/mesa/state_tracker')
-rw-r--r--mesalib/src/mesa/state_tracker/st_atom_clip.c20
-rw-r--r--mesalib/src/mesa/state_tracker/st_atom_texture.c11
-rw-r--r--mesalib/src/mesa/state_tracker/st_cb_texture.c40
-rw-r--r--mesalib/src/mesa/state_tracker/st_glsl_to_tgsi.cpp11
-rw-r--r--mesalib/src/mesa/state_tracker/st_program.c18
5 files changed, 60 insertions, 40 deletions
diff --git a/mesalib/src/mesa/state_tracker/st_atom_clip.c b/mesalib/src/mesa/state_tracker/st_atom_clip.c
index 1330db843..236d3cf40 100644
--- a/mesalib/src/mesa/state_tracker/st_atom_clip.c
+++ b/mesalib/src/mesa/state_tracker/st_atom_clip.c
@@ -34,7 +34,7 @@
#include "st_context.h"
#include "pipe/p_context.h"
#include "st_atom.h"
-
+#include "st_program.h"
#include "cso_cache/cso_context.h"
@@ -45,15 +45,23 @@ static void update_clip( struct st_context *st )
struct pipe_clip_state clip;
const struct gl_context *ctx = st->ctx;
GLuint i;
+ bool use_eye = FALSE;
memset(&clip, 0, sizeof(clip));
+ /* if we have a vertex shader that writes clip vertex we need to pass
+ the pre-projection transformed coordinates into the driver. */
+ if (st->vp) {
+ if (ctx->Shader.CurrentVertexProgram)
+ use_eye = TRUE;
+ }
+
for (i = 0; i < PIPE_MAX_CLIP_PLANES; i++) {
if (ctx->Transform.ClipPlanesEnabled & (1 << i)) {
- memcpy(clip.ucp[clip.nr],
- ctx->Transform._ClipUserPlane[i],
- sizeof(clip.ucp[0]));
- clip.nr++;
+ memcpy(clip.ucp[clip.nr],
+ use_eye ? ctx->Transform.EyeUserPlane[i] : ctx->Transform._ClipUserPlane[i],
+ sizeof(clip.ucp[0]));
+ clip.nr++;
}
}
@@ -69,7 +77,7 @@ static void update_clip( struct st_context *st )
const struct st_tracked_state st_update_clip = {
"st_update_clip", /* name */
{ /* dirty */
- (_NEW_TRANSFORM), /* mesa */
+ (_NEW_TRANSFORM | _NEW_PROGRAM), /* mesa */
0, /* st */
},
update_clip /* update */
diff --git a/mesalib/src/mesa/state_tracker/st_atom_texture.c b/mesalib/src/mesa/state_tracker/st_atom_texture.c
index 3115a2511..008e9bd10 100644
--- a/mesalib/src/mesa/state_tracker/st_atom_texture.c
+++ b/mesalib/src/mesa/state_tracker/st_atom_texture.c
@@ -267,14 +267,13 @@ update_vertex_textures(struct st_context *st)
GLboolean retval;
GLuint texUnit;
- texUnit = vprog->Base.SamplerUnits[su];
+ texUnit = vprog->Base.SamplerUnits[su];
- retval = update_single_texture(st, &sampler_view, texUnit);
- if (retval == GL_FALSE)
- continue;
-
- st->state.num_vertex_textures = su + 1;
+ retval = update_single_texture(st, &sampler_view, texUnit);
+ if (retval == GL_FALSE)
+ continue;
+ st->state.num_vertex_textures = su + 1;
}
pipe_sampler_view_reference(&st->state.sampler_vertex_views[su], sampler_view);
}
diff --git a/mesalib/src/mesa/state_tracker/st_cb_texture.c b/mesalib/src/mesa/state_tracker/st_cb_texture.c
index 592d04b92..ad4f23c7e 100644
--- a/mesalib/src/mesa/state_tracker/st_cb_texture.c
+++ b/mesalib/src/mesa/state_tracker/st_cb_texture.c
@@ -736,7 +736,7 @@ st_GetTexImage(struct gl_context * ctx,
* Note: srcY=0=TOP of renderbuffer
*/
static void
-fallback_copy_texsubimage(struct gl_context *ctx, GLenum target, GLint level,
+fallback_copy_texsubimage(struct gl_context *ctx,
struct st_renderbuffer *strb,
struct st_texture_image *stImage,
GLenum baseFormat,
@@ -931,17 +931,12 @@ compatible_src_dst_formats(struct gl_context *ctx,
*/
static void
st_copy_texsubimage(struct gl_context *ctx,
- GLenum target, GLint level,
+ struct gl_texture_image *texImage,
GLint destX, GLint destY, GLint destZ,
+ struct gl_renderbuffer *rb,
GLint srcX, GLint srcY,
GLsizei width, GLsizei height)
{
- struct gl_texture_unit *texUnit =
- &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
- struct gl_texture_object *texObj =
- _mesa_select_tex_object(ctx, texUnit, target);
- struct gl_texture_image *texImage =
- _mesa_select_tex_image(ctx, texObj, target, level);
struct st_texture_image *stImage = st_texture_image(texImage);
const GLenum texBaseFormat = texImage->_BaseFormat;
struct gl_framebuffer *fb = ctx->ReadBuffer;
@@ -1096,7 +1091,7 @@ st_copy_texsubimage(struct gl_context *ctx,
fallback:
/* software fallback */
- fallback_copy_texsubimage(ctx, target, level,
+ fallback_copy_texsubimage(ctx,
strb, stImage, texBaseFormat,
destX, destY, destZ,
srcX, srcY, width, height);
@@ -1105,37 +1100,44 @@ fallback:
static void
-st_CopyTexSubImage1D(struct gl_context * ctx, GLenum target, GLint level,
- GLint xoffset, GLint x, GLint y, GLsizei width)
+st_CopyTexSubImage1D(struct gl_context *ctx,
+ struct gl_texture_image *texImage,
+ GLint xoffset,
+ struct gl_renderbuffer *rb,
+ GLint x, GLint y, GLsizei width)
{
const GLint yoffset = 0, zoffset = 0;
const GLsizei height = 1;
- st_copy_texsubimage(ctx, target, level,
+ st_copy_texsubimage(ctx, texImage,
xoffset, yoffset, zoffset, /* destX,Y,Z */
- x, y, width, height); /* src X, Y, size */
+ rb, x, y, width, height); /* src X, Y, size */
}
static void
-st_CopyTexSubImage2D(struct gl_context * ctx, GLenum target, GLint level,
+st_CopyTexSubImage2D(struct gl_context *ctx,
+ struct gl_texture_image *texImage,
GLint xoffset, GLint yoffset,
+ struct gl_renderbuffer *rb,
GLint x, GLint y, GLsizei width, GLsizei height)
{
const GLint zoffset = 0;
- st_copy_texsubimage(ctx, target, level,
+ st_copy_texsubimage(ctx, texImage,
xoffset, yoffset, zoffset, /* destX,Y,Z */
- x, y, width, height); /* src X, Y, size */
+ rb, x, y, width, height); /* src X, Y, size */
}
static void
-st_CopyTexSubImage3D(struct gl_context * ctx, GLenum target, GLint level,
+st_CopyTexSubImage3D(struct gl_context *ctx,
+ struct gl_texture_image *texImage,
GLint xoffset, GLint yoffset, GLint zoffset,
+ struct gl_renderbuffer *rb,
GLint x, GLint y, GLsizei width, GLsizei height)
{
- st_copy_texsubimage(ctx, target, level,
+ st_copy_texsubimage(ctx, texImage,
xoffset, yoffset, zoffset, /* destX,Y,Z */
- x, y, width, height); /* src X, Y, size */
+ rb, x, y, width, height); /* src X, Y, size */
}
diff --git a/mesalib/src/mesa/state_tracker/st_glsl_to_tgsi.cpp b/mesalib/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
index 73d956ea1..3b8e2fe37 100644
--- a/mesalib/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
+++ b/mesalib/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
@@ -1402,8 +1402,7 @@ glsl_to_tgsi_visitor::visit(ir_expression *ir)
}
break;
case ir_unop_neg:
- assert(result_dst.type == GLSL_TYPE_FLOAT || result_dst.type == GLSL_TYPE_INT);
- if (result_dst.type == GLSL_TYPE_INT)
+ if (result_dst.type == GLSL_TYPE_INT || result_dst.type == GLSL_TYPE_UINT)
emit(ir, TGSI_OPCODE_INEG, result_dst, op[0]);
else {
op[0].negate = ~op[0].negate;
@@ -1411,8 +1410,10 @@ glsl_to_tgsi_visitor::visit(ir_expression *ir)
}
break;
case ir_unop_abs:
- assert(result_dst.type == GLSL_TYPE_FLOAT);
- emit(ir, TGSI_OPCODE_ABS, result_dst, op[0]);
+ if (result_dst.type == GLSL_TYPE_INT || result_dst.type == GLSL_TYPE_UINT)
+ emit(ir, TGSI_OPCODE_IABS, result_dst, op[0]);
+ else
+ emit(ir, TGSI_OPCODE_ABS, result_dst, op[0]);
break;
case ir_unop_sign:
emit(ir, TGSI_OPCODE_SSG, result_dst, op[0]);
@@ -2375,7 +2376,7 @@ glsl_to_tgsi_visitor::visit(ir_constant *ir)
gl_type = native_integers ? GL_BOOL : GL_FLOAT;
for (i = 0; i < ir->type->vector_elements; i++) {
if (native_integers)
- values[i].b = ir->value.b[i];
+ values[i].u = ir->value.b[i] ? ~0 : 0;
else
values[i].f = ir->value.b[i];
}
diff --git a/mesalib/src/mesa/state_tracker/st_program.c b/mesalib/src/mesa/state_tracker/st_program.c
index aceaaf8c5..8d7469dfb 100644
--- a/mesalib/src/mesa/state_tracker/st_program.c
+++ b/mesalib/src/mesa/state_tracker/st_program.c
@@ -255,6 +255,10 @@ st_prepare_vertex_program(struct gl_context *ctx,
case VERT_RESULT_EDGE:
assert(0);
break;
+ case VERT_RESULT_CLIP_VERTEX:
+ stvp->output_semantic_name[slot] = TGSI_SEMANTIC_CLIPVERTEX;
+ stvp->output_semantic_index[slot] = 0;
+ break;
case VERT_RESULT_TEX0:
case VERT_RESULT_TEX1:
@@ -432,10 +436,13 @@ st_get_vp_variant(struct st_context *st,
static unsigned
-st_translate_interp(enum glsl_interp_qualifier glsl_qual)
+st_translate_interp(enum glsl_interp_qualifier glsl_qual, bool is_color)
{
switch (glsl_qual) {
case INTERP_QUALIFIER_NONE:
+ if (is_color)
+ return TGSI_INTERPOLATE_LINEAR;
+ return TGSI_INTERPOLATE_PERSPECTIVE;
case INTERP_QUALIFIER_SMOOTH:
return TGSI_INTERPOLATE_PERSPECTIVE;
case INTERP_QUALIFIER_FLAT:
@@ -538,12 +545,14 @@ st_translate_fragment_program(struct st_context *st,
case FRAG_ATTRIB_COL0:
input_semantic_name[slot] = TGSI_SEMANTIC_COLOR;
input_semantic_index[slot] = 0;
- interpMode[slot] = st_translate_interp(stfp->Base.InterpQualifier[attr]);
+ interpMode[slot] = st_translate_interp(stfp->Base.InterpQualifier[attr],
+ TRUE);
break;
case FRAG_ATTRIB_COL1:
input_semantic_name[slot] = TGSI_SEMANTIC_COLOR;
input_semantic_index[slot] = 1;
- interpMode[slot] = st_translate_interp(stfp->Base.InterpQualifier[attr]);
+ interpMode[slot] = st_translate_interp(stfp->Base.InterpQualifier[attr],
+ TRUE);
break;
case FRAG_ATTRIB_FOGC:
input_semantic_name[slot] = TGSI_SEMANTIC_FOG;
@@ -600,7 +609,8 @@ st_translate_fragment_program(struct st_context *st,
if (attr == FRAG_ATTRIB_PNTC)
interpMode[slot] = TGSI_INTERPOLATE_LINEAR;
else
- interpMode[slot] = st_translate_interp(stfp->Base.InterpQualifier[attr]);
+ interpMode[slot] = st_translate_interp(stfp->Base.InterpQualifier[attr],
+ FALSE);
break;
}
}