2009-07-26 23:44:38 +01:00
|
|
|
/**************************************************************************
|
|
|
|
*
|
s/Tungsten Graphics/VMware/
Tungsten Graphics Inc. was acquired by VMware Inc. in 2008. Leaving the
old copyright name is creating unnecessary confusion, hence this change.
This was the sed script I used:
$ cat tg2vmw.sed
# Run as:
#
# git reset --hard HEAD && find include scons src -type f -not -name 'sed*' -print0 | xargs -0 sed -i -f tg2vmw.sed
#
# Rename copyrights
s/Tungsten Gra\(ph\|hp\)ics,\? [iI]nc\.\?\(, Cedar Park\)\?\(, Austin\)\?\(, \(Texas\|TX\)\)\?\.\?/VMware, Inc./g
/Copyright/s/Tungsten Graphics\(,\? [iI]nc\.\)\?\(, Cedar Park\)\?\(, Austin\)\?\(, \(Texas\|TX\)\)\?\.\?/VMware, Inc./
s/TUNGSTEN GRAPHICS/VMWARE/g
# Rename emails
s/alanh@tungstengraphics.com/alanh@vmware.com/
s/jens@tungstengraphics.com/jowen@vmware.com/g
s/jrfonseca-at-tungstengraphics-dot-com/jfonseca-at-vmware-dot-com/
s/jrfonseca\?@tungstengraphics.com/jfonseca@vmware.com/g
s/keithw\?@tungstengraphics.com/keithw@vmware.com/g
s/michel@tungstengraphics.com/daenzer@vmware.com/g
s/thomas-at-tungstengraphics-dot-com/thellstom-at-vmware-dot-com/
s/zack@tungstengraphics.com/zackr@vmware.com/
# Remove dead links
s@Tungsten Graphics (http://www.tungstengraphics.com)@Tungsten Graphics@g
# C string src/gallium/state_trackers/vega/api_misc.c
s/"Tungsten Graphics, Inc"/"VMware, Inc"/
Reviewed-by: Brian Paul <brianp@vmware.com>
2014-01-17 16:27:50 +00:00
|
|
|
* Copyright 2003 VMware, Inc.
|
2009-07-26 23:44:38 +01:00
|
|
|
* All Rights Reserved.
|
|
|
|
*
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a
|
|
|
|
* copy of this software and associated documentation files (the
|
|
|
|
* "Software"), to deal in the Software without restriction, including
|
|
|
|
* without limitation the rights to use, copy, modify, merge, publish,
|
|
|
|
* distribute, sub license, and/or sell copies of the Software, and to
|
|
|
|
* permit persons to whom the Software is furnished to do so, subject to
|
|
|
|
* the following conditions:
|
|
|
|
*
|
|
|
|
* The above copyright notice and this permission notice (including the
|
|
|
|
* next paragraph) shall be included in all copies or substantial portions
|
|
|
|
* of the Software.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
|
|
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
|
|
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
|
s/Tungsten Graphics/VMware/
Tungsten Graphics Inc. was acquired by VMware Inc. in 2008. Leaving the
old copyright name is creating unnecessary confusion, hence this change.
This was the sed script I used:
$ cat tg2vmw.sed
# Run as:
#
# git reset --hard HEAD && find include scons src -type f -not -name 'sed*' -print0 | xargs -0 sed -i -f tg2vmw.sed
#
# Rename copyrights
s/Tungsten Gra\(ph\|hp\)ics,\? [iI]nc\.\?\(, Cedar Park\)\?\(, Austin\)\?\(, \(Texas\|TX\)\)\?\.\?/VMware, Inc./g
/Copyright/s/Tungsten Graphics\(,\? [iI]nc\.\)\?\(, Cedar Park\)\?\(, Austin\)\?\(, \(Texas\|TX\)\)\?\.\?/VMware, Inc./
s/TUNGSTEN GRAPHICS/VMWARE/g
# Rename emails
s/alanh@tungstengraphics.com/alanh@vmware.com/
s/jens@tungstengraphics.com/jowen@vmware.com/g
s/jrfonseca-at-tungstengraphics-dot-com/jfonseca-at-vmware-dot-com/
s/jrfonseca\?@tungstengraphics.com/jfonseca@vmware.com/g
s/keithw\?@tungstengraphics.com/keithw@vmware.com/g
s/michel@tungstengraphics.com/daenzer@vmware.com/g
s/thomas-at-tungstengraphics-dot-com/thellstom-at-vmware-dot-com/
s/zack@tungstengraphics.com/zackr@vmware.com/
# Remove dead links
s@Tungsten Graphics (http://www.tungstengraphics.com)@Tungsten Graphics@g
# C string src/gallium/state_trackers/vega/api_misc.c
s/"Tungsten Graphics, Inc"/"VMware, Inc"/
Reviewed-by: Brian Paul <brianp@vmware.com>
2014-01-17 16:27:50 +00:00
|
|
|
* IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
|
2009-07-26 23:44:38 +01:00
|
|
|
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
|
|
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
|
|
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
|
|
*
|
|
|
|
**************************************************************************/
|
|
|
|
|
|
|
|
#include "util/u_math.h"
|
|
|
|
#include "util/u_memory.h"
|
|
|
|
#include "pipe/p_shader_tokens.h"
|
|
|
|
#include "draw/draw_context.h"
|
|
|
|
#include "draw/draw_vertex.h"
|
|
|
|
#include "draw/draw_private.h"
|
|
|
|
#include "lp_context.h"
|
2009-07-17 10:44:22 +01:00
|
|
|
#include "lp_screen.h"
|
2009-10-09 13:41:33 +01:00
|
|
|
#include "lp_setup.h"
|
2009-07-26 23:44:38 +01:00
|
|
|
#include "lp_state.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The vertex info describes how to convert the post-transformed vertices
|
|
|
|
* (simple float[][4]) used by the 'draw' module into vertices for
|
|
|
|
* rasterization.
|
|
|
|
*
|
2010-01-06 17:00:26 +00:00
|
|
|
* This function validates the vertex layout.
|
2009-07-26 23:44:38 +01:00
|
|
|
*/
|
2010-01-06 16:44:43 +00:00
|
|
|
static void
|
|
|
|
compute_vertex_info(struct llvmpipe_context *llvmpipe)
|
2009-07-26 23:44:38 +01:00
|
|
|
{
|
2015-12-19 05:12:27 +00:00
|
|
|
const struct tgsi_shader_info *fsInfo = &llvmpipe->fs->info.base;
|
2010-01-06 17:00:26 +00:00
|
|
|
struct vertex_info *vinfo = &llvmpipe->vertex_info;
|
2013-05-24 21:39:59 +01:00
|
|
|
int vs_index;
|
2010-01-06 16:44:43 +00:00
|
|
|
uint i;
|
|
|
|
|
2013-07-31 12:34:49 +01:00
|
|
|
draw_prepare_shader_outputs(llvmpipe->draw);
|
|
|
|
|
2015-12-19 05:12:27 +00:00
|
|
|
/*
|
|
|
|
* Those can't actually be 0 (because pos is always at 0).
|
|
|
|
* But use ints anyway to avoid confusion (in vs outputs, they
|
|
|
|
* can very well be at pos 0).
|
|
|
|
*/
|
|
|
|
llvmpipe->color_slot[0] = -1;
|
|
|
|
llvmpipe->color_slot[1] = -1;
|
|
|
|
llvmpipe->bcolor_slot[0] = -1;
|
|
|
|
llvmpipe->bcolor_slot[1] = -1;
|
|
|
|
llvmpipe->viewport_index_slot = -1;
|
|
|
|
llvmpipe->layer_slot = -1;
|
|
|
|
llvmpipe->face_slot = -1;
|
|
|
|
llvmpipe->psize_slot = -1;
|
2010-11-19 16:17:36 +00:00
|
|
|
|
2010-04-18 09:34:01 +01:00
|
|
|
/*
|
2010-09-05 13:17:43 +01:00
|
|
|
* Match FS inputs against VS outputs, emitting the necessary
|
|
|
|
* attributes. Could cache these structs and look them up with a
|
|
|
|
* combination of fragment shader, vertex shader ids.
|
2010-01-06 16:44:43 +00:00
|
|
|
*/
|
2009-09-17 16:05:08 +01:00
|
|
|
|
2010-04-18 09:34:01 +01:00
|
|
|
vinfo->num_attribs = 0;
|
2009-07-26 23:44:38 +01:00
|
|
|
|
2010-04-18 09:34:01 +01:00
|
|
|
vs_index = draw_find_shader_output(llvmpipe->draw,
|
2015-12-19 05:12:27 +00:00
|
|
|
TGSI_SEMANTIC_POSITION, 0);
|
2010-04-18 09:34:01 +01:00
|
|
|
|
2015-12-19 02:43:14 +00:00
|
|
|
draw_emit_vertex_attr(vinfo, EMIT_4F, vs_index);
|
2010-04-18 09:34:01 +01:00
|
|
|
|
2015-12-19 05:12:27 +00:00
|
|
|
for (i = 0; i < fsInfo->num_inputs; i++) {
|
2010-04-18 09:34:01 +01:00
|
|
|
/*
|
|
|
|
* Search for each input in current vs output:
|
|
|
|
*/
|
|
|
|
vs_index = draw_find_shader_output(llvmpipe->draw,
|
2015-12-19 05:12:27 +00:00
|
|
|
fsInfo->input_semantic_name[i],
|
|
|
|
fsInfo->input_semantic_index[i]);
|
2010-11-19 16:17:36 +00:00
|
|
|
|
2015-12-19 05:12:27 +00:00
|
|
|
if (fsInfo->input_semantic_name[i] == TGSI_SEMANTIC_COLOR &&
|
|
|
|
fsInfo->input_semantic_index[i] < 2) {
|
|
|
|
int idx = fsInfo->input_semantic_index[i];
|
|
|
|
llvmpipe->color_slot[idx] = (int)vinfo->num_attribs;
|
2010-10-29 00:47:13 +01:00
|
|
|
}
|
2010-11-19 16:17:36 +00:00
|
|
|
|
2015-12-19 05:12:27 +00:00
|
|
|
if (fsInfo->input_semantic_name[i] == TGSI_SEMANTIC_FACE) {
|
|
|
|
llvmpipe->face_slot = (int)vinfo->num_attribs;
|
2015-12-19 02:43:14 +00:00
|
|
|
draw_emit_vertex_attr(vinfo, EMIT_4F, vs_index);
|
llvmpipe: fix layer/vp input into fs when not written by prior stages
ARB_fragment_layer_viewport requires that if a fs reads layer or viewport
index but it wasn't output by gs (or vs with other extensions), then it reads
0. This never worked for llvmpipe, and is surprisingly non-trivial to fix.
The problem is the mechanism to handle non-existing outputs in draw is rather
crude, it will simply redirect them to whatever is at output 0, thus later
stages will just get garbage. So, rather than trying to fix this up (which
looks non-trivial), fix this up in llvmpipe setup by detecting this case there
and output a fixed zero directly.
While here, also optimize the hw vertex layout a bit - previously if the gs
outputted layer (or vp) and the fs read those inputs, we'd add them twice
to the vertex layout, which is unnecessary.
And do some minor cleanup, slots don't require that many bits, there was some
bogus (but harmless) float/int mixup for psize slot too, make the slots all
unsigned (we always put pos at pos zero thus everything else has to be positive
if it exists), and make sure they are properly initialized (layer and vp index
slot were not which looked fishy as they might not have got set back to zero
when changing from a gs which outputs them to one which does not).
This fixes the failures in piglit's arb_fragment_layer_viewport group
(3 each for layer and vp).
Reviewed-by: Jose Fonseca <jfonseca@vmware.com>
2015-12-09 03:56:15 +00:00
|
|
|
/*
|
|
|
|
* For vp index and layer, if the fs requires them but the vs doesn't
|
2015-12-18 20:44:06 +00:00
|
|
|
* provide them, draw (vbuf) will give us the required 0 (slot -1).
|
|
|
|
* (This means in this case we'll also use those slots in setup, which
|
|
|
|
* isn't necessary but they'll contain the correct (0) value.)
|
llvmpipe: fix layer/vp input into fs when not written by prior stages
ARB_fragment_layer_viewport requires that if a fs reads layer or viewport
index but it wasn't output by gs (or vs with other extensions), then it reads
0. This never worked for llvmpipe, and is surprisingly non-trivial to fix.
The problem is the mechanism to handle non-existing outputs in draw is rather
crude, it will simply redirect them to whatever is at output 0, thus later
stages will just get garbage. So, rather than trying to fix this up (which
looks non-trivial), fix this up in llvmpipe setup by detecting this case there
and output a fixed zero directly.
While here, also optimize the hw vertex layout a bit - previously if the gs
outputted layer (or vp) and the fs read those inputs, we'd add them twice
to the vertex layout, which is unnecessary.
And do some minor cleanup, slots don't require that many bits, there was some
bogus (but harmless) float/int mixup for psize slot too, make the slots all
unsigned (we always put pos at pos zero thus everything else has to be positive
if it exists), and make sure they are properly initialized (layer and vp index
slot were not which looked fishy as they might not have got set back to zero
when changing from a gs which outputs them to one which does not).
This fixes the failures in piglit's arb_fragment_layer_viewport group
(3 each for layer and vp).
Reviewed-by: Jose Fonseca <jfonseca@vmware.com>
2015-12-09 03:56:15 +00:00
|
|
|
*/
|
2015-12-19 05:12:27 +00:00
|
|
|
} else if (fsInfo->input_semantic_name[i] ==
|
llvmpipe: fix layer/vp input into fs when not written by prior stages
ARB_fragment_layer_viewport requires that if a fs reads layer or viewport
index but it wasn't output by gs (or vs with other extensions), then it reads
0. This never worked for llvmpipe, and is surprisingly non-trivial to fix.
The problem is the mechanism to handle non-existing outputs in draw is rather
crude, it will simply redirect them to whatever is at output 0, thus later
stages will just get garbage. So, rather than trying to fix this up (which
looks non-trivial), fix this up in llvmpipe setup by detecting this case there
and output a fixed zero directly.
While here, also optimize the hw vertex layout a bit - previously if the gs
outputted layer (or vp) and the fs read those inputs, we'd add them twice
to the vertex layout, which is unnecessary.
And do some minor cleanup, slots don't require that many bits, there was some
bogus (but harmless) float/int mixup for psize slot too, make the slots all
unsigned (we always put pos at pos zero thus everything else has to be positive
if it exists), and make sure they are properly initialized (layer and vp index
slot were not which looked fishy as they might not have got set back to zero
when changing from a gs which outputs them to one which does not).
This fixes the failures in piglit's arb_fragment_layer_viewport group
(3 each for layer and vp).
Reviewed-by: Jose Fonseca <jfonseca@vmware.com>
2015-12-09 03:56:15 +00:00
|
|
|
TGSI_SEMANTIC_VIEWPORT_INDEX) {
|
2015-12-19 05:12:27 +00:00
|
|
|
llvmpipe->viewport_index_slot = (int)vinfo->num_attribs;
|
2015-12-19 02:43:14 +00:00
|
|
|
draw_emit_vertex_attr(vinfo, EMIT_4F, vs_index);
|
2015-12-19 05:12:27 +00:00
|
|
|
} else if (fsInfo->input_semantic_name[i] == TGSI_SEMANTIC_LAYER) {
|
|
|
|
llvmpipe->layer_slot = (int)vinfo->num_attribs;
|
2015-12-19 02:43:14 +00:00
|
|
|
draw_emit_vertex_attr(vinfo, EMIT_4F, vs_index);
|
2013-08-02 06:53:15 +01:00
|
|
|
} else {
|
|
|
|
/*
|
2015-12-19 05:12:27 +00:00
|
|
|
* Note that we'd actually want to skip position (as we won't use
|
|
|
|
* the attribute in the fs) but can't. The reason is that we don't
|
Remove wrongly repeated words in comments
Clean up misrepetitions ('if if', 'the the' etc) found throughout the
comments. This has been done manually, after grepping
case-insensitively for duplicate if, is, the, then, do, for, an,
plus a few other typos corrected in fly-by
v2:
* proper commit message and non-joke title;
* replace two 'as is' followed by 'is' to 'as-is'.
v3:
* 'a integer' => 'an integer' and similar (originally spotted by
Jason Ekstrand, I fixed a few other similar ones while at it)
Signed-off-by: Giuseppe Bilotta <giuseppe.bilotta@gmail.com>
Reviewed-by: Chad Versace <chad.versace@intel.com>
2016-06-23 18:20:18 +01:00
|
|
|
* actually have an input/output map for setup (even though it looks
|
2015-12-19 05:12:27 +00:00
|
|
|
* like we do...). Could adjust for this though even without a map
|
|
|
|
* (in llvmpipe_create_fs_state()).
|
2013-08-02 06:53:15 +01:00
|
|
|
*/
|
2015-12-19 02:43:14 +00:00
|
|
|
draw_emit_vertex_attr(vinfo, EMIT_4F, vs_index);
|
2013-08-02 06:53:15 +01:00
|
|
|
}
|
2010-01-06 16:44:43 +00:00
|
|
|
}
|
llvmpipe: fix layer/vp input into fs when not written by prior stages
ARB_fragment_layer_viewport requires that if a fs reads layer or viewport
index but it wasn't output by gs (or vs with other extensions), then it reads
0. This never worked for llvmpipe, and is surprisingly non-trivial to fix.
The problem is the mechanism to handle non-existing outputs in draw is rather
crude, it will simply redirect them to whatever is at output 0, thus later
stages will just get garbage. So, rather than trying to fix this up (which
looks non-trivial), fix this up in llvmpipe setup by detecting this case there
and output a fixed zero directly.
While here, also optimize the hw vertex layout a bit - previously if the gs
outputted layer (or vp) and the fs read those inputs, we'd add them twice
to the vertex layout, which is unnecessary.
And do some minor cleanup, slots don't require that many bits, there was some
bogus (but harmless) float/int mixup for psize slot too, make the slots all
unsigned (we always put pos at pos zero thus everything else has to be positive
if it exists), and make sure they are properly initialized (layer and vp index
slot were not which looked fishy as they might not have got set back to zero
when changing from a gs which outputs them to one which does not).
This fixes the failures in piglit's arb_fragment_layer_viewport group
(3 each for layer and vp).
Reviewed-by: Jose Fonseca <jfonseca@vmware.com>
2015-12-09 03:56:15 +00:00
|
|
|
|
2010-10-29 00:47:13 +01:00
|
|
|
/* Figure out if we need bcolor as well.
|
|
|
|
*/
|
2010-11-19 16:17:36 +00:00
|
|
|
for (i = 0; i < 2; i++) {
|
|
|
|
vs_index = draw_find_shader_output(llvmpipe->draw,
|
|
|
|
TGSI_SEMANTIC_BCOLOR, i);
|
2010-10-29 00:47:13 +01:00
|
|
|
|
2013-05-24 21:39:59 +01:00
|
|
|
if (vs_index >= 0) {
|
2015-12-19 05:12:27 +00:00
|
|
|
llvmpipe->bcolor_slot[i] = (int)vinfo->num_attribs;
|
2015-12-19 02:43:14 +00:00
|
|
|
draw_emit_vertex_attr(vinfo, EMIT_4F, vs_index);
|
2010-11-19 16:17:36 +00:00
|
|
|
}
|
2010-10-29 00:47:13 +01:00
|
|
|
}
|
|
|
|
|
2010-08-27 10:37:09 +01:00
|
|
|
/* Figure out if we need pointsize as well.
|
|
|
|
*/
|
2010-08-10 11:41:32 +01:00
|
|
|
vs_index = draw_find_shader_output(llvmpipe->draw,
|
|
|
|
TGSI_SEMANTIC_PSIZE, 0);
|
|
|
|
|
2013-05-24 21:39:59 +01:00
|
|
|
if (vs_index >= 0) {
|
2015-12-19 05:12:27 +00:00
|
|
|
llvmpipe->psize_slot = (int)vinfo->num_attribs;
|
2015-12-19 02:43:14 +00:00
|
|
|
draw_emit_vertex_attr(vinfo, EMIT_4F, vs_index);
|
2010-08-27 10:37:09 +01:00
|
|
|
}
|
|
|
|
|
llvmpipe: fix layer/vp input into fs when not written by prior stages
ARB_fragment_layer_viewport requires that if a fs reads layer or viewport
index but it wasn't output by gs (or vs with other extensions), then it reads
0. This never worked for llvmpipe, and is surprisingly non-trivial to fix.
The problem is the mechanism to handle non-existing outputs in draw is rather
crude, it will simply redirect them to whatever is at output 0, thus later
stages will just get garbage. So, rather than trying to fix this up (which
looks non-trivial), fix this up in llvmpipe setup by detecting this case there
and output a fixed zero directly.
While here, also optimize the hw vertex layout a bit - previously if the gs
outputted layer (or vp) and the fs read those inputs, we'd add them twice
to the vertex layout, which is unnecessary.
And do some minor cleanup, slots don't require that many bits, there was some
bogus (but harmless) float/int mixup for psize slot too, make the slots all
unsigned (we always put pos at pos zero thus everything else has to be positive
if it exists), and make sure they are properly initialized (layer and vp index
slot were not which looked fishy as they might not have got set back to zero
when changing from a gs which outputs them to one which does not).
This fixes the failures in piglit's arb_fragment_layer_viewport group
(3 each for layer and vp).
Reviewed-by: Jose Fonseca <jfonseca@vmware.com>
2015-12-09 03:56:15 +00:00
|
|
|
/* Figure out if we need viewport index (if it wasn't already in fs input) */
|
2015-12-19 05:12:27 +00:00
|
|
|
if (llvmpipe->viewport_index_slot < 0) {
|
llvmpipe: fix layer/vp input into fs when not written by prior stages
ARB_fragment_layer_viewport requires that if a fs reads layer or viewport
index but it wasn't output by gs (or vs with other extensions), then it reads
0. This never worked for llvmpipe, and is surprisingly non-trivial to fix.
The problem is the mechanism to handle non-existing outputs in draw is rather
crude, it will simply redirect them to whatever is at output 0, thus later
stages will just get garbage. So, rather than trying to fix this up (which
looks non-trivial), fix this up in llvmpipe setup by detecting this case there
and output a fixed zero directly.
While here, also optimize the hw vertex layout a bit - previously if the gs
outputted layer (or vp) and the fs read those inputs, we'd add them twice
to the vertex layout, which is unnecessary.
And do some minor cleanup, slots don't require that many bits, there was some
bogus (but harmless) float/int mixup for psize slot too, make the slots all
unsigned (we always put pos at pos zero thus everything else has to be positive
if it exists), and make sure they are properly initialized (layer and vp index
slot were not which looked fishy as they might not have got set back to zero
when changing from a gs which outputs them to one which does not).
This fixes the failures in piglit's arb_fragment_layer_viewport group
(3 each for layer and vp).
Reviewed-by: Jose Fonseca <jfonseca@vmware.com>
2015-12-09 03:56:15 +00:00
|
|
|
vs_index = draw_find_shader_output(llvmpipe->draw,
|
|
|
|
TGSI_SEMANTIC_VIEWPORT_INDEX,
|
|
|
|
0);
|
|
|
|
if (vs_index >= 0) {
|
2015-12-19 05:12:27 +00:00
|
|
|
llvmpipe->viewport_index_slot =(int)vinfo->num_attribs;
|
2015-12-19 02:43:14 +00:00
|
|
|
draw_emit_vertex_attr(vinfo, EMIT_4F, vs_index);
|
llvmpipe: fix layer/vp input into fs when not written by prior stages
ARB_fragment_layer_viewport requires that if a fs reads layer or viewport
index but it wasn't output by gs (or vs with other extensions), then it reads
0. This never worked for llvmpipe, and is surprisingly non-trivial to fix.
The problem is the mechanism to handle non-existing outputs in draw is rather
crude, it will simply redirect them to whatever is at output 0, thus later
stages will just get garbage. So, rather than trying to fix this up (which
looks non-trivial), fix this up in llvmpipe setup by detecting this case there
and output a fixed zero directly.
While here, also optimize the hw vertex layout a bit - previously if the gs
outputted layer (or vp) and the fs read those inputs, we'd add them twice
to the vertex layout, which is unnecessary.
And do some minor cleanup, slots don't require that many bits, there was some
bogus (but harmless) float/int mixup for psize slot too, make the slots all
unsigned (we always put pos at pos zero thus everything else has to be positive
if it exists), and make sure they are properly initialized (layer and vp index
slot were not which looked fishy as they might not have got set back to zero
when changing from a gs which outputs them to one which does not).
This fixes the failures in piglit's arb_fragment_layer_viewport group
(3 each for layer and vp).
Reviewed-by: Jose Fonseca <jfonseca@vmware.com>
2015-12-09 03:56:15 +00:00
|
|
|
}
|
2013-05-24 21:28:19 +01:00
|
|
|
}
|
2013-06-07 20:03:40 +01:00
|
|
|
|
llvmpipe: fix layer/vp input into fs when not written by prior stages
ARB_fragment_layer_viewport requires that if a fs reads layer or viewport
index but it wasn't output by gs (or vs with other extensions), then it reads
0. This never worked for llvmpipe, and is surprisingly non-trivial to fix.
The problem is the mechanism to handle non-existing outputs in draw is rather
crude, it will simply redirect them to whatever is at output 0, thus later
stages will just get garbage. So, rather than trying to fix this up (which
looks non-trivial), fix this up in llvmpipe setup by detecting this case there
and output a fixed zero directly.
While here, also optimize the hw vertex layout a bit - previously if the gs
outputted layer (or vp) and the fs read those inputs, we'd add them twice
to the vertex layout, which is unnecessary.
And do some minor cleanup, slots don't require that many bits, there was some
bogus (but harmless) float/int mixup for psize slot too, make the slots all
unsigned (we always put pos at pos zero thus everything else has to be positive
if it exists), and make sure they are properly initialized (layer and vp index
slot were not which looked fishy as they might not have got set back to zero
when changing from a gs which outputs them to one which does not).
This fixes the failures in piglit's arb_fragment_layer_viewport group
(3 each for layer and vp).
Reviewed-by: Jose Fonseca <jfonseca@vmware.com>
2015-12-09 03:56:15 +00:00
|
|
|
/* Figure out if we need layer (if it wasn't already in fs input) */
|
2015-12-19 05:12:27 +00:00
|
|
|
if (llvmpipe->layer_slot < 0) {
|
llvmpipe: fix layer/vp input into fs when not written by prior stages
ARB_fragment_layer_viewport requires that if a fs reads layer or viewport
index but it wasn't output by gs (or vs with other extensions), then it reads
0. This never worked for llvmpipe, and is surprisingly non-trivial to fix.
The problem is the mechanism to handle non-existing outputs in draw is rather
crude, it will simply redirect them to whatever is at output 0, thus later
stages will just get garbage. So, rather than trying to fix this up (which
looks non-trivial), fix this up in llvmpipe setup by detecting this case there
and output a fixed zero directly.
While here, also optimize the hw vertex layout a bit - previously if the gs
outputted layer (or vp) and the fs read those inputs, we'd add them twice
to the vertex layout, which is unnecessary.
And do some minor cleanup, slots don't require that many bits, there was some
bogus (but harmless) float/int mixup for psize slot too, make the slots all
unsigned (we always put pos at pos zero thus everything else has to be positive
if it exists), and make sure they are properly initialized (layer and vp index
slot were not which looked fishy as they might not have got set back to zero
when changing from a gs which outputs them to one which does not).
This fixes the failures in piglit's arb_fragment_layer_viewport group
(3 each for layer and vp).
Reviewed-by: Jose Fonseca <jfonseca@vmware.com>
2015-12-09 03:56:15 +00:00
|
|
|
vs_index = draw_find_shader_output(llvmpipe->draw,
|
|
|
|
TGSI_SEMANTIC_LAYER,
|
|
|
|
0);
|
|
|
|
if (vs_index >= 0) {
|
2015-12-19 05:12:27 +00:00
|
|
|
llvmpipe->layer_slot = (int)vinfo->num_attribs;
|
2015-12-19 02:43:14 +00:00
|
|
|
draw_emit_vertex_attr(vinfo, EMIT_4F, vs_index);
|
llvmpipe: fix layer/vp input into fs when not written by prior stages
ARB_fragment_layer_viewport requires that if a fs reads layer or viewport
index but it wasn't output by gs (or vs with other extensions), then it reads
0. This never worked for llvmpipe, and is surprisingly non-trivial to fix.
The problem is the mechanism to handle non-existing outputs in draw is rather
crude, it will simply redirect them to whatever is at output 0, thus later
stages will just get garbage. So, rather than trying to fix this up (which
looks non-trivial), fix this up in llvmpipe setup by detecting this case there
and output a fixed zero directly.
While here, also optimize the hw vertex layout a bit - previously if the gs
outputted layer (or vp) and the fs read those inputs, we'd add them twice
to the vertex layout, which is unnecessary.
And do some minor cleanup, slots don't require that many bits, there was some
bogus (but harmless) float/int mixup for psize slot too, make the slots all
unsigned (we always put pos at pos zero thus everything else has to be positive
if it exists), and make sure they are properly initialized (layer and vp index
slot were not which looked fishy as they might not have got set back to zero
when changing from a gs which outputs them to one which does not).
This fixes the failures in piglit's arb_fragment_layer_viewport group
(3 each for layer and vp).
Reviewed-by: Jose Fonseca <jfonseca@vmware.com>
2015-12-09 03:56:15 +00:00
|
|
|
}
|
2013-06-07 20:03:40 +01:00
|
|
|
}
|
|
|
|
|
2010-04-18 09:34:01 +01:00
|
|
|
draw_compute_vertex_size(vinfo);
|
|
|
|
lp_setup_set_vertex_info(llvmpipe->setup, vinfo);
|
2009-07-26 23:44:38 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-01-13 17:58:13 +00:00
|
|
|
/**
|
|
|
|
* Handle state changes.
|
|
|
|
* Called just prior to drawing anything (pipe::draw_arrays(), etc).
|
|
|
|
*
|
|
|
|
* Hopefully this will remain quite simple, otherwise need to pull in
|
2009-07-26 23:44:38 +01:00
|
|
|
* something like the state tracker mechanism.
|
|
|
|
*/
|
|
|
|
void llvmpipe_update_derived( struct llvmpipe_context *llvmpipe )
|
|
|
|
{
|
2009-07-17 10:44:22 +01:00
|
|
|
struct llvmpipe_screen *lp_screen = llvmpipe_screen(llvmpipe->pipe.screen);
|
|
|
|
|
|
|
|
/* Check for updated textures.
|
|
|
|
*/
|
|
|
|
if (llvmpipe->tex_timestamp != lp_screen->timestamp) {
|
|
|
|
llvmpipe->tex_timestamp = lp_screen->timestamp;
|
2009-12-10 08:23:15 +00:00
|
|
|
llvmpipe->dirty |= LP_NEW_SAMPLER_VIEW;
|
2009-07-17 10:44:22 +01:00
|
|
|
}
|
2016-01-20 23:04:56 +00:00
|
|
|
|
|
|
|
/* This needs LP_NEW_RASTERIZER because of draw_prepare_shader_outputs(). */
|
|
|
|
if (llvmpipe->dirty & (LP_NEW_RASTERIZER |
|
|
|
|
LP_NEW_FS |
|
2017-05-27 03:34:14 +01:00
|
|
|
LP_NEW_GS |
|
2009-07-27 11:36:24 +01:00
|
|
|
LP_NEW_VS))
|
2015-12-19 02:43:14 +00:00
|
|
|
compute_vertex_info(llvmpipe);
|
2009-07-26 23:44:38 +01:00
|
|
|
|
2009-08-19 20:42:50 +01:00
|
|
|
if (llvmpipe->dirty & (LP_NEW_FS |
|
2012-11-30 17:32:29 +00:00
|
|
|
LP_NEW_FRAMEBUFFER |
|
2009-08-22 12:39:44 +01:00
|
|
|
LP_NEW_BLEND |
|
2010-01-15 02:15:00 +00:00
|
|
|
LP_NEW_SCISSOR |
|
2009-09-07 14:52:39 +01:00
|
|
|
LP_NEW_DEPTH_STENCIL_ALPHA |
|
2010-01-11 12:06:51 +00:00
|
|
|
LP_NEW_RASTERIZER |
|
2009-09-07 14:52:39 +01:00
|
|
|
LP_NEW_SAMPLER |
|
2010-05-06 18:45:42 +01:00
|
|
|
LP_NEW_SAMPLER_VIEW |
|
2012-12-03 07:00:37 +00:00
|
|
|
LP_NEW_OCCLUSION_QUERY))
|
2018-05-22 01:12:38 +01:00
|
|
|
llvmpipe_update_fs(llvmpipe);
|
2009-08-19 20:42:50 +01:00
|
|
|
|
2018-05-22 01:12:38 +01:00
|
|
|
if (llvmpipe->dirty & (LP_NEW_FS |
|
|
|
|
LP_NEW_FRAMEBUFFER |
|
|
|
|
LP_NEW_RASTERIZER |
|
|
|
|
LP_NEW_DEPTH_STENCIL_ALPHA)) {
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Rasterization is disabled if there is no pixel shader and
|
|
|
|
* both depth and stencil testing are disabled:
|
|
|
|
* http://msdn.microsoft.com/en-us/library/windows/desktop/bb205125
|
|
|
|
* FIXME: set rasterizer_discard in state tracker instead.
|
|
|
|
*/
|
|
|
|
boolean null_fs = !llvmpipe->fs ||
|
|
|
|
llvmpipe->fs->info.base.num_instructions <= 1;
|
2014-01-06 18:45:49 +00:00
|
|
|
boolean discard =
|
|
|
|
(llvmpipe->sample_mask & 1) == 0 ||
|
2018-05-22 01:12:38 +01:00
|
|
|
(llvmpipe->rasterizer ? llvmpipe->rasterizer->rasterizer_discard : FALSE) ||
|
|
|
|
(null_fs &&
|
|
|
|
!llvmpipe->depth_stencil->depth.enabled &&
|
|
|
|
!llvmpipe->depth_stencil->stencil[0].enabled);
|
2014-01-06 18:45:49 +00:00
|
|
|
lp_setup_set_rasterizer_discard(llvmpipe->setup, discard);
|
|
|
|
}
|
|
|
|
|
2010-09-05 13:17:43 +01:00
|
|
|
if (llvmpipe->dirty & (LP_NEW_FS |
|
2013-10-29 20:36:41 +00:00
|
|
|
LP_NEW_FRAMEBUFFER |
|
|
|
|
LP_NEW_RASTERIZER))
|
2010-09-05 13:17:43 +01:00
|
|
|
llvmpipe_update_setup( llvmpipe );
|
|
|
|
|
2009-10-09 13:41:33 +01:00
|
|
|
if (llvmpipe->dirty & LP_NEW_BLEND_COLOR)
|
2010-01-06 16:44:43 +00:00
|
|
|
lp_setup_set_blend_color(llvmpipe->setup,
|
|
|
|
&llvmpipe->blend_color);
|
2009-10-09 13:41:33 +01:00
|
|
|
|
2010-01-15 02:15:00 +00:00
|
|
|
if (llvmpipe->dirty & LP_NEW_SCISSOR)
|
2013-05-24 21:28:19 +01:00
|
|
|
lp_setup_set_scissors(llvmpipe->setup, llvmpipe->scissors);
|
2010-01-15 02:15:00 +00:00
|
|
|
|
2010-03-16 20:00:40 +00:00
|
|
|
if (llvmpipe->dirty & LP_NEW_DEPTH_STENCIL_ALPHA) {
|
2010-01-06 16:44:43 +00:00
|
|
|
lp_setup_set_alpha_ref_value(llvmpipe->setup,
|
|
|
|
llvmpipe->depth_stencil->alpha.ref_value);
|
2010-03-16 20:00:40 +00:00
|
|
|
lp_setup_set_stencil_ref_values(llvmpipe->setup,
|
|
|
|
llvmpipe->stencil_ref.ref_value);
|
|
|
|
}
|
2009-10-09 13:41:33 +01:00
|
|
|
|
2016-06-13 16:49:01 +01:00
|
|
|
if (llvmpipe->dirty & LP_NEW_FS_CONSTANTS)
|
2012-12-04 14:52:44 +00:00
|
|
|
lp_setup_set_fs_constants(llvmpipe->setup,
|
2016-04-25 23:00:31 +01:00
|
|
|
ARRAY_SIZE(llvmpipe->constants[PIPE_SHADER_FRAGMENT]),
|
2012-12-04 14:52:44 +00:00
|
|
|
llvmpipe->constants[PIPE_SHADER_FRAGMENT]);
|
2009-10-09 13:41:33 +01:00
|
|
|
|
2010-09-29 12:05:19 +01:00
|
|
|
if (llvmpipe->dirty & (LP_NEW_SAMPLER_VIEW))
|
2010-06-14 15:18:09 +01:00
|
|
|
lp_setup_set_fragment_sampler_views(llvmpipe->setup,
|
2012-08-04 15:46:42 +01:00
|
|
|
llvmpipe->num_sampler_views[PIPE_SHADER_FRAGMENT],
|
|
|
|
llvmpipe->sampler_views[PIPE_SHADER_FRAGMENT]);
|
2009-08-19 20:42:50 +01:00
|
|
|
|
2010-09-29 12:05:19 +01:00
|
|
|
if (llvmpipe->dirty & (LP_NEW_SAMPLER))
|
|
|
|
lp_setup_set_fragment_sampler_state(llvmpipe->setup,
|
2012-08-04 15:46:42 +01:00
|
|
|
llvmpipe->num_samplers[PIPE_SHADER_FRAGMENT],
|
|
|
|
llvmpipe->samplers[PIPE_SHADER_FRAGMENT]);
|
2009-08-19 20:42:50 +01:00
|
|
|
|
2013-11-26 18:50:27 +00:00
|
|
|
if (llvmpipe->dirty & LP_NEW_VIEWPORT) {
|
|
|
|
/*
|
|
|
|
* Update setup and fragment's view of the active viewport state.
|
|
|
|
*
|
|
|
|
* XXX TODO: It is possible to only loop over the active viewports
|
|
|
|
* instead of all viewports (PIPE_MAX_VIEWPORTS).
|
|
|
|
*/
|
|
|
|
lp_setup_set_viewports(llvmpipe->setup,
|
|
|
|
PIPE_MAX_VIEWPORTS,
|
|
|
|
llvmpipe->viewports);
|
|
|
|
}
|
|
|
|
|
2009-07-26 23:44:38 +01:00
|
|
|
llvmpipe->dirty = 0;
|
|
|
|
}
|
2009-10-08 11:47:33 +01:00
|
|
|
|