51
51
const struct lp_fragment_shader *lpfs = llvmpipe->fs;
52
52
struct vertex_info *vinfo = &llvmpipe->vertex_info;
53
const uint num = draw_num_shader_outputs(llvmpipe->draw);
53
struct lp_shader_input *inputs = llvmpipe->inputs;
56
/* Tell setup to tell the draw module to simply emit the whole
57
* post-xform vertex as-is.
59
* Not really sure if this is the best approach.
58
* Match FS inputs against VS outputs, emitting the necessary attributes.
61
61
vinfo->num_attribs = 0;
62
for (i = 0; i < num; i++) {
63
draw_emit_vertex_attr(vinfo, EMIT_4F, INTERP_PERSPECTIVE, i);
63
vs_index = draw_find_shader_output(llvmpipe->draw,
64
TGSI_SEMANTIC_POSITION,
67
draw_emit_vertex_attr(vinfo, EMIT_4F, INTERP_PERSPECTIVE, vs_index);
69
for (i = 0; i < lpfs->info.num_inputs; i++) {
71
* Search for each input in current vs output:
74
vs_index = draw_find_shader_output(llvmpipe->draw,
75
lpfs->info.input_semantic_name[i],
76
lpfs->info.input_semantic_index[i]);
79
* This can happen with sprite coordinates - the vertex
80
* shader doesn't need to provide an output as we generate
81
* them internally. However, lets keep pretending that there
82
* is something there to not confuse other code.
87
/* This can be pre-computed, except for flatshade:
89
inputs[i].usage_mask = lpfs->info.input_usage_mask[i];
91
switch (lpfs->info.input_interpolate[i]) {
92
case TGSI_INTERPOLATE_CONSTANT:
93
inputs[i].interp = LP_INTERP_CONSTANT;
95
case TGSI_INTERPOLATE_LINEAR:
96
inputs[i].interp = LP_INTERP_LINEAR;
98
case TGSI_INTERPOLATE_PERSPECTIVE:
99
inputs[i].interp = LP_INTERP_PERSPECTIVE;
106
switch (lpfs->info.input_semantic_name[i]) {
107
case TGSI_SEMANTIC_FACE:
108
inputs[i].interp = LP_INTERP_FACING;
110
case TGSI_SEMANTIC_POSITION:
111
/* Position was already emitted above
113
inputs[i].interp = LP_INTERP_POSITION;
114
inputs[i].src_index = 0;
116
case TGSI_SEMANTIC_COLOR:
117
/* Colors are linearly inputs[i].interpolated in the fragment shader
118
* even when flatshading is active. This just tells the
119
* setup module to use coefficients with ddx==0 and
122
if (llvmpipe->rasterizer->flatshade)
123
inputs[i].interp = LP_INTERP_CONSTANT;
131
* Emit the requested fs attribute for all but position.
134
inputs[i].src_index = vinfo->num_attribs;
135
draw_emit_vertex_attr(vinfo, EMIT_4F, INTERP_PERSPECTIVE, vs_index);
138
/* Figure out if we need pointsize as well.
140
vs_index = draw_find_shader_output(llvmpipe->draw,
141
TGSI_SEMANTIC_PSIZE, 0);
144
llvmpipe->psize_slot = vinfo->num_attribs;
145
draw_emit_vertex_attr(vinfo, EMIT_4F, INTERP_CONSTANT, vs_index);
148
llvmpipe->num_inputs = lpfs->info.num_inputs;
65
150
draw_compute_vertex_size(vinfo);
68
152
lp_setup_set_vertex_info(llvmpipe->setup, vinfo);
71
llvmpipe->psize_slot = draw_find_vs_output(llvmpipe->draw,
72
TGSI_SEMANTIC_PSIZE, 0);
75
/* Now match FS inputs against emitted vertex data. It's also
76
* entirely possible to just have a fixed layout for FS input,
77
* determined by the fragment shader itself, and adjust the draw
78
* outputs to match that.
81
struct lp_shader_input inputs[PIPE_MAX_SHADER_INPUTS];
83
for (i = 0; i < lpfs->info.num_inputs; i++) {
85
/* This can be precomputed, except for flatshade:
87
switch (lpfs->info.input_semantic_name[i]) {
88
case TGSI_SEMANTIC_FACE:
89
inputs[i].interp = LP_INTERP_FACING;
91
case TGSI_SEMANTIC_POSITION:
92
inputs[i].interp = LP_INTERP_POSITION;
94
case TGSI_SEMANTIC_COLOR:
95
/* Colors are linearly interpolated in the fragment shader
96
* even when flatshading is active. This just tells the
97
* setup module to use coefficients with ddx==0 and
100
if (llvmpipe->rasterizer->flatshade)
101
inputs[i].interp = LP_INTERP_CONSTANT;
103
inputs[i].interp = LP_INTERP_LINEAR;
107
switch (lpfs->info.input_interpolate[i]) {
108
case TGSI_INTERPOLATE_CONSTANT:
109
inputs[i].interp = LP_INTERP_CONSTANT;
111
case TGSI_INTERPOLATE_LINEAR:
112
inputs[i].interp = LP_INTERP_LINEAR;
114
case TGSI_INTERPOLATE_PERSPECTIVE:
115
inputs[i].interp = LP_INTERP_PERSPECTIVE;
123
/* Search for each input in current vs output:
125
inputs[i].src_index =
126
draw_find_shader_output(llvmpipe->draw,
127
lpfs->info.input_semantic_name[i],
128
lpfs->info.input_semantic_index[i]);
131
lp_setup_set_fs_inputs(llvmpipe->setup,
133
lpfs->info.num_inputs);
154
lp_setup_set_fs_inputs(llvmpipe->setup,
156
lpfs->info.num_inputs);
174
197
if (llvmpipe->dirty & LP_NEW_SCISSOR)
175
198
lp_setup_set_scissor(llvmpipe->setup, &llvmpipe->scissor);
177
if (llvmpipe->dirty & LP_NEW_DEPTH_STENCIL_ALPHA)
200
if (llvmpipe->dirty & LP_NEW_DEPTH_STENCIL_ALPHA) {
178
201
lp_setup_set_alpha_ref_value(llvmpipe->setup,
179
202
llvmpipe->depth_stencil->alpha.ref_value);
203
lp_setup_set_stencil_ref_values(llvmpipe->setup,
204
llvmpipe->stencil_ref.ref_value);
181
207
if (llvmpipe->dirty & LP_NEW_CONSTANTS)
182
208
lp_setup_set_fs_constants(llvmpipe->setup,
183
llvmpipe->constants[PIPE_SHADER_FRAGMENT]);
209
llvmpipe->constants[PIPE_SHADER_FRAGMENT][0]);
185
if (llvmpipe->dirty & LP_NEW_TEXTURE)
186
lp_setup_set_sampler_textures(llvmpipe->setup,
187
llvmpipe->num_textures,
211
if (llvmpipe->dirty & LP_NEW_SAMPLER_VIEW)
212
lp_setup_set_fragment_sampler_views(llvmpipe->setup,
213
llvmpipe->num_fragment_sampler_views,
214
llvmpipe->fragment_sampler_views);
190
216
llvmpipe->dirty = 0;