98
100
case TGSI_INTERPOLATE_PERSPECTIVE:
99
101
interp = INTERP_PERSPECTIVE;
103
case TGSI_INTERPOLATE_COLOR:
104
assert(fsInfo->input_semantic_name[i] == TGSI_SEMANTIC_COLOR);
103
108
interp = INTERP_LINEAR;
106
switch (spfs->info.input_semantic_name[i]) {
111
switch (fsInfo->input_semantic_name[i]) {
107
112
case TGSI_SEMANTIC_POSITION:
108
113
interp = INTERP_POS;
111
116
case TGSI_SEMANTIC_COLOR:
112
if (softpipe->rasterizer->flatshade) {
113
interp = INTERP_CONSTANT;
117
if (fsInfo->input_interpolate[i] == TGSI_INTERPOLATE_COLOR) {
118
if (softpipe->rasterizer->flatshade)
119
interp = INTERP_CONSTANT;
121
interp = INTERP_PERSPECTIVE;
118
126
/* this includes texcoords and varying vars */
119
127
src = draw_find_shader_output(softpipe->draw,
120
spfs->info.input_semantic_name[i],
121
spfs->info.input_semantic_index[i]);
128
fsInfo->input_semantic_name[i],
129
fsInfo->input_semantic_index[i]);
130
if (fsInfo->input_semantic_name[i] == TGSI_SEMANTIC_COLOR && src == 0)
131
/* try and find a bcolor */
132
src = draw_find_shader_output(softpipe->draw,
133
TGSI_SEMANTIC_BCOLOR, fsInfo->input_semantic_index[i]);
122
135
draw_emit_vertex_attr(vinfo, EMIT_4F, interp, src);
258
update_fragment_shader(struct softpipe_context *softpipe, unsigned prim)
260
struct sp_fragment_shader_variant_key key;
262
memset(&key, 0, sizeof(key));
264
if (prim == PIPE_PRIM_TRIANGLES)
265
key.polygon_stipple = softpipe->rasterizer->poly_stipple_enable;
268
softpipe->fs_variant = softpipe_find_fs_variant(softpipe,
272
softpipe->fs_variant = NULL;
275
/* This would be the logical place to pass the fragment shader
276
* to the draw module. However, doing this here, during state
277
* validation, causes problems with the 'draw' module helpers for
278
* wide/AA/stippled lines.
279
* In principle, the draw's fragment shader should be per-variant
280
* but that doesn't work. So we use a single draw fragment shader
281
* per fragment shader, not per variant.
284
if (softpipe->fs_variant) {
285
draw_bind_fragment_shader(softpipe->draw,
286
softpipe->fs_variant->draw_shader);
289
draw_bind_fragment_shader(softpipe->draw, NULL);
296
* This should be called when the polygon stipple pattern changes.
297
* We create a new texture from the stipple pattern and create a new
301
update_polygon_stipple_pattern(struct softpipe_context *softpipe)
303
struct pipe_resource *tex;
304
struct pipe_sampler_view *view;
306
tex = util_pstipple_create_stipple_texture(&softpipe->pipe,
307
softpipe->poly_stipple.stipple);
308
pipe_resource_reference(&softpipe->pstipple.texture, tex);
309
pipe_resource_reference(&tex, NULL);
311
view = util_pstipple_create_sampler_view(&softpipe->pipe,
312
softpipe->pstipple.texture);
313
pipe_sampler_view_reference(&softpipe->pstipple.sampler_view, view);
314
pipe_sampler_view_reference(&view, NULL);
319
* Should be called when polygon stipple is enabled/disabled or when
320
* the fragment shader changes.
321
* We add/update the fragment sampler and sampler views to sample from
322
* the polygon stipple texture. The texture unit that we use depends on
323
* the fragment shader (we need to use a unit not otherwise used by the
327
update_polygon_stipple_enable(struct softpipe_context *softpipe, unsigned prim)
329
if (prim == PIPE_PRIM_TRIANGLES &&
330
softpipe->fs_variant->key.polygon_stipple) {
331
const unsigned unit = softpipe->fs_variant->stipple_sampler_unit;
333
assert(unit >= softpipe->num_fragment_samplers);
336
softpipe->fragment_samplers[unit] = softpipe->pstipple.sampler;
339
pipe_sampler_view_reference(&softpipe->fragment_sampler_views[unit],
340
softpipe->pstipple.sampler_view);
342
sp_tex_tile_cache_set_sampler_view(softpipe->fragment_tex_cache[unit],
343
softpipe->pstipple.sampler_view);
345
softpipe->dirty |= SP_NEW_SAMPLER;
244
350
/* Hopefully this will remain quite simple, otherwise need to pull in
245
351
* something like the state tracker mechanism.
247
void softpipe_update_derived( struct softpipe_context *softpipe )
354
softpipe_update_derived(struct softpipe_context *softpipe, unsigned prim)
249
356
struct softpipe_screen *sp_screen = softpipe_screen(softpipe->pipe.screen);
254
361
softpipe->tex_timestamp = sp_screen->timestamp;
255
362
softpipe->dirty |= SP_NEW_TEXTURE;
365
#if DO_PSTIPPLE_IN_HELPER_MODULE
366
if (softpipe->dirty & SP_NEW_STIPPLE)
367
/* before updating samplers! */
368
update_polygon_stipple_pattern(softpipe);
371
if (softpipe->dirty & (SP_NEW_RASTERIZER |
373
update_fragment_shader(softpipe, prim);
375
#if DO_PSTIPPLE_IN_HELPER_MODULE
376
if (softpipe->dirty & (SP_NEW_RASTERIZER |
379
update_polygon_stipple_enable(softpipe, prim);
258
382
if (softpipe->dirty & (SP_NEW_SAMPLER |