summaryrefslogtreecommitdiffstats
path: root/src/mesa/state_tracker
diff options
context:
space:
mode:
authorIlia Mirkin <[email protected]>2014-03-30 18:21:50 -0400
committerIlia Mirkin <[email protected]>2014-04-26 11:52:52 -0400
commitc5d822dad902b19f06c9be3c6863a51e1881ec5b (patch)
tree4d2f07f9cb6f0aad08c594759b2a631bdda54b8e /src/mesa/state_tracker
parent88d8d88d8c151ca1e8ec3af0caba16a4e34ca281 (diff)
mesa/st: add support for ARB_sample_shading
Signed-off-by: Ilia Mirkin <[email protected]> Reviewed-by: Marek Olšák <[email protected]> Reviewed-by: Roland Scheidegger <[email protected]>
Diffstat (limited to 'src/mesa/state_tracker')
-rw-r--r--src/mesa/state_tracker/st_atom.c1
-rw-r--r--src/mesa/state_tracker/st_atom.h1
-rw-r--r--src/mesa/state_tracker/st_atom_msaa.c23
-rw-r--r--src/mesa/state_tracker/st_cb_clear.c3
-rw-r--r--src/mesa/state_tracker/st_extensions.c3
-rw-r--r--src/mesa/state_tracker/st_glsl_to_tgsi.cpp16
-rw-r--r--src/mesa/state_tracker/st_program.c21
7 files changed, 57 insertions, 11 deletions
diff --git a/src/mesa/state_tracker/st_atom.c b/src/mesa/state_tracker/st_atom.c
index 99e9df26b47..625ea2965fe 100644
--- a/src/mesa/state_tracker/st_atom.c
+++ b/src/mesa/state_tracker/st_atom.c
@@ -61,6 +61,7 @@ static const struct st_tracked_state *atoms[] =
&st_update_sampler, /* depends on update_*_texture for swizzle */
&st_update_framebuffer,
&st_update_msaa,
+ &st_update_sample_shading,
&st_update_vs_constants,
&st_update_gs_constants,
&st_update_fs_constants,
diff --git a/src/mesa/state_tracker/st_atom.h b/src/mesa/state_tracker/st_atom.h
index 60d89d75f0d..c50111d501f 100644
--- a/src/mesa/state_tracker/st_atom.h
+++ b/src/mesa/state_tracker/st_atom.h
@@ -59,6 +59,7 @@ extern const struct st_tracked_state st_update_viewport;
extern const struct st_tracked_state st_update_scissor;
extern const struct st_tracked_state st_update_blend;
extern const struct st_tracked_state st_update_msaa;
+extern const struct st_tracked_state st_update_sample_shading;
extern const struct st_tracked_state st_update_sampler;
extern const struct st_tracked_state st_update_fragment_texture;
extern const struct st_tracked_state st_update_vertex_texture;
diff --git a/src/mesa/state_tracker/st_atom_msaa.c b/src/mesa/state_tracker/st_atom_msaa.c
index 2f3a42e0248..703cb5e755c 100644
--- a/src/mesa/state_tracker/st_atom_msaa.c
+++ b/src/mesa/state_tracker/st_atom_msaa.c
@@ -27,8 +27,10 @@
#include "st_context.h"
+#include "pipe/p_screen.h"
#include "pipe/p_context.h"
#include "st_atom.h"
+#include "st_program.h"
#include "cso_cache/cso_context.h"
#include "util/u_framebuffer.h"
@@ -70,6 +72,18 @@ static void update_sample_mask( struct st_context *st )
}
}
+static void update_sample_shading( struct st_context *st )
+{
+ if (!st->fp)
+ return;
+
+ if (!st->ctx->Extensions.ARB_sample_shading)
+ return;
+
+ cso_set_min_samples(
+ st->cso_context,
+ _mesa_get_min_invocations_per_fragment(st->ctx, &st->fp->Base, false));
+}
const struct st_tracked_state st_update_msaa = {
"st_update_msaa", /* name */
@@ -79,3 +93,12 @@ const struct st_tracked_state st_update_msaa = {
},
update_sample_mask /* update */
};
+
+const struct st_tracked_state st_update_sample_shading = {
+ "st_update_sample_shading", /* name */
+ { /* dirty */
+ (_NEW_MULTISAMPLE | _NEW_PROGRAM | _NEW_BUFFERS), /* mesa */
+ ST_NEW_FRAGMENT_PROGRAM | ST_NEW_FRAMEBUFFER, /* st */
+ },
+ update_sample_shading /* update */
+};
diff --git a/src/mesa/state_tracker/st_cb_clear.c b/src/mesa/state_tracker/st_cb_clear.c
index fcd7e1382be..371f7fcdae7 100644
--- a/src/mesa/state_tracker/st_cb_clear.c
+++ b/src/mesa/state_tracker/st_cb_clear.c
@@ -240,6 +240,7 @@ clear_with_quad(struct gl_context *ctx, unsigned clear_buffers)
cso_save_depth_stencil_alpha(st->cso_context);
cso_save_rasterizer(st->cso_context);
cso_save_sample_mask(st->cso_context);
+ cso_save_min_samples(st->cso_context);
cso_save_viewport(st->cso_context);
cso_save_fragment_shader(st->cso_context);
cso_save_stream_outputs(st->cso_context);
@@ -309,6 +310,7 @@ clear_with_quad(struct gl_context *ctx, unsigned clear_buffers)
cso_set_vertex_elements(st->cso_context, 2, st->velems_util_draw);
cso_set_stream_outputs(st->cso_context, 0, NULL, NULL);
cso_set_sample_mask(st->cso_context, ~0);
+ cso_set_min_samples(st->cso_context, 1);
cso_set_rasterizer(st->cso_context, &st->clear.raster);
/* viewport state: viewport matching window dims */
@@ -348,6 +350,7 @@ clear_with_quad(struct gl_context *ctx, unsigned clear_buffers)
cso_restore_depth_stencil_alpha(st->cso_context);
cso_restore_rasterizer(st->cso_context);
cso_restore_sample_mask(st->cso_context);
+ cso_restore_min_samples(st->cso_context);
cso_restore_viewport(st->cso_context);
cso_restore_fragment_shader(st->cso_context);
cso_restore_vertex_shader(st->cso_context);
diff --git a/src/mesa/state_tracker/st_extensions.c b/src/mesa/state_tracker/st_extensions.c
index 70726886e57..a245fdf1877 100644
--- a/src/mesa/state_tracker/st_extensions.c
+++ b/src/mesa/state_tracker/st_extensions.c
@@ -425,7 +425,8 @@ void st_init_extensions(struct st_context *st)
{ o(OES_standard_derivatives), PIPE_CAP_SM3 },
{ o(ARB_texture_cube_map_array), PIPE_CAP_CUBE_MAP_ARRAY },
{ o(ARB_texture_multisample), PIPE_CAP_TEXTURE_MULTISAMPLE },
- { o(ARB_texture_query_lod), PIPE_CAP_TEXTURE_QUERY_LOD }
+ { o(ARB_texture_query_lod), PIPE_CAP_TEXTURE_QUERY_LOD },
+ { o(ARB_sample_shading), PIPE_CAP_SAMPLE_SHADING },
};
/* Required: render target and sampler support */
diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
index 15b5279b8f5..0d69c703fb8 100644
--- a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
+++ b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
@@ -4163,7 +4163,9 @@ struct st_translate {
static unsigned mesa_sysval_to_semantic[SYSTEM_VALUE_MAX] = {
TGSI_SEMANTIC_FACE,
TGSI_SEMANTIC_VERTEXID,
- TGSI_SEMANTIC_INSTANCEID
+ TGSI_SEMANTIC_INSTANCEID,
+ TGSI_SEMANTIC_SAMPLEID,
+ TGSI_SEMANTIC_SAMPLEPOS,
};
/**
@@ -4381,7 +4383,8 @@ translate_dst(struct st_translate *t,
break;
case TGSI_PROCESSOR_FRAGMENT:
- if (dst_reg->index >= FRAG_RESULT_COLOR) {
+ if (dst_reg->index == FRAG_RESULT_COLOR ||
+ dst_reg->index >= FRAG_RESULT_DATA0) {
dst = ureg_saturate(dst);
}
break;
@@ -4876,6 +4879,15 @@ st_translate_program(
TGSI_SEMANTIC_COLOR,
outputSemanticIndex[i]);
break;
+ case TGSI_SEMANTIC_SAMPLEMASK:
+ t->outputs[i] = ureg_DECL_output(ureg,
+ TGSI_SEMANTIC_SAMPLEMASK,
+ outputSemanticIndex[i]);
+ /* TODO: If we ever support more than 32 samples, this will have
+ * to become an array.
+ */
+ t->outputs[i] = ureg_writemask(t->outputs[i], TGSI_WRITEMASK_X);
+ break;
default:
assert(!"fragment shader outputs must be POSITION/STENCIL/COLOR");
ret = PIPE_ERROR_BAD_INPUT;
diff --git a/src/mesa/state_tracker/st_program.c b/src/mesa/state_tracker/st_program.c
index 2f0ec32f554..f9887a2c440 100644
--- a/src/mesa/state_tracker/st_program.c
+++ b/src/mesa/state_tracker/st_program.c
@@ -682,6 +682,7 @@ st_translate_fragment_program(struct st_context *st,
/* handle remaining outputs (color) */
for (attr = 0; attr < FRAG_RESULT_MAX; attr++) {
if (outputsWritten & BITFIELD64_BIT(attr)) {
+ int semantic = TGSI_SEMANTIC_COLOR;
switch (attr) {
case FRAG_RESULT_DEPTH:
case FRAG_RESULT_STENCIL:
@@ -689,17 +690,21 @@ st_translate_fragment_program(struct st_context *st,
assert(0);
break;
case FRAG_RESULT_COLOR:
- write_all = GL_TRUE; /* fallthrough */
- default:
- assert(attr == FRAG_RESULT_COLOR ||
- (FRAG_RESULT_DATA0 <= attr && attr < FRAG_RESULT_MAX));
- fs_output_semantic_name[fs_num_outputs] = TGSI_SEMANTIC_COLOR;
- fs_output_semantic_index[fs_num_outputs] = numColors;
- outputMapping[attr] = fs_num_outputs;
- numColors++;
+ write_all = GL_TRUE;
+ break;
+ case FRAG_RESULT_SAMPLE_MASK:
+ semantic = TGSI_SEMANTIC_SAMPLEMASK;
break;
}
+ assert(attr == FRAG_RESULT_COLOR ||
+ attr == FRAG_RESULT_SAMPLE_MASK ||
+ (FRAG_RESULT_DATA0 <= attr && attr < FRAG_RESULT_MAX));
+ fs_output_semantic_name[fs_num_outputs] = semantic;
+ fs_output_semantic_index[fs_num_outputs] = numColors;
+ outputMapping[attr] = fs_num_outputs;
+ numColors++;
+
fs_num_outputs++;
}
}