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_texture.c35
-rw-r--r--mesalib/src/mesa/state_tracker/st_draw.c3
-rw-r--r--mesalib/src/mesa/state_tracker/st_draw_feedback.c2
-rw-r--r--mesalib/src/mesa/state_tracker/st_extensions.c31
-rw-r--r--mesalib/src/mesa/state_tracker/st_glsl_to_tgsi.cpp34
-rw-r--r--mesalib/src/mesa/state_tracker/st_manager.c20
-rw-r--r--mesalib/src/mesa/state_tracker/st_mesa_to_tgsi.c7
-rw-r--r--mesalib/src/mesa/state_tracker/st_mesa_to_tgsi.h5
8 files changed, 84 insertions, 53 deletions
diff --git a/mesalib/src/mesa/state_tracker/st_atom_texture.c b/mesalib/src/mesa/state_tracker/st_atom_texture.c
index 008e9bd10..88e6128c8 100644
--- a/mesalib/src/mesa/state_tracker/st_atom_texture.c
+++ b/mesalib/src/mesa/state_tracker/st_atom_texture.c
@@ -1,8 +1,8 @@
/**************************************************************************
- *
+ *
* Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
* All Rights Reserved.
- *
+ *
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
@@ -10,11 +10,11 @@
* distribute, sub license, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
- *
+ *
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial portions
* of the Software.
- *
+ *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
@@ -22,7 +22,7 @@
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
+ *
**************************************************************************/
/*
@@ -30,7 +30,7 @@
* Keith Whitwell <keith@tungstengraphics.com>
* Brian Paul
*/
-
+
#include "main/macros.h"
#include "main/mtypes.h"
@@ -182,8 +182,10 @@ st_get_texture_sampler_view_from_stobj(struct st_texture_object *stObj,
return stObj->sampler_view;
}
+
static GLboolean
-update_single_texture(struct st_context *st, struct pipe_sampler_view **sampler_view,
+update_single_texture(struct st_context *st,
+ struct pipe_sampler_view **sampler_view,
GLuint texUnit)
{
struct pipe_context *pipe = st->pipe;
@@ -233,7 +235,6 @@ update_single_texture(struct st_context *st, struct pipe_sampler_view **sampler_
st_view_format = firstImageFormat;
}
-
/* if sampler view has changed dereference it */
if (stObj->sampler_view) {
if (check_sampler_swizzle(stObj->sampler_view,
@@ -251,7 +252,8 @@ update_single_texture(struct st_context *st, struct pipe_sampler_view **sampler_
return GL_TRUE;
}
-static void
+
+static void
update_vertex_textures(struct st_context *st)
{
const struct gl_context *ctx = st->ctx;
@@ -275,7 +277,8 @@ update_vertex_textures(struct st_context *st)
st->state.num_vertex_textures = su + 1;
}
- pipe_sampler_view_reference(&st->state.sampler_vertex_views[su], sampler_view);
+ pipe_sampler_view_reference(&st->state.sampler_vertex_views[su],
+ sampler_view);
}
if (ctx->Const.MaxVertexTextureImageUnits > 0) {
@@ -287,7 +290,8 @@ update_vertex_textures(struct st_context *st)
}
}
-static void
+
+static void
update_fragment_textures(struct st_context *st)
{
const struct gl_context *ctx = st->ctx;
@@ -319,6 +323,7 @@ update_fragment_textures(struct st_context *st)
st->state.sampler_views);
}
+
const struct st_tracked_state st_update_texture = {
"st_update_texture", /* name */
{ /* dirty */
@@ -328,8 +333,9 @@ const struct st_tracked_state st_update_texture = {
update_fragment_textures /* update */
};
+
const struct st_tracked_state st_update_vertex_texture = {
- "st_update_vertex_texture", /* name */
+ "st_update_vertex_texture", /* name */
{ /* dirty */
_NEW_TEXTURE, /* mesa */
ST_NEW_VERTEX_PROGRAM, /* st */
@@ -337,7 +343,9 @@ const struct st_tracked_state st_update_vertex_texture = {
update_vertex_textures /* update */
};
-static void
+
+
+static void
finalize_textures(struct st_context *st)
{
struct gl_context *ctx = st->ctx;
@@ -371,7 +379,6 @@ finalize_textures(struct st_context *st)
}
-
const struct st_tracked_state st_finalize_textures = {
"st_finalize_textures", /* name */
{ /* dirty */
diff --git a/mesalib/src/mesa/state_tracker/st_draw.c b/mesalib/src/mesa/state_tracker/st_draw.c
index 6d6fc858d..c0554cfc7 100644
--- a/mesalib/src/mesa/state_tracker/st_draw.c
+++ b/mesalib/src/mesa/state_tracker/st_draw.c
@@ -990,7 +990,8 @@ st_draw_vbo(struct gl_context *ctx,
/* Gallium probably doesn't want this in some cases. */
if (!index_bounds_valid)
if (!all_varyings_in_vbos(arrays))
- vbo_get_minmax_index(ctx, prims, ib, &min_index, &max_index);
+ vbo_get_minmax_indices(ctx, prims, ib, &min_index, &max_index,
+ nr_prims);
for (i = 0; i < nr_prims; i++) {
num_instances = MAX2(num_instances, prims[i].num_instances);
diff --git a/mesalib/src/mesa/state_tracker/st_draw_feedback.c b/mesalib/src/mesa/state_tracker/st_draw_feedback.c
index fbf0349b4..a559b733a 100644
--- a/mesalib/src/mesa/state_tracker/st_draw_feedback.c
+++ b/mesalib/src/mesa/state_tracker/st_draw_feedback.c
@@ -119,7 +119,7 @@ st_feedback_draw_vbo(struct gl_context *ctx,
st_validate_state(st);
if (!index_bounds_valid)
- vbo_get_minmax_index(ctx, prims, ib, &min_index, &max_index);
+ vbo_get_minmax_indices(ctx, prims, ib, &min_index, &max_index, nr_prims);
/* must get these after state validation! */
vp = st->vp;
diff --git a/mesalib/src/mesa/state_tracker/st_extensions.c b/mesalib/src/mesa/state_tracker/st_extensions.c
index a9d405436..49c874710 100644
--- a/mesalib/src/mesa/state_tracker/st_extensions.c
+++ b/mesalib/src/mesa/state_tracker/st_extensions.c
@@ -263,12 +263,6 @@ void st_init_extensions(struct st_context *st)
ctx->Const.GLSLVersion = 120;
_mesa_override_glsl_version(st->ctx);
- /* Extensions that only depend on the GLSL version:
- */
- if (ctx->Const.GLSLVersion >= 130) {
- ctx->Extensions.ARB_conservative_depth = GL_TRUE;
- }
-
/*
* Extensions that are supported by all Gallium drivers:
*/
@@ -587,6 +581,23 @@ void st_init_extensions(struct st_context *st)
#endif
}
+ if (screen->get_shader_param(screen, PIPE_SHADER_VERTEX,
+ PIPE_SHADER_CAP_INTEGERS) &&
+ screen->get_shader_param(screen, PIPE_SHADER_FRAGMENT,
+ PIPE_SHADER_CAP_INTEGERS)) {
+ ctx->Const.NativeIntegers = GL_TRUE;
+ }
+
+ if (ctx->Const.NativeIntegers)
+ ctx->Const.GLSLVersion = 130;
+
+ /* Extensions that only depend on the GLSL version:
+ */
+ if (ctx->Const.GLSLVersion >= 130) {
+ ctx->Extensions.ARB_conservative_depth = GL_TRUE;
+ ctx->Const.MaxClipPlanes = 8;
+ }
+
ctx->Extensions.NV_primitive_restart = GL_TRUE;
if (!screen->get_param(screen, PIPE_CAP_PRIMITIVE_RESTART)) {
st->sw_primitive_restart = GL_TRUE;
@@ -703,4 +714,12 @@ void st_init_extensions(struct st_context *st)
ctx->Extensions.ARB_transform_feedback2 = GL_TRUE;
}
}
+
+ if (ctx->Const.NativeIntegers &&
+ screen->is_format_supported(screen, PIPE_FORMAT_R32G32B32A32_UINT, PIPE_TEXTURE_2D, 0,
+ PIPE_BIND_SAMPLER_VIEW | PIPE_BIND_RENDER_TARGET) &&
+ screen->is_format_supported(screen, PIPE_FORMAT_R32G32B32A32_SINT, PIPE_TEXTURE_2D, 0,
+ PIPE_BIND_SAMPLER_VIEW | PIPE_BIND_RENDER_TARGET))
+ ctx->Extensions.EXT_texture_integer = GL_TRUE;
+
}
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 3b8e2fe37..26047cfe0 100644
--- a/mesalib/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
+++ b/mesalib/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
@@ -664,6 +664,9 @@ glsl_to_tgsi_visitor::get_opcode(ir_instruction *ir, unsigned op,
case3(SLT, ISLT, USLT);
case2iu(ISHR, USHR);
+
+ case2fi(SSG, ISSG);
+ case3(ABS, IABS, IABS);
default: break;
}
@@ -1410,10 +1413,7 @@ glsl_to_tgsi_visitor::visit(ir_expression *ir)
}
break;
case ir_unop_abs:
- 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]);
+ emit(ir, TGSI_OPCODE_ABS, result_dst, op[0]);
break;
case ir_unop_sign:
emit(ir, TGSI_OPCODE_SSG, result_dst, op[0]);
@@ -2646,8 +2646,9 @@ glsl_to_tgsi_visitor::visit(ir_texture *ir)
ir->shadow_comparitor->accept(this);
/* XXX This will need to be updated for cubemap array samplers. */
- if (sampler_type->sampler_dimensionality == GLSL_SAMPLER_DIM_2D &&
- sampler_type->sampler_array) {
+ if ((sampler_type->sampler_dimensionality == GLSL_SAMPLER_DIM_2D &&
+ sampler_type->sampler_array) ||
+ sampler_type->sampler_dimensionality == GLSL_SAMPLER_DIM_CUBE) {
coord_dst.writemask = WRITEMASK_W;
} else {
coord_dst.writemask = WRITEMASK_Z;
@@ -2842,8 +2843,6 @@ count_resources(glsl_to_tgsi_visitor *v, gl_program *prog)
if (is_tex_instruction(inst->op)) {
v->samplers_used |= 1 << inst->sampler;
- prog->SamplerTargets[inst->sampler] =
- (gl_texture_index)inst->tex_target;
if (inst->tex_shadow) {
prog->ShadowSamplers |= 1 << inst->sampler;
}
@@ -2851,7 +2850,9 @@ count_resources(glsl_to_tgsi_visitor *v, gl_program *prog)
}
prog->SamplersUsed = v->samplers_used;
- _mesa_update_shader_textures_used(prog);
+
+ if (v->shader_program != NULL)
+ _mesa_update_shader_textures_used(v->shader_program, prog);
}
static void
@@ -4181,7 +4182,7 @@ compile_tgsi_instruction(struct st_translate *t,
ureg_tex_insn(ureg,
inst->op,
dst, num_dst,
- translate_texture_target(inst->tex_target, inst->tex_shadow),
+ st_translate_texture_target(inst->tex_target, inst->tex_shadow),
texoffsets, inst->tex_offset_num_offset,
src, num_src);
return;
@@ -5010,13 +5011,18 @@ st_link_shader(struct gl_context *ctx, struct gl_shader_program *prog)
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;
+ if (options->EmitNoPow)
+ what_to_lower |= POW_TO_EXP2;
+ if (!ctx->Const.NativeIntegers)
+ what_to_lower |= INT_DIV_TO_MUL_RCP;
+
progress = false;
/* Lowering */
do_mat_op_to_vec(ir);
- lower_instructions(ir, (MOD_TO_FRACT | DIV_TO_MUL_RCP | EXP_TO_EXP2
- | LOG_TO_LOG2 | INT_DIV_TO_MUL_RCP
- | ((options->EmitNoPow) ? POW_TO_EXP2 : 0)));
+ lower_instructions(ir, what_to_lower);
progress = do_lower_jumps(ir, true, true, options->EmitNoMainReturn, options->EmitNoCont, options->EmitNoLoops) || progress;
@@ -5087,7 +5093,7 @@ st_link_shader(struct gl_context *ctx, struct gl_shader_program *prog)
}
void
-st_translate_stream_output_info(struct glsl_to_tgsi_visitor *glsl_to_tgsi,
+st_translate_stream_output_info(glsl_to_tgsi_visitor *glsl_to_tgsi,
const GLuint outputMapping[],
struct pipe_stream_output_info *so)
{
diff --git a/mesalib/src/mesa/state_tracker/st_manager.c b/mesalib/src/mesa/state_tracker/st_manager.c
index b83cb2339..63920a39e 100644
--- a/mesalib/src/mesa/state_tracker/st_manager.c
+++ b/mesalib/src/mesa/state_tracker/st_manager.c
@@ -26,16 +26,6 @@
* Chia-I Wu <olv@lunarg.com>
*/
-#include "state_tracker/st_gl_api.h"
-
-#include "pipe/p_context.h"
-#include "pipe/p_screen.h"
-#include "util/u_format.h"
-#include "util/u_pointer.h"
-#include "util/u_inlines.h"
-#include "util/u_atomic.h"
-#include "util/u_surface.h"
-
#include "main/mtypes.h"
#include "main/context.h"
#include "main/mfeatures.h"
@@ -54,6 +44,16 @@
#include "st_cb_flush.h"
#include "st_manager.h"
+#include "state_tracker/st_gl_api.h"
+
+#include "pipe/p_context.h"
+#include "pipe/p_screen.h"
+#include "util/u_format.h"
+#include "util/u_pointer.h"
+#include "util/u_inlines.h"
+#include "util/u_atomic.h"
+#include "util/u_surface.h"
+
/**
* Cast wrapper to convert a struct gl_framebuffer to an st_framebuffer.
* Return NULL if the struct gl_framebuffer is a user-created framebuffer.
diff --git a/mesalib/src/mesa/state_tracker/st_mesa_to_tgsi.c b/mesalib/src/mesa/state_tracker/st_mesa_to_tgsi.c
index ac615343a..0764234bd 100644
--- a/mesalib/src/mesa/state_tracker/st_mesa_to_tgsi.c
+++ b/mesalib/src/mesa/state_tracker/st_mesa_to_tgsi.c
@@ -269,7 +269,7 @@ src_register( struct st_translate *t,
* Map mesa texture target to TGSI texture target.
*/
unsigned
-translate_texture_target( GLuint textarget,
+st_translate_texture_target( GLuint textarget,
GLboolean shadow )
{
if (shadow) {
@@ -279,6 +279,7 @@ translate_texture_target( GLuint textarget,
case TEXTURE_RECT_INDEX: return TGSI_TEXTURE_SHADOWRECT;
case TEXTURE_1D_ARRAY_INDEX: return TGSI_TEXTURE_SHADOW1D_ARRAY;
case TEXTURE_2D_ARRAY_INDEX: return TGSI_TEXTURE_SHADOW2D_ARRAY;
+ case TEXTURE_CUBE_INDEX: return TGSI_TEXTURE_SHADOWCUBE;
default: break;
}
}
@@ -515,7 +516,7 @@ static void emit_ddy( struct st_translate *t,
-unsigned
+static unsigned
translate_opcode( unsigned op )
{
switch( op ) {
@@ -707,7 +708,7 @@ compile_instruction(
ureg_tex_insn( ureg,
translate_opcode( inst->Opcode ),
dst, num_dst,
- translate_texture_target( inst->TexSrcTarget,
+ st_translate_texture_target( inst->TexSrcTarget,
inst->TexShadow ),
NULL, 0,
src, num_src );
diff --git a/mesalib/src/mesa/state_tracker/st_mesa_to_tgsi.h b/mesalib/src/mesa/state_tracker/st_mesa_to_tgsi.h
index 0dbdf5f61..7563c8050 100644
--- a/mesalib/src/mesa/state_tracker/st_mesa_to_tgsi.h
+++ b/mesalib/src/mesa/state_tracker/st_mesa_to_tgsi.h
@@ -65,10 +65,7 @@ void
st_free_tokens(const struct tgsi_token *tokens);
unsigned
-translate_opcode(unsigned op);
-
-unsigned
-translate_texture_target(GLuint textarget, GLboolean shadow);
+st_translate_texture_target(GLuint textarget, GLboolean shadow);
#if defined __cplusplus