aboutsummaryrefslogtreecommitdiff
path: root/mesalib/src/mesa/state_tracker
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2011-04-12 13:48:18 +0000
committermarha <marha@users.sourceforge.net>2011-04-12 13:48:18 +0000
commite2c8d047679db3bbb166d709b86e18180be6d713 (patch)
treed7468ac76dc71bb8d38c816be6db988bcbcbb863 /mesalib/src/mesa/state_tracker
parent57fb3f76b66c5f7a9f7bed9c42fb9fec9d56ee05 (diff)
parent7730393619080086530e24d3b594351b4114f608 (diff)
downloadvcxsrv-e2c8d047679db3bbb166d709b86e18180be6d713.tar.gz
vcxsrv-e2c8d047679db3bbb166d709b86e18180be6d713.tar.bz2
vcxsrv-e2c8d047679db3bbb166d709b86e18180be6d713.zip
svn merge ^/branches/released .
Diffstat (limited to 'mesalib/src/mesa/state_tracker')
-rw-r--r--mesalib/src/mesa/state_tracker/st_atom_sampler.c31
-rw-r--r--mesalib/src/mesa/state_tracker/st_atom_texture.c18
-rw-r--r--mesalib/src/mesa/state_tracker/st_cb_texture.c12
-rw-r--r--mesalib/src/mesa/state_tracker/st_context.c2
-rw-r--r--mesalib/src/mesa/state_tracker/st_extensions.c1
-rw-r--r--mesalib/src/mesa/state_tracker/st_texture.h15
6 files changed, 55 insertions, 24 deletions
diff --git a/mesalib/src/mesa/state_tracker/st_atom_sampler.c b/mesalib/src/mesa/state_tracker/st_atom_sampler.c
index 48b94500d..cb1817970 100644
--- a/mesalib/src/mesa/state_tracker/st_atom_sampler.c
+++ b/mesalib/src/mesa/state_tracker/st_atom_sampler.c
@@ -38,6 +38,7 @@
#include "st_cb_texture.h"
#include "st_format.h"
#include "st_atom.h"
+#include "st_texture.h"
#include "pipe/p_context.h"
#include "pipe/p_defines.h"
@@ -138,6 +139,7 @@ update_samplers(struct st_context *st)
if (samplersUsed & (1 << su)) {
struct gl_texture_object *texobj;
struct gl_texture_image *teximg;
+ struct gl_sampler_object *msamp;
GLuint texUnit;
if (fprog->Base.SamplersUsed & (1 << su))
@@ -152,25 +154,27 @@ update_samplers(struct st_context *st)
teximg = texobj->Image[0][texobj->BaseLevel];
- sampler->wrap_s = gl_wrap_xlate(texobj->WrapS);
- sampler->wrap_t = gl_wrap_xlate(texobj->WrapT);
- sampler->wrap_r = gl_wrap_xlate(texobj->WrapR);
+ msamp = st_get_mesa_sampler(st->ctx, texUnit);
- sampler->min_img_filter = gl_filter_to_img_filter(texobj->MinFilter);
- sampler->min_mip_filter = gl_filter_to_mip_filter(texobj->MinFilter);
- sampler->mag_img_filter = gl_filter_to_img_filter(texobj->MagFilter);
+ sampler->wrap_s = gl_wrap_xlate(msamp->WrapS);
+ sampler->wrap_t = gl_wrap_xlate(msamp->WrapT);
+ sampler->wrap_r = gl_wrap_xlate(msamp->WrapR);
+
+ sampler->min_img_filter = gl_filter_to_img_filter(msamp->MinFilter);
+ sampler->min_mip_filter = gl_filter_to_mip_filter(msamp->MinFilter);
+ sampler->mag_img_filter = gl_filter_to_img_filter(msamp->MagFilter);
if (texobj->Target != GL_TEXTURE_RECTANGLE_ARB)
sampler->normalized_coords = 1;
sampler->lod_bias = st->ctx->Texture.Unit[texUnit].LodBias +
- texobj->LodBias;
+ msamp->LodBias;
- sampler->min_lod = CLAMP(texobj->MinLod,
+ sampler->min_lod = CLAMP(msamp->MinLod,
0.0f,
(GLfloat) texobj->MaxLevel - texobj->BaseLevel);
sampler->max_lod = MIN2((GLfloat) texobj->MaxLevel - texobj->BaseLevel,
- texobj->MaxLod);
+ msamp->MaxLod);
if (sampler->max_lod < sampler->min_lod) {
/* The GL spec doesn't seem to specify what to do in this case.
* Swap the values.
@@ -181,17 +185,18 @@ update_samplers(struct st_context *st)
assert(sampler->min_lod <= sampler->max_lod);
}
- st_translate_color(texobj->BorderColor.f,
+ st_translate_color(msamp->BorderColor.f,
teximg ? teximg->_BaseFormat : GL_RGBA,
sampler->border_color);
- sampler->max_anisotropy = (texobj->MaxAnisotropy == 1.0 ? 0 : (GLuint)texobj->MaxAnisotropy);
+ sampler->max_anisotropy = (msamp->MaxAnisotropy == 1.0 ?
+ 0 : (GLuint) msamp->MaxAnisotropy);
/* only care about ARB_shadow, not SGI shadow */
- if (texobj->CompareMode == GL_COMPARE_R_TO_TEXTURE) {
+ if (msamp->CompareMode == GL_COMPARE_R_TO_TEXTURE) {
sampler->compare_mode = PIPE_TEX_COMPARE_R_TO_TEXTURE;
sampler->compare_func
- = st_compare_func_to_pipe(texobj->CompareFunc);
+ = st_compare_func_to_pipe(msamp->CompareFunc);
}
st->state.num_samplers = su + 1;
diff --git a/mesalib/src/mesa/state_tracker/st_atom_texture.c b/mesalib/src/mesa/state_tracker/st_atom_texture.c
index 04825ba4a..532e9b5a3 100644
--- a/mesalib/src/mesa/state_tracker/st_atom_texture.c
+++ b/mesalib/src/mesa/state_tracker/st_atom_texture.c
@@ -138,12 +138,13 @@ check_sampler_swizzle(struct pipe_sampler_view *sv,
static INLINE struct pipe_sampler_view *
st_create_texture_sampler_view_from_stobj(struct pipe_context *pipe,
struct st_texture_object *stObj,
+ const struct gl_sampler_object *samp,
enum pipe_format format)
{
struct pipe_sampler_view templ;
GLuint swizzle = apply_depthmode(stObj->pt->format,
stObj->base._Swizzle,
- stObj->base.DepthMode);
+ samp->DepthMode);
u_sampler_view_default_template(&templ,
stObj->pt,
@@ -164,6 +165,7 @@ st_create_texture_sampler_view_from_stobj(struct pipe_context *pipe,
static INLINE struct pipe_sampler_view *
st_get_texture_sampler_view_from_stobj(struct st_texture_object *stObj,
struct pipe_context *pipe,
+ const struct gl_sampler_object *samp,
enum pipe_format format)
{
if (!stObj || !stObj->pt) {
@@ -172,7 +174,7 @@ st_get_texture_sampler_view_from_stobj(struct st_texture_object *stObj,
if (!stObj->sampler_view) {
stObj->sampler_view =
- st_create_texture_sampler_view_from_stobj(pipe, stObj, format);
+ st_create_texture_sampler_view_from_stobj(pipe, stObj, samp, format);
}
return stObj->sampler_view;
@@ -200,16 +202,20 @@ update_textures(struct st_context *st)
struct st_texture_object *stObj;
GLboolean retval;
GLuint texUnit;
+ const struct gl_sampler_object *samp;
if (fprog->Base.SamplersUsed & (1 << su))
texUnit = fprog->Base.SamplerUnits[su];
else
texUnit = vprog->Base.SamplerUnits[su];
+ samp = st_get_mesa_sampler(st->ctx, texUnit);
+
texObj = st->ctx->Texture.Unit[texUnit]._Current;
if (!texObj) {
texObj = st_get_default_texture(st);
+ samp = &texObj->Sampler;
}
stObj = st_texture_object(texObj);
@@ -228,7 +234,7 @@ update_textures(struct st_context *st)
enum pipe_format firstImageFormat =
st_mesa_format_to_pipe_format(texFormat);
- if ((stObj->base.sRGBDecode == GL_SKIP_DECODE_EXT) &&
+ if ((samp->sRGBDecode == GL_SKIP_DECODE_EXT) &&
(_mesa_get_format_color_encoding(texFormat) == GL_SRGB)) {
/* don't do sRGB->RGB conversion. Interpret the texture
* texture data as linear values.
@@ -248,12 +254,14 @@ update_textures(struct st_context *st)
if (stObj->sampler_view)
if (check_sampler_swizzle(stObj->sampler_view,
stObj->base._Swizzle,
- stObj->base.DepthMode) ||
+ samp->DepthMode) ||
(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, st_view_format);
+ sampler_view = st_get_texture_sampler_view_from_stobj(stObj, pipe,
+ samp,
+ st_view_format);
}
pipe_sampler_view_reference(&st->state.sampler_views[su], sampler_view);
}
diff --git a/mesalib/src/mesa/state_tracker/st_cb_texture.c b/mesalib/src/mesa/state_tracker/st_cb_texture.c
index ab0db46df..6223733d3 100644
--- a/mesalib/src/mesa/state_tracker/st_cb_texture.c
+++ b/mesalib/src/mesa/state_tracker/st_cb_texture.c
@@ -362,8 +362,8 @@ guess_and_alloc_texture(struct st_context *st,
* to re-allocating a texture buffer with space for more (or fewer)
* mipmap levels later.
*/
- if ((stObj->base.MinFilter == GL_NEAREST ||
- stObj->base.MinFilter == GL_LINEAR ||
+ if ((stObj->base.Sampler.MinFilter == GL_NEAREST ||
+ stObj->base.Sampler.MinFilter == GL_LINEAR ||
stImage->base._BaseFormat == GL_DEPTH_COMPONENT ||
stImage->base._BaseFormat == GL_DEPTH_STENCIL_EXT) &&
!stObj->base.GenerateMipmap &&
@@ -1742,8 +1742,8 @@ st_finalize_texture(struct gl_context *ctx,
* incomplete. In that case, we'll have set stObj->lastLevel before
* we get here.
*/
- if (stObj->base.MinFilter == GL_LINEAR ||
- stObj->base.MinFilter == GL_NEAREST)
+ if (stObj->base.Sampler.MinFilter == GL_LINEAR ||
+ stObj->base.Sampler.MinFilter == GL_NEAREST)
stObj->lastLevel = stObj->base.BaseLevel;
else
stObj->lastLevel = stObj->base._MaxLevel;
@@ -1890,8 +1890,8 @@ st_get_default_texture(struct st_context *st)
texObj, texImg,
0, 0);
- texObj->MinFilter = GL_NEAREST;
- texObj->MagFilter = GL_NEAREST;
+ texObj->Sampler.MinFilter = GL_NEAREST;
+ texObj->Sampler.MagFilter = GL_NEAREST;
texObj->_Complete = GL_TRUE;
st->default_texture = texObj;
diff --git a/mesalib/src/mesa/state_tracker/st_context.c b/mesalib/src/mesa/state_tracker/st_context.c
index 458968486..ce5a68c0a 100644
--- a/mesalib/src/mesa/state_tracker/st_context.c
+++ b/mesalib/src/mesa/state_tracker/st_context.c
@@ -27,6 +27,7 @@
#include "main/imports.h"
#include "main/context.h"
+#include "main/samplerobj.h"
#include "main/shaderobj.h"
#include "program/prog_cache.h"
#include "vbo/vbo.h"
@@ -269,6 +270,7 @@ void st_destroy_context( struct st_context *st )
void st_init_driver_functions(struct dd_function_table *functions)
{
_mesa_init_shader_object_functions(functions);
+ _mesa_init_sampler_object_functions(functions);
st_init_accum_functions(functions);
st_init_blit_functions(functions);
diff --git a/mesalib/src/mesa/state_tracker/st_extensions.c b/mesalib/src/mesa/state_tracker/st_extensions.c
index bb4099a95..9a3fb4ee6 100644
--- a/mesalib/src/mesa/state_tracker/st_extensions.c
+++ b/mesalib/src/mesa/state_tracker/st_extensions.c
@@ -228,6 +228,7 @@ void st_init_extensions(struct st_context *st)
ctx->Extensions.ARB_half_float_pixel = GL_TRUE;
ctx->Extensions.ARB_map_buffer_range = GL_TRUE;
ctx->Extensions.ARB_multisample = GL_TRUE;
+ ctx->Extensions.ARB_sampler_objects = GL_TRUE;
ctx->Extensions.ARB_texture_border_clamp = GL_TRUE; /* XXX temp */
ctx->Extensions.ARB_texture_compression = GL_TRUE;
ctx->Extensions.ARB_texture_cube_map = GL_TRUE;
diff --git a/mesalib/src/mesa/state_tracker/st_texture.h b/mesalib/src/mesa/state_tracker/st_texture.h
index b25f16410..5c7216e60 100644
--- a/mesalib/src/mesa/state_tracker/st_texture.h
+++ b/mesalib/src/mesa/state_tracker/st_texture.h
@@ -163,6 +163,21 @@ st_get_texture_sampler_view(struct st_texture_object *stObj,
}
+/**
+ * Get pointer to the active sampler object for the given texture unit.
+ * This will either be a user-defined sampler object or the texture
+ * object's own sampler state.
+ */
+static INLINE struct gl_sampler_object *
+st_get_mesa_sampler(const struct gl_context *ctx, GLuint unit)
+{
+ if (ctx->Texture.Unit[unit].Sampler)
+ return ctx->Texture.Unit[unit].Sampler;
+ else
+ return &ctx->Texture.Unit[unit]._Current->Sampler;
+}
+
+
extern struct pipe_resource *
st_texture_create(struct st_context *st,
enum pipe_texture_target target,