gallium/swr: Make flat shading tris work.
authorGeorge Kyriazis <george.kyriazis@intel.com>
Wed, 13 Apr 2016 15:48:55 +0000 (10:48 -0500)
committerTim Rowley <timothy.o.rowley@intel.com>
Wed, 13 Apr 2016 18:46:37 +0000 (13:46 -0500)
- Incorporate flatshade flag into the shader generation
- Use provoking vertex (vc) in shader when flat shading.

Reviewed-by: Bruce Cherniak <bruce.cherniak@intel.com>
src/gallium/drivers/swr/swr_shader.cpp
src/gallium/drivers/swr/swr_shader.h

index 90f0f22a6a2e0e97d9be5fd2469b2946af956229..83e32163ecc3d7c71cc68cd14ba68872f9ca77ee 100644 (file)
@@ -102,6 +102,7 @@ swr_generate_fs_key(struct swr_jit_fs_key &key,
 
    key.nr_cbufs = ctx->framebuffer.nr_cbufs;
    key.light_twoside = ctx->rasterizer->light_twoside;
+   key.flatshade = ctx->rasterizer->flatshade;
    memcpy(&key.vs_output_semantic_name,
           &ctx->vs->info.base.output_semantic_name,
           sizeof(key.vs_output_semantic_name));
@@ -491,6 +492,9 @@ BuilderSWR::CompileFS(struct swr_context *ctx, swr_jit_fs_key &key)
 
             if (interpMode == TGSI_INTERPOLATE_CONSTANT) {
                inputs[attrib][channel] = wrap(va);
+            } else if ((interpMode == TGSI_INTERPOLATE_COLOR) &&
+                       (key.flatshade == true)) {
+               inputs[attrib][channel] = wrap(vc);
             } else {
                Value *vk = FSUB(FSUB(VIMMED1(1.0f), vi), vj);
 
index 4814b9d914cf51e4ae1005856fc936db396f94f9..3f79570bbd9512622f664447d198cf8edf8e18cd 100644 (file)
@@ -51,6 +51,7 @@ struct swr_jit_sampler_key {
 struct swr_jit_fs_key : swr_jit_sampler_key {
    unsigned nr_cbufs;
    unsigned light_twoside;
+   unsigned flatshade;
    ubyte vs_output_semantic_name[PIPE_MAX_SHADER_OUTPUTS];
    ubyte vs_output_semantic_idx[PIPE_MAX_SHADER_OUTPUTS];
 };