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_context.c10
-rw-r--r--mesalib/src/mesa/state_tracker/st_context.h10
-rw-r--r--mesalib/src/mesa/state_tracker/st_extensions.c7
-rw-r--r--mesalib/src/mesa/state_tracker/st_glsl_to_tgsi.cpp84
-rw-r--r--mesalib/src/mesa/state_tracker/st_program.h9
5 files changed, 86 insertions, 34 deletions
diff --git a/mesalib/src/mesa/state_tracker/st_context.c b/mesalib/src/mesa/state_tracker/st_context.c
index 17235132e..9fd6caece 100644
--- a/mesalib/src/mesa/state_tracker/st_context.c
+++ b/mesalib/src/mesa/state_tracker/st_context.c
@@ -136,6 +136,8 @@ st_destroy_context_priv(struct st_context *st)
if (st->constbuf_uploader) {
u_upload_destroy(st->constbuf_uploader);
}
+
+ cso_destroy_context(st->cso_context);
free( st );
}
@@ -271,6 +273,8 @@ st_create_context_priv( struct gl_context *ctx, struct pipe_context *pipe,
*/
st->ctx->Point.MaxSize = MAX2(ctx->Const.MaxPointSize,
ctx->Const.MaxPointSizeAA);
+ /* For vertex shaders, make sure not to emit saturate when SM 3.0 is not supported */
+ ctx->Const.ShaderCompilerOptions[MESA_SHADER_VERTEX].EmitNoSat = !st->has_shader_model3;
_mesa_compute_version(ctx);
@@ -346,15 +350,11 @@ destroy_tex_sampler_cb(GLuint id, void *data, void *userData)
void st_destroy_context( struct st_context *st )
{
struct pipe_context *pipe = st->pipe;
- struct cso_context *cso = st->cso_context;
struct gl_context *ctx = st->ctx;
GLuint i;
_mesa_HashWalk(ctx->Shared->TexObjects, destroy_tex_sampler_cb, st);
- /* need to unbind and destroy CSO objects before anything else */
- cso_release_all(st->cso_context);
-
st_reference_fragprog(st, &st->fp, NULL);
st_reference_geomprog(st, &st->gp, NULL);
st_reference_vertprog(st, &st->vp, NULL);
@@ -384,8 +384,6 @@ void st_destroy_context( struct st_context *st )
st_destroy_context_priv(st);
st = NULL;
- cso_destroy_context(cso);
-
pipe->destroy( pipe );
free(ctx);
diff --git a/mesalib/src/mesa/state_tracker/st_context.h b/mesalib/src/mesa/state_tracker/st_context.h
index 15f9df492..20d567864 100644
--- a/mesalib/src/mesa/state_tracker/st_context.h
+++ b/mesalib/src/mesa/state_tracker/st_context.h
@@ -33,6 +33,12 @@
#include "state_tracker/st_api.h"
#include "main/fbobject.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
struct bitmap_cache;
struct dd_function_table;
struct draw_context;
@@ -278,4 +284,8 @@ extern void
st_destroy_context(struct st_context *st);
+#ifdef __cplusplus
+}
+#endif
+
#endif
diff --git a/mesalib/src/mesa/state_tracker/st_extensions.c b/mesalib/src/mesa/state_tracker/st_extensions.c
index bdfab8b41..e472b84a8 100644
--- a/mesalib/src/mesa/state_tracker/st_extensions.c
+++ b/mesalib/src/mesa/state_tracker/st_extensions.c
@@ -674,6 +674,10 @@ void st_init_extensions(struct pipe_screen *screen,
consts->NativeIntegers = GL_TRUE;
consts->MaxClipPlanes = 8;
+ if (screen->get_param(screen, PIPE_CAP_VERTEXID_NOBASE)) {
+ consts->VertexID_is_zero_based = GL_TRUE;
+ }
+
/* Extensions that either depend on GLSL 1.30 or are a subset thereof. */
extensions->ARB_conservative_depth = GL_TRUE;
extensions->ARB_shading_language_packing = GL_TRUE;
@@ -696,6 +700,9 @@ void st_init_extensions(struct pipe_screen *screen,
extensions->EXT_shader_integer_mix = GL_TRUE;
}
+
+ /* Integer textures make no sense before GLSL 1.30 */
+ extensions->EXT_texture_integer = GL_FALSE;
}
consts->UniformBooleanTrue = consts->NativeIntegers ? ~0 : fui(1.0f);
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 8e91c4b61..89654344b 100644
--- a/mesalib/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
+++ b/mesalib/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
@@ -44,10 +44,8 @@
#include "main/mtypes.h"
#include "main/shaderobj.h"
#include "main/uniforms.h"
-#include "program/hash_table.h"
-
-extern "C" {
#include "main/shaderapi.h"
+#include "program/hash_table.h"
#include "program/prog_instruction.h"
#include "program/prog_optimize.h"
#include "program/prog_print.h"
@@ -67,7 +65,7 @@ extern "C" {
#include "st_program.h"
#include "st_glsl_to_tgsi.h"
#include "st_mesa_to_tgsi.h"
-}
+
#define PROGRAM_IMMEDIATE PROGRAM_FILE_MAX
#define PROGRAM_ANY_CONST ((1 << PROGRAM_STATE_VAR) | \
@@ -2288,6 +2286,37 @@ glsl_to_tgsi_visitor::process_move_condition(ir_rvalue *ir)
bool switch_order = false;
ir_expression *const expr = ir->as_expression();
+
+ if (native_integers) {
+ if ((expr != NULL) && (expr->get_num_operands() == 2)) {
+ enum glsl_base_type type = expr->operands[0]->type->base_type;
+ if (type == GLSL_TYPE_INT || type == GLSL_TYPE_UINT ||
+ type == GLSL_TYPE_BOOL) {
+ if (expr->operation == ir_binop_equal) {
+ if (expr->operands[0]->is_zero()) {
+ src_ir = expr->operands[1];
+ switch_order = true;
+ }
+ else if (expr->operands[1]->is_zero()) {
+ src_ir = expr->operands[0];
+ switch_order = true;
+ }
+ }
+ else if (expr->operation == ir_binop_nequal) {
+ if (expr->operands[0]->is_zero()) {
+ src_ir = expr->operands[1];
+ }
+ else if (expr->operands[1]->is_zero()) {
+ src_ir = expr->operands[0];
+ }
+ }
+ }
+ }
+
+ src_ir->accept(this);
+ return switch_order;
+ }
+
if ((expr != NULL) && (expr->get_num_operands() == 2)) {
bool zero_on_left = false;
@@ -2379,7 +2408,7 @@ glsl_to_tgsi_visitor::emit_block_mov(ir_assignment *ir, const struct glsl_type *
const struct glsl_type *vec_type;
vec_type = glsl_type::get_instance(GLSL_TYPE_FLOAT,
- type->vector_elements, 1);
+ type->vector_elements, 1);
for (int i = 0; i < type->matrix_columns; i++) {
emit_block_mov(ir, vec_type, l, r);
@@ -2447,7 +2476,7 @@ glsl_to_tgsi_visitor::visit(ir_assignment *ir)
swizzles[i] = first_enabled_chan;
}
r.swizzle = MAKE_SWIZZLE4(swizzles[0], swizzles[1],
- swizzles[2], swizzles[3]);
+ swizzles[2], swizzles[3]);
}
assert(l.file != PROGRAM_UNDEFINED);
@@ -2460,24 +2489,21 @@ glsl_to_tgsi_visitor::visit(ir_assignment *ir)
for (i = 0; i < type_size(ir->lhs->type); i++) {
st_src_reg l_src = st_src_reg(l);
st_src_reg condition_temp = condition;
+ st_src_reg op1, op2;
l_src.swizzle = swizzle_for_size(ir->lhs->type->vector_elements);
-
+
+ op1 = r;
+ op2 = l_src;
+ if (switch_order) {
+ op1 = l_src;
+ op2 = r;
+ }
+
if (native_integers) {
- /* This is necessary because TGSI's CMP instruction expects the
- * condition to be a float, and we store booleans as integers.
- * TODO: really want to avoid i2f path and use UCMP. Requires
- * changes to process_move_condition though too.
- */
- condition_temp = get_temp(glsl_type::vec4_type);
- condition.negate = 0;
- emit(ir, TGSI_OPCODE_I2F, st_dst_reg(condition_temp), condition);
- condition_temp.swizzle = condition.swizzle;
+ emit(ir, TGSI_OPCODE_UCMP, l, condition_temp, op1, op2);
}
-
- if (switch_order) {
- emit(ir, TGSI_OPCODE_CMP, l, condition_temp, l_src, r);
- } else {
- emit(ir, TGSI_OPCODE_CMP, l, condition_temp, r, l_src);
+ else {
+ emit(ir, TGSI_OPCODE_CMP, l, condition_temp, op1, op2);
}
l.index++;
@@ -3527,7 +3553,8 @@ glsl_to_tgsi_visitor::copy_propagate(void)
first = copy_chan;
} else {
if (first->src[0].file != copy_chan->src[0].file ||
- first->src[0].index != copy_chan->src[0].index) {
+ first->src[0].index != copy_chan->src[0].index ||
+ first->src[0].index2D != copy_chan->src[0].index2D) {
good = false;
break;
}
@@ -4167,8 +4194,8 @@ const unsigned _mesa_sysval_to_semantic[SYSTEM_VALUE_MAX] = {
*/
TGSI_SEMANTIC_VERTEXID,
TGSI_SEMANTIC_INSTANCEID,
- 0,
- 0,
+ TGSI_SEMANTIC_VERTEXID_NOBASE,
+ TGSI_SEMANTIC_BASEVERTEX,
/* Geometry shader
*/
@@ -4879,6 +4906,10 @@ st_translate_program(
TGSI_SEMANTIC_SAMPLEMASK);
assert(_mesa_sysval_to_semantic[SYSTEM_VALUE_INVOCATION_ID] ==
TGSI_SEMANTIC_INVOCATIONID);
+ assert(_mesa_sysval_to_semantic[SYSTEM_VALUE_VERTEX_ID_ZERO_BASE] ==
+ TGSI_SEMANTIC_VERTEXID_NOBASE);
+ assert(_mesa_sysval_to_semantic[SYSTEM_VALUE_BASE_VERTEX] ==
+ TGSI_SEMANTIC_BASEVERTEX);
t = CALLOC_STRUCT(st_translate);
if (!t) {
@@ -5391,9 +5422,6 @@ st_link_shader(struct gl_context *ctx, struct gl_shader_program *prog)
if (!pscreen->get_param(pscreen, PIPE_CAP_TEXTURE_GATHER_OFFSETS))
lower_offset_arrays(ir);
do_mat_op_to_vec(ir);
- /* Emit saturates in the vertex shader only if SM 3.0 is supported. */
- bool vs_sm3 = (_mesa_shader_stage_to_program(prog->_LinkedShaders[i]->Stage) ==
- GL_VERTEX_PROGRAM_ARB) && st_context(ctx)->has_shader_model3;
lower_instructions(ir,
MOD_TO_FRACT |
DIV_TO_MUL_RCP |
@@ -5404,7 +5432,7 @@ st_link_shader(struct gl_context *ctx, struct gl_shader_program *prog)
BORROW_TO_ARITH |
(options->EmitNoPow ? POW_TO_EXP2 : 0) |
(!ctx->Const.NativeIntegers ? INT_DIV_TO_MUL_RCP : 0) |
- (vs_sm3 ? SAT_TO_CLAMP : 0));
+ (options->EmitNoSat ? SAT_TO_CLAMP : 0));
lower_ubo_reference(prog->_LinkedShaders[i], ir);
do_vec_index_to_cond_assign(ir);
diff --git a/mesalib/src/mesa/state_tracker/st_program.h b/mesalib/src/mesa/state_tracker/st_program.h
index cf1b40a55..870d0d57a 100644
--- a/mesalib/src/mesa/state_tracker/st_program.h
+++ b/mesalib/src/mesa/state_tracker/st_program.h
@@ -41,6 +41,11 @@
#include "st_glsl_to_tgsi.h"
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
/** Fragment program variant key */
struct st_fp_variant_key
{
@@ -347,4 +352,8 @@ extern void
st_print_current_vertex_program(void);
+#ifdef __cplusplus
+}
+#endif
+
#endif