aboutsummaryrefslogtreecommitdiff
path: root/mesalib/src/mesa/state_tracker
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2012-06-21 08:11:16 +0200
committermarha <marha@users.sourceforge.net>2012-06-21 08:11:16 +0200
commit478ec8cab167e7d8be4973fc3f8d425b1baa4496 (patch)
tree0b05eb5a0e3a989a66baff04a954db416444f7c5 /mesalib/src/mesa/state_tracker
parent62d040da7ea0a76d48014b5247d98b428ca50a15 (diff)
parentda6ea6d64418710cbf7e0639dfefd2d856d53f1a (diff)
downloadvcxsrv-478ec8cab167e7d8be4973fc3f8d425b1baa4496.tar.gz
vcxsrv-478ec8cab167e7d8be4973fc3f8d425b1baa4496.tar.bz2
vcxsrv-478ec8cab167e7d8be4973fc3f8d425b1baa4496.zip
Merge remote-tracking branch 'origin/released'
Diffstat (limited to 'mesalib/src/mesa/state_tracker')
-rw-r--r--mesalib/src/mesa/state_tracker/st_cb_drawpixels.c41
-rw-r--r--mesalib/src/mesa/state_tracker/st_draw.c1
-rw-r--r--mesalib/src/mesa/state_tracker/st_extensions.c2
-rw-r--r--mesalib/src/mesa/state_tracker/st_glsl_to_tgsi.cpp49
4 files changed, 44 insertions, 49 deletions
diff --git a/mesalib/src/mesa/state_tracker/st_cb_drawpixels.c b/mesalib/src/mesa/state_tracker/st_cb_drawpixels.c
index d3f8d1368..2bcbada4f 100644
--- a/mesalib/src/mesa/state_tracker/st_cb_drawpixels.c
+++ b/mesalib/src/mesa/state_tracker/st_cb_drawpixels.c
@@ -1056,6 +1056,28 @@ get_depth_stencil_fp_variant(struct st_context *st, GLboolean write_depth,
/**
+ * Clamp glDrawPixels width and height to the maximum texture size.
+ */
+static void
+clamp_size(struct pipe_context *pipe, GLsizei *width, GLsizei *height,
+ struct gl_pixelstore_attrib *unpack)
+{
+ const unsigned maxSize =
+ 1 << (pipe->screen->get_param(pipe->screen,
+ PIPE_CAP_MAX_TEXTURE_2D_LEVELS) - 1);
+
+ if (*width > maxSize) {
+ if (unpack->RowLength == 0)
+ unpack->RowLength = *width;
+ *width = maxSize;
+ }
+ if (*height > maxSize) {
+ *height = maxSize;
+ }
+}
+
+
+/**
* Called via ctx->Driver.DrawPixels()
*/
static void
@@ -1072,6 +1094,20 @@ st_DrawPixels(struct gl_context *ctx, GLint x, GLint y,
struct pipe_sampler_view *sv[2];
int num_sampler_view = 1;
struct st_fp_variant *fpv;
+ struct gl_pixelstore_attrib clippedUnpack;
+
+ /* Mesa state should be up to date by now */
+ assert(ctx->NewState == 0x0);
+
+ st_validate_state(st);
+
+ /* Limit the size of the glDrawPixels to the max texture size.
+ * Strictly speaking, that's not correct but since we don't handle
+ * larger images yet, this is better than crashing.
+ */
+ clippedUnpack = *unpack;
+ unpack = &clippedUnpack;
+ clamp_size(st->pipe, &width, &height, &clippedUnpack);
if (format == GL_DEPTH_STENCIL)
write_stencil = write_depth = GL_TRUE;
@@ -1088,11 +1124,6 @@ st_DrawPixels(struct gl_context *ctx, GLint x, GLint y,
return;
}
- /* Mesa state should be up to date by now */
- assert(ctx->NewState == 0x0);
-
- st_validate_state(st);
-
/*
* Get vertex/fragment shaders
*/
diff --git a/mesalib/src/mesa/state_tracker/st_draw.c b/mesalib/src/mesa/state_tracker/st_draw.c
index db8caa566..4dc09e7fb 100644
--- a/mesalib/src/mesa/state_tracker/st_draw.c
+++ b/mesalib/src/mesa/state_tracker/st_draw.c
@@ -246,6 +246,7 @@ st_draw_vbo(struct gl_context *ctx,
info.mode = translate_prim( ctx, prims[i].mode );
info.start = prims[i].start;
info.count = prims[i].count;
+ info.start_instance = prims[i].base_instance;
info.instance_count = prims[i].num_instances;
info.index_bias = prims[i].basevertex;
if (!ib) {
diff --git a/mesalib/src/mesa/state_tracker/st_extensions.c b/mesalib/src/mesa/state_tracker/st_extensions.c
index a9071f58c..dacad9bfb 100644
--- a/mesalib/src/mesa/state_tracker/st_extensions.c
+++ b/mesalib/src/mesa/state_tracker/st_extensions.c
@@ -222,6 +222,7 @@ void st_init_limits(struct st_context *st)
options->MaxUnrollIterations = MIN2(screen->get_shader_param(screen, sh, PIPE_SHADER_CAP_MAX_INSTRUCTIONS), 65536);
else
options->MaxUnrollIterations = 255; /* SM3 limit */
+ options->LowerClipDistance = true;
}
/* PIPE_SHADER_CAP_MAX_INPUTS for the FS specifies the maximum number
@@ -337,6 +338,7 @@ void st_init_extensions(struct st_context *st)
GLboolean *extensions = (GLboolean *) &ctx->Extensions;
static const struct st_extension_cap_mapping cap_mapping[] = {
+ { o(ARB_base_instance), PIPE_CAP_START_INSTANCE },
{ o(ARB_depth_clamp), PIPE_CAP_DEPTH_CLIP_DISABLE },
{ o(ARB_depth_texture), PIPE_CAP_TEXTURE_SHADOW_MAP },
{ o(ARB_draw_buffers_blend), PIPE_CAP_INDEP_BLEND_FUNC },
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 5802b52b7..b6abe84ac 100644
--- a/mesalib/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
+++ b/mesalib/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
@@ -304,7 +304,6 @@ public:
int samplers_used;
bool indirect_addr_temps;
bool indirect_addr_consts;
- int num_clip_distances;
int glsl_version;
bool native_integers;
@@ -2825,7 +2824,6 @@ glsl_to_tgsi_visitor::glsl_to_tgsi_visitor()
samplers_used = 0;
indirect_addr_temps = false;
indirect_addr_consts = false;
- num_clip_distances = 0;
glsl_version = 0;
native_integers = false;
mem_ctx = ralloc_context(NULL);
@@ -4593,17 +4591,9 @@ st_translate_program(
}
for (i = 0; i < numOutputs; i++) {
- if (outputSemanticName[i] == TGSI_SEMANTIC_CLIPDIST) {
- int mask = ((1 << (program->num_clip_distances - 4*outputSemanticIndex[i])) - 1) & TGSI_WRITEMASK_XYZW;
- t->outputs[i] = ureg_DECL_output_masked(ureg,
- outputSemanticName[i],
- outputSemanticIndex[i],
- mask);
- } else {
- t->outputs[i] = ureg_DECL_output(ureg,
- outputSemanticName[i],
- outputSemanticIndex[i]);
- }
+ t->outputs[i] = ureg_DECL_output(ureg,
+ outputSemanticName[i],
+ outputSemanticIndex[i]);
}
if (passthrough_edgeflags)
emit_edgeflags(t);
@@ -4759,8 +4749,7 @@ out:
static struct gl_program *
get_mesa_program(struct gl_context *ctx,
struct gl_shader_program *shader_program,
- struct gl_shader *shader,
- int num_clip_distances)
+ struct gl_shader *shader)
{
glsl_to_tgsi_visitor* v = new glsl_to_tgsi_visitor();
struct gl_program *prog;
@@ -4800,7 +4789,6 @@ get_mesa_program(struct gl_context *ctx,
v->options = options;
v->glsl_version = ctx->Const.GLSLVersion;
v->native_integers = ctx->Const.NativeIntegers;
- v->num_clip_distances = num_clip_distances;
_mesa_generate_parameters_list_for_uniforms(shader_program, shader,
prog->Parameters);
@@ -4925,25 +4913,6 @@ get_mesa_program(struct gl_context *ctx,
return prog;
}
-/**
- * Searches through the IR for a declaration of gl_ClipDistance and returns the
- * declared size of the gl_ClipDistance array. Returns 0 if gl_ClipDistance is
- * not declared in the IR.
- */
-int get_clip_distance_size(exec_list *ir)
-{
- foreach_iter (exec_list_iterator, iter, *ir) {
- ir_instruction *inst = (ir_instruction *)iter.get();
- ir_variable *var = inst->as_variable();
- if (var == NULL) continue;
- if (!strcmp(var->name, "gl_ClipDistance")) {
- return var->type->length;
- }
- }
-
- return 0;
-}
-
extern "C" {
struct gl_shader *
@@ -4982,7 +4951,6 @@ st_new_shader_program(struct gl_context *ctx, GLuint name)
GLboolean
st_link_shader(struct gl_context *ctx, struct gl_shader_program *prog)
{
- int num_clip_distances[MESA_SHADER_TYPES];
assert(prog->LinkStatus);
for (unsigned i = 0; i < MESA_SHADER_TYPES; i++) {
@@ -4994,11 +4962,6 @@ st_link_shader(struct gl_context *ctx, struct gl_shader_program *prog)
const struct gl_shader_compiler_options *options =
&ctx->ShaderCompilerOptions[_mesa_shader_type_to_index(prog->_LinkedShaders[i]->Type)];
- /* We have to determine the length of the gl_ClipDistance array before
- * the array is lowered to two vec4s by lower_clip_distance().
- */
- num_clip_distances[i] = get_clip_distance_size(ir);
-
do {
unsigned what_to_lower = MOD_TO_FRACT | DIV_TO_MUL_RCP |
EXP_TO_EXP2 | LOG_TO_LOG2;
@@ -5020,7 +4983,6 @@ st_link_shader(struct gl_context *ctx, struct gl_shader_program *prog)
|| progress;
progress = lower_quadop_vector(ir, false) || progress;
- progress = lower_clip_distance(ir) || progress;
if (options->MaxIfDepth == 0)
progress = lower_discard(ir) || progress;
@@ -5055,8 +5017,7 @@ st_link_shader(struct gl_context *ctx, struct gl_shader_program *prog)
if (prog->_LinkedShaders[i] == NULL)
continue;
- linked_prog = get_mesa_program(ctx, prog, prog->_LinkedShaders[i],
- num_clip_distances[i]);
+ linked_prog = get_mesa_program(ctx, prog, prog->_LinkedShaders[i]);
if (linked_prog) {
static const GLenum targets[] = {