2007-08-07 15:11:20 -06:00
|
|
|
/**************************************************************************
|
2012-01-09 09:30:13 -07:00
|
|
|
*
|
2007-08-07 15:11:20 -06:00
|
|
|
* Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
|
|
|
|
* All Rights Reserved.
|
2012-01-09 09:30:13 -07:00
|
|
|
*
|
2007-08-07 15:11:20 -06:00
|
|
|
* 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:
|
2012-01-09 09:30:13 -07:00
|
|
|
*
|
2007-08-07 15:11:20 -06:00
|
|
|
* The above copyright notice and this permission notice (including the
|
|
|
|
* next paragraph) shall be included in all copies or substantial portions
|
|
|
|
* of the Software.
|
2012-01-09 09:30:13 -07:00
|
|
|
*
|
2007-08-07 15:11:20 -06:00
|
|
|
* 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.
|
|
|
|
* IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
|
|
|
|
* 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.
|
2012-01-09 09:30:13 -07:00
|
|
|
*
|
2007-08-07 15:11:20 -06:00
|
|
|
**************************************************************************/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Authors:
|
|
|
|
* Keith Whitwell <keith@tungstengraphics.com>
|
|
|
|
* Brian Paul
|
|
|
|
*/
|
2012-01-09 09:30:13 -07:00
|
|
|
|
2007-08-07 15:11:20 -06:00
|
|
|
|
2009-12-01 11:19:33 +01:00
|
|
|
#include "main/macros.h"
|
2011-04-20 11:48:31 -07:00
|
|
|
#include "main/mtypes.h"
|
|
|
|
#include "main/samplerobj.h"
|
2012-02-12 16:30:28 -07:00
|
|
|
#include "main/texobj.h"
|
2010-06-10 23:02:41 -06:00
|
|
|
#include "program/prog_instruction.h"
|
2009-12-01 11:19:33 +01:00
|
|
|
|
2007-08-07 15:11:20 -06:00
|
|
|
#include "st_context.h"
|
|
|
|
#include "st_atom.h"
|
2008-02-20 11:20:25 -07:00
|
|
|
#include "st_texture.h"
|
2010-04-24 18:53:55 +10:00
|
|
|
#include "st_format.h"
|
2007-08-07 15:11:20 -06:00
|
|
|
#include "st_cb_texture.h"
|
|
|
|
#include "pipe/p_context.h"
|
2010-07-19 20:46:15 +02:00
|
|
|
#include "util/u_format.h"
|
2010-02-02 14:42:17 +00:00
|
|
|
#include "util/u_inlines.h"
|
2008-04-25 15:23:21 -06:00
|
|
|
#include "cso_cache/cso_context.h"
|
|
|
|
|
2011-01-20 08:38:19 -07:00
|
|
|
|
2010-07-19 20:46:15 +02:00
|
|
|
/**
|
|
|
|
* Combine depth texture mode with "swizzle" so that depth mode swizzling
|
|
|
|
* takes place before texture swizzling, and return the resulting swizzle.
|
|
|
|
* If the format is not a depth format, return "swizzle" unchanged.
|
|
|
|
*
|
|
|
|
* \param format PIPE_FORMAT_*.
|
|
|
|
* \param swizzle Texture swizzle, a bitmask computed using MAKE_SWIZZLE4.
|
2010-08-11 19:04:05 +10:00
|
|
|
* \param depthmode One of GL_LUMINANCE, GL_INTENSITY, GL_ALPHA, GL_RED.
|
2010-07-19 20:46:15 +02:00
|
|
|
*/
|
2011-01-20 08:38:19 -07:00
|
|
|
static GLuint
|
|
|
|
apply_depthmode(enum pipe_format format, GLuint swizzle, GLenum depthmode)
|
2010-07-19 20:46:15 +02:00
|
|
|
{
|
|
|
|
const struct util_format_description *desc =
|
|
|
|
util_format_description(format);
|
|
|
|
unsigned char swiz[4];
|
|
|
|
unsigned i;
|
|
|
|
|
|
|
|
if (desc->colorspace != UTIL_FORMAT_COLORSPACE_ZS ||
|
|
|
|
desc->swizzle[0] == UTIL_FORMAT_SWIZZLE_NONE) {
|
|
|
|
/* Not a depth format. */
|
|
|
|
return swizzle;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < 4; i++)
|
|
|
|
swiz[i] = GET_SWZ(swizzle, i);
|
|
|
|
|
|
|
|
switch (depthmode) {
|
|
|
|
case GL_LUMINANCE:
|
|
|
|
/* Rewrite reads from W to ONE, and reads from XYZ to XXX. */
|
|
|
|
for (i = 0; i < 4; i++)
|
|
|
|
if (swiz[i] == SWIZZLE_W)
|
|
|
|
swiz[i] = SWIZZLE_ONE;
|
|
|
|
else if (swiz[i] < SWIZZLE_W)
|
|
|
|
swiz[i] = SWIZZLE_X;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GL_INTENSITY:
|
|
|
|
/* Rewrite reads from XYZW to XXXX. */
|
|
|
|
for (i = 0; i < 4; i++)
|
|
|
|
if (swiz[i] <= SWIZZLE_W)
|
|
|
|
swiz[i] = SWIZZLE_X;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GL_ALPHA:
|
|
|
|
/* Rewrite reads from W to X, and reads from XYZ to 000. */
|
|
|
|
for (i = 0; i < 4; i++)
|
|
|
|
if (swiz[i] == SWIZZLE_W)
|
|
|
|
swiz[i] = SWIZZLE_X;
|
|
|
|
else if (swiz[i] < SWIZZLE_W)
|
|
|
|
swiz[i] = SWIZZLE_ZERO;
|
|
|
|
break;
|
2010-08-11 19:04:05 +10:00
|
|
|
case GL_RED:
|
|
|
|
/* Rewrite reads W to 1, XYZ to X00 */
|
|
|
|
for (i = 0; i < 4; i++)
|
|
|
|
if (swiz[i] == SWIZZLE_W)
|
|
|
|
swiz[i] = SWIZZLE_ONE;
|
|
|
|
else if (swiz[i] == SWIZZLE_Y || swiz[i] == SWIZZLE_Z)
|
|
|
|
swiz[i] = SWIZZLE_ZERO;
|
|
|
|
break;
|
2010-07-19 20:46:15 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return MAKE_SWIZZLE4(swiz[0], swiz[1], swiz[2], swiz[3]);
|
|
|
|
}
|
|
|
|
|
2011-01-20 08:38:19 -07:00
|
|
|
|
2010-07-19 20:46:15 +02:00
|
|
|
/**
|
|
|
|
* Return TRUE if the swizzling described by "swizzle" and
|
|
|
|
* "depthmode" (for depth textures only) is different from the swizzling
|
|
|
|
* set in the given sampler view.
|
|
|
|
*
|
|
|
|
* \param sv A sampler view.
|
|
|
|
* \param swizzle Texture swizzle, a bitmask computed using MAKE_SWIZZLE4.
|
|
|
|
* \param depthmode One of GL_LUMINANCE, GL_INTENSITY, GL_ALPHA.
|
|
|
|
*/
|
2011-01-20 08:38:19 -07:00
|
|
|
static boolean
|
|
|
|
check_sampler_swizzle(struct pipe_sampler_view *sv,
|
|
|
|
GLuint swizzle, GLenum depthmode)
|
2010-04-27 21:06:44 +10:00
|
|
|
{
|
2010-07-19 20:46:15 +02:00
|
|
|
swizzle = apply_depthmode(sv->texture->format, swizzle, depthmode);
|
|
|
|
|
|
|
|
if ((sv->swizzle_r != GET_SWZ(swizzle, 0)) ||
|
|
|
|
(sv->swizzle_g != GET_SWZ(swizzle, 1)) ||
|
|
|
|
(sv->swizzle_b != GET_SWZ(swizzle, 2)) ||
|
|
|
|
(sv->swizzle_a != GET_SWZ(swizzle, 3)))
|
2011-01-20 08:38:19 -07:00
|
|
|
return TRUE;
|
|
|
|
return FALSE;
|
2010-04-27 21:06:44 +10:00
|
|
|
}
|
|
|
|
|
2011-01-20 08:38:19 -07:00
|
|
|
|
2012-02-13 15:41:57 -07:00
|
|
|
static struct pipe_sampler_view *
|
2010-04-27 21:06:44 +10:00
|
|
|
st_create_texture_sampler_view_from_stobj(struct pipe_context *pipe,
|
2010-04-24 18:53:55 +10:00
|
|
|
struct st_texture_object *stObj,
|
2011-04-10 12:44:46 -06:00
|
|
|
const struct gl_sampler_object *samp,
|
2010-04-24 18:53:55 +10:00
|
|
|
enum pipe_format format)
|
2010-04-27 21:06:44 +10:00
|
|
|
{
|
|
|
|
struct pipe_sampler_view templ;
|
2010-07-19 20:46:15 +02:00
|
|
|
GLuint swizzle = apply_depthmode(stObj->pt->format,
|
|
|
|
stObj->base._Swizzle,
|
mesa: Move DepthMode to texture object
GL_DEPTH_TEXTURE_MODE isn't meant to be part of sampler state based on
compatibility profile specifications.
OpenGL specification 4.1 compatibility 20100725 3.9.2:
"... The values accepted in the pname parameter
are TEXTURE_WRAP_S, TEXTURE_WRAP_T, TEXTURE_WRAP_R, TEXTURE_MIN_-
FILTER, TEXTURE_MAG_FILTER, TEXTURE_BORDER_COLOR, TEXTURE_MIN_-
LOD, TEXTURE_MAX_LOD, TEXTURE_LOD_BIAS, TEXTURE_COMPARE_MODE, and
TEXTURE_COMPARE_FUNC. Texture state listed in table 6.25 but not listed here and
in the sampler state in table 6.26 is not part of the sampler state, and remains in the
texture object."
The list of states is in Table 6.24 "Textures (state per texture
object)" instead of 6.25 mentioned in the specification text.
Same can be found from 3.3 compatibility specification.
Signed-off-by: Pauli Nieminen <pauli.nieminen@linux.intel.com>
Reviewed-by: Brian Paul <brianp@vmware.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
2012-06-12 21:38:46 +03:00
|
|
|
stObj->base.DepthMode);
|
2010-04-27 21:06:44 +10:00
|
|
|
|
|
|
|
u_sampler_view_default_template(&templ,
|
|
|
|
stObj->pt,
|
2010-04-24 18:53:55 +10:00
|
|
|
format);
|
2011-01-17 22:03:30 +01:00
|
|
|
templ.u.tex.first_level = stObj->base.BaseLevel;
|
2010-04-27 21:06:44 +10:00
|
|
|
|
2010-07-19 20:46:15 +02:00
|
|
|
if (swizzle != SWIZZLE_NOOP) {
|
|
|
|
templ.swizzle_r = GET_SWZ(swizzle, 0);
|
|
|
|
templ.swizzle_g = GET_SWZ(swizzle, 1);
|
|
|
|
templ.swizzle_b = GET_SWZ(swizzle, 2);
|
|
|
|
templ.swizzle_a = GET_SWZ(swizzle, 3);
|
2010-04-27 21:06:44 +10:00
|
|
|
}
|
|
|
|
|
|
|
|
return pipe->create_sampler_view(pipe, stObj->pt, &templ);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-02-13 15:41:57 -07:00
|
|
|
static struct pipe_sampler_view *
|
2010-04-27 21:06:44 +10:00
|
|
|
st_get_texture_sampler_view_from_stobj(struct st_texture_object *stObj,
|
2010-04-24 18:53:55 +10:00
|
|
|
struct pipe_context *pipe,
|
2011-04-10 12:44:46 -06:00
|
|
|
const struct gl_sampler_object *samp,
|
2010-04-24 18:53:55 +10:00
|
|
|
enum pipe_format format)
|
2010-04-27 21:06:44 +10:00
|
|
|
{
|
|
|
|
if (!stObj || !stObj->pt) {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!stObj->sampler_view) {
|
2011-01-20 08:38:19 -07:00
|
|
|
stObj->sampler_view =
|
2011-04-10 12:44:46 -06:00
|
|
|
st_create_texture_sampler_view_from_stobj(pipe, stObj, samp, format);
|
2010-04-27 21:06:44 +10:00
|
|
|
}
|
|
|
|
|
|
|
|
return stObj->sampler_view;
|
|
|
|
}
|
2008-04-25 15:23:21 -06:00
|
|
|
|
2012-01-09 09:30:13 -07:00
|
|
|
|
2011-05-14 18:04:08 +10:00
|
|
|
static GLboolean
|
2012-01-09 09:30:13 -07:00
|
|
|
update_single_texture(struct st_context *st,
|
|
|
|
struct pipe_sampler_view **sampler_view,
|
2011-05-14 18:04:08 +10:00
|
|
|
GLuint texUnit)
|
|
|
|
{
|
|
|
|
struct pipe_context *pipe = st->pipe;
|
2011-06-14 09:15:36 -06:00
|
|
|
struct gl_context *ctx = st->ctx;
|
2011-05-14 18:04:08 +10:00
|
|
|
const struct gl_sampler_object *samp;
|
|
|
|
struct gl_texture_object *texObj;
|
|
|
|
struct st_texture_object *stObj;
|
|
|
|
enum pipe_format st_view_format;
|
|
|
|
GLboolean retval;
|
|
|
|
|
2011-06-14 09:15:36 -06:00
|
|
|
samp = _mesa_get_samplerobj(ctx, texUnit);
|
2011-05-14 18:04:08 +10:00
|
|
|
|
2011-06-14 09:15:36 -06:00
|
|
|
texObj = ctx->Texture.Unit[texUnit]._Current;
|
2011-05-14 18:04:08 +10:00
|
|
|
|
|
|
|
if (!texObj) {
|
2012-02-12 16:30:28 -07:00
|
|
|
texObj = _mesa_get_fallback_texture(ctx, TEXTURE_2D_INDEX);
|
2011-05-14 18:04:08 +10:00
|
|
|
samp = &texObj->Sampler;
|
|
|
|
}
|
|
|
|
stObj = st_texture_object(texObj);
|
|
|
|
|
2011-06-14 09:15:36 -06:00
|
|
|
retval = st_finalize_texture(ctx, st->pipe, texObj);
|
2011-05-14 18:04:08 +10:00
|
|
|
if (!retval) {
|
|
|
|
/* out of mem */
|
|
|
|
return GL_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Determine the format of the texture sampler view */
|
|
|
|
st_view_format = stObj->pt->format;
|
|
|
|
{
|
|
|
|
const struct st_texture_image *firstImage =
|
|
|
|
st_texture_image(stObj->base.Image[0][stObj->base.BaseLevel]);
|
|
|
|
const gl_format texFormat = firstImage->base.TexFormat;
|
|
|
|
enum pipe_format firstImageFormat =
|
|
|
|
st_mesa_format_to_pipe_format(texFormat);
|
|
|
|
|
|
|
|
if ((samp->sRGBDecode == GL_SKIP_DECODE_EXT) &&
|
|
|
|
(_mesa_get_format_color_encoding(texFormat) == GL_SRGB)) {
|
2011-07-27 15:49:39 -06:00
|
|
|
/* Don't do sRGB->RGB conversion. Interpret the texture data as
|
|
|
|
* linear values.
|
|
|
|
*/
|
2011-05-14 18:04:08 +10:00
|
|
|
const gl_format linearFormat =
|
|
|
|
_mesa_get_srgb_format_linear(texFormat);
|
|
|
|
firstImageFormat = st_mesa_format_to_pipe_format(linearFormat);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (firstImageFormat != stObj->pt->format)
|
|
|
|
st_view_format = firstImageFormat;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* if sampler view has changed dereference it */
|
|
|
|
if (stObj->sampler_view) {
|
|
|
|
if (check_sampler_swizzle(stObj->sampler_view,
|
|
|
|
stObj->base._Swizzle,
|
mesa: Move DepthMode to texture object
GL_DEPTH_TEXTURE_MODE isn't meant to be part of sampler state based on
compatibility profile specifications.
OpenGL specification 4.1 compatibility 20100725 3.9.2:
"... The values accepted in the pname parameter
are TEXTURE_WRAP_S, TEXTURE_WRAP_T, TEXTURE_WRAP_R, TEXTURE_MIN_-
FILTER, TEXTURE_MAG_FILTER, TEXTURE_BORDER_COLOR, TEXTURE_MIN_-
LOD, TEXTURE_MAX_LOD, TEXTURE_LOD_BIAS, TEXTURE_COMPARE_MODE, and
TEXTURE_COMPARE_FUNC. Texture state listed in table 6.25 but not listed here and
in the sampler state in table 6.26 is not part of the sampler state, and remains in the
texture object."
The list of states is in Table 6.24 "Textures (state per texture
object)" instead of 6.25 mentioned in the specification text.
Same can be found from 3.3 compatibility specification.
Signed-off-by: Pauli Nieminen <pauli.nieminen@linux.intel.com>
Reviewed-by: Brian Paul <brianp@vmware.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
2012-06-12 21:38:46 +03:00
|
|
|
stObj->base.DepthMode) ||
|
2011-05-14 18:04:08 +10:00
|
|
|
(st_view_format != stObj->sampler_view->format) ||
|
|
|
|
stObj->base.BaseLevel != stObj->sampler_view->u.tex.first_level) {
|
|
|
|
pipe_sampler_view_reference(&stObj->sampler_view, NULL);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
*sampler_view = st_get_texture_sampler_view_from_stobj(stObj, pipe,
|
|
|
|
samp,
|
|
|
|
st_view_format);
|
|
|
|
return GL_TRUE;
|
|
|
|
}
|
2011-01-20 08:38:19 -07:00
|
|
|
|
2012-01-09 09:30:13 -07:00
|
|
|
|
2012-08-06 08:35:20 -06:00
|
|
|
|
2012-01-09 09:30:13 -07:00
|
|
|
static void
|
2012-08-06 08:35:20 -06:00
|
|
|
update_textures(struct st_context *st,
|
|
|
|
unsigned shader_stage,
|
|
|
|
const struct gl_program *prog,
|
|
|
|
unsigned max_units,
|
|
|
|
struct pipe_sampler_view **sampler_views,
|
|
|
|
unsigned *num_textures)
|
2007-08-07 15:11:20 -06:00
|
|
|
{
|
2012-08-06 08:35:20 -06:00
|
|
|
const GLuint old_max = *num_textures;
|
|
|
|
GLbitfield samplers_used = prog->SamplersUsed;
|
|
|
|
GLuint unit;
|
2011-05-14 18:04:08 +10:00
|
|
|
|
2012-08-06 08:35:20 -06:00
|
|
|
if (samplers_used == 0x0 && old_max == 0)
|
2012-02-07 16:18:05 +00:00
|
|
|
return;
|
|
|
|
|
2012-08-06 08:35:20 -06:00
|
|
|
*num_textures = 0;
|
2011-05-14 18:04:08 +10:00
|
|
|
|
|
|
|
/* loop over sampler units (aka tex image units) */
|
2012-08-06 08:35:20 -06:00
|
|
|
for (unit = 0; unit < max_units; unit++, samplers_used >>= 1) {
|
2011-05-14 18:04:08 +10:00
|
|
|
struct pipe_sampler_view *sampler_view = NULL;
|
2012-08-06 08:35:20 -06:00
|
|
|
|
|
|
|
if (samplers_used & 1) {
|
2012-08-06 08:35:20 -06:00
|
|
|
const GLuint texUnit = prog->SamplerUnits[unit];
|
2011-05-14 18:04:08 +10:00
|
|
|
GLboolean retval;
|
|
|
|
|
2011-11-07 19:38:13 +01:00
|
|
|
retval = update_single_texture(st, &sampler_view, texUnit);
|
|
|
|
if (retval == GL_FALSE)
|
|
|
|
continue;
|
2011-05-14 18:04:08 +10:00
|
|
|
|
2012-08-06 08:35:20 -06:00
|
|
|
*num_textures = unit + 1;
|
|
|
|
}
|
|
|
|
else if (samplers_used == 0 && unit >= old_max) {
|
2012-08-06 08:35:20 -06:00
|
|
|
/* if we've reset all the old views and we have no more new ones */
|
|
|
|
break;
|
2011-05-14 18:04:08 +10:00
|
|
|
}
|
2012-08-06 08:35:20 -06:00
|
|
|
|
2012-08-06 08:35:20 -06:00
|
|
|
pipe_sampler_view_reference(&(sampler_views[unit]), sampler_view);
|
2011-05-14 18:04:08 +10:00
|
|
|
}
|
|
|
|
|
2012-08-06 08:35:20 -06:00
|
|
|
cso_set_sampler_views(st->cso_context,
|
|
|
|
shader_stage,
|
|
|
|
MIN2(*num_textures, max_units),
|
|
|
|
sampler_views);
|
2011-05-14 18:04:08 +10:00
|
|
|
}
|
|
|
|
|
2012-01-09 09:30:13 -07:00
|
|
|
|
2012-08-06 08:35:20 -06:00
|
|
|
|
2012-01-09 09:30:13 -07:00
|
|
|
static void
|
2012-08-06 08:35:20 -06:00
|
|
|
update_vertex_textures(struct st_context *st)
|
2011-05-14 18:04:08 +10:00
|
|
|
{
|
2011-06-14 09:15:36 -06:00
|
|
|
const struct gl_context *ctx = st->ctx;
|
2012-02-08 13:58:14 +00:00
|
|
|
|
2012-08-06 08:35:20 -06:00
|
|
|
if (ctx->Const.MaxVertexTextureImageUnits > 0) {
|
|
|
|
update_textures(st,
|
|
|
|
PIPE_SHADER_VERTEX,
|
|
|
|
&ctx->VertexProgram._Current->Base,
|
|
|
|
ctx->Const.MaxVertexTextureImageUnits,
|
2012-08-09 20:59:44 -06:00
|
|
|
st->state.sampler_views[PIPE_SHADER_VERTEX],
|
|
|
|
&st->state.num_sampler_views[PIPE_SHADER_VERTEX]);
|
2012-08-06 08:35:20 -06:00
|
|
|
}
|
|
|
|
}
|
2008-08-14 15:38:09 -06:00
|
|
|
|
2011-05-14 18:04:08 +10:00
|
|
|
|
2012-08-06 08:35:20 -06:00
|
|
|
static void
|
|
|
|
update_fragment_textures(struct st_context *st)
|
|
|
|
{
|
|
|
|
const struct gl_context *ctx = st->ctx;
|
2008-03-05 10:50:14 +01:00
|
|
|
|
2012-08-06 08:35:20 -06:00
|
|
|
update_textures(st,
|
|
|
|
PIPE_SHADER_FRAGMENT,
|
|
|
|
&ctx->FragmentProgram._Current->Base,
|
|
|
|
ctx->Const.MaxTextureImageUnits,
|
2012-08-09 20:59:44 -06:00
|
|
|
st->state.sampler_views[PIPE_SHADER_FRAGMENT],
|
|
|
|
&st->state.num_sampler_views[PIPE_SHADER_FRAGMENT]);
|
2007-08-07 15:11:20 -06:00
|
|
|
}
|
|
|
|
|
2012-01-09 09:30:13 -07:00
|
|
|
|
2007-08-07 15:11:20 -06:00
|
|
|
const struct st_tracked_state st_update_texture = {
|
2008-05-02 10:08:03 +00:00
|
|
|
"st_update_texture", /* name */
|
|
|
|
{ /* dirty */
|
|
|
|
_NEW_TEXTURE, /* mesa */
|
|
|
|
ST_NEW_FRAGMENT_PROGRAM, /* st */
|
2007-08-07 15:11:20 -06:00
|
|
|
},
|
2011-05-18 17:27:39 +10:00
|
|
|
update_fragment_textures /* update */
|
|
|
|
};
|
|
|
|
|
2012-01-09 09:30:13 -07:00
|
|
|
|
2011-05-18 17:27:39 +10:00
|
|
|
const struct st_tracked_state st_update_vertex_texture = {
|
2012-01-09 09:30:13 -07:00
|
|
|
"st_update_vertex_texture", /* name */
|
2011-05-18 17:27:39 +10:00
|
|
|
{ /* dirty */
|
|
|
|
_NEW_TEXTURE, /* mesa */
|
|
|
|
ST_NEW_VERTEX_PROGRAM, /* st */
|
|
|
|
},
|
|
|
|
update_vertex_textures /* update */
|
2007-08-07 15:11:20 -06:00
|
|
|
};
|
2008-05-07 16:44:33 -06:00
|
|
|
|
2012-01-09 09:30:13 -07:00
|
|
|
|
|
|
|
|
|
|
|
static void
|
2008-05-07 16:44:33 -06:00
|
|
|
finalize_textures(struct st_context *st)
|
|
|
|
{
|
2011-06-14 09:15:36 -06:00
|
|
|
struct gl_context *ctx = st->ctx;
|
|
|
|
struct gl_fragment_program *fprog = ctx->FragmentProgram._Current;
|
2008-05-07 16:44:33 -06:00
|
|
|
const GLboolean prev_missing_textures = st->missing_textures;
|
|
|
|
GLuint su;
|
|
|
|
|
|
|
|
st->missing_textures = GL_FALSE;
|
|
|
|
|
2011-06-14 09:15:36 -06:00
|
|
|
for (su = 0; su < ctx->Const.MaxTextureCoordUnits; su++) {
|
2008-05-07 16:44:33 -06:00
|
|
|
if (fprog->Base.SamplersUsed & (1 << su)) {
|
|
|
|
const GLuint texUnit = fprog->Base.SamplerUnits[su];
|
|
|
|
struct gl_texture_object *texObj
|
2011-06-14 09:15:36 -06:00
|
|
|
= ctx->Texture.Unit[texUnit]._Current;
|
2008-05-07 16:44:33 -06:00
|
|
|
|
|
|
|
if (texObj) {
|
2010-05-03 16:13:20 -06:00
|
|
|
GLboolean retval;
|
2008-05-07 16:44:33 -06:00
|
|
|
|
2011-06-14 09:15:36 -06:00
|
|
|
retval = st_finalize_texture(ctx, st->pipe, texObj);
|
2008-05-07 16:44:33 -06:00
|
|
|
if (!retval) {
|
|
|
|
/* out of mem */
|
|
|
|
st->missing_textures = GL_TRUE;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (prev_missing_textures != st->missing_textures)
|
|
|
|
st->dirty.st |= ST_NEW_FRAGMENT_PROGRAM;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const struct st_tracked_state st_finalize_textures = {
|
|
|
|
"st_finalize_textures", /* name */
|
|
|
|
{ /* dirty */
|
|
|
|
_NEW_TEXTURE, /* mesa */
|
|
|
|
0, /* st */
|
|
|
|
},
|
|
|
|
finalize_textures /* update */
|
|
|
|
};
|