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...
This commit is contained in:
parent
1410b7bb50
commit
f74279002a
|
@ -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];
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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... */
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue