2007-09-25 14:21:18 -06: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.
|
2007-09-25 14:21:18 -06: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
|
2007-09-25 14:21:18 -06: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.
|
|
|
|
*
|
|
|
|
**************************************************************************/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* State validation for vertex/fragment shaders.
|
|
|
|
* Note that we have to delay most vertex/fragment shader translation
|
|
|
|
* until rendering time since the linkage between the vertex outputs and
|
|
|
|
* fragment inputs can vary depending on the pairing of shaders.
|
|
|
|
*
|
|
|
|
* Authors:
|
|
|
|
* Brian Paul
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "main/imports.h"
|
|
|
|
#include "main/mtypes.h"
|
2016-02-27 11:01:27 -05:00
|
|
|
#include "main/framebuffer.h"
|
2010-06-10 23:02:41 -06:00
|
|
|
#include "program/program.h"
|
2007-09-25 14:21:18 -06:00
|
|
|
|
|
|
|
#include "pipe/p_context.h"
|
2015-03-18 12:38:19 +01:00
|
|
|
#include "pipe/p_shader_tokens.h"
|
2008-05-07 16:44:33 -06:00
|
|
|
#include "util/u_simple_shaders.h"
|
2008-03-11 18:54:31 -06:00
|
|
|
#include "cso_cache/cso_context.h"
|
2008-01-14 19:12:46 -07:00
|
|
|
|
2007-09-25 14:21:18 -06:00
|
|
|
#include "st_context.h"
|
|
|
|
#include "st_atom.h"
|
|
|
|
#include "st_program.h"
|
|
|
|
|
|
|
|
|
2010-01-11 19:04:11 -07:00
|
|
|
/**
|
|
|
|
* Update fragment program state/atom. This involves translating the
|
|
|
|
* Mesa fragment program into a gallium fragment program and binding it.
|
|
|
|
*/
|
2007-09-25 14:21:18 -06:00
|
|
|
static void
|
2009-11-15 11:15:25 -08:00
|
|
|
update_fp( struct st_context *st )
|
2007-09-25 14:21:18 -06:00
|
|
|
{
|
|
|
|
struct st_fragment_program *stfp;
|
2010-12-16 08:43:21 -07:00
|
|
|
struct st_fp_variant_key key;
|
2007-09-25 14:21:18 -06:00
|
|
|
|
2007-10-29 09:24:29 -06:00
|
|
|
assert(st->ctx->FragmentProgram._Current);
|
|
|
|
stfp = st_fragment_program(st->ctx->FragmentProgram._Current);
|
2008-05-07 08:55:33 -06:00
|
|
|
assert(stfp->Base.Base.Target == GL_FRAGMENT_PROGRAM_ARB);
|
2007-09-25 14:21:18 -06:00
|
|
|
|
2010-12-13 17:20:12 -07:00
|
|
|
memset(&key, 0, sizeof(key));
|
2015-09-27 23:36:59 +02:00
|
|
|
key.st = st->has_shareable_shaders ? NULL : st;
|
2010-12-13 17:20:12 -07:00
|
|
|
|
2012-01-23 03:11:17 +01:00
|
|
|
/* _NEW_FRAG_CLAMP */
|
|
|
|
key.clamp_color = st->clamp_frag_color_in_shader &&
|
2013-03-28 01:56:01 +01:00
|
|
|
st->ctx->Color._ClampFragmentColor;
|
2012-01-23 03:11:17 +01:00
|
|
|
|
2016-02-27 11:01:27 -05:00
|
|
|
/* _NEW_MULTISAMPLE | _NEW_BUFFERS */
|
2014-07-04 23:01:39 -04:00
|
|
|
key.persample_shading =
|
2015-10-20 00:12:53 +02:00
|
|
|
st->force_persample_in_shader &&
|
2016-03-24 08:30:09 -06:00
|
|
|
_mesa_is_multisample_enabled(st->ctx) &&
|
2016-02-27 11:01:27 -05:00
|
|
|
st->ctx->Multisample.SampleShading &&
|
|
|
|
st->ctx->Multisample.MinSampleShadingValue *
|
|
|
|
_mesa_geometric_samples(st->ctx->DrawBuffer) > 1;
|
2014-07-04 23:01:39 -04:00
|
|
|
|
2010-12-16 08:43:21 -07:00
|
|
|
st->fp_variant = st_get_fp_variant(st, stfp, &key);
|
2007-09-25 14:21:18 -06:00
|
|
|
|
2008-05-07 08:55:33 -06:00
|
|
|
st_reference_fragprog(st, &st->fp, stfp);
|
2008-03-11 18:54:31 -06:00
|
|
|
|
2015-07-28 20:41:16 +02:00
|
|
|
cso_set_fragment_shader_handle(st->cso_context,
|
|
|
|
st->fp_variant->driver_shader);
|
2009-11-15 11:15:25 -08:00
|
|
|
}
|
|
|
|
|
2010-01-11 19:04:11 -07:00
|
|
|
|
2009-11-15 11:15:25 -08:00
|
|
|
const struct st_tracked_state st_update_fp = {
|
|
|
|
"st_update_fp", /* name */
|
|
|
|
{ /* dirty */
|
2014-07-04 23:01:39 -04:00
|
|
|
_NEW_BUFFERS | _NEW_MULTISAMPLE, /* mesa */
|
2009-11-15 11:15:25 -08:00
|
|
|
ST_NEW_FRAGMENT_PROGRAM /* st */
|
|
|
|
},
|
|
|
|
update_fp /* update */
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
2010-01-11 19:04:11 -07:00
|
|
|
/**
|
|
|
|
* Update vertex program state/atom. This involves translating the
|
|
|
|
* Mesa vertex program into a gallium fragment program and binding it.
|
|
|
|
*/
|
2009-11-15 11:15:25 -08:00
|
|
|
static void
|
|
|
|
update_vp( struct st_context *st )
|
|
|
|
{
|
|
|
|
struct st_vertex_program *stvp;
|
2010-12-16 08:43:21 -07:00
|
|
|
struct st_vp_variant_key key;
|
2009-11-15 11:15:25 -08:00
|
|
|
|
|
|
|
/* find active shader and params -- Should be covered by
|
|
|
|
* ST_NEW_VERTEX_PROGRAM
|
|
|
|
*/
|
|
|
|
assert(st->ctx->VertexProgram._Current);
|
|
|
|
stvp = st_vertex_program(st->ctx->VertexProgram._Current);
|
|
|
|
assert(stvp->Base.Base.Target == GL_VERTEX_PROGRAM_ARB);
|
|
|
|
|
2010-12-13 17:20:12 -07:00
|
|
|
memset(&key, 0, sizeof key);
|
2015-09-27 23:36:59 +02:00
|
|
|
key.st = st->has_shareable_shaders ? NULL : st;
|
2010-12-13 17:20:12 -07:00
|
|
|
|
|
|
|
/* When this is true, we will add an extra input to the vertex
|
|
|
|
* shader translation (for edgeflags), an extra output with
|
|
|
|
* edgeflag semantics, and extend the vertex shader to pass through
|
|
|
|
* the input to the output. We'll need to use similar logic to set
|
|
|
|
* up the extra vertex_element input for edgeflags.
|
|
|
|
*/
|
2014-03-04 01:45:48 +01:00
|
|
|
key.passthrough_edgeflags = st->vertdata_edgeflags;
|
2010-12-13 17:20:12 -07:00
|
|
|
|
2012-01-23 03:11:17 +01:00
|
|
|
key.clamp_color = st->clamp_vert_color_in_shader &&
|
2015-01-11 18:38:03 +01:00
|
|
|
st->ctx->Light._ClampVertexColor &&
|
|
|
|
(stvp->Base.Base.OutputsWritten &
|
|
|
|
(VARYING_SLOT_COL0 |
|
|
|
|
VARYING_SLOT_COL1 |
|
|
|
|
VARYING_SLOT_BFC0 |
|
|
|
|
VARYING_SLOT_BFC1));
|
2012-01-23 03:11:17 +01:00
|
|
|
|
2010-12-16 08:43:21 -07:00
|
|
|
st->vp_variant = st_get_vp_variant(st, stvp, &key);
|
2009-11-15 11:15:25 -08:00
|
|
|
|
|
|
|
st_reference_vertprog(st, &st->vp, stvp);
|
|
|
|
|
|
|
|
cso_set_vertex_shader_handle(st->cso_context,
|
2010-12-16 08:43:21 -07:00
|
|
|
st->vp_variant->driver_shader);
|
2007-09-25 14:21:18 -06:00
|
|
|
|
2009-11-15 11:15:25 -08:00
|
|
|
st->vertex_result_to_slot = stvp->result_to_output;
|
2007-09-25 14:21:18 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-11-15 11:15:25 -08:00
|
|
|
const struct st_tracked_state st_update_vp = {
|
|
|
|
"st_update_vp", /* name */
|
2008-05-02 10:08:03 +00:00
|
|
|
{ /* dirty */
|
2014-03-04 01:45:48 +01:00
|
|
|
0, /* mesa */
|
|
|
|
ST_NEW_VERTEX_PROGRAM /* st */
|
2007-09-25 14:21:18 -06:00
|
|
|
},
|
2010-12-13 17:20:12 -07:00
|
|
|
update_vp /* update */
|
2007-09-25 14:21:18 -06:00
|
|
|
};
|
2010-06-28 17:31:21 -04:00
|
|
|
|
2010-12-13 17:20:12 -07:00
|
|
|
|
|
|
|
|
2010-06-28 17:31:21 -04:00
|
|
|
static void
|
|
|
|
update_gp( struct st_context *st )
|
|
|
|
{
|
|
|
|
struct st_geometry_program *stgp;
|
|
|
|
|
|
|
|
if (!st->ctx->GeometryProgram._Current) {
|
|
|
|
cso_set_geometry_shader_handle(st->cso_context, NULL);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
stgp = st_geometry_program(st->ctx->GeometryProgram._Current);
|
2015-05-28 18:14:29 +02:00
|
|
|
assert(stgp->Base.Base.Target == GL_GEOMETRY_PROGRAM_NV);
|
2010-06-28 17:31:21 -04:00
|
|
|
|
2016-02-11 16:40:54 +01:00
|
|
|
st->gp_variant = st_get_basic_variant(st, PIPE_SHADER_GEOMETRY,
|
|
|
|
&stgp->tgsi, &stgp->variants);
|
2010-06-28 17:31:21 -04:00
|
|
|
|
|
|
|
st_reference_geomprog(st, &st->gp, stgp);
|
|
|
|
|
2010-12-13 17:20:12 -07:00
|
|
|
cso_set_geometry_shader_handle(st->cso_context,
|
2010-12-16 08:43:21 -07:00
|
|
|
st->gp_variant->driver_shader);
|
2010-06-28 17:31:21 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
const struct st_tracked_state st_update_gp = {
|
2010-12-13 17:20:12 -07:00
|
|
|
"st_update_gp", /* name */
|
|
|
|
{ /* dirty */
|
|
|
|
0, /* mesa */
|
|
|
|
ST_NEW_GEOMETRY_PROGRAM /* st */
|
2010-06-28 17:31:21 -04:00
|
|
|
},
|
2010-12-13 17:20:12 -07:00
|
|
|
update_gp /* update */
|
2010-06-28 17:31:21 -04:00
|
|
|
};
|
2014-07-11 22:11:21 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
update_tcp( struct st_context *st )
|
|
|
|
{
|
|
|
|
struct st_tessctrl_program *sttcp;
|
|
|
|
|
|
|
|
if (!st->ctx->TessCtrlProgram._Current) {
|
|
|
|
cso_set_tessctrl_shader_handle(st->cso_context, NULL);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
sttcp = st_tessctrl_program(st->ctx->TessCtrlProgram._Current);
|
|
|
|
assert(sttcp->Base.Base.Target == GL_TESS_CONTROL_PROGRAM_NV);
|
|
|
|
|
2016-02-11 16:40:54 +01:00
|
|
|
st->tcp_variant = st_get_basic_variant(st, PIPE_SHADER_TESS_CTRL,
|
|
|
|
&sttcp->tgsi, &sttcp->variants);
|
2014-07-11 22:11:21 -04:00
|
|
|
|
|
|
|
st_reference_tesscprog(st, &st->tcp, sttcp);
|
|
|
|
|
|
|
|
cso_set_tessctrl_shader_handle(st->cso_context,
|
|
|
|
st->tcp_variant->driver_shader);
|
|
|
|
}
|
|
|
|
|
|
|
|
const struct st_tracked_state st_update_tcp = {
|
|
|
|
"st_update_tcp", /* name */
|
|
|
|
{ /* dirty */
|
|
|
|
0, /* mesa */
|
|
|
|
ST_NEW_TESSCTRL_PROGRAM /* st */
|
|
|
|
},
|
|
|
|
update_tcp /* update */
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
update_tep( struct st_context *st )
|
|
|
|
{
|
|
|
|
struct st_tesseval_program *sttep;
|
|
|
|
|
|
|
|
if (!st->ctx->TessEvalProgram._Current) {
|
|
|
|
cso_set_tesseval_shader_handle(st->cso_context, NULL);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
sttep = st_tesseval_program(st->ctx->TessEvalProgram._Current);
|
|
|
|
assert(sttep->Base.Base.Target == GL_TESS_EVALUATION_PROGRAM_NV);
|
|
|
|
|
2016-02-11 16:40:54 +01:00
|
|
|
st->tep_variant = st_get_basic_variant(st, PIPE_SHADER_TESS_EVAL,
|
|
|
|
&sttep->tgsi, &sttep->variants);
|
2014-07-11 22:11:21 -04:00
|
|
|
|
|
|
|
st_reference_tesseprog(st, &st->tep, sttep);
|
|
|
|
|
|
|
|
cso_set_tesseval_shader_handle(st->cso_context,
|
|
|
|
st->tep_variant->driver_shader);
|
|
|
|
}
|
|
|
|
|
|
|
|
const struct st_tracked_state st_update_tep = {
|
|
|
|
"st_update_tep", /* name */
|
|
|
|
{ /* dirty */
|
|
|
|
0, /* mesa */
|
|
|
|
ST_NEW_TESSEVAL_PROGRAM /* st */
|
|
|
|
},
|
|
|
|
update_tep /* update */
|
|
|
|
};
|
2016-01-07 22:02:43 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
update_cp( struct st_context *st )
|
|
|
|
{
|
|
|
|
struct st_compute_program *stcp;
|
|
|
|
|
|
|
|
if (!st->ctx->ComputeProgram._Current) {
|
|
|
|
cso_set_compute_shader_handle(st->cso_context, NULL);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
stcp = st_compute_program(st->ctx->ComputeProgram._Current);
|
|
|
|
assert(stcp->Base.Base.Target == GL_COMPUTE_PROGRAM_NV);
|
|
|
|
|
|
|
|
st->cp_variant = st_get_cp_variant(st, &stcp->tgsi, &stcp->variants);
|
|
|
|
|
|
|
|
st_reference_compprog(st, &st->cp, stcp);
|
|
|
|
|
|
|
|
cso_set_compute_shader_handle(st->cso_context,
|
|
|
|
st->cp_variant->driver_shader);
|
|
|
|
}
|
|
|
|
|
|
|
|
const struct st_tracked_state st_update_cp = {
|
|
|
|
"st_update_cp", /* name */
|
|
|
|
{ /* dirty */
|
|
|
|
0, /* mesa */
|
|
|
|
ST_NEW_COMPUTE_PROGRAM /* st */
|
|
|
|
},
|
|
|
|
update_cp /* update */
|
|
|
|
};
|