intel: Add support for ARB_sampler_objects.
This extension support consists of replacing "gl_texture_obj->Sampler." with "_mesa_get_samplerobj(ctx, unit)->". One instance of referencing the texture's base sampler remains in the initial miptree allocation, where I'm not sure we have a clear association with any texture unit. Tested with piglit ARB_sampler_objects/sampler-objects. Reviewed-by: Brian Paul <brianp@vmware.com>
This commit is contained in:
@@ -41,6 +41,7 @@
|
|||||||
#include "main/bufferobj.h"
|
#include "main/bufferobj.h"
|
||||||
#include "main/fbobject.h"
|
#include "main/fbobject.h"
|
||||||
#include "main/texrender.h"
|
#include "main/texrender.h"
|
||||||
|
#include "main/samplerobj.h"
|
||||||
#include "main/syncobj.h"
|
#include "main/syncobj.h"
|
||||||
#include "main/texturebarrier.h"
|
#include "main/texturebarrier.h"
|
||||||
#include "main/transformfeedback.h"
|
#include "main/transformfeedback.h"
|
||||||
@@ -200,6 +201,8 @@ _mesa_init_driver_functions(struct dd_function_table *driver)
|
|||||||
|
|
||||||
_mesa_init_transform_feedback_functions(driver);
|
_mesa_init_transform_feedback_functions(driver);
|
||||||
|
|
||||||
|
_mesa_init_sampler_object_functions(driver);
|
||||||
|
|
||||||
/* T&L stuff */
|
/* T&L stuff */
|
||||||
driver->NeedValidate = GL_FALSE;
|
driver->NeedValidate = GL_FALSE;
|
||||||
driver->ValidateTnlModule = NULL;
|
driver->ValidateTnlModule = NULL;
|
||||||
|
@@ -29,6 +29,7 @@
|
|||||||
#include "main/enums.h"
|
#include "main/enums.h"
|
||||||
#include "main/colormac.h"
|
#include "main/colormac.h"
|
||||||
#include "main/macros.h"
|
#include "main/macros.h"
|
||||||
|
#include "main/samplerobj.h"
|
||||||
|
|
||||||
#include "intel_mipmap_tree.h"
|
#include "intel_mipmap_tree.h"
|
||||||
#include "intel_tex.h"
|
#include "intel_tex.h"
|
||||||
@@ -120,6 +121,7 @@ i830_update_tex_unit(struct intel_context *intel, GLuint unit, GLuint ss3)
|
|||||||
struct gl_texture_object *tObj = tUnit->_Current;
|
struct gl_texture_object *tObj = tUnit->_Current;
|
||||||
struct intel_texture_object *intelObj = intel_texture_object(tObj);
|
struct intel_texture_object *intelObj = intel_texture_object(tObj);
|
||||||
struct gl_texture_image *firstImage;
|
struct gl_texture_image *firstImage;
|
||||||
|
struct gl_sampler_object *sampler = _mesa_get_samplerobj(ctx, unit);
|
||||||
GLuint *state = i830->state.Tex[unit], format, pitch;
|
GLuint *state = i830->state.Tex[unit], format, pitch;
|
||||||
GLint lodbias;
|
GLint lodbias;
|
||||||
GLubyte border[4];
|
GLubyte border[4];
|
||||||
@@ -193,7 +195,7 @@ i830_update_tex_unit(struct intel_context *intel, GLuint unit, GLuint ss3)
|
|||||||
float maxlod;
|
float maxlod;
|
||||||
uint32_t minlod_fixed, maxlod_fixed;
|
uint32_t minlod_fixed, maxlod_fixed;
|
||||||
|
|
||||||
switch (tObj->Sampler.MinFilter) {
|
switch (sampler->MinFilter) {
|
||||||
case GL_NEAREST:
|
case GL_NEAREST:
|
||||||
minFilt = FILTER_NEAREST;
|
minFilt = FILTER_NEAREST;
|
||||||
mipFilt = MIPFILTER_NONE;
|
mipFilt = MIPFILTER_NONE;
|
||||||
@@ -222,12 +224,12 @@ i830_update_tex_unit(struct intel_context *intel, GLuint unit, GLuint ss3)
|
|||||||
return GL_FALSE;
|
return GL_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tObj->Sampler.MaxAnisotropy > 1.0) {
|
if (sampler->MaxAnisotropy > 1.0) {
|
||||||
minFilt = FILTER_ANISOTROPIC;
|
minFilt = FILTER_ANISOTROPIC;
|
||||||
magFilt = FILTER_ANISOTROPIC;
|
magFilt = FILTER_ANISOTROPIC;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
switch (tObj->Sampler.MagFilter) {
|
switch (sampler->MagFilter) {
|
||||||
case GL_NEAREST:
|
case GL_NEAREST:
|
||||||
magFilt = FILTER_NEAREST;
|
magFilt = FILTER_NEAREST;
|
||||||
break;
|
break;
|
||||||
@@ -239,7 +241,7 @@ i830_update_tex_unit(struct intel_context *intel, GLuint unit, GLuint ss3)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
lodbias = (int) ((tUnit->LodBias + tObj->Sampler.LodBias) * 16.0);
|
lodbias = (int) ((tUnit->LodBias + sampler->LodBias) * 16.0);
|
||||||
if (lodbias < -64)
|
if (lodbias < -64)
|
||||||
lodbias = -64;
|
lodbias = -64;
|
||||||
if (lodbias > 63)
|
if (lodbias > 63)
|
||||||
@@ -259,8 +261,8 @@ i830_update_tex_unit(struct intel_context *intel, GLuint unit, GLuint ss3)
|
|||||||
* addressable (smallest resolution) LOD. Use it to cover both
|
* addressable (smallest resolution) LOD. Use it to cover both
|
||||||
* MAX_LEVEL and MAX_LOD.
|
* MAX_LEVEL and MAX_LOD.
|
||||||
*/
|
*/
|
||||||
minlod_fixed = U_FIXED(CLAMP(tObj->Sampler.MinLod, 0.0, 11), 4);
|
minlod_fixed = U_FIXED(CLAMP(sampler->MinLod, 0.0, 11), 4);
|
||||||
maxlod = MIN2(tObj->Sampler.MaxLod, tObj->_MaxLevel - tObj->BaseLevel);
|
maxlod = MIN2(sampler->MaxLod, tObj->_MaxLevel - tObj->BaseLevel);
|
||||||
if (intel->intelScreen->deviceID == PCI_CHIP_I855_GM ||
|
if (intel->intelScreen->deviceID == PCI_CHIP_I855_GM ||
|
||||||
intel->intelScreen->deviceID == PCI_CHIP_I865_G) {
|
intel->intelScreen->deviceID == PCI_CHIP_I865_G) {
|
||||||
maxlod_fixed = U_FIXED(CLAMP(maxlod, 0.0, 11.75), 2);
|
maxlod_fixed = U_FIXED(CLAMP(maxlod, 0.0, 11.75), 2);
|
||||||
@@ -279,8 +281,8 @@ i830_update_tex_unit(struct intel_context *intel, GLuint unit, GLuint ss3)
|
|||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
GLenum ws = tObj->Sampler.WrapS;
|
GLenum ws = sampler->WrapS;
|
||||||
GLenum wt = tObj->Sampler.WrapT;
|
GLenum wt = sampler->WrapT;
|
||||||
|
|
||||||
|
|
||||||
/* 3D textures not available on i830
|
/* 3D textures not available on i830
|
||||||
@@ -300,10 +302,10 @@ i830_update_tex_unit(struct intel_context *intel, GLuint unit, GLuint ss3)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* convert border color from float to ubyte */
|
/* convert border color from float to ubyte */
|
||||||
CLAMPED_FLOAT_TO_UBYTE(border[0], tObj->Sampler.BorderColor.f[0]);
|
CLAMPED_FLOAT_TO_UBYTE(border[0], sampler->BorderColor.f[0]);
|
||||||
CLAMPED_FLOAT_TO_UBYTE(border[1], tObj->Sampler.BorderColor.f[1]);
|
CLAMPED_FLOAT_TO_UBYTE(border[1], sampler->BorderColor.f[1]);
|
||||||
CLAMPED_FLOAT_TO_UBYTE(border[2], tObj->Sampler.BorderColor.f[2]);
|
CLAMPED_FLOAT_TO_UBYTE(border[2], sampler->BorderColor.f[2]);
|
||||||
CLAMPED_FLOAT_TO_UBYTE(border[3], tObj->Sampler.BorderColor.f[3]);
|
CLAMPED_FLOAT_TO_UBYTE(border[3], sampler->BorderColor.f[3]);
|
||||||
|
|
||||||
state[I830_TEXREG_TM0S4] = PACK_COLOR_8888(border[3],
|
state[I830_TEXREG_TM0S4] = PACK_COLOR_8888(border[3],
|
||||||
border[0],
|
border[0],
|
||||||
|
@@ -29,6 +29,7 @@
|
|||||||
#include "main/enums.h"
|
#include "main/enums.h"
|
||||||
#include "main/macros.h"
|
#include "main/macros.h"
|
||||||
#include "main/colormac.h"
|
#include "main/colormac.h"
|
||||||
|
#include "main/samplerobj.h"
|
||||||
|
|
||||||
#include "intel_mipmap_tree.h"
|
#include "intel_mipmap_tree.h"
|
||||||
#include "intel_tex.h"
|
#include "intel_tex.h"
|
||||||
@@ -136,6 +137,7 @@ i915_update_tex_unit(struct intel_context *intel, GLuint unit, GLuint ss3)
|
|||||||
struct gl_texture_object *tObj = tUnit->_Current;
|
struct gl_texture_object *tObj = tUnit->_Current;
|
||||||
struct intel_texture_object *intelObj = intel_texture_object(tObj);
|
struct intel_texture_object *intelObj = intel_texture_object(tObj);
|
||||||
struct gl_texture_image *firstImage;
|
struct gl_texture_image *firstImage;
|
||||||
|
struct gl_sampler_object *sampler = _mesa_get_samplerobj(ctx, unit);
|
||||||
GLuint *state = i915->state.Tex[unit], format, pitch;
|
GLuint *state = i915->state.Tex[unit], format, pitch;
|
||||||
GLint lodbias, aniso = 0;
|
GLint lodbias, aniso = 0;
|
||||||
GLubyte border[4];
|
GLubyte border[4];
|
||||||
@@ -164,7 +166,7 @@ i915_update_tex_unit(struct intel_context *intel, GLuint unit, GLuint ss3)
|
|||||||
|
|
||||||
format = translate_texture_format(firstImage->TexFormat,
|
format = translate_texture_format(firstImage->TexFormat,
|
||||||
firstImage->InternalFormat,
|
firstImage->InternalFormat,
|
||||||
tObj->Sampler.DepthMode);
|
sampler->DepthMode);
|
||||||
pitch = intelObj->mt->region->pitch * intelObj->mt->cpp;
|
pitch = intelObj->mt->region->pitch * intelObj->mt->cpp;
|
||||||
|
|
||||||
state[I915_TEXREG_MS3] =
|
state[I915_TEXREG_MS3] =
|
||||||
@@ -181,7 +183,7 @@ i915_update_tex_unit(struct intel_context *intel, GLuint unit, GLuint ss3)
|
|||||||
* (lowest resolution) LOD. Use it to cover both MAX_LEVEL and
|
* (lowest resolution) LOD. Use it to cover both MAX_LEVEL and
|
||||||
* MAX_LOD.
|
* MAX_LOD.
|
||||||
*/
|
*/
|
||||||
maxlod = MIN2(tObj->Sampler.MaxLod, tObj->_MaxLevel - tObj->BaseLevel);
|
maxlod = MIN2(sampler->MaxLod, tObj->_MaxLevel - tObj->BaseLevel);
|
||||||
state[I915_TEXREG_MS4] =
|
state[I915_TEXREG_MS4] =
|
||||||
((((pitch / 4) - 1) << MS4_PITCH_SHIFT) |
|
((((pitch / 4) - 1) << MS4_PITCH_SHIFT) |
|
||||||
MS4_CUBE_FACE_ENA_MASK |
|
MS4_CUBE_FACE_ENA_MASK |
|
||||||
@@ -192,7 +194,7 @@ i915_update_tex_unit(struct intel_context *intel, GLuint unit, GLuint ss3)
|
|||||||
{
|
{
|
||||||
GLuint minFilt, mipFilt, magFilt;
|
GLuint minFilt, mipFilt, magFilt;
|
||||||
|
|
||||||
switch (tObj->Sampler.MinFilter) {
|
switch (sampler->MinFilter) {
|
||||||
case GL_NEAREST:
|
case GL_NEAREST:
|
||||||
minFilt = FILTER_NEAREST;
|
minFilt = FILTER_NEAREST;
|
||||||
mipFilt = MIPFILTER_NONE;
|
mipFilt = MIPFILTER_NONE;
|
||||||
@@ -221,16 +223,16 @@ i915_update_tex_unit(struct intel_context *intel, GLuint unit, GLuint ss3)
|
|||||||
return GL_FALSE;
|
return GL_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tObj->Sampler.MaxAnisotropy > 1.0) {
|
if (sampler->MaxAnisotropy > 1.0) {
|
||||||
minFilt = FILTER_ANISOTROPIC;
|
minFilt = FILTER_ANISOTROPIC;
|
||||||
magFilt = FILTER_ANISOTROPIC;
|
magFilt = FILTER_ANISOTROPIC;
|
||||||
if (tObj->Sampler.MaxAnisotropy > 2.0)
|
if (sampler->MaxAnisotropy > 2.0)
|
||||||
aniso = SS2_MAX_ANISO_4;
|
aniso = SS2_MAX_ANISO_4;
|
||||||
else
|
else
|
||||||
aniso = SS2_MAX_ANISO_2;
|
aniso = SS2_MAX_ANISO_2;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
switch (tObj->Sampler.MagFilter) {
|
switch (sampler->MagFilter) {
|
||||||
case GL_NEAREST:
|
case GL_NEAREST:
|
||||||
magFilt = FILTER_NEAREST;
|
magFilt = FILTER_NEAREST;
|
||||||
break;
|
break;
|
||||||
@@ -242,7 +244,7 @@ i915_update_tex_unit(struct intel_context *intel, GLuint unit, GLuint ss3)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
lodbias = (int) ((tUnit->LodBias + tObj->Sampler.LodBias) * 16.0);
|
lodbias = (int) ((tUnit->LodBias + sampler->LodBias) * 16.0);
|
||||||
if (lodbias < -256)
|
if (lodbias < -256)
|
||||||
lodbias = -256;
|
lodbias = -256;
|
||||||
if (lodbias > 255)
|
if (lodbias > 255)
|
||||||
@@ -258,14 +260,14 @@ i915_update_tex_unit(struct intel_context *intel, GLuint unit, GLuint ss3)
|
|||||||
|
|
||||||
/* Shadow:
|
/* 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) {
|
tObj->Target != GL_TEXTURE_3D) {
|
||||||
if (tObj->Target == GL_TEXTURE_1D)
|
if (tObj->Target == GL_TEXTURE_1D)
|
||||||
return GL_FALSE;
|
return GL_FALSE;
|
||||||
|
|
||||||
state[I915_TEXREG_SS2] |=
|
state[I915_TEXREG_SS2] |=
|
||||||
(SS2_SHADOW_ENABLE |
|
(SS2_SHADOW_ENABLE |
|
||||||
intel_translate_shadow_compare_func(tObj->Sampler.CompareFunc));
|
intel_translate_shadow_compare_func(sampler->CompareFunc));
|
||||||
|
|
||||||
minFilt = FILTER_4X4_FLAT;
|
minFilt = FILTER_4X4_FLAT;
|
||||||
magFilt = FILTER_4X4_FLAT;
|
magFilt = FILTER_4X4_FLAT;
|
||||||
@@ -278,9 +280,9 @@ i915_update_tex_unit(struct intel_context *intel, GLuint unit, GLuint ss3)
|
|||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
GLenum ws = tObj->Sampler.WrapS;
|
GLenum ws = sampler->WrapS;
|
||||||
GLenum wt = tObj->Sampler.WrapT;
|
GLenum wt = sampler->WrapT;
|
||||||
GLenum wr = tObj->Sampler.WrapR;
|
GLenum wr = sampler->WrapR;
|
||||||
float minlod;
|
float minlod;
|
||||||
|
|
||||||
/* We program 1D textures as 2D textures, so the 2D texcoord could
|
/* We program 1D textures as 2D textures, so the 2D texcoord could
|
||||||
@@ -298,8 +300,8 @@ i915_update_tex_unit(struct intel_context *intel, GLuint unit, GLuint ss3)
|
|||||||
* clamp_to_border.
|
* clamp_to_border.
|
||||||
*/
|
*/
|
||||||
if (tObj->Target == GL_TEXTURE_3D &&
|
if (tObj->Target == GL_TEXTURE_3D &&
|
||||||
(tObj->Sampler.MinFilter != GL_NEAREST ||
|
(sampler->MinFilter != GL_NEAREST ||
|
||||||
tObj->Sampler.MagFilter != GL_NEAREST) &&
|
sampler->MagFilter != GL_NEAREST) &&
|
||||||
(ws == GL_CLAMP ||
|
(ws == GL_CLAMP ||
|
||||||
wt == GL_CLAMP ||
|
wt == GL_CLAMP ||
|
||||||
wr == GL_CLAMP ||
|
wr == GL_CLAMP ||
|
||||||
@@ -322,7 +324,7 @@ i915_update_tex_unit(struct intel_context *intel, GLuint unit, GLuint ss3)
|
|||||||
(translate_wrap_mode(wt) << SS3_TCY_ADDR_MODE_SHIFT) |
|
(translate_wrap_mode(wt) << SS3_TCY_ADDR_MODE_SHIFT) |
|
||||||
(translate_wrap_mode(wr) << SS3_TCZ_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] |= (unit << SS3_TEXTUREMAP_INDEX_SHIFT);
|
||||||
state[I915_TEXREG_SS3] |= (U_FIXED(CLAMP(minlod, 0.0, 11.0), 4) <<
|
state[I915_TEXREG_SS3] |= (U_FIXED(CLAMP(minlod, 0.0, 11.0), 4) <<
|
||||||
SS3_MIN_LOD_SHIFT);
|
SS3_MIN_LOD_SHIFT);
|
||||||
@@ -330,10 +332,10 @@ i915_update_tex_unit(struct intel_context *intel, GLuint unit, GLuint ss3)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* convert border color from float to ubyte */
|
/* convert border color from float to ubyte */
|
||||||
CLAMPED_FLOAT_TO_UBYTE(border[0], tObj->Sampler.BorderColor.f[0]);
|
CLAMPED_FLOAT_TO_UBYTE(border[0], sampler->BorderColor.f[0]);
|
||||||
CLAMPED_FLOAT_TO_UBYTE(border[1], tObj->Sampler.BorderColor.f[1]);
|
CLAMPED_FLOAT_TO_UBYTE(border[1], sampler->BorderColor.f[1]);
|
||||||
CLAMPED_FLOAT_TO_UBYTE(border[2], tObj->Sampler.BorderColor.f[2]);
|
CLAMPED_FLOAT_TO_UBYTE(border[2], sampler->BorderColor.f[2]);
|
||||||
CLAMPED_FLOAT_TO_UBYTE(border[3], tObj->Sampler.BorderColor.f[3]);
|
CLAMPED_FLOAT_TO_UBYTE(border[3], sampler->BorderColor.f[3]);
|
||||||
|
|
||||||
if (firstImage->_BaseFormat == GL_DEPTH_COMPONENT) {
|
if (firstImage->_BaseFormat == GL_DEPTH_COMPONENT) {
|
||||||
/* GL specs that border color for depth textures is taken from the
|
/* GL specs that border color for depth textures is taken from the
|
||||||
|
@@ -29,6 +29,7 @@
|
|||||||
#include "main/glheader.h"
|
#include "main/glheader.h"
|
||||||
#include "main/context.h"
|
#include "main/context.h"
|
||||||
#include "main/condrender.h"
|
#include "main/condrender.h"
|
||||||
|
#include "main/samplerobj.h"
|
||||||
#include "main/state.h"
|
#include "main/state.h"
|
||||||
#include "main/enums.h"
|
#include "main/enums.h"
|
||||||
#include "tnl/tnl.h"
|
#include "tnl/tnl.h"
|
||||||
@@ -279,22 +280,25 @@ static GLboolean check_fallbacks( struct brw_context *brw,
|
|||||||
int u;
|
int u;
|
||||||
for (u = 0; u < ctx->Const.MaxTextureCoordUnits; u++) {
|
for (u = 0; u < ctx->Const.MaxTextureCoordUnits; u++) {
|
||||||
struct gl_texture_unit *texUnit = &ctx->Texture.Unit[u];
|
struct gl_texture_unit *texUnit = &ctx->Texture.Unit[u];
|
||||||
|
|
||||||
if (texUnit->Enabled) {
|
if (texUnit->Enabled) {
|
||||||
|
struct gl_sampler_object *sampler = _mesa_get_samplerobj(ctx, u);
|
||||||
|
|
||||||
if (texUnit->Enabled & TEXTURE_1D_BIT) {
|
if (texUnit->Enabled & TEXTURE_1D_BIT) {
|
||||||
if (texUnit->CurrentTex[TEXTURE_1D_INDEX]->Sampler.WrapS == GL_CLAMP) {
|
if (sampler->WrapS == GL_CLAMP) {
|
||||||
return GL_TRUE;
|
return GL_TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (texUnit->Enabled & TEXTURE_2D_BIT) {
|
if (texUnit->Enabled & TEXTURE_2D_BIT) {
|
||||||
if (texUnit->CurrentTex[TEXTURE_2D_INDEX]->Sampler.WrapS == GL_CLAMP ||
|
if (sampler->WrapS == GL_CLAMP ||
|
||||||
texUnit->CurrentTex[TEXTURE_2D_INDEX]->Sampler.WrapT == GL_CLAMP) {
|
sampler->WrapT == GL_CLAMP) {
|
||||||
return GL_TRUE;
|
return GL_TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (texUnit->Enabled & TEXTURE_3D_BIT) {
|
if (texUnit->Enabled & TEXTURE_3D_BIT) {
|
||||||
if (texUnit->CurrentTex[TEXTURE_3D_INDEX]->Sampler.WrapS == GL_CLAMP ||
|
if (sampler->WrapS == GL_CLAMP ||
|
||||||
texUnit->CurrentTex[TEXTURE_3D_INDEX]->Sampler.WrapT == GL_CLAMP ||
|
sampler->WrapT == GL_CLAMP ||
|
||||||
texUnit->CurrentTex[TEXTURE_3D_INDEX]->Sampler.WrapR == GL_CLAMP) {
|
sampler->WrapR == GL_CLAMP) {
|
||||||
return GL_TRUE;
|
return GL_TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -33,6 +33,7 @@
|
|||||||
#include "brw_wm.h"
|
#include "brw_wm.h"
|
||||||
#include "brw_state.h"
|
#include "brw_state.h"
|
||||||
#include "main/formats.h"
|
#include "main/formats.h"
|
||||||
|
#include "main/samplerobj.h"
|
||||||
|
|
||||||
/** Return number of src args for given instruction */
|
/** Return number of src args for given instruction */
|
||||||
GLuint brw_wm_nr_args( GLuint opcode )
|
GLuint brw_wm_nr_args( GLuint opcode )
|
||||||
@@ -373,6 +374,7 @@ static void brw_wm_populate_key( struct brw_context *brw,
|
|||||||
if (unit->_ReallyEnabled) {
|
if (unit->_ReallyEnabled) {
|
||||||
const struct gl_texture_object *t = unit->_Current;
|
const struct gl_texture_object *t = unit->_Current;
|
||||||
const struct gl_texture_image *img = t->Image[0][t->BaseLevel];
|
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] = {
|
int swizzles[SWIZZLE_NIL + 1] = {
|
||||||
SWIZZLE_X,
|
SWIZZLE_X,
|
||||||
SWIZZLE_Y,
|
SWIZZLE_Y,
|
||||||
@@ -388,14 +390,14 @@ static void brw_wm_populate_key( struct brw_context *brw,
|
|||||||
* well and our shadow compares always return the result in
|
* well and our shadow compares always return the result in
|
||||||
* all 4 channels.
|
* all 4 channels.
|
||||||
*/
|
*/
|
||||||
if (t->Sampler.CompareMode == GL_COMPARE_R_TO_TEXTURE_ARB) {
|
if (sampler->CompareMode == GL_COMPARE_R_TO_TEXTURE_ARB) {
|
||||||
if (t->Sampler.DepthMode == GL_ALPHA) {
|
if (sampler->DepthMode == GL_ALPHA) {
|
||||||
swizzles[0] = SWIZZLE_ZERO;
|
swizzles[0] = SWIZZLE_ZERO;
|
||||||
swizzles[1] = SWIZZLE_ZERO;
|
swizzles[1] = SWIZZLE_ZERO;
|
||||||
swizzles[2] = SWIZZLE_ZERO;
|
swizzles[2] = SWIZZLE_ZERO;
|
||||||
} else if (t->Sampler.DepthMode == GL_LUMINANCE) {
|
} else if (sampler->DepthMode == GL_LUMINANCE) {
|
||||||
swizzles[3] = SWIZZLE_ONE;
|
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. */
|
/* See table 3.23 of the GL 3.0 spec. */
|
||||||
swizzles[1] = SWIZZLE_ZERO;
|
swizzles[1] = SWIZZLE_ZERO;
|
||||||
swizzles[2] = SWIZZLE_ZERO;
|
swizzles[2] = SWIZZLE_ZERO;
|
||||||
|
@@ -35,7 +35,7 @@
|
|||||||
#include "brw_defines.h"
|
#include "brw_defines.h"
|
||||||
|
|
||||||
#include "main/macros.h"
|
#include "main/macros.h"
|
||||||
|
#include "main/samplerobj.h"
|
||||||
|
|
||||||
|
|
||||||
/* Samplers aren't strictly wm state from the hardware's perspective,
|
/* Samplers aren't strictly wm state from the hardware's perspective,
|
||||||
@@ -278,6 +278,7 @@ brw_wm_sampler_populate_key(struct brw_context *brw,
|
|||||||
struct gl_texture_object *texObj = texUnit->_Current;
|
struct gl_texture_object *texObj = texUnit->_Current;
|
||||||
struct gl_texture_image *firstImage =
|
struct gl_texture_image *firstImage =
|
||||||
texObj->Image[0][texObj->BaseLevel];
|
texObj->Image[0][texObj->BaseLevel];
|
||||||
|
struct gl_sampler_object *sampler = _mesa_get_samplerobj(ctx, unit);
|
||||||
|
|
||||||
memset(last_entry_end, 0,
|
memset(last_entry_end, 0,
|
||||||
(char*)entry - last_entry_end + sizeof(*entry));
|
(char*)entry - last_entry_end + sizeof(*entry));
|
||||||
@@ -288,26 +289,26 @@ brw_wm_sampler_populate_key(struct brw_context *brw,
|
|||||||
entry->seamless_cube_map = (texObj->Target == GL_TEXTURE_CUBE_MAP)
|
entry->seamless_cube_map = (texObj->Target == GL_TEXTURE_CUBE_MAP)
|
||||||
? ctx->Texture.CubeMapSeamless : GL_FALSE;
|
? ctx->Texture.CubeMapSeamless : GL_FALSE;
|
||||||
|
|
||||||
entry->wrap_r = texObj->Sampler.WrapR;
|
entry->wrap_r = sampler->WrapR;
|
||||||
entry->wrap_s = texObj->Sampler.WrapS;
|
entry->wrap_s = sampler->WrapS;
|
||||||
entry->wrap_t = texObj->Sampler.WrapT;
|
entry->wrap_t = sampler->WrapT;
|
||||||
|
|
||||||
entry->maxlod = texObj->Sampler.MaxLod;
|
entry->maxlod = sampler->MaxLod;
|
||||||
entry->minlod = texObj->Sampler.MinLod;
|
entry->minlod = sampler->MinLod;
|
||||||
entry->lod_bias = texUnit->LodBias + texObj->Sampler.LodBias;
|
entry->lod_bias = texUnit->LodBias + sampler->LodBias;
|
||||||
entry->max_aniso = texObj->Sampler.MaxAnisotropy;
|
entry->max_aniso = sampler->MaxAnisotropy;
|
||||||
entry->minfilter = texObj->Sampler.MinFilter;
|
entry->minfilter = sampler->MinFilter;
|
||||||
entry->magfilter = texObj->Sampler.MagFilter;
|
entry->magfilter = sampler->MagFilter;
|
||||||
entry->comparemode = texObj->Sampler.CompareMode;
|
entry->comparemode = sampler->CompareMode;
|
||||||
entry->comparefunc = texObj->Sampler.CompareFunc;
|
entry->comparefunc = sampler->CompareFunc;
|
||||||
|
|
||||||
drm_intel_bo_unreference(brw->wm.sdc_bo[unit]);
|
drm_intel_bo_unreference(brw->wm.sdc_bo[unit]);
|
||||||
if (firstImage->_BaseFormat == GL_DEPTH_COMPONENT) {
|
if (firstImage->_BaseFormat == GL_DEPTH_COMPONENT) {
|
||||||
float bordercolor[4] = {
|
float bordercolor[4] = {
|
||||||
texObj->Sampler.BorderColor.f[0],
|
sampler->BorderColor.f[0],
|
||||||
texObj->Sampler.BorderColor.f[0],
|
sampler->BorderColor.f[0],
|
||||||
texObj->Sampler.BorderColor.f[0],
|
sampler->BorderColor.f[0],
|
||||||
texObj->Sampler.BorderColor.f[0]
|
sampler->BorderColor.f[0]
|
||||||
};
|
};
|
||||||
/* GL specs that border color for depth textures is taken from the
|
/* GL specs that border color for depth textures is taken from the
|
||||||
* R channel, while the hardware uses A. Spam R into all the
|
* R channel, while the hardware uses A. Spam R into all the
|
||||||
@@ -316,7 +317,7 @@ brw_wm_sampler_populate_key(struct brw_context *brw,
|
|||||||
brw->wm.sdc_bo[unit] = upload_default_color(brw, bordercolor);
|
brw->wm.sdc_bo[unit] = upload_default_color(brw, bordercolor);
|
||||||
} else {
|
} else {
|
||||||
brw->wm.sdc_bo[unit] = upload_default_color(brw,
|
brw->wm.sdc_bo[unit] = upload_default_color(brw,
|
||||||
texObj->Sampler.BorderColor.f);
|
sampler->BorderColor.f);
|
||||||
}
|
}
|
||||||
key->sampler_count = unit + 1;
|
key->sampler_count = unit + 1;
|
||||||
}
|
}
|
||||||
|
@@ -31,6 +31,7 @@
|
|||||||
|
|
||||||
|
|
||||||
#include "main/mtypes.h"
|
#include "main/mtypes.h"
|
||||||
|
#include "main/samplerobj.h"
|
||||||
#include "main/texstore.h"
|
#include "main/texstore.h"
|
||||||
#include "program/prog_parameter.h"
|
#include "program/prog_parameter.h"
|
||||||
|
|
||||||
@@ -217,6 +218,7 @@ brw_update_texture_surface( struct gl_context *ctx, GLuint unit )
|
|||||||
struct gl_texture_object *tObj = ctx->Texture.Unit[unit]._Current;
|
struct gl_texture_object *tObj = ctx->Texture.Unit[unit]._Current;
|
||||||
struct intel_texture_object *intelObj = intel_texture_object(tObj);
|
struct intel_texture_object *intelObj = intel_texture_object(tObj);
|
||||||
struct gl_texture_image *firstImage = tObj->Image[0][tObj->BaseLevel];
|
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);
|
const GLuint surf_index = SURF_INDEX_TEXTURE(unit);
|
||||||
struct brw_surface_state *surf;
|
struct brw_surface_state *surf;
|
||||||
|
|
||||||
@@ -228,8 +230,8 @@ brw_update_texture_surface( struct gl_context *ctx, GLuint unit )
|
|||||||
surf->ss0.surface_type = translate_tex_target(tObj->Target);
|
surf->ss0.surface_type = translate_tex_target(tObj->Target);
|
||||||
surf->ss0.surface_format = translate_tex_format(firstImage->TexFormat,
|
surf->ss0.surface_format = translate_tex_format(firstImage->TexFormat,
|
||||||
firstImage->InternalFormat,
|
firstImage->InternalFormat,
|
||||||
tObj->Sampler.DepthMode,
|
sampler->DepthMode,
|
||||||
tObj->Sampler.sRGBDecode);
|
sampler->sRGBDecode);
|
||||||
|
|
||||||
/* This is ok for all textures with channel width 8bit or less:
|
/* This is ok for all textures with channel width 8bit or less:
|
||||||
*/
|
*/
|
||||||
|
@@ -91,6 +91,7 @@ static const struct dri_extension card_extensions[] = {
|
|||||||
{ "GL_ARB_pixel_buffer_object", NULL },
|
{ "GL_ARB_pixel_buffer_object", NULL },
|
||||||
{ "GL_ARB_point_parameters", GL_ARB_point_parameters_functions },
|
{ "GL_ARB_point_parameters", GL_ARB_point_parameters_functions },
|
||||||
{ "GL_ARB_point_sprite", NULL },
|
{ "GL_ARB_point_sprite", NULL },
|
||||||
|
{ "GL_ARB_sampler_objects", NULL },
|
||||||
{ "GL_ARB_shader_objects", GL_ARB_shader_objects_functions },
|
{ "GL_ARB_shader_objects", GL_ARB_shader_objects_functions },
|
||||||
{ "GL_ARB_shading_language_100", GL_VERSION_2_0_functions },
|
{ "GL_ARB_shading_language_100", GL_VERSION_2_0_functions },
|
||||||
{ "GL_ARB_sync", GL_ARB_sync_functions },
|
{ "GL_ARB_sync", GL_ARB_sync_functions },
|
||||||
|
@@ -1,5 +1,6 @@
|
|||||||
#include "main/mtypes.h"
|
#include "main/mtypes.h"
|
||||||
#include "main/macros.h"
|
#include "main/macros.h"
|
||||||
|
#include "main/samplerobj.h"
|
||||||
|
|
||||||
#include "intel_context.h"
|
#include "intel_context.h"
|
||||||
#include "intel_mipmap_tree.h"
|
#include "intel_mipmap_tree.h"
|
||||||
@@ -14,11 +15,13 @@
|
|||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
intel_update_max_level(struct intel_context *intel,
|
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;
|
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;
|
intelObj->_MaxLevel = tObj->BaseLevel;
|
||||||
} else {
|
} else {
|
||||||
intelObj->_MaxLevel = tObj->_MaxLevel;
|
intelObj->_MaxLevel = tObj->_MaxLevel;
|
||||||
@@ -70,8 +73,10 @@ copy_image_data_to_tree(struct intel_context *intel,
|
|||||||
GLuint
|
GLuint
|
||||||
intel_finalize_mipmap_tree(struct intel_context *intel, GLuint unit)
|
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 gl_texture_object *tObj = intel->ctx.Texture.Unit[unit]._Current;
|
||||||
struct intel_texture_object *intelObj = intel_texture_object(tObj);
|
struct intel_texture_object *intelObj = intel_texture_object(tObj);
|
||||||
|
struct gl_sampler_object *sampler = _mesa_get_samplerobj(ctx, unit);
|
||||||
int comp_byte = 0;
|
int comp_byte = 0;
|
||||||
int cpp;
|
int cpp;
|
||||||
GLuint face, i;
|
GLuint face, i;
|
||||||
@@ -84,7 +89,7 @@ intel_finalize_mipmap_tree(struct intel_context *intel, GLuint unit)
|
|||||||
|
|
||||||
/* What levels must the tree include at a minimum?
|
/* 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]);
|
firstImage = intel_texture_image(tObj->Image[0][tObj->BaseLevel]);
|
||||||
|
|
||||||
/* Fallback case:
|
/* Fallback case:
|
||||||
|
@@ -28,6 +28,14 @@
|
|||||||
|
|
||||||
struct dd_function_table;
|
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
|
extern void
|
||||||
_mesa_reference_sampler_object(struct gl_context *ctx,
|
_mesa_reference_sampler_object(struct gl_context *ctx,
|
||||||
|
@@ -33,6 +33,8 @@
|
|||||||
|
|
||||||
|
|
||||||
#include "main/macros.h"
|
#include "main/macros.h"
|
||||||
|
#include "main/mtypes.h"
|
||||||
|
#include "main/samplerobj.h"
|
||||||
|
|
||||||
#include "st_context.h"
|
#include "st_context.h"
|
||||||
#include "st_cb_texture.h"
|
#include "st_cb_texture.h"
|
||||||
@@ -154,7 +156,7 @@ update_samplers(struct st_context *st)
|
|||||||
|
|
||||||
teximg = texobj->Image[0][texobj->BaseLevel];
|
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_s = gl_wrap_xlate(msamp->WrapS);
|
||||||
sampler->wrap_t = gl_wrap_xlate(msamp->WrapT);
|
sampler->wrap_t = gl_wrap_xlate(msamp->WrapT);
|
||||||
|
@@ -33,6 +33,8 @@
|
|||||||
|
|
||||||
|
|
||||||
#include "main/macros.h"
|
#include "main/macros.h"
|
||||||
|
#include "main/mtypes.h"
|
||||||
|
#include "main/samplerobj.h"
|
||||||
#include "program/prog_instruction.h"
|
#include "program/prog_instruction.h"
|
||||||
|
|
||||||
#include "st_context.h"
|
#include "st_context.h"
|
||||||
@@ -209,7 +211,7 @@ update_textures(struct st_context *st)
|
|||||||
else
|
else
|
||||||
texUnit = vprog->Base.SamplerUnits[su];
|
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;
|
texObj = st->ctx->Texture.Unit[texUnit]._Current;
|
||||||
|
|
||||||
|
@@ -163,21 +163,6 @@ 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 *
|
extern struct pipe_resource *
|
||||||
st_texture_create(struct st_context *st,
|
st_texture_create(struct st_context *st,
|
||||||
enum pipe_texture_target target,
|
enum pipe_texture_target target,
|
||||||
|
Reference in New Issue
Block a user