summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBrian <brian.paul@tungstengraphics.com>2008-02-26 10:13:39 -0700
committerBrian <brian.paul@tungstengraphics.com>2008-02-26 10:13:39 -0700
commitf74279002a0ae0b106bd5410487ef9c0e9b1d8b6 (patch)
treef9273881651ea0df206c6281337f6872df2878db /src
parent1410b7bb509ef37c41043b173bc1047257483af0 (diff)
gallium: added tgsi_shader_field to sp_fragment_shader
Use the shader semantic info from there, instead of from pipe_shader_state. Carry this idea to draw module and other drivers...
Diffstat (limited to 'src')
-rw-r--r--src/gallium/drivers/softpipe/sp_fs_llvm.c2
-rw-r--r--src/gallium/drivers/softpipe/sp_prim_setup.c18
-rw-r--r--src/gallium/drivers/softpipe/sp_quad.c2
-rw-r--r--src/gallium/drivers/softpipe/sp_quad_fs.c4
-rw-r--r--src/gallium/drivers/softpipe/sp_state.h6
-rw-r--r--src/gallium/drivers/softpipe/sp_state_derived.c9
-rw-r--r--src/gallium/drivers/softpipe/sp_state_fs.c16
7 files changed, 32 insertions, 25 deletions
diff --git a/src/gallium/drivers/softpipe/sp_fs_llvm.c b/src/gallium/drivers/softpipe/sp_fs_llvm.c
index 34b2b7d4e2..07d058155f 100644
--- a/src/gallium/drivers/softpipe/sp_fs_llvm.c
+++ b/src/gallium/drivers/softpipe/sp_fs_llvm.c
@@ -96,7 +96,7 @@ shade_quad_llvm(struct quad_stage *qs,
if (qss->colorOutSlot >= 0) {
unsigned i;
/* XXX need to handle multiple color outputs someday */
- allvmrt(qss->stage.softpipe->fs->shader.output_semantic_name[qss->colorOutSlot]
+ allvmrt(qss->stage.softpipe->fs->info.output_semantic_name[qss->colorOutSlot]
== TGSI_SEMANTIC_COLOR);
for (i = 0; i < QUAD_SIZE; ++i) {
quad->outputs.color[0][i] = dests[i][qss->colorOutSlot][0];
diff --git a/src/gallium/drivers/softpipe/sp_prim_setup.c b/src/gallium/drivers/softpipe/sp_prim_setup.c
index b6a3fddb29..17284539b0 100644
--- a/src/gallium/drivers/softpipe/sp_prim_setup.c
+++ b/src/gallium/drivers/softpipe/sp_prim_setup.c
@@ -514,7 +514,7 @@ setup_fragcoord_coeff(struct setup_stage *setup, uint slot)
static void setup_tri_coefficients( struct setup_stage *setup )
{
struct softpipe_context *softpipe = setup->softpipe;
- const struct pipe_shader_state *fs = &softpipe->fs->shader;
+ const struct sp_fragment_shader *spfs = softpipe->fs;
const struct vertex_info *vinfo = softpipe_get_vertex_info(softpipe);
uint fragSlot;
@@ -525,7 +525,7 @@ static void setup_tri_coefficients( struct setup_stage *setup )
/* setup interpolation for all the remaining attributes:
*/
- for (fragSlot = 0; fragSlot < fs->num_inputs; fragSlot++) {
+ for (fragSlot = 0; fragSlot < spfs->info.num_inputs; fragSlot++) {
const uint vertSlot = vinfo->src_index[fragSlot];
uint j;
@@ -549,7 +549,7 @@ static void setup_tri_coefficients( struct setup_stage *setup )
assert(0);
}
- if (fs->input_semantic_name[fragSlot] == TGSI_SEMANTIC_FOG) {
+ if (spfs->info.input_semantic_name[fragSlot] == TGSI_SEMANTIC_FOG) {
/* FOG.y = front/back facing XXX fix this */
setup->coef[fragSlot].a0[1] = 1.0f - setup->quad.facing;
setup->coef[fragSlot].dadx[1] = 0.0;
@@ -757,7 +757,7 @@ static INLINE void
setup_line_coefficients(struct setup_stage *setup, struct prim_header *prim)
{
struct softpipe_context *softpipe = setup->softpipe;
- const struct pipe_shader_state *fs = &setup->softpipe->fs->shader;
+ const struct sp_fragment_shader *spfs = softpipe->fs;
const struct vertex_info *vinfo = softpipe_get_vertex_info(softpipe);
uint fragSlot;
@@ -779,7 +779,7 @@ setup_line_coefficients(struct setup_stage *setup, struct prim_header *prim)
/* setup interpolation for all the remaining attributes:
*/
- for (fragSlot = 0; fragSlot < fs->num_inputs; fragSlot++) {
+ for (fragSlot = 0; fragSlot < spfs->info.num_inputs; fragSlot++) {
const uint vertSlot = vinfo->src_index[fragSlot];
uint j;
@@ -803,7 +803,7 @@ setup_line_coefficients(struct setup_stage *setup, struct prim_header *prim)
assert(0);
}
- if (fs->input_semantic_name[fragSlot] == TGSI_SEMANTIC_FOG) {
+ if (spfs->info.input_semantic_name[fragSlot] == TGSI_SEMANTIC_FOG) {
/* FOG.y = front/back facing XXX fix this */
setup->coef[fragSlot].a0[1] = 1.0f - setup->quad.facing;
setup->coef[fragSlot].dadx[1] = 0.0;
@@ -967,7 +967,7 @@ setup_point(struct draw_stage *stage, struct prim_header *prim)
{
struct setup_stage *setup = setup_stage( stage );
struct softpipe_context *softpipe = setup->softpipe;
- const struct pipe_shader_state *fs = &softpipe->fs->shader;
+ const struct sp_fragment_shader *spfs = softpipe->fs;
const struct vertex_header *v0 = prim->v[0];
const int sizeAttr = setup->softpipe->psize_slot;
const float size
@@ -1002,7 +1002,7 @@ setup_point(struct draw_stage *stage, struct prim_header *prim)
const_coeff(setup, &setup->posCoef, 0, 2);
const_coeff(setup, &setup->posCoef, 0, 3);
- for (fragSlot = 0; fragSlot < fs->num_inputs; fragSlot++) {
+ for (fragSlot = 0; fragSlot < spfs->info.num_inputs; fragSlot++) {
const uint vertSlot = vinfo->src_index[fragSlot];
uint j;
@@ -1025,7 +1025,7 @@ setup_point(struct draw_stage *stage, struct prim_header *prim)
assert(0);
}
- if (fs->input_semantic_name[fragSlot] == TGSI_SEMANTIC_FOG) {
+ if (spfs->info.input_semantic_name[fragSlot] == TGSI_SEMANTIC_FOG) {
/* FOG.y = front/back facing XXX fix this */
setup->coef[fragSlot].a0[1] = 1.0f - setup->quad.facing;
setup->coef[fragSlot].dadx[1] = 0.0;
diff --git a/src/gallium/drivers/softpipe/sp_quad.c b/src/gallium/drivers/softpipe/sp_quad.c
index 142dbcc771..0aaf94021f 100644
--- a/src/gallium/drivers/softpipe/sp_quad.c
+++ b/src/gallium/drivers/softpipe/sp_quad.c
@@ -61,7 +61,7 @@ sp_build_quad_pipeline(struct softpipe_context *sp)
sp->framebuffer.zsbuf &&
!sp->depth_stencil->alpha.enabled &&
!sp->fs->uses_kill &&
- !sp->fs->writes_z;
+ !sp->fs->info.writes_z;
/* build up the pipeline in reverse order... */
diff --git a/src/gallium/drivers/softpipe/sp_quad_fs.c b/src/gallium/drivers/softpipe/sp_quad_fs.c
index 2f40e09d5c..1794fb5a61 100644
--- a/src/gallium/drivers/softpipe/sp_quad_fs.c
+++ b/src/gallium/drivers/softpipe/sp_quad_fs.c
@@ -91,7 +91,7 @@ shade_quad(
/* store result color */
if (qss->colorOutSlot >= 0) {
/* XXX need to handle multiple color outputs someday */
- assert(qss->stage.softpipe->fs->shader.output_semantic_name[qss->colorOutSlot]
+ assert(qss->stage.softpipe->fs->info.output_semantic_name[qss->colorOutSlot]
== TGSI_SEMANTIC_COLOR);
memcpy(
quad->outputs.color,
@@ -149,7 +149,7 @@ static void shade_begin(struct quad_stage *qs)
qss->colorOutSlot = -1;
qss->depthOutSlot = -1;
for (i = 0; i < qss->stage.softpipe->fs->shader.num_outputs; i++) {
- switch (qss->stage.softpipe->fs->shader.output_semantic_name[i]) {
+ switch (qss->stage.softpipe->fs->info.output_semantic_name[i]) {
case TGSI_SEMANTIC_POSITION:
qss->depthOutSlot = i;
break;
diff --git a/src/gallium/drivers/softpipe/sp_state.h b/src/gallium/drivers/softpipe/sp_state.h
index 5aaa9e346b..b1070e185a 100644
--- a/src/gallium/drivers/softpipe/sp_state.h
+++ b/src/gallium/drivers/softpipe/sp_state.h
@@ -32,6 +32,7 @@
#define SP_STATE_H
#include "pipe/p_state.h"
+#include "tgsi/util/tgsi_scan.h"
#define SP_NEW_VIEWPORT 0x1
@@ -61,10 +62,11 @@ struct tgsi_exec_machine;
* This is starting to look an awful lot like a quad pipeline stage...
*/
struct sp_fragment_shader {
- struct pipe_shader_state shader;
+ struct pipe_shader_state shader;
+
+ struct tgsi_shader_info info;
boolean uses_kill;
- boolean writes_z;
void (*prepare)( const struct sp_fragment_shader *shader,
struct tgsi_exec_machine *machine,
diff --git a/src/gallium/drivers/softpipe/sp_state_derived.c b/src/gallium/drivers/softpipe/sp_state_derived.c
index 4c6313001f..68702eafcf 100644
--- a/src/gallium/drivers/softpipe/sp_state_derived.c
+++ b/src/gallium/drivers/softpipe/sp_state_derived.c
@@ -62,6 +62,7 @@ softpipe_get_vertex_info(struct softpipe_context *softpipe)
if (vinfo->num_attribs == 0) {
/* compute vertex layout now */
const struct pipe_shader_state *vs = &softpipe->vs->shader;
+ const struct sp_fragment_shader *spfs = softpipe->fs;
const struct pipe_shader_state *fs = &softpipe->fs->shader;
const enum interp_mode colorInterp
= softpipe->rasterizer->flatshade ? INTERP_CONSTANT : INTERP_LINEAR;
@@ -83,9 +84,9 @@ softpipe_get_vertex_info(struct softpipe_context *softpipe)
* from the vertex shader.
*/
vinfo->num_attribs = 0;
- for (i = 0; i < fs->num_inputs; i++) {
+ for (i = 0; i < spfs->info.num_inputs; i++) {
int src;
- switch (fs->input_semantic_name[i]) {
+ switch (spfs->info.input_semantic_name[i]) {
case TGSI_SEMANTIC_POSITION:
src = draw_find_vs_output(softpipe->draw,
TGSI_SEMANTIC_POSITION, 0);
@@ -94,7 +95,7 @@ softpipe_get_vertex_info(struct softpipe_context *softpipe)
case TGSI_SEMANTIC_COLOR:
src = draw_find_vs_output(softpipe->draw, TGSI_SEMANTIC_COLOR,
- fs->input_semantic_index[i]);
+ spfs->info.input_semantic_index[i]);
draw_emit_vertex_attr(vinfo, EMIT_4F, colorInterp, src);
break;
@@ -106,7 +107,7 @@ softpipe_get_vertex_info(struct softpipe_context *softpipe)
case TGSI_SEMANTIC_GENERIC:
/* this includes texcoords and varying vars */
src = draw_find_vs_output(softpipe->draw, TGSI_SEMANTIC_GENERIC,
- fs->input_semantic_index[i]);
+ spfs->info.input_semantic_index[i]);
draw_emit_vertex_attr(vinfo, EMIT_4F, INTERP_PERSPECTIVE, src);
break;
diff --git a/src/gallium/drivers/softpipe/sp_state_fs.c b/src/gallium/drivers/softpipe/sp_state_fs.c
index b184ac61bb..2715dca0f0 100644
--- a/src/gallium/drivers/softpipe/sp_state_fs.c
+++ b/src/gallium/drivers/softpipe/sp_state_fs.c
@@ -45,13 +45,12 @@ softpipe_create_fs_state(struct pipe_context *pipe,
{
struct softpipe_context *softpipe = softpipe_context(pipe);
struct sp_fragment_shader *state;
- struct tgsi_shader_info info;
-
- tgsi_scan_shader(templ->tokens, &info);
+ /* debug */
if (softpipe->dump_fs)
tgsi_dump(templ->tokens, 0);
+ /* codegen */
state = softpipe_create_fs_llvm( softpipe, templ );
if (!state) {
state = softpipe_create_fs_sse( softpipe, templ );
@@ -59,10 +58,15 @@ softpipe_create_fs_state(struct pipe_context *pipe,
state = softpipe_create_fs_exec( softpipe, templ );
}
}
+
assert(state);
- state->uses_kill = (info.opcode_count[TGSI_OPCODE_KIL] ||
- info.opcode_count[TGSI_OPCODE_KILP]);
- state->writes_z = info.writes_z;
+
+ /* get/save the summary info for this shader */
+ tgsi_scan_shader(templ->tokens, &state->info);
+
+ /* convenience field */
+ state->uses_kill = (state->info.opcode_count[TGSI_OPCODE_KIL] ||
+ state->info.opcode_count[TGSI_OPCODE_KILP]);
return state;
}