#include "main/bufferobj.h"
#include "main/fbobject.h"
#include "main/texrender.h"
+#include "main/samplerobj.h"
#include "main/syncobj.h"
#include "main/texturebarrier.h"
#include "main/transformfeedback.h"
_mesa_init_transform_feedback_functions(driver);
+ _mesa_init_sampler_object_functions(driver);
+
/* T&L stuff */
driver->NeedValidate = GL_FALSE;
driver->ValidateTnlModule = NULL;
#include "main/enums.h"
#include "main/colormac.h"
#include "main/macros.h"
+#include "main/samplerobj.h"
#include "intel_mipmap_tree.h"
#include "intel_tex.h"
struct gl_texture_object *tObj = tUnit->_Current;
struct intel_texture_object *intelObj = intel_texture_object(tObj);
struct gl_texture_image *firstImage;
+ struct gl_sampler_object *sampler = _mesa_get_samplerobj(ctx, unit);
GLuint *state = i830->state.Tex[unit], format, pitch;
GLint lodbias;
GLubyte border[4];
float maxlod;
uint32_t minlod_fixed, maxlod_fixed;
- switch (tObj->Sampler.MinFilter) {
+ switch (sampler->MinFilter) {
case GL_NEAREST:
minFilt = FILTER_NEAREST;
mipFilt = MIPFILTER_NONE;
return GL_FALSE;
}
- if (tObj->Sampler.MaxAnisotropy > 1.0) {
+ if (sampler->MaxAnisotropy > 1.0) {
minFilt = FILTER_ANISOTROPIC;
magFilt = FILTER_ANISOTROPIC;
}
else {
- switch (tObj->Sampler.MagFilter) {
+ switch (sampler->MagFilter) {
case GL_NEAREST:
magFilt = FILTER_NEAREST;
break;
}
}
- lodbias = (int) ((tUnit->LodBias + tObj->Sampler.LodBias) * 16.0);
+ lodbias = (int) ((tUnit->LodBias + sampler->LodBias) * 16.0);
if (lodbias < -64)
lodbias = -64;
if (lodbias > 63)
* addressable (smallest resolution) LOD. Use it to cover both
* MAX_LEVEL and MAX_LOD.
*/
- minlod_fixed = U_FIXED(CLAMP(tObj->Sampler.MinLod, 0.0, 11), 4);
- maxlod = MIN2(tObj->Sampler.MaxLod, tObj->_MaxLevel - tObj->BaseLevel);
+ minlod_fixed = U_FIXED(CLAMP(sampler->MinLod, 0.0, 11), 4);
+ maxlod = MIN2(sampler->MaxLod, tObj->_MaxLevel - tObj->BaseLevel);
if (intel->intelScreen->deviceID == PCI_CHIP_I855_GM ||
intel->intelScreen->deviceID == PCI_CHIP_I865_G) {
maxlod_fixed = U_FIXED(CLAMP(maxlod, 0.0, 11.75), 2);
}
{
- GLenum ws = tObj->Sampler.WrapS;
- GLenum wt = tObj->Sampler.WrapT;
+ GLenum ws = sampler->WrapS;
+ GLenum wt = sampler->WrapT;
/* 3D textures not available on i830
}
/* convert border color from float to ubyte */
- CLAMPED_FLOAT_TO_UBYTE(border[0], tObj->Sampler.BorderColor.f[0]);
- CLAMPED_FLOAT_TO_UBYTE(border[1], tObj->Sampler.BorderColor.f[1]);
- CLAMPED_FLOAT_TO_UBYTE(border[2], tObj->Sampler.BorderColor.f[2]);
- CLAMPED_FLOAT_TO_UBYTE(border[3], tObj->Sampler.BorderColor.f[3]);
+ CLAMPED_FLOAT_TO_UBYTE(border[0], sampler->BorderColor.f[0]);
+ CLAMPED_FLOAT_TO_UBYTE(border[1], sampler->BorderColor.f[1]);
+ CLAMPED_FLOAT_TO_UBYTE(border[2], sampler->BorderColor.f[2]);
+ CLAMPED_FLOAT_TO_UBYTE(border[3], sampler->BorderColor.f[3]);
state[I830_TEXREG_TM0S4] = PACK_COLOR_8888(border[3],
border[0],
#include "main/enums.h"
#include "main/macros.h"
#include "main/colormac.h"
+#include "main/samplerobj.h"
#include "intel_mipmap_tree.h"
#include "intel_tex.h"
struct gl_texture_object *tObj = tUnit->_Current;
struct intel_texture_object *intelObj = intel_texture_object(tObj);
struct gl_texture_image *firstImage;
+ struct gl_sampler_object *sampler = _mesa_get_samplerobj(ctx, unit);
GLuint *state = i915->state.Tex[unit], format, pitch;
GLint lodbias, aniso = 0;
GLubyte border[4];
format = translate_texture_format(firstImage->TexFormat,
firstImage->InternalFormat,
- tObj->Sampler.DepthMode);
+ sampler->DepthMode);
pitch = intelObj->mt->region->pitch * intelObj->mt->cpp;
state[I915_TEXREG_MS3] =
* (lowest resolution) LOD. Use it to cover both MAX_LEVEL and
* MAX_LOD.
*/
- maxlod = MIN2(tObj->Sampler.MaxLod, tObj->_MaxLevel - tObj->BaseLevel);
+ maxlod = MIN2(sampler->MaxLod, tObj->_MaxLevel - tObj->BaseLevel);
state[I915_TEXREG_MS4] =
((((pitch / 4) - 1) << MS4_PITCH_SHIFT) |
MS4_CUBE_FACE_ENA_MASK |
{
GLuint minFilt, mipFilt, magFilt;
- switch (tObj->Sampler.MinFilter) {
+ switch (sampler->MinFilter) {
case GL_NEAREST:
minFilt = FILTER_NEAREST;
mipFilt = MIPFILTER_NONE;
return GL_FALSE;
}
- if (tObj->Sampler.MaxAnisotropy > 1.0) {
+ if (sampler->MaxAnisotropy > 1.0) {
minFilt = FILTER_ANISOTROPIC;
magFilt = FILTER_ANISOTROPIC;
- if (tObj->Sampler.MaxAnisotropy > 2.0)
+ if (sampler->MaxAnisotropy > 2.0)
aniso = SS2_MAX_ANISO_4;
else
aniso = SS2_MAX_ANISO_2;
}
else {
- switch (tObj->Sampler.MagFilter) {
+ switch (sampler->MagFilter) {
case GL_NEAREST:
magFilt = FILTER_NEAREST;
break;
}
}
- lodbias = (int) ((tUnit->LodBias + tObj->Sampler.LodBias) * 16.0);
+ lodbias = (int) ((tUnit->LodBias + sampler->LodBias) * 16.0);
if (lodbias < -256)
lodbias = -256;
if (lodbias > 255)
/* Shadow:
*/
- if (tObj->Sampler.CompareMode == GL_COMPARE_R_TO_TEXTURE_ARB &&
+ if (sampler->CompareMode == GL_COMPARE_R_TO_TEXTURE_ARB &&
tObj->Target != GL_TEXTURE_3D) {
if (tObj->Target == GL_TEXTURE_1D)
return GL_FALSE;
state[I915_TEXREG_SS2] |=
(SS2_SHADOW_ENABLE |
- intel_translate_shadow_compare_func(tObj->Sampler.CompareFunc));
+ intel_translate_shadow_compare_func(sampler->CompareFunc));
minFilt = FILTER_4X4_FLAT;
magFilt = FILTER_4X4_FLAT;
}
{
- GLenum ws = tObj->Sampler.WrapS;
- GLenum wt = tObj->Sampler.WrapT;
- GLenum wr = tObj->Sampler.WrapR;
+ GLenum ws = sampler->WrapS;
+ GLenum wt = sampler->WrapT;
+ GLenum wr = sampler->WrapR;
float minlod;
/* We program 1D textures as 2D textures, so the 2D texcoord could
* clamp_to_border.
*/
if (tObj->Target == GL_TEXTURE_3D &&
- (tObj->Sampler.MinFilter != GL_NEAREST ||
- tObj->Sampler.MagFilter != GL_NEAREST) &&
+ (sampler->MinFilter != GL_NEAREST ||
+ sampler->MagFilter != GL_NEAREST) &&
(ws == GL_CLAMP ||
wt == GL_CLAMP ||
wr == GL_CLAMP ||
(translate_wrap_mode(wt) << SS3_TCY_ADDR_MODE_SHIFT) |
(translate_wrap_mode(wr) << SS3_TCZ_ADDR_MODE_SHIFT));
- minlod = MIN2(tObj->Sampler.MinLod, tObj->_MaxLevel - tObj->BaseLevel);
+ minlod = MIN2(sampler->MinLod, tObj->_MaxLevel - tObj->BaseLevel);
state[I915_TEXREG_SS3] |= (unit << SS3_TEXTUREMAP_INDEX_SHIFT);
state[I915_TEXREG_SS3] |= (U_FIXED(CLAMP(minlod, 0.0, 11.0), 4) <<
SS3_MIN_LOD_SHIFT);
}
/* convert border color from float to ubyte */
- CLAMPED_FLOAT_TO_UBYTE(border[0], tObj->Sampler.BorderColor.f[0]);
- CLAMPED_FLOAT_TO_UBYTE(border[1], tObj->Sampler.BorderColor.f[1]);
- CLAMPED_FLOAT_TO_UBYTE(border[2], tObj->Sampler.BorderColor.f[2]);
- CLAMPED_FLOAT_TO_UBYTE(border[3], tObj->Sampler.BorderColor.f[3]);
+ CLAMPED_FLOAT_TO_UBYTE(border[0], sampler->BorderColor.f[0]);
+ CLAMPED_FLOAT_TO_UBYTE(border[1], sampler->BorderColor.f[1]);
+ CLAMPED_FLOAT_TO_UBYTE(border[2], sampler->BorderColor.f[2]);
+ CLAMPED_FLOAT_TO_UBYTE(border[3], sampler->BorderColor.f[3]);
if (firstImage->_BaseFormat == GL_DEPTH_COMPONENT) {
/* GL specs that border color for depth textures is taken from the
#include "main/glheader.h"
#include "main/context.h"
#include "main/condrender.h"
+#include "main/samplerobj.h"
#include "main/state.h"
#include "main/enums.h"
#include "tnl/tnl.h"
int u;
for (u = 0; u < ctx->Const.MaxTextureCoordUnits; u++) {
struct gl_texture_unit *texUnit = &ctx->Texture.Unit[u];
+
if (texUnit->Enabled) {
+ struct gl_sampler_object *sampler = _mesa_get_samplerobj(ctx, u);
+
if (texUnit->Enabled & TEXTURE_1D_BIT) {
- if (texUnit->CurrentTex[TEXTURE_1D_INDEX]->Sampler.WrapS == GL_CLAMP) {
+ if (sampler->WrapS == GL_CLAMP) {
return GL_TRUE;
}
}
if (texUnit->Enabled & TEXTURE_2D_BIT) {
- if (texUnit->CurrentTex[TEXTURE_2D_INDEX]->Sampler.WrapS == GL_CLAMP ||
- texUnit->CurrentTex[TEXTURE_2D_INDEX]->Sampler.WrapT == GL_CLAMP) {
+ if (sampler->WrapS == GL_CLAMP ||
+ sampler->WrapT == GL_CLAMP) {
return GL_TRUE;
}
}
if (texUnit->Enabled & TEXTURE_3D_BIT) {
- if (texUnit->CurrentTex[TEXTURE_3D_INDEX]->Sampler.WrapS == GL_CLAMP ||
- texUnit->CurrentTex[TEXTURE_3D_INDEX]->Sampler.WrapT == GL_CLAMP ||
- texUnit->CurrentTex[TEXTURE_3D_INDEX]->Sampler.WrapR == GL_CLAMP) {
+ if (sampler->WrapS == GL_CLAMP ||
+ sampler->WrapT == GL_CLAMP ||
+ sampler->WrapR == GL_CLAMP) {
return GL_TRUE;
}
}
#include "brw_wm.h"
#include "brw_state.h"
#include "main/formats.h"
+#include "main/samplerobj.h"
/** Return number of src args for given instruction */
GLuint brw_wm_nr_args( GLuint opcode )
if (unit->_ReallyEnabled) {
const struct gl_texture_object *t = unit->_Current;
const struct gl_texture_image *img = t->Image[0][t->BaseLevel];
+ struct gl_sampler_object *sampler = _mesa_get_samplerobj(ctx, i);
int swizzles[SWIZZLE_NIL + 1] = {
SWIZZLE_X,
SWIZZLE_Y,
* well and our shadow compares always return the result in
* all 4 channels.
*/
- if (t->Sampler.CompareMode == GL_COMPARE_R_TO_TEXTURE_ARB) {
- if (t->Sampler.DepthMode == GL_ALPHA) {
+ if (sampler->CompareMode == GL_COMPARE_R_TO_TEXTURE_ARB) {
+ if (sampler->DepthMode == GL_ALPHA) {
swizzles[0] = SWIZZLE_ZERO;
swizzles[1] = SWIZZLE_ZERO;
swizzles[2] = SWIZZLE_ZERO;
- } else if (t->Sampler.DepthMode == GL_LUMINANCE) {
+ } else if (sampler->DepthMode == GL_LUMINANCE) {
swizzles[3] = SWIZZLE_ONE;
- } else if (t->Sampler.DepthMode == GL_RED) {
+ } else if (sampler->DepthMode == GL_RED) {
/* See table 3.23 of the GL 3.0 spec. */
swizzles[1] = SWIZZLE_ZERO;
swizzles[2] = SWIZZLE_ZERO;
#include "brw_defines.h"
#include "main/macros.h"
-
+#include "main/samplerobj.h"
/* Samplers aren't strictly wm state from the hardware's perspective,
struct gl_texture_object *texObj = texUnit->_Current;
struct gl_texture_image *firstImage =
texObj->Image[0][texObj->BaseLevel];
+ struct gl_sampler_object *sampler = _mesa_get_samplerobj(ctx, unit);
memset(last_entry_end, 0,
(char*)entry - last_entry_end + sizeof(*entry));
entry->seamless_cube_map = (texObj->Target == GL_TEXTURE_CUBE_MAP)
? ctx->Texture.CubeMapSeamless : GL_FALSE;
- entry->wrap_r = texObj->Sampler.WrapR;
- entry->wrap_s = texObj->Sampler.WrapS;
- entry->wrap_t = texObj->Sampler.WrapT;
+ entry->wrap_r = sampler->WrapR;
+ entry->wrap_s = sampler->WrapS;
+ entry->wrap_t = sampler->WrapT;
- entry->maxlod = texObj->Sampler.MaxLod;
- entry->minlod = texObj->Sampler.MinLod;
- entry->lod_bias = texUnit->LodBias + texObj->Sampler.LodBias;
- entry->max_aniso = texObj->Sampler.MaxAnisotropy;
- entry->minfilter = texObj->Sampler.MinFilter;
- entry->magfilter = texObj->Sampler.MagFilter;
- entry->comparemode = texObj->Sampler.CompareMode;
- entry->comparefunc = texObj->Sampler.CompareFunc;
+ entry->maxlod = sampler->MaxLod;
+ entry->minlod = sampler->MinLod;
+ entry->lod_bias = texUnit->LodBias + sampler->LodBias;
+ entry->max_aniso = sampler->MaxAnisotropy;
+ entry->minfilter = sampler->MinFilter;
+ entry->magfilter = sampler->MagFilter;
+ entry->comparemode = sampler->CompareMode;
+ entry->comparefunc = sampler->CompareFunc;
drm_intel_bo_unreference(brw->wm.sdc_bo[unit]);
if (firstImage->_BaseFormat == GL_DEPTH_COMPONENT) {
float bordercolor[4] = {
- texObj->Sampler.BorderColor.f[0],
- texObj->Sampler.BorderColor.f[0],
- texObj->Sampler.BorderColor.f[0],
- texObj->Sampler.BorderColor.f[0]
+ sampler->BorderColor.f[0],
+ sampler->BorderColor.f[0],
+ sampler->BorderColor.f[0],
+ sampler->BorderColor.f[0]
};
/* GL specs that border color for depth textures is taken from the
* R channel, while the hardware uses A. Spam R into all the
brw->wm.sdc_bo[unit] = upload_default_color(brw, bordercolor);
} else {
brw->wm.sdc_bo[unit] = upload_default_color(brw,
- texObj->Sampler.BorderColor.f);
+ sampler->BorderColor.f);
}
key->sampler_count = unit + 1;
}
#include "main/mtypes.h"
+#include "main/samplerobj.h"
#include "main/texstore.h"
#include "program/prog_parameter.h"
struct gl_texture_object *tObj = ctx->Texture.Unit[unit]._Current;
struct intel_texture_object *intelObj = intel_texture_object(tObj);
struct gl_texture_image *firstImage = tObj->Image[0][tObj->BaseLevel];
+ struct gl_sampler_object *sampler = _mesa_get_samplerobj(ctx, unit);
const GLuint surf_index = SURF_INDEX_TEXTURE(unit);
struct brw_surface_state *surf;
surf->ss0.surface_type = translate_tex_target(tObj->Target);
surf->ss0.surface_format = translate_tex_format(firstImage->TexFormat,
firstImage->InternalFormat,
- tObj->Sampler.DepthMode,
- tObj->Sampler.sRGBDecode);
+ sampler->DepthMode,
+ sampler->sRGBDecode);
/* This is ok for all textures with channel width 8bit or less:
*/
{ "GL_ARB_pixel_buffer_object", NULL },
{ "GL_ARB_point_parameters", GL_ARB_point_parameters_functions },
{ "GL_ARB_point_sprite", NULL },
+ { "GL_ARB_sampler_objects", NULL },
{ "GL_ARB_shader_objects", GL_ARB_shader_objects_functions },
{ "GL_ARB_shading_language_100", GL_VERSION_2_0_functions },
{ "GL_ARB_sync", GL_ARB_sync_functions },
#include "main/mtypes.h"
#include "main/macros.h"
+#include "main/samplerobj.h"
#include "intel_context.h"
#include "intel_mipmap_tree.h"
*/
static void
intel_update_max_level(struct intel_context *intel,
- struct intel_texture_object *intelObj)
+ struct intel_texture_object *intelObj,
+ struct gl_sampler_object *sampler)
{
struct gl_texture_object *tObj = &intelObj->base;
- if (tObj->Sampler.MinFilter == GL_NEAREST || tObj->Sampler.MinFilter == GL_LINEAR) {
+ if (sampler->MinFilter == GL_NEAREST ||
+ sampler->MinFilter == GL_LINEAR) {
intelObj->_MaxLevel = tObj->BaseLevel;
} else {
intelObj->_MaxLevel = tObj->_MaxLevel;
GLuint
intel_finalize_mipmap_tree(struct intel_context *intel, GLuint unit)
{
+ struct gl_context *ctx = &intel->ctx;
struct gl_texture_object *tObj = intel->ctx.Texture.Unit[unit]._Current;
struct intel_texture_object *intelObj = intel_texture_object(tObj);
+ struct gl_sampler_object *sampler = _mesa_get_samplerobj(ctx, unit);
int comp_byte = 0;
int cpp;
GLuint face, i;
/* What levels must the tree include at a minimum?
*/
- intel_update_max_level(intel, intelObj);
+ intel_update_max_level(intel, intelObj, sampler);
firstImage = intel_texture_image(tObj->Image[0][tObj->BaseLevel]);
/* Fallback case:
struct dd_function_table;
+static INLINE struct gl_sampler_object *
+_mesa_get_samplerobj(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 void
_mesa_reference_sampler_object(struct gl_context *ctx,
#include "main/macros.h"
+#include "main/mtypes.h"
+#include "main/samplerobj.h"
#include "st_context.h"
#include "st_cb_texture.h"
teximg = texobj->Image[0][texobj->BaseLevel];
- msamp = st_get_mesa_sampler(st->ctx, texUnit);
+ msamp = _mesa_get_samplerobj(st->ctx, texUnit);
sampler->wrap_s = gl_wrap_xlate(msamp->WrapS);
sampler->wrap_t = gl_wrap_xlate(msamp->WrapT);
#include "main/macros.h"
+#include "main/mtypes.h"
+#include "main/samplerobj.h"
#include "program/prog_instruction.h"
#include "st_context.h"
else
texUnit = vprog->Base.SamplerUnits[su];
- samp = st_get_mesa_sampler(st->ctx, texUnit);
+ samp = _mesa_get_samplerobj(st->ctx, texUnit);
texObj = st->ctx->Texture.Unit[texUnit]._Current;
}
-/**
- * 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,