mesa: translate into pipe_sampler_state in GL functions
- pipe_sampler_state is added into gl_sampler_attrib. - The border color field is redundant, so the non-gallium field is removed. - Other GL fields are still tracked because of glGet. - Some fields are not set by GL functions because they are always derived from multiple states. - The behavior in GL functions is the same as st_convert_sampler. This reduces overhead by 2% for drawoverhead/8 textures, and more is going to be done. Reviewed-By: Mike Blumenkrantz <michael.blumenkrantz@gmail.com> Reviewed-by: Emma Anholt <emma@anholt.net> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11339>
This commit is contained in:
parent
553588194e
commit
0c70a63f5f
|
@ -302,10 +302,10 @@ i830_update_tex_unit(struct intel_context *intel, GLuint unit, GLuint ss3)
|
|||
}
|
||||
|
||||
/* convert border color from float to ubyte */
|
||||
CLAMPED_FLOAT_TO_UBYTE(border[0], sampler->Attrib.BorderColor.f[0]);
|
||||
CLAMPED_FLOAT_TO_UBYTE(border[1], sampler->Attrib.BorderColor.f[1]);
|
||||
CLAMPED_FLOAT_TO_UBYTE(border[2], sampler->Attrib.BorderColor.f[2]);
|
||||
CLAMPED_FLOAT_TO_UBYTE(border[3], sampler->Attrib.BorderColor.f[3]);
|
||||
CLAMPED_FLOAT_TO_UBYTE(border[0], sampler->Attrib.state.border_color.f[0]);
|
||||
CLAMPED_FLOAT_TO_UBYTE(border[1], sampler->Attrib.state.border_color.f[1]);
|
||||
CLAMPED_FLOAT_TO_UBYTE(border[2], sampler->Attrib.state.border_color.f[2]);
|
||||
CLAMPED_FLOAT_TO_UBYTE(border[3], sampler->Attrib.state.border_color.f[3]);
|
||||
|
||||
state[I830_TEXREG_TM0S4] = PACK_COLOR_8888(border[3],
|
||||
border[0],
|
||||
|
|
|
@ -366,10 +366,10 @@ i915_update_tex_unit(struct intel_context *intel, GLuint unit, GLuint ss3)
|
|||
}
|
||||
|
||||
/* convert border color from float to ubyte */
|
||||
CLAMPED_FLOAT_TO_UBYTE(border[0], sampler->Attrib.BorderColor.f[0]);
|
||||
CLAMPED_FLOAT_TO_UBYTE(border[1], sampler->Attrib.BorderColor.f[1]);
|
||||
CLAMPED_FLOAT_TO_UBYTE(border[2], sampler->Attrib.BorderColor.f[2]);
|
||||
CLAMPED_FLOAT_TO_UBYTE(border[3], sampler->Attrib.BorderColor.f[3]);
|
||||
CLAMPED_FLOAT_TO_UBYTE(border[0], sampler->Attrib.state.border_color.f[0]);
|
||||
CLAMPED_FLOAT_TO_UBYTE(border[1], sampler->Attrib.state.border_color.f[1]);
|
||||
CLAMPED_FLOAT_TO_UBYTE(border[2], sampler->Attrib.state.border_color.f[2]);
|
||||
CLAMPED_FLOAT_TO_UBYTE(border[3], sampler->Attrib.state.border_color.f[3]);
|
||||
|
||||
if (firstImage->_BaseFormat == GL_DEPTH_COMPONENT) {
|
||||
/* GL specs that border color for depth textures is taken from the
|
||||
|
|
|
@ -4967,40 +4967,40 @@ genX(upload_default_color)(struct brw_context *brw,
|
|||
* R channel, while the hardware uses A. Spam R into all the
|
||||
* channels for safety.
|
||||
*/
|
||||
color.ui[0] = sampler->Attrib.BorderColor.ui[0];
|
||||
color.ui[1] = sampler->Attrib.BorderColor.ui[0];
|
||||
color.ui[2] = sampler->Attrib.BorderColor.ui[0];
|
||||
color.ui[3] = sampler->Attrib.BorderColor.ui[0];
|
||||
color.ui[0] = sampler->Attrib.state.border_color.ui[0];
|
||||
color.ui[1] = sampler->Attrib.state.border_color.ui[0];
|
||||
color.ui[2] = sampler->Attrib.state.border_color.ui[0];
|
||||
color.ui[3] = sampler->Attrib.state.border_color.ui[0];
|
||||
break;
|
||||
case GL_ALPHA:
|
||||
color.ui[0] = 0u;
|
||||
color.ui[1] = 0u;
|
||||
color.ui[2] = 0u;
|
||||
color.ui[3] = sampler->Attrib.BorderColor.ui[3];
|
||||
color.ui[3] = sampler->Attrib.state.border_color.ui[3];
|
||||
break;
|
||||
case GL_INTENSITY:
|
||||
color.ui[0] = sampler->Attrib.BorderColor.ui[0];
|
||||
color.ui[1] = sampler->Attrib.BorderColor.ui[0];
|
||||
color.ui[2] = sampler->Attrib.BorderColor.ui[0];
|
||||
color.ui[3] = sampler->Attrib.BorderColor.ui[0];
|
||||
color.ui[0] = sampler->Attrib.state.border_color.ui[0];
|
||||
color.ui[1] = sampler->Attrib.state.border_color.ui[0];
|
||||
color.ui[2] = sampler->Attrib.state.border_color.ui[0];
|
||||
color.ui[3] = sampler->Attrib.state.border_color.ui[0];
|
||||
break;
|
||||
case GL_LUMINANCE:
|
||||
color.ui[0] = sampler->Attrib.BorderColor.ui[0];
|
||||
color.ui[1] = sampler->Attrib.BorderColor.ui[0];
|
||||
color.ui[2] = sampler->Attrib.BorderColor.ui[0];
|
||||
color.ui[0] = sampler->Attrib.state.border_color.ui[0];
|
||||
color.ui[1] = sampler->Attrib.state.border_color.ui[0];
|
||||
color.ui[2] = sampler->Attrib.state.border_color.ui[0];
|
||||
color.ui[3] = float_as_int(1.0);
|
||||
break;
|
||||
case GL_LUMINANCE_ALPHA:
|
||||
color.ui[0] = sampler->Attrib.BorderColor.ui[0];
|
||||
color.ui[1] = sampler->Attrib.BorderColor.ui[0];
|
||||
color.ui[2] = sampler->Attrib.BorderColor.ui[0];
|
||||
color.ui[3] = sampler->Attrib.BorderColor.ui[3];
|
||||
color.ui[0] = sampler->Attrib.state.border_color.ui[0];
|
||||
color.ui[1] = sampler->Attrib.state.border_color.ui[0];
|
||||
color.ui[2] = sampler->Attrib.state.border_color.ui[0];
|
||||
color.ui[3] = sampler->Attrib.state.border_color.ui[3];
|
||||
break;
|
||||
default:
|
||||
color.ui[0] = sampler->Attrib.BorderColor.ui[0];
|
||||
color.ui[1] = sampler->Attrib.BorderColor.ui[1];
|
||||
color.ui[2] = sampler->Attrib.BorderColor.ui[2];
|
||||
color.ui[3] = sampler->Attrib.BorderColor.ui[3];
|
||||
color.ui[0] = sampler->Attrib.state.border_color.ui[0];
|
||||
color.ui[1] = sampler->Attrib.state.border_color.ui[1];
|
||||
color.ui[2] = sampler->Attrib.state.border_color.ui[2];
|
||||
color.ui[3] = sampler->Attrib.state.border_color.ui[3];
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
@ -213,10 +213,10 @@ nv20_emit_tex_obj(struct gl_context *ctx, int emit)
|
|||
| nvgl_filter_mode(sa->Attrib.MinFilter) << 16
|
||||
| 2 << 12;
|
||||
|
||||
r = FLOAT_TO_UBYTE(sa->Attrib.BorderColor.f[0]);
|
||||
g = FLOAT_TO_UBYTE(sa->Attrib.BorderColor.f[1]);
|
||||
b = FLOAT_TO_UBYTE(sa->Attrib.BorderColor.f[2]);
|
||||
a = FLOAT_TO_UBYTE(sa->Attrib.BorderColor.f[3]);
|
||||
r = FLOAT_TO_UBYTE(sa->Attrib.state.border_color.f[0]);
|
||||
g = FLOAT_TO_UBYTE(sa->Attrib.state.border_color.f[1]);
|
||||
b = FLOAT_TO_UBYTE(sa->Attrib.state.border_color.f[2]);
|
||||
a = FLOAT_TO_UBYTE(sa->Attrib.state.border_color.f[3]);
|
||||
switch (ti->_BaseFormat) {
|
||||
case GL_LUMINANCE:
|
||||
a = 0xff;
|
||||
|
|
|
@ -368,7 +368,7 @@ void r200TexUpdateParameters(struct gl_context *ctx, GLuint unit)
|
|||
r200SetTexMaxAnisotropy(t , samp->Attrib.MaxAnisotropy);
|
||||
r200SetTexFilter(t, samp->Attrib.MinFilter, samp->Attrib.MagFilter);
|
||||
r200SetTexWrap(t, samp->Attrib.WrapS, samp->Attrib.WrapT, samp->Attrib.WrapR);
|
||||
r200SetTexBorderColor(t, samp->Attrib.BorderColor.f);
|
||||
r200SetTexBorderColor(t, samp->Attrib.state.border_color.f);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -483,7 +483,7 @@ static struct gl_texture_object *r200NewTextureObject(struct gl_context * ctx,
|
|||
r200SetTexWrap( t, t->base.Sampler.Attrib.WrapS, t->base.Sampler.Attrib.WrapT, t->base.Sampler.Attrib.WrapR );
|
||||
r200SetTexMaxAnisotropy( t, t->base.Sampler.Attrib.MaxAnisotropy );
|
||||
r200SetTexFilter(t, t->base.Sampler.Attrib.MinFilter, t->base.Sampler.Attrib.MagFilter);
|
||||
r200SetTexBorderColor(t, t->base.Sampler.Attrib.BorderColor.f);
|
||||
r200SetTexBorderColor(t, t->base.Sampler.Attrib.state.border_color.f);
|
||||
|
||||
return &t->base;
|
||||
}
|
||||
|
|
|
@ -318,7 +318,7 @@ void radeonTexUpdateParameters(struct gl_context *ctx, GLuint unit)
|
|||
radeonSetTexMaxAnisotropy(t , samp->Attrib.MaxAnisotropy);
|
||||
radeonSetTexFilter(t, samp->Attrib.MinFilter, samp->Attrib.MagFilter);
|
||||
radeonSetTexWrap(t, samp->Attrib.WrapS, samp->Attrib.WrapT);
|
||||
radeonSetTexBorderColor(t, samp->Attrib.BorderColor.f);
|
||||
radeonSetTexBorderColor(t, samp->Attrib.state.border_color.f);
|
||||
}
|
||||
|
||||
|
||||
|
@ -422,7 +422,7 @@ radeonNewTextureObject( struct gl_context *ctx, GLuint name, GLenum target )
|
|||
radeonSetTexWrap( t, t->base.Sampler.Attrib.WrapS, t->base.Sampler.Attrib.WrapT );
|
||||
radeonSetTexMaxAnisotropy( t, t->base.Sampler.Attrib.MaxAnisotropy );
|
||||
radeonSetTexFilter( t, t->base.Sampler.Attrib.MinFilter, t->base.Sampler.Attrib.MagFilter );
|
||||
radeonSetTexBorderColor( t, t->base.Sampler.Attrib.BorderColor.f );
|
||||
radeonSetTexBorderColor( t, t->base.Sampler.Attrib.state.border_color.f );
|
||||
return &t->base;
|
||||
}
|
||||
|
||||
|
|
|
@ -1023,6 +1023,9 @@ build_bitmap_atlas(struct gl_context *ctx, struct gl_bitmap_atlas *atlas,
|
|||
|
||||
atlas->texObj->Sampler.Attrib.MinFilter = GL_NEAREST;
|
||||
atlas->texObj->Sampler.Attrib.MagFilter = GL_NEAREST;
|
||||
atlas->texObj->Sampler.Attrib.state.min_img_filter = PIPE_TEX_FILTER_NEAREST;
|
||||
atlas->texObj->Sampler.Attrib.state.min_mip_filter = PIPE_TEX_MIPFILTER_NONE;
|
||||
atlas->texObj->Sampler.Attrib.state.mag_img_filter = PIPE_TEX_FILTER_NEAREST;
|
||||
atlas->texObj->Attrib.MaxLevel = 0;
|
||||
atlas->texObj->Immutable = GL_TRUE;
|
||||
|
||||
|
|
|
@ -907,7 +907,6 @@ struct gl_sampler_attrib
|
|||
GLenum16 MinFilter; /**< minification filter */
|
||||
GLenum16 MagFilter; /**< magnification filter */
|
||||
GLenum16 sRGBDecode; /**< GL_DECODE_EXT or GL_SKIP_DECODE_EXT */
|
||||
union gl_color_union BorderColor; /**< Interpreted according to texture format */
|
||||
GLfloat MinLod; /**< min lambda, OpenGL 1.2 */
|
||||
GLfloat MaxLod; /**< max lambda, OpenGL 1.2 */
|
||||
GLfloat LodBias; /**< OpenGL 1.4 */
|
||||
|
@ -916,6 +915,8 @@ struct gl_sampler_attrib
|
|||
GLenum16 CompareFunc; /**< GL_ARB_shadow */
|
||||
GLboolean CubeMapSeamless; /**< GL_AMD_seamless_cubemap_per_texture */
|
||||
GLenum16 ReductionMode; /**< GL_EXT_texture_filter_minmax */
|
||||
|
||||
struct pipe_sampler_state state; /**< Gallium representation */
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
@ -40,6 +40,17 @@
|
|||
#include "main/texturebindless.h"
|
||||
#include "util/u_memory.h"
|
||||
|
||||
/* Take advantage of how the enums are defined. */
|
||||
const enum pipe_tex_wrap wrap_to_gallium_table[32] = {
|
||||
[GL_REPEAT & 0x1f] = PIPE_TEX_WRAP_REPEAT,
|
||||
[GL_CLAMP & 0x1f] = PIPE_TEX_WRAP_CLAMP,
|
||||
[GL_CLAMP_TO_EDGE & 0x1f] = PIPE_TEX_WRAP_CLAMP_TO_EDGE,
|
||||
[GL_CLAMP_TO_BORDER & 0x1f] = PIPE_TEX_WRAP_CLAMP_TO_BORDER,
|
||||
[GL_MIRRORED_REPEAT & 0x1f] = PIPE_TEX_WRAP_MIRROR_REPEAT,
|
||||
[GL_MIRROR_CLAMP_EXT & 0x1f] = PIPE_TEX_WRAP_MIRROR_CLAMP,
|
||||
[GL_MIRROR_CLAMP_TO_EDGE & 0x1f] = PIPE_TEX_WRAP_MIRROR_CLAMP_TO_EDGE,
|
||||
[GL_MIRROR_CLAMP_TO_BORDER_EXT & 0x1f] = PIPE_TEX_WRAP_MIRROR_CLAMP_TO_BORDER,
|
||||
};
|
||||
|
||||
struct gl_sampler_object *
|
||||
_mesa_lookup_samplerobj(struct gl_context *ctx, GLuint name)
|
||||
|
@ -109,21 +120,35 @@ _mesa_init_sampler_object(struct gl_sampler_object *sampObj, GLuint name)
|
|||
sampObj->Attrib.WrapS = GL_REPEAT;
|
||||
sampObj->Attrib.WrapT = GL_REPEAT;
|
||||
sampObj->Attrib.WrapR = GL_REPEAT;
|
||||
sampObj->Attrib.state.wrap_s = PIPE_TEX_WRAP_REPEAT;
|
||||
sampObj->Attrib.state.wrap_t = PIPE_TEX_WRAP_REPEAT;
|
||||
sampObj->Attrib.state.wrap_r = PIPE_TEX_WRAP_REPEAT;
|
||||
sampObj->Attrib.MinFilter = GL_NEAREST_MIPMAP_LINEAR;
|
||||
sampObj->Attrib.MagFilter = GL_LINEAR;
|
||||
sampObj->Attrib.BorderColor.f[0] = 0.0;
|
||||
sampObj->Attrib.BorderColor.f[1] = 0.0;
|
||||
sampObj->Attrib.BorderColor.f[2] = 0.0;
|
||||
sampObj->Attrib.BorderColor.f[3] = 0.0;
|
||||
sampObj->Attrib.state.min_img_filter = PIPE_TEX_FILTER_NEAREST;
|
||||
sampObj->Attrib.state.min_mip_filter = PIPE_TEX_MIPFILTER_LINEAR;
|
||||
sampObj->Attrib.state.mag_img_filter = PIPE_TEX_FILTER_LINEAR;
|
||||
sampObj->Attrib.state.border_color.f[0] = 0;
|
||||
sampObj->Attrib.state.border_color.f[1] = 0;
|
||||
sampObj->Attrib.state.border_color.f[2] = 0;
|
||||
sampObj->Attrib.state.border_color.f[3] = 0;
|
||||
sampObj->Attrib.MinLod = -1000.0F;
|
||||
sampObj->Attrib.MaxLod = 1000.0F;
|
||||
sampObj->Attrib.state.min_lod = 0; /* Gallium doesn't allow negative numbers */
|
||||
sampObj->Attrib.state.max_lod = 1000;
|
||||
sampObj->Attrib.LodBias = 0.0F;
|
||||
sampObj->Attrib.state.lod_bias = 0;
|
||||
sampObj->Attrib.MaxAnisotropy = 1.0F;
|
||||
sampObj->Attrib.state.max_anisotropy = 0; /* Gallium uses 0 instead of 1. */
|
||||
sampObj->Attrib.CompareMode = GL_NONE;
|
||||
sampObj->Attrib.CompareFunc = GL_LEQUAL;
|
||||
sampObj->Attrib.state.compare_mode = PIPE_TEX_COMPARE_NONE;
|
||||
sampObj->Attrib.state.compare_func = PIPE_FUNC_LEQUAL;
|
||||
sampObj->Attrib.sRGBDecode = GL_DECODE_EXT;
|
||||
sampObj->Attrib.CubeMapSeamless = GL_FALSE;
|
||||
sampObj->Attrib.state.seamless_cube_map = false;
|
||||
sampObj->Attrib.ReductionMode = GL_WEIGHTED_AVERAGE_EXT;
|
||||
sampObj->Attrib.state.reduction_mode = PIPE_TEX_REDUCTION_WEIGHTED_AVERAGE;
|
||||
sampObj->HandleAllocated = GL_FALSE;
|
||||
|
||||
/* GL_ARB_bindless_texture */
|
||||
|
@ -520,6 +545,9 @@ _mesa_set_sampler_wrap(struct gl_context *ctx, struct gl_sampler_object *samp,
|
|||
samp->Attrib.WrapS = s;
|
||||
samp->Attrib.WrapT = t;
|
||||
samp->Attrib.WrapR = r;
|
||||
samp->Attrib.state.wrap_s = wrap_to_gallium(s);
|
||||
samp->Attrib.state.wrap_t = wrap_to_gallium(t);
|
||||
samp->Attrib.state.wrap_r = wrap_to_gallium(r);
|
||||
}
|
||||
|
||||
#define INVALID_PARAM 0x100
|
||||
|
@ -543,6 +571,7 @@ set_sampler_wrap_s(struct gl_context *ctx, struct gl_sampler_object *samp,
|
|||
if (is_wrap_gl_clamp(samp->Attrib.WrapS) != is_wrap_gl_clamp(param))
|
||||
ctx->NewDriverState |= ctx->DriverFlags.NewSamplersWithClamp;
|
||||
samp->Attrib.WrapS = param;
|
||||
samp->Attrib.state.wrap_s = wrap_to_gallium(param);
|
||||
return GL_TRUE;
|
||||
}
|
||||
return INVALID_PARAM;
|
||||
|
@ -560,6 +589,7 @@ set_sampler_wrap_t(struct gl_context *ctx, struct gl_sampler_object *samp,
|
|||
if (is_wrap_gl_clamp(samp->Attrib.WrapT) != is_wrap_gl_clamp(param))
|
||||
ctx->NewDriverState |= ctx->DriverFlags.NewSamplersWithClamp;
|
||||
samp->Attrib.WrapT = param;
|
||||
samp->Attrib.state.wrap_t = wrap_to_gallium(param);
|
||||
return GL_TRUE;
|
||||
}
|
||||
return INVALID_PARAM;
|
||||
|
@ -577,6 +607,7 @@ set_sampler_wrap_r(struct gl_context *ctx, struct gl_sampler_object *samp,
|
|||
if (is_wrap_gl_clamp(samp->Attrib.WrapR) != is_wrap_gl_clamp(param))
|
||||
ctx->NewDriverState |= ctx->DriverFlags.NewSamplersWithClamp;
|
||||
samp->Attrib.WrapR = param;
|
||||
samp->Attrib.state.wrap_r = wrap_to_gallium(param);
|
||||
return GL_TRUE;
|
||||
}
|
||||
return INVALID_PARAM;
|
||||
|
@ -602,6 +633,9 @@ _mesa_set_sampler_filters(struct gl_context *ctx,
|
|||
flush(ctx);
|
||||
samp->Attrib.MinFilter = min_filter;
|
||||
samp->Attrib.MagFilter = mag_filter;
|
||||
samp->Attrib.state.min_img_filter = filter_to_gallium(min_filter);
|
||||
samp->Attrib.state.min_mip_filter = mipfilter_to_gallium(min_filter);
|
||||
samp->Attrib.state.mag_img_filter = filter_to_gallium(mag_filter);
|
||||
}
|
||||
|
||||
static GLuint
|
||||
|
@ -620,6 +654,8 @@ set_sampler_min_filter(struct gl_context *ctx, struct gl_sampler_object *samp,
|
|||
case GL_LINEAR_MIPMAP_LINEAR:
|
||||
flush(ctx);
|
||||
samp->Attrib.MinFilter = param;
|
||||
samp->Attrib.state.min_img_filter = filter_to_gallium(param);
|
||||
samp->Attrib.state.min_mip_filter = mipfilter_to_gallium(param);
|
||||
return GL_TRUE;
|
||||
default:
|
||||
return INVALID_PARAM;
|
||||
|
@ -639,6 +675,7 @@ set_sampler_mag_filter(struct gl_context *ctx, struct gl_sampler_object *samp,
|
|||
case GL_LINEAR:
|
||||
flush(ctx);
|
||||
samp->Attrib.MagFilter = param;
|
||||
samp->Attrib.state.mag_img_filter = filter_to_gallium(param);
|
||||
return GL_TRUE;
|
||||
default:
|
||||
return INVALID_PARAM;
|
||||
|
@ -655,6 +692,7 @@ set_sampler_lod_bias(struct gl_context *ctx, struct gl_sampler_object *samp,
|
|||
|
||||
flush(ctx);
|
||||
samp->Attrib.LodBias = param;
|
||||
samp->Attrib.state.lod_bias = param;
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
|
@ -665,10 +703,7 @@ set_sampler_border_colorf(struct gl_context *ctx,
|
|||
const GLfloat params[4])
|
||||
{
|
||||
flush(ctx);
|
||||
samp->Attrib.BorderColor.f[RCOMP] = params[0];
|
||||
samp->Attrib.BorderColor.f[GCOMP] = params[1];
|
||||
samp->Attrib.BorderColor.f[BCOMP] = params[2];
|
||||
samp->Attrib.BorderColor.f[ACOMP] = params[3];
|
||||
memcpy(samp->Attrib.state.border_color.f, params, 4 * sizeof(float));
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
|
@ -679,10 +714,7 @@ set_sampler_border_colori(struct gl_context *ctx,
|
|||
const GLint params[4])
|
||||
{
|
||||
flush(ctx);
|
||||
samp->Attrib.BorderColor.i[RCOMP] = params[0];
|
||||
samp->Attrib.BorderColor.i[GCOMP] = params[1];
|
||||
samp->Attrib.BorderColor.i[BCOMP] = params[2];
|
||||
samp->Attrib.BorderColor.i[ACOMP] = params[3];
|
||||
memcpy(samp->Attrib.state.border_color.i, params, 4 * sizeof(float));
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
|
@ -693,10 +725,7 @@ set_sampler_border_colorui(struct gl_context *ctx,
|
|||
const GLuint params[4])
|
||||
{
|
||||
flush(ctx);
|
||||
samp->Attrib.BorderColor.ui[RCOMP] = params[0];
|
||||
samp->Attrib.BorderColor.ui[GCOMP] = params[1];
|
||||
samp->Attrib.BorderColor.ui[BCOMP] = params[2];
|
||||
samp->Attrib.BorderColor.ui[ACOMP] = params[3];
|
||||
memcpy(samp->Attrib.state.border_color.ui, params, 4 * sizeof(float));
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
|
@ -710,6 +739,8 @@ set_sampler_min_lod(struct gl_context *ctx, struct gl_sampler_object *samp,
|
|||
|
||||
flush(ctx);
|
||||
samp->Attrib.MinLod = param;
|
||||
samp->Attrib.state.min_lod = MAX2(param, 0.0f); /* only positive */
|
||||
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
|
@ -723,6 +754,7 @@ set_sampler_max_lod(struct gl_context *ctx, struct gl_sampler_object *samp,
|
|||
|
||||
flush(ctx);
|
||||
samp->Attrib.MaxLod = param;
|
||||
samp->Attrib.state.max_lod = param;
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
|
@ -777,6 +809,7 @@ set_sampler_compare_func(struct gl_context *ctx,
|
|||
case GL_NEVER:
|
||||
flush(ctx);
|
||||
samp->Attrib.CompareFunc = param;
|
||||
samp->Attrib.state.compare_func = func_to_gallium(param);
|
||||
return GL_TRUE;
|
||||
default:
|
||||
return INVALID_PARAM;
|
||||
|
@ -800,6 +833,9 @@ set_sampler_max_anisotropy(struct gl_context *ctx,
|
|||
flush(ctx);
|
||||
/* clamp to max, that's what NVIDIA does */
|
||||
samp->Attrib.MaxAnisotropy = MIN2(param, ctx->Const.MaxTextureMaxAnisotropy);
|
||||
/* gallium sets 0 for 1 */
|
||||
samp->Attrib.state.max_anisotropy = samp->Attrib.MaxAnisotropy == 1 ?
|
||||
0 : samp->Attrib.MaxAnisotropy;
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
|
@ -820,6 +856,7 @@ set_sampler_cube_map_seamless(struct gl_context *ctx,
|
|||
|
||||
flush(ctx);
|
||||
samp->Attrib.CubeMapSeamless = param;
|
||||
samp->Attrib.state.seamless_cube_map = param;
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
|
@ -878,6 +915,7 @@ set_sampler_reduction_mode(struct gl_context *ctx,
|
|||
|
||||
flush(ctx);
|
||||
samp->Attrib.ReductionMode = param;
|
||||
samp->Attrib.state.reduction_mode = reduction_to_gallium(param);
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
|
@ -1504,10 +1542,10 @@ _mesa_GetSamplerParameteriv(GLuint sampler, GLenum pname, GLint *params)
|
|||
case GL_TEXTURE_BORDER_COLOR:
|
||||
if (!ctx->Extensions.ARB_texture_border_clamp)
|
||||
goto invalid_pname;
|
||||
params[0] = FLOAT_TO_INT(sampObj->Attrib.BorderColor.f[0]);
|
||||
params[1] = FLOAT_TO_INT(sampObj->Attrib.BorderColor.f[1]);
|
||||
params[2] = FLOAT_TO_INT(sampObj->Attrib.BorderColor.f[2]);
|
||||
params[3] = FLOAT_TO_INT(sampObj->Attrib.BorderColor.f[3]);
|
||||
params[0] = FLOAT_TO_INT(sampObj->Attrib.state.border_color.f[0]);
|
||||
params[1] = FLOAT_TO_INT(sampObj->Attrib.state.border_color.f[1]);
|
||||
params[2] = FLOAT_TO_INT(sampObj->Attrib.state.border_color.f[2]);
|
||||
params[3] = FLOAT_TO_INT(sampObj->Attrib.state.border_color.f[3]);
|
||||
break;
|
||||
case GL_TEXTURE_CUBE_MAP_SEAMLESS:
|
||||
if (!ctx->Extensions.AMD_seamless_cubemap_per_texture)
|
||||
|
@ -1582,10 +1620,10 @@ _mesa_GetSamplerParameterfv(GLuint sampler, GLenum pname, GLfloat *params)
|
|||
*params = sampObj->Attrib.MaxAnisotropy;
|
||||
break;
|
||||
case GL_TEXTURE_BORDER_COLOR:
|
||||
params[0] = sampObj->Attrib.BorderColor.f[0];
|
||||
params[1] = sampObj->Attrib.BorderColor.f[1];
|
||||
params[2] = sampObj->Attrib.BorderColor.f[2];
|
||||
params[3] = sampObj->Attrib.BorderColor.f[3];
|
||||
params[0] = sampObj->Attrib.state.border_color.f[0];
|
||||
params[1] = sampObj->Attrib.state.border_color.f[1];
|
||||
params[2] = sampObj->Attrib.state.border_color.f[2];
|
||||
params[3] = sampObj->Attrib.state.border_color.f[3];
|
||||
break;
|
||||
case GL_TEXTURE_CUBE_MAP_SEAMLESS:
|
||||
if (!ctx->Extensions.AMD_seamless_cubemap_per_texture)
|
||||
|
@ -1660,10 +1698,10 @@ _mesa_GetSamplerParameterIiv(GLuint sampler, GLenum pname, GLint *params)
|
|||
*params = (GLint) sampObj->Attrib.MaxAnisotropy;
|
||||
break;
|
||||
case GL_TEXTURE_BORDER_COLOR:
|
||||
params[0] = sampObj->Attrib.BorderColor.i[0];
|
||||
params[1] = sampObj->Attrib.BorderColor.i[1];
|
||||
params[2] = sampObj->Attrib.BorderColor.i[2];
|
||||
params[3] = sampObj->Attrib.BorderColor.i[3];
|
||||
params[0] = sampObj->Attrib.state.border_color.i[0];
|
||||
params[1] = sampObj->Attrib.state.border_color.i[1];
|
||||
params[2] = sampObj->Attrib.state.border_color.i[2];
|
||||
params[3] = sampObj->Attrib.state.border_color.i[3];
|
||||
break;
|
||||
case GL_TEXTURE_CUBE_MAP_SEAMLESS:
|
||||
if (!ctx->Extensions.AMD_seamless_cubemap_per_texture)
|
||||
|
@ -1738,10 +1776,10 @@ _mesa_GetSamplerParameterIuiv(GLuint sampler, GLenum pname, GLuint *params)
|
|||
*params = (GLuint) sampObj->Attrib.MaxAnisotropy;
|
||||
break;
|
||||
case GL_TEXTURE_BORDER_COLOR:
|
||||
params[0] = sampObj->Attrib.BorderColor.ui[0];
|
||||
params[1] = sampObj->Attrib.BorderColor.ui[1];
|
||||
params[2] = sampObj->Attrib.BorderColor.ui[2];
|
||||
params[3] = sampObj->Attrib.BorderColor.ui[3];
|
||||
params[0] = sampObj->Attrib.state.border_color.ui[0];
|
||||
params[1] = sampObj->Attrib.state.border_color.ui[1];
|
||||
params[2] = sampObj->Attrib.state.border_color.ui[2];
|
||||
params[3] = sampObj->Attrib.state.border_color.ui[3];
|
||||
break;
|
||||
case GL_TEXTURE_CUBE_MAP_SEAMLESS:
|
||||
if (!ctx->Extensions.AMD_seamless_cubemap_per_texture)
|
||||
|
|
|
@ -149,6 +149,75 @@ _mesa_GetSamplerParameterIiv(GLuint sampler, GLenum pname, GLint *params);
|
|||
void GLAPIENTRY
|
||||
_mesa_GetSamplerParameterIuiv(GLuint sampler, GLenum pname, GLuint *params);
|
||||
|
||||
extern const enum pipe_tex_wrap wrap_to_gallium_table[32];
|
||||
|
||||
/**
|
||||
* Convert GLenum texcoord wrap tokens to pipe tokens.
|
||||
*/
|
||||
static inline enum pipe_tex_wrap
|
||||
wrap_to_gallium(GLenum wrap)
|
||||
{
|
||||
return wrap_to_gallium_table[wrap & 0x1f];
|
||||
}
|
||||
|
||||
|
||||
static inline enum pipe_tex_mipfilter
|
||||
mipfilter_to_gallium(GLenum filter)
|
||||
{
|
||||
/* Take advantage of how the enums are defined. */
|
||||
if (filter <= GL_LINEAR)
|
||||
return PIPE_TEX_MIPFILTER_NONE;
|
||||
if (filter <= GL_LINEAR_MIPMAP_NEAREST)
|
||||
return PIPE_TEX_MIPFILTER_NEAREST;
|
||||
|
||||
return PIPE_TEX_MIPFILTER_LINEAR;
|
||||
}
|
||||
|
||||
|
||||
static inline enum pipe_tex_filter
|
||||
filter_to_gallium(GLenum filter)
|
||||
{
|
||||
/* Take advantage of how the enums are defined. */
|
||||
if (filter & 1)
|
||||
return PIPE_TEX_FILTER_LINEAR;
|
||||
|
||||
return PIPE_TEX_FILTER_NEAREST;
|
||||
}
|
||||
|
||||
static inline enum pipe_tex_reduction_mode
|
||||
reduction_to_gallium(GLenum reduction_mode)
|
||||
{
|
||||
switch (reduction_mode) {
|
||||
case GL_MIN:
|
||||
return PIPE_TEX_REDUCTION_MIN;
|
||||
case GL_MAX:
|
||||
return PIPE_TEX_REDUCTION_MAX;
|
||||
case GL_WEIGHTED_AVERAGE_EXT:
|
||||
default:
|
||||
return PIPE_TEX_REDUCTION_WEIGHTED_AVERAGE;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert an OpenGL compare mode to a pipe tokens.
|
||||
*/
|
||||
static inline enum pipe_compare_func
|
||||
func_to_gallium(GLenum func)
|
||||
{
|
||||
/* Same values, just biased */
|
||||
STATIC_ASSERT(PIPE_FUNC_NEVER == GL_NEVER - GL_NEVER);
|
||||
STATIC_ASSERT(PIPE_FUNC_LESS == GL_LESS - GL_NEVER);
|
||||
STATIC_ASSERT(PIPE_FUNC_EQUAL == GL_EQUAL - GL_NEVER);
|
||||
STATIC_ASSERT(PIPE_FUNC_LEQUAL == GL_LEQUAL - GL_NEVER);
|
||||
STATIC_ASSERT(PIPE_FUNC_GREATER == GL_GREATER - GL_NEVER);
|
||||
STATIC_ASSERT(PIPE_FUNC_NOTEQUAL == GL_NOTEQUAL - GL_NEVER);
|
||||
STATIC_ASSERT(PIPE_FUNC_GEQUAL == GL_GEQUAL - GL_NEVER);
|
||||
STATIC_ASSERT(PIPE_FUNC_ALWAYS == GL_ALWAYS - GL_NEVER);
|
||||
assert(func >= GL_NEVER);
|
||||
assert(func <= GL_ALWAYS);
|
||||
return (enum pipe_compare_func)(func - GL_NEVER);
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -336,23 +336,41 @@ _mesa_initialize_texture_object( struct gl_context *ctx,
|
|||
obj->Sampler.Attrib.WrapT = GL_CLAMP_TO_EDGE;
|
||||
obj->Sampler.Attrib.WrapR = GL_CLAMP_TO_EDGE;
|
||||
obj->Sampler.Attrib.MinFilter = GL_LINEAR;
|
||||
obj->Sampler.Attrib.state.wrap_s = PIPE_TEX_WRAP_CLAMP_TO_EDGE;
|
||||
obj->Sampler.Attrib.state.wrap_t = PIPE_TEX_WRAP_CLAMP_TO_EDGE;
|
||||
obj->Sampler.Attrib.state.wrap_r = PIPE_TEX_WRAP_CLAMP_TO_EDGE;
|
||||
obj->Sampler.Attrib.state.min_img_filter = PIPE_TEX_FILTER_LINEAR;
|
||||
obj->Sampler.Attrib.state.min_mip_filter = PIPE_TEX_MIPFILTER_NONE;
|
||||
}
|
||||
else {
|
||||
obj->Sampler.Attrib.WrapS = GL_REPEAT;
|
||||
obj->Sampler.Attrib.WrapT = GL_REPEAT;
|
||||
obj->Sampler.Attrib.WrapR = GL_REPEAT;
|
||||
obj->Sampler.Attrib.MinFilter = GL_NEAREST_MIPMAP_LINEAR;
|
||||
obj->Sampler.Attrib.state.wrap_s = PIPE_TEX_WRAP_REPEAT;
|
||||
obj->Sampler.Attrib.state.wrap_t = PIPE_TEX_WRAP_REPEAT;
|
||||
obj->Sampler.Attrib.state.wrap_r = PIPE_TEX_WRAP_REPEAT;
|
||||
obj->Sampler.Attrib.state.min_img_filter = PIPE_TEX_FILTER_NEAREST;
|
||||
obj->Sampler.Attrib.state.min_mip_filter = PIPE_TEX_MIPFILTER_LINEAR;
|
||||
}
|
||||
obj->Sampler.Attrib.MagFilter = GL_LINEAR;
|
||||
obj->Sampler.Attrib.state.mag_img_filter = PIPE_TEX_FILTER_LINEAR;
|
||||
obj->Sampler.Attrib.MinLod = -1000.0;
|
||||
obj->Sampler.Attrib.MaxLod = 1000.0;
|
||||
obj->Sampler.Attrib.state.min_lod = 0; /* no negative numbers */
|
||||
obj->Sampler.Attrib.state.max_lod = 1000;
|
||||
obj->Sampler.Attrib.LodBias = 0.0;
|
||||
obj->Sampler.Attrib.state.lod_bias = 0;
|
||||
obj->Sampler.Attrib.MaxAnisotropy = 1.0;
|
||||
obj->Sampler.Attrib.state.max_anisotropy = 0; /* gallium sets 0 instead of 1 */
|
||||
obj->Sampler.Attrib.CompareMode = GL_NONE; /* ARB_shadow */
|
||||
obj->Sampler.Attrib.CompareFunc = GL_LEQUAL; /* ARB_shadow */
|
||||
obj->Sampler.Attrib.state.compare_mode = PIPE_TEX_COMPARE_NONE;
|
||||
obj->Sampler.Attrib.state.compare_func = PIPE_FUNC_LEQUAL;
|
||||
obj->Attrib.DepthMode = ctx->API == API_OPENGL_CORE ? GL_RED : GL_LUMINANCE;
|
||||
obj->StencilSampling = false;
|
||||
obj->Sampler.Attrib.CubeMapSeamless = GL_FALSE;
|
||||
obj->Sampler.Attrib.state.seamless_cube_map = false;
|
||||
obj->Sampler.HandleAllocated = GL_FALSE;
|
||||
obj->Attrib.Swizzle[0] = GL_RED;
|
||||
obj->Attrib.Swizzle[1] = GL_GREEN;
|
||||
|
@ -361,6 +379,7 @@ _mesa_initialize_texture_object( struct gl_context *ctx,
|
|||
obj->Attrib._Swizzle = SWIZZLE_NOOP;
|
||||
obj->Sampler.Attrib.sRGBDecode = GL_DECODE_EXT;
|
||||
obj->Sampler.Attrib.ReductionMode = GL_WEIGHTED_AVERAGE_EXT;
|
||||
obj->Sampler.Attrib.state.reduction_mode = PIPE_TEX_REDUCTION_WEIGHTED_AVERAGE;
|
||||
obj->BufferObjectFormat = GL_R8;
|
||||
obj->_BufferObjectFormat = MESA_FORMAT_R_UNORM8;
|
||||
obj->Attrib.ImageFormatCompatibilityType = GL_IMAGE_FORMAT_COMPATIBILITY_BY_SIZE;
|
||||
|
@ -397,8 +416,14 @@ finish_texture_init(struct gl_context *ctx, GLenum target,
|
|||
obj->Sampler.Attrib.WrapS = GL_CLAMP_TO_EDGE;
|
||||
obj->Sampler.Attrib.WrapT = GL_CLAMP_TO_EDGE;
|
||||
obj->Sampler.Attrib.WrapR = GL_CLAMP_TO_EDGE;
|
||||
obj->Sampler.Attrib.state.wrap_s = PIPE_TEX_WRAP_CLAMP_TO_EDGE;
|
||||
obj->Sampler.Attrib.state.wrap_t = PIPE_TEX_WRAP_CLAMP_TO_EDGE;
|
||||
obj->Sampler.Attrib.state.wrap_r = PIPE_TEX_WRAP_CLAMP_TO_EDGE;
|
||||
obj->Sampler.Attrib.MinFilter = filter;
|
||||
obj->Sampler.Attrib.MagFilter = filter;
|
||||
obj->Sampler.Attrib.state.min_img_filter = filter_to_gallium(filter);
|
||||
obj->Sampler.Attrib.state.min_mip_filter = mipfilter_to_gallium(filter);
|
||||
obj->Sampler.Attrib.state.mag_img_filter = filter_to_gallium(filter);
|
||||
if (ctx->Driver.TexParameter) {
|
||||
/* XXX we probably don't need to make all these calls */
|
||||
ctx->Driver.TexParameter(ctx, obj, GL_TEXTURE_WRAP_S);
|
||||
|
@ -973,6 +998,9 @@ _mesa_get_fallback_texture(struct gl_context *ctx, gl_texture_index tex)
|
|||
assert(texObj->RefCount == 1);
|
||||
texObj->Sampler.Attrib.MinFilter = GL_NEAREST;
|
||||
texObj->Sampler.Attrib.MagFilter = GL_NEAREST;
|
||||
texObj->Sampler.Attrib.state.min_img_filter = PIPE_TEX_FILTER_NEAREST;
|
||||
texObj->Sampler.Attrib.state.min_mip_filter = PIPE_TEX_MIPFILTER_NONE;
|
||||
texObj->Sampler.Attrib.state.mag_img_filter = PIPE_TEX_FILTER_NEAREST;
|
||||
|
||||
texFormat = ctx->Driver.ChooseTextureFormat(ctx, target,
|
||||
GL_RGBA, GL_RGBA,
|
||||
|
|
|
@ -285,6 +285,8 @@ set_tex_parameteri(struct gl_context *ctx,
|
|||
case GL_LINEAR:
|
||||
flush(ctx);
|
||||
texObj->Sampler.Attrib.MinFilter = params[0];
|
||||
texObj->Sampler.Attrib.state.min_img_filter = filter_to_gallium(params[0]);
|
||||
texObj->Sampler.Attrib.state.min_mip_filter = mipfilter_to_gallium(params[0]);
|
||||
return GL_TRUE;
|
||||
case GL_NEAREST_MIPMAP_NEAREST:
|
||||
case GL_LINEAR_MIPMAP_NEAREST:
|
||||
|
@ -294,6 +296,8 @@ set_tex_parameteri(struct gl_context *ctx,
|
|||
texObj->Target != GL_TEXTURE_EXTERNAL_OES) {
|
||||
flush(ctx);
|
||||
texObj->Sampler.Attrib.MinFilter = params[0];
|
||||
texObj->Sampler.Attrib.state.min_img_filter = filter_to_gallium(params[0]);
|
||||
texObj->Sampler.Attrib.state.min_mip_filter = mipfilter_to_gallium(params[0]);
|
||||
return GL_TRUE;
|
||||
}
|
||||
FALLTHROUGH;
|
||||
|
@ -313,6 +317,7 @@ set_tex_parameteri(struct gl_context *ctx,
|
|||
case GL_LINEAR:
|
||||
flush(ctx); /* does not effect completeness */
|
||||
texObj->Sampler.Attrib.MagFilter = params[0];
|
||||
texObj->Sampler.Attrib.state.mag_img_filter = filter_to_gallium(params[0]);
|
||||
return GL_TRUE;
|
||||
default:
|
||||
goto invalid_param;
|
||||
|
@ -330,6 +335,7 @@ set_tex_parameteri(struct gl_context *ctx,
|
|||
if (is_wrap_gl_clamp(texObj->Sampler.Attrib.WrapS) != is_wrap_gl_clamp(params[0]))
|
||||
ctx->NewDriverState |= ctx->DriverFlags.NewSamplersWithClamp;
|
||||
texObj->Sampler.Attrib.WrapS = params[0];
|
||||
texObj->Sampler.Attrib.state.wrap_s = wrap_to_gallium(params[0]);
|
||||
return GL_TRUE;
|
||||
}
|
||||
return GL_FALSE;
|
||||
|
@ -345,6 +351,7 @@ set_tex_parameteri(struct gl_context *ctx,
|
|||
if (is_wrap_gl_clamp(texObj->Sampler.Attrib.WrapT) != is_wrap_gl_clamp(params[0]))
|
||||
ctx->NewDriverState |= ctx->DriverFlags.NewSamplersWithClamp;
|
||||
texObj->Sampler.Attrib.WrapT = params[0];
|
||||
texObj->Sampler.Attrib.state.wrap_t = wrap_to_gallium(params[0]);
|
||||
return GL_TRUE;
|
||||
}
|
||||
return GL_FALSE;
|
||||
|
@ -360,6 +367,7 @@ set_tex_parameteri(struct gl_context *ctx,
|
|||
if (is_wrap_gl_clamp(texObj->Sampler.Attrib.WrapR) != is_wrap_gl_clamp(params[0]))
|
||||
ctx->NewDriverState |= ctx->DriverFlags.NewSamplersWithClamp;
|
||||
texObj->Sampler.Attrib.WrapR = params[0];
|
||||
texObj->Sampler.Attrib.state.wrap_r = wrap_to_gallium(params[0]);
|
||||
return GL_TRUE;
|
||||
}
|
||||
return GL_FALSE;
|
||||
|
@ -487,6 +495,7 @@ set_tex_parameteri(struct gl_context *ctx,
|
|||
case GL_NEVER:
|
||||
flush(ctx);
|
||||
texObj->Sampler.Attrib.CompareFunc = params[0];
|
||||
texObj->Sampler.Attrib.state.compare_func = func_to_gallium(params[0]);
|
||||
return GL_TRUE;
|
||||
default:
|
||||
goto invalid_param;
|
||||
|
@ -612,6 +621,7 @@ set_tex_parameteri(struct gl_context *ctx,
|
|||
if (texObj->Sampler.Attrib.ReductionMode != mode) {
|
||||
flush(ctx);
|
||||
texObj->Sampler.Attrib.ReductionMode = mode;
|
||||
texObj->Sampler.Attrib.state.reduction_mode = reduction_to_gallium(mode);
|
||||
}
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
@ -632,6 +642,7 @@ set_tex_parameteri(struct gl_context *ctx,
|
|||
if (param != texObj->Sampler.Attrib.CubeMapSeamless) {
|
||||
flush(ctx);
|
||||
texObj->Sampler.Attrib.CubeMapSeamless = param;
|
||||
texObj->Sampler.Attrib.state.seamless_cube_map = param;
|
||||
}
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
@ -711,6 +722,7 @@ set_tex_parameterf(struct gl_context *ctx,
|
|||
return GL_FALSE;
|
||||
flush(ctx);
|
||||
texObj->Sampler.Attrib.MinLod = params[0];
|
||||
texObj->Sampler.Attrib.state.min_lod = MAX2(params[0], 0.0f); /* only positive vals */
|
||||
return GL_TRUE;
|
||||
|
||||
case GL_TEXTURE_MAX_LOD:
|
||||
|
@ -724,6 +736,7 @@ set_tex_parameterf(struct gl_context *ctx,
|
|||
return GL_FALSE;
|
||||
flush(ctx);
|
||||
texObj->Sampler.Attrib.MaxLod = params[0];
|
||||
texObj->Sampler.Attrib.state.max_lod = params[0];
|
||||
return GL_TRUE;
|
||||
|
||||
case GL_TEXTURE_PRIORITY:
|
||||
|
@ -750,6 +763,9 @@ set_tex_parameterf(struct gl_context *ctx,
|
|||
/* clamp to max, that's what NVIDIA does */
|
||||
texObj->Sampler.Attrib.MaxAnisotropy = MIN2(params[0],
|
||||
ctx->Const.MaxTextureMaxAnisotropy);
|
||||
texObj->Sampler.Attrib.state.max_anisotropy =
|
||||
texObj->Sampler.Attrib.MaxAnisotropy == 1 ?
|
||||
0 : texObj->Sampler.Attrib.MaxAnisotropy; /* gallium sets 0 for 1 */
|
||||
return GL_TRUE;
|
||||
}
|
||||
else {
|
||||
|
@ -770,6 +786,7 @@ set_tex_parameterf(struct gl_context *ctx,
|
|||
if (texObj->Sampler.Attrib.LodBias != params[0]) {
|
||||
flush(ctx);
|
||||
texObj->Sampler.Attrib.LodBias = params[0];
|
||||
texObj->Sampler.Attrib.state.lod_bias = params[0];
|
||||
return GL_TRUE;
|
||||
}
|
||||
break;
|
||||
|
@ -793,15 +810,12 @@ set_tex_parameterf(struct gl_context *ctx,
|
|||
flush(ctx);
|
||||
/* ARB_texture_float disables clamping */
|
||||
if (ctx->Extensions.ARB_texture_float) {
|
||||
texObj->Sampler.Attrib.BorderColor.f[RCOMP] = params[0];
|
||||
texObj->Sampler.Attrib.BorderColor.f[GCOMP] = params[1];
|
||||
texObj->Sampler.Attrib.BorderColor.f[BCOMP] = params[2];
|
||||
texObj->Sampler.Attrib.BorderColor.f[ACOMP] = params[3];
|
||||
memcpy(texObj->Sampler.Attrib.state.border_color.f, params, 4 * sizeof(float));
|
||||
} else {
|
||||
texObj->Sampler.Attrib.BorderColor.f[RCOMP] = CLAMP(params[0], 0.0F, 1.0F);
|
||||
texObj->Sampler.Attrib.BorderColor.f[GCOMP] = CLAMP(params[1], 0.0F, 1.0F);
|
||||
texObj->Sampler.Attrib.BorderColor.f[BCOMP] = CLAMP(params[2], 0.0F, 1.0F);
|
||||
texObj->Sampler.Attrib.BorderColor.f[ACOMP] = CLAMP(params[3], 0.0F, 1.0F);
|
||||
texObj->Sampler.Attrib.state.border_color.f[RCOMP] = CLAMP(params[0], 0.0F, 1.0F);
|
||||
texObj->Sampler.Attrib.state.border_color.f[GCOMP] = CLAMP(params[1], 0.0F, 1.0F);
|
||||
texObj->Sampler.Attrib.state.border_color.f[BCOMP] = CLAMP(params[2], 0.0F, 1.0F);
|
||||
texObj->Sampler.Attrib.state.border_color.f[ACOMP] = CLAMP(params[3], 0.0F, 1.0F);
|
||||
}
|
||||
return GL_TRUE;
|
||||
|
||||
|
@ -1066,7 +1080,7 @@ _mesa_texture_parameterIiv(struct gl_context *ctx,
|
|||
}
|
||||
FLUSH_VERTICES(ctx, _NEW_TEXTURE_OBJECT, GL_TEXTURE_BIT);
|
||||
/* set the integer-valued border color */
|
||||
COPY_4V(texObj->Sampler.Attrib.BorderColor.i, params);
|
||||
COPY_4V(texObj->Sampler.Attrib.state.border_color.i, params);
|
||||
break;
|
||||
default:
|
||||
_mesa_texture_parameteriv(ctx, texObj, pname, params, dsa);
|
||||
|
@ -1094,7 +1108,7 @@ _mesa_texture_parameterIuiv(struct gl_context *ctx,
|
|||
}
|
||||
FLUSH_VERTICES(ctx, _NEW_TEXTURE_OBJECT, GL_TEXTURE_BIT);
|
||||
/* set the unsigned integer-valued border color */
|
||||
COPY_4V(texObj->Sampler.Attrib.BorderColor.ui, params);
|
||||
COPY_4V(texObj->Sampler.Attrib.state.border_color.ui, params);
|
||||
break;
|
||||
default:
|
||||
_mesa_texture_parameteriv(ctx, texObj, pname, (const GLint *) params,
|
||||
|
@ -2204,16 +2218,16 @@ get_tex_parameterfv(struct gl_context *ctx,
|
|||
goto invalid_pname;
|
||||
|
||||
if (_mesa_get_clamp_fragment_color(ctx, ctx->DrawBuffer)) {
|
||||
params[0] = CLAMP(obj->Sampler.Attrib.BorderColor.f[0], 0.0F, 1.0F);
|
||||
params[1] = CLAMP(obj->Sampler.Attrib.BorderColor.f[1], 0.0F, 1.0F);
|
||||
params[2] = CLAMP(obj->Sampler.Attrib.BorderColor.f[2], 0.0F, 1.0F);
|
||||
params[3] = CLAMP(obj->Sampler.Attrib.BorderColor.f[3], 0.0F, 1.0F);
|
||||
params[0] = CLAMP(obj->Sampler.Attrib.state.border_color.f[0], 0.0F, 1.0F);
|
||||
params[1] = CLAMP(obj->Sampler.Attrib.state.border_color.f[1], 0.0F, 1.0F);
|
||||
params[2] = CLAMP(obj->Sampler.Attrib.state.border_color.f[2], 0.0F, 1.0F);
|
||||
params[3] = CLAMP(obj->Sampler.Attrib.state.border_color.f[3], 0.0F, 1.0F);
|
||||
}
|
||||
else {
|
||||
params[0] = obj->Sampler.Attrib.BorderColor.f[0];
|
||||
params[1] = obj->Sampler.Attrib.BorderColor.f[1];
|
||||
params[2] = obj->Sampler.Attrib.BorderColor.f[2];
|
||||
params[3] = obj->Sampler.Attrib.BorderColor.f[3];
|
||||
params[0] = obj->Sampler.Attrib.state.border_color.f[0];
|
||||
params[1] = obj->Sampler.Attrib.state.border_color.f[1];
|
||||
params[2] = obj->Sampler.Attrib.state.border_color.f[2];
|
||||
params[3] = obj->Sampler.Attrib.state.border_color.f[3];
|
||||
}
|
||||
break;
|
||||
case GL_TEXTURE_RESIDENT:
|
||||
|
@ -2450,10 +2464,10 @@ get_tex_parameteriv(struct gl_context *ctx,
|
|||
|
||||
{
|
||||
GLfloat b[4];
|
||||
b[0] = CLAMP(obj->Sampler.Attrib.BorderColor.f[0], 0.0F, 1.0F);
|
||||
b[1] = CLAMP(obj->Sampler.Attrib.BorderColor.f[1], 0.0F, 1.0F);
|
||||
b[2] = CLAMP(obj->Sampler.Attrib.BorderColor.f[2], 0.0F, 1.0F);
|
||||
b[3] = CLAMP(obj->Sampler.Attrib.BorderColor.f[3], 0.0F, 1.0F);
|
||||
b[0] = CLAMP(obj->Sampler.Attrib.state.border_color.f[0], 0.0F, 1.0F);
|
||||
b[1] = CLAMP(obj->Sampler.Attrib.state.border_color.f[1], 0.0F, 1.0F);
|
||||
b[2] = CLAMP(obj->Sampler.Attrib.state.border_color.f[2], 0.0F, 1.0F);
|
||||
b[3] = CLAMP(obj->Sampler.Attrib.state.border_color.f[3], 0.0F, 1.0F);
|
||||
params[0] = FLOAT_TO_INT(b[0]);
|
||||
params[1] = FLOAT_TO_INT(b[1]);
|
||||
params[2] = FLOAT_TO_INT(b[2]);
|
||||
|
@ -2700,7 +2714,7 @@ get_tex_parameterIiv(struct gl_context *ctx,
|
|||
{
|
||||
switch (pname) {
|
||||
case GL_TEXTURE_BORDER_COLOR:
|
||||
COPY_4V(params, obj->Sampler.Attrib.BorderColor.i);
|
||||
COPY_4V(params, obj->Sampler.Attrib.state.border_color.i);
|
||||
break;
|
||||
default:
|
||||
get_tex_parameteriv(ctx, obj, pname, params, dsa);
|
||||
|
|
|
@ -510,7 +510,7 @@ is_sampler_border_color_valid(struct gl_sampler_object *samp)
|
|||
{ 1, 1, 1, 0 },
|
||||
{ 1, 1, 1, 1 },
|
||||
};
|
||||
size_t size = sizeof(samp->Attrib.BorderColor.ui);
|
||||
size_t size = sizeof(samp->Attrib.state.border_color.ui);
|
||||
|
||||
/* The ARB_bindless_texture spec says:
|
||||
*
|
||||
|
@ -523,16 +523,16 @@ is_sampler_border_color_valid(struct gl_sampler_object *samp)
|
|||
* (0.0,0.0,0.0,0.0), (0.0,0.0,0.0,1.0), (1.0,1.0,1.0,0.0), and
|
||||
* (1.0,1.0,1.0,1.0)."
|
||||
*/
|
||||
if (!memcmp(samp->Attrib.BorderColor.f, valid_float_border_colors[0], size) ||
|
||||
!memcmp(samp->Attrib.BorderColor.f, valid_float_border_colors[1], size) ||
|
||||
!memcmp(samp->Attrib.BorderColor.f, valid_float_border_colors[2], size) ||
|
||||
!memcmp(samp->Attrib.BorderColor.f, valid_float_border_colors[3], size))
|
||||
if (!memcmp(samp->Attrib.state.border_color.f, valid_float_border_colors[0], size) ||
|
||||
!memcmp(samp->Attrib.state.border_color.f, valid_float_border_colors[1], size) ||
|
||||
!memcmp(samp->Attrib.state.border_color.f, valid_float_border_colors[2], size) ||
|
||||
!memcmp(samp->Attrib.state.border_color.f, valid_float_border_colors[3], size))
|
||||
return GL_TRUE;
|
||||
|
||||
if (!memcmp(samp->Attrib.BorderColor.ui, valid_integer_border_colors[0], size) ||
|
||||
!memcmp(samp->Attrib.BorderColor.ui, valid_integer_border_colors[1], size) ||
|
||||
!memcmp(samp->Attrib.BorderColor.ui, valid_integer_border_colors[2], size) ||
|
||||
!memcmp(samp->Attrib.BorderColor.ui, valid_integer_border_colors[3], size))
|
||||
if (!memcmp(samp->Attrib.state.border_color.ui, valid_integer_border_colors[0], size) ||
|
||||
!memcmp(samp->Attrib.state.border_color.ui, valid_integer_border_colors[1], size) ||
|
||||
!memcmp(samp->Attrib.state.border_color.ui, valid_integer_border_colors[2], size) ||
|
||||
!memcmp(samp->Attrib.state.border_color.ui, valid_integer_border_colors[3], size))
|
||||
return GL_TRUE;
|
||||
|
||||
return GL_FALSE;
|
||||
|
|
|
@ -57,7 +57,6 @@ enum st_pipeline {
|
|||
void st_init_atoms( struct st_context *st );
|
||||
void st_destroy_atoms( struct st_context *st );
|
||||
void st_validate_state( struct st_context *st, enum st_pipeline pipeline );
|
||||
GLuint st_compare_func_to_pipe(GLenum func);
|
||||
|
||||
void
|
||||
st_setup_arrays(struct st_context *st,
|
||||
|
|
|
@ -40,31 +40,10 @@
|
|||
#include "pipe/p_context.h"
|
||||
#include "pipe/p_defines.h"
|
||||
#include "cso_cache/cso_context.h"
|
||||
|
||||
#include "main/samplerobj.h"
|
||||
#include "main/stencil.h"
|
||||
|
||||
|
||||
/**
|
||||
* Convert an OpenGL compare mode to a pipe tokens.
|
||||
*/
|
||||
GLuint
|
||||
st_compare_func_to_pipe(GLenum func)
|
||||
{
|
||||
/* Same values, just biased */
|
||||
STATIC_ASSERT(PIPE_FUNC_NEVER == GL_NEVER - GL_NEVER);
|
||||
STATIC_ASSERT(PIPE_FUNC_LESS == GL_LESS - GL_NEVER);
|
||||
STATIC_ASSERT(PIPE_FUNC_EQUAL == GL_EQUAL - GL_NEVER);
|
||||
STATIC_ASSERT(PIPE_FUNC_LEQUAL == GL_LEQUAL - GL_NEVER);
|
||||
STATIC_ASSERT(PIPE_FUNC_GREATER == GL_GREATER - GL_NEVER);
|
||||
STATIC_ASSERT(PIPE_FUNC_NOTEQUAL == GL_NOTEQUAL - GL_NEVER);
|
||||
STATIC_ASSERT(PIPE_FUNC_GEQUAL == GL_GEQUAL - GL_NEVER);
|
||||
STATIC_ASSERT(PIPE_FUNC_ALWAYS == GL_ALWAYS - GL_NEVER);
|
||||
assert(func >= GL_NEVER);
|
||||
assert(func <= GL_ALWAYS);
|
||||
return func - GL_NEVER;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Convert GLenum stencil op tokens to pipe tokens.
|
||||
*/
|
||||
|
@ -107,7 +86,7 @@ st_update_depth_stencil_alpha(struct st_context *st)
|
|||
if (ctx->DrawBuffer->Visual.depthBits > 0) {
|
||||
if (ctx->Depth.Test) {
|
||||
dsa->depth_enabled = 1;
|
||||
dsa->depth_func = st_compare_func_to_pipe(ctx->Depth.Func);
|
||||
dsa->depth_func = func_to_gallium(ctx->Depth.Func);
|
||||
if (dsa->depth_func != PIPE_FUNC_EQUAL)
|
||||
dsa->depth_writemask = ctx->Depth.Mask;
|
||||
}
|
||||
|
@ -120,7 +99,7 @@ st_update_depth_stencil_alpha(struct st_context *st)
|
|||
|
||||
if (ctx->Stencil.Enabled && ctx->DrawBuffer->Visual.stencilBits > 0) {
|
||||
dsa->stencil[0].enabled = 1;
|
||||
dsa->stencil[0].func = st_compare_func_to_pipe(ctx->Stencil.Function[0]);
|
||||
dsa->stencil[0].func = func_to_gallium(ctx->Stencil.Function[0]);
|
||||
dsa->stencil[0].fail_op = gl_stencil_op_to_pipe(ctx->Stencil.FailFunc[0]);
|
||||
dsa->stencil[0].zfail_op = gl_stencil_op_to_pipe(ctx->Stencil.ZFailFunc[0]);
|
||||
dsa->stencil[0].zpass_op = gl_stencil_op_to_pipe(ctx->Stencil.ZPassFunc[0]);
|
||||
|
@ -131,7 +110,7 @@ st_update_depth_stencil_alpha(struct st_context *st)
|
|||
if (_mesa_stencil_is_two_sided(ctx)) {
|
||||
const GLuint back = ctx->Stencil._BackFace;
|
||||
dsa->stencil[1].enabled = 1;
|
||||
dsa->stencil[1].func = st_compare_func_to_pipe(ctx->Stencil.Function[back]);
|
||||
dsa->stencil[1].func = func_to_gallium(ctx->Stencil.Function[back]);
|
||||
dsa->stencil[1].fail_op = gl_stencil_op_to_pipe(ctx->Stencil.FailFunc[back]);
|
||||
dsa->stencil[1].zfail_op = gl_stencil_op_to_pipe(ctx->Stencil.ZFailFunc[back]);
|
||||
dsa->stencil[1].zpass_op = gl_stencil_op_to_pipe(ctx->Stencil.ZPassFunc[back]);
|
||||
|
@ -152,7 +131,7 @@ st_update_depth_stencil_alpha(struct st_context *st)
|
|||
if (ctx->Color.AlphaEnabled && !st->lower_alpha_test &&
|
||||
!(ctx->DrawBuffer->_IntegerBuffers & 0x1)) {
|
||||
dsa->alpha_enabled = 1;
|
||||
dsa->alpha_func = st_compare_func_to_pipe(ctx->Color.AlphaFunc);
|
||||
dsa->alpha_func = func_to_gallium(ctx->Color.AlphaFunc);
|
||||
dsa->alpha_ref_value = ctx->Color.AlphaRefUnclamped;
|
||||
}
|
||||
|
||||
|
|
|
@ -53,51 +53,6 @@
|
|||
#include "util/format/u_format.h"
|
||||
|
||||
|
||||
/**
|
||||
* Convert GLenum texcoord wrap tokens to pipe tokens.
|
||||
*/
|
||||
static GLuint
|
||||
gl_wrap_xlate(GLenum wrap)
|
||||
{
|
||||
/* Take advantage of how the enums are defined. */
|
||||
static const unsigned table[32] = {
|
||||
[GL_REPEAT & 0x1f] = PIPE_TEX_WRAP_REPEAT,
|
||||
[GL_CLAMP & 0x1f] = PIPE_TEX_WRAP_CLAMP,
|
||||
[GL_CLAMP_TO_EDGE & 0x1f] = PIPE_TEX_WRAP_CLAMP_TO_EDGE,
|
||||
[GL_CLAMP_TO_BORDER & 0x1f] = PIPE_TEX_WRAP_CLAMP_TO_BORDER,
|
||||
[GL_MIRRORED_REPEAT & 0x1f] = PIPE_TEX_WRAP_MIRROR_REPEAT,
|
||||
[GL_MIRROR_CLAMP_EXT & 0x1f] = PIPE_TEX_WRAP_MIRROR_CLAMP,
|
||||
[GL_MIRROR_CLAMP_TO_EDGE & 0x1f] = PIPE_TEX_WRAP_MIRROR_CLAMP_TO_EDGE,
|
||||
[GL_MIRROR_CLAMP_TO_BORDER_EXT & 0x1f] = PIPE_TEX_WRAP_MIRROR_CLAMP_TO_BORDER,
|
||||
};
|
||||
|
||||
return table[wrap & 0x1f];
|
||||
}
|
||||
|
||||
|
||||
static GLuint
|
||||
gl_filter_to_mip_filter(GLenum filter)
|
||||
{
|
||||
/* Take advantage of how the enums are defined. */
|
||||
if (filter <= GL_LINEAR)
|
||||
return PIPE_TEX_MIPFILTER_NONE;
|
||||
if (filter <= GL_LINEAR_MIPMAP_NEAREST)
|
||||
return PIPE_TEX_MIPFILTER_NEAREST;
|
||||
|
||||
return PIPE_TEX_MIPFILTER_LINEAR;
|
||||
}
|
||||
|
||||
|
||||
static GLuint
|
||||
gl_filter_to_img_filter(GLenum filter)
|
||||
{
|
||||
/* Take advantage of how the enums are defined. */
|
||||
if (filter & 1)
|
||||
return PIPE_TEX_FILTER_LINEAR;
|
||||
|
||||
return PIPE_TEX_FILTER_NEAREST;
|
||||
}
|
||||
|
||||
static inline unsigned
|
||||
get_border_clamp(unsigned wrap, bool clamp_to_border)
|
||||
{
|
||||
|
@ -110,20 +65,6 @@ get_border_clamp(unsigned wrap, bool clamp_to_border)
|
|||
return wrap;
|
||||
}
|
||||
|
||||
static inline enum pipe_tex_reduction_mode
|
||||
gl_reduction_mode_to_pipe(GLenum reduction_mode)
|
||||
{
|
||||
switch (reduction_mode) {
|
||||
case GL_MIN:
|
||||
return PIPE_TEX_REDUCTION_MIN;
|
||||
case GL_MAX:
|
||||
return PIPE_TEX_REDUCTION_MAX;
|
||||
case GL_WEIGHTED_AVERAGE_EXT:
|
||||
default:
|
||||
return PIPE_TEX_REDUCTION_WEIGHTED_AVERAGE;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a gl_sampler_object to a pipe_sampler_state object.
|
||||
*/
|
||||
|
@ -134,19 +75,12 @@ st_convert_sampler(const struct st_context *st,
|
|||
float tex_unit_lod_bias,
|
||||
struct pipe_sampler_state *sampler)
|
||||
{
|
||||
memset(sampler, 0, sizeof(*sampler));
|
||||
sampler->wrap_s = gl_wrap_xlate(msamp->Attrib.WrapS);
|
||||
sampler->wrap_t = gl_wrap_xlate(msamp->Attrib.WrapT);
|
||||
sampler->wrap_r = gl_wrap_xlate(msamp->Attrib.WrapR);
|
||||
memcpy(sampler, &msamp->Attrib.state, sizeof(*sampler));
|
||||
|
||||
if (texobj->_IsIntegerFormat && st->ctx->Const.ForceIntegerTexNearest) {
|
||||
sampler->min_img_filter = gl_filter_to_img_filter(GL_NEAREST);
|
||||
sampler->mag_img_filter = gl_filter_to_img_filter(GL_NEAREST);
|
||||
} else {
|
||||
sampler->min_img_filter = gl_filter_to_img_filter(msamp->Attrib.MinFilter);
|
||||
sampler->mag_img_filter = gl_filter_to_img_filter(msamp->Attrib.MagFilter);
|
||||
sampler->min_img_filter = PIPE_TEX_FILTER_NEAREST;
|
||||
sampler->mag_img_filter = PIPE_TEX_FILTER_NEAREST;
|
||||
}
|
||||
sampler->min_mip_filter = gl_filter_to_mip_filter(msamp->Attrib.MinFilter);
|
||||
|
||||
if (st->emulate_gl_clamp) {
|
||||
bool clamp_to_border = sampler->min_img_filter != PIPE_TEX_FILTER_NEAREST &&
|
||||
|
@ -159,7 +93,7 @@ st_convert_sampler(const struct st_context *st,
|
|||
if (texobj->Target != GL_TEXTURE_RECTANGLE_ARB)
|
||||
sampler->normalized_coords = 1;
|
||||
|
||||
sampler->lod_bias = msamp->Attrib.LodBias + tex_unit_lod_bias;
|
||||
sampler->lod_bias += tex_unit_lod_bias;
|
||||
/* Reduce the number of states by allowing only the values that AMD GCN
|
||||
* can represent. Apps use lod_bias for smooth transitions to bigger mipmap
|
||||
* levels.
|
||||
|
@ -167,9 +101,6 @@ st_convert_sampler(const struct st_context *st,
|
|||
sampler->lod_bias = CLAMP(sampler->lod_bias, -16, 16);
|
||||
sampler->lod_bias = roundf(sampler->lod_bias * 256) / 256;
|
||||
|
||||
sampler->min_lod = MAX2(msamp->Attrib.MinLod, 0.0f);
|
||||
sampler->max_lod = msamp->Attrib.MaxLod;
|
||||
|
||||
/* Check that only wrap modes using the border color have the first bit
|
||||
* set.
|
||||
*/
|
||||
|
@ -185,10 +116,10 @@ st_convert_sampler(const struct st_context *st,
|
|||
/* For non-black borders... */
|
||||
if (/* This is true if wrap modes are using the border color: */
|
||||
(sampler->wrap_s | sampler->wrap_t | sampler->wrap_r) & 0x1 &&
|
||||
(msamp->Attrib.BorderColor.ui[0] ||
|
||||
msamp->Attrib.BorderColor.ui[1] ||
|
||||
msamp->Attrib.BorderColor.ui[2] ||
|
||||
msamp->Attrib.BorderColor.ui[3])) {
|
||||
(msamp->Attrib.state.border_color.ui[0] ||
|
||||
msamp->Attrib.state.border_color.ui[1] ||
|
||||
msamp->Attrib.state.border_color.ui[2] ||
|
||||
msamp->Attrib.state.border_color.ui[3])) {
|
||||
const GLboolean is_integer = texobj->_IsIntegerFormat;
|
||||
GLenum texBaseFormat = _mesa_base_tex_image(texobj)->_BaseFormat;
|
||||
|
||||
|
@ -202,7 +133,7 @@ st_convert_sampler(const struct st_context *st,
|
|||
|
||||
if (sv) {
|
||||
struct pipe_sampler_view *view = sv->view;
|
||||
union pipe_color_union tmp;
|
||||
union pipe_color_union tmp = sampler->border_color;
|
||||
const unsigned char swz[4] =
|
||||
{
|
||||
view->swizzle_r,
|
||||
|
@ -211,45 +142,29 @@ st_convert_sampler(const struct st_context *st,
|
|||
view->swizzle_a,
|
||||
};
|
||||
|
||||
st_translate_color(&msamp->Attrib.BorderColor, &tmp,
|
||||
texBaseFormat, is_integer);
|
||||
st_translate_color(&tmp, texBaseFormat, is_integer);
|
||||
|
||||
util_format_apply_color_swizzle(&sampler->border_color,
|
||||
&tmp, swz, is_integer);
|
||||
} else {
|
||||
st_translate_color(&msamp->Attrib.BorderColor,
|
||||
&sampler->border_color,
|
||||
st_translate_color(&sampler->border_color,
|
||||
texBaseFormat, is_integer);
|
||||
}
|
||||
} else {
|
||||
st_translate_color(&msamp->Attrib.BorderColor,
|
||||
&sampler->border_color,
|
||||
st_translate_color(&sampler->border_color,
|
||||
texBaseFormat, is_integer);
|
||||
}
|
||||
sampler->border_color_is_integer = is_integer;
|
||||
}
|
||||
|
||||
sampler->max_anisotropy = (msamp->Attrib.MaxAnisotropy == 1.0 ?
|
||||
0 : (GLuint) msamp->Attrib.MaxAnisotropy);
|
||||
|
||||
/* If sampling a depth texture and using shadow comparison */
|
||||
if (msamp->Attrib.CompareMode == GL_COMPARE_R_TO_TEXTURE) {
|
||||
GLenum texBaseFormat = _mesa_base_tex_image(texobj)->_BaseFormat;
|
||||
|
||||
if (texBaseFormat == GL_DEPTH_COMPONENT ||
|
||||
(texBaseFormat == GL_DEPTH_STENCIL && !texobj->StencilSampling)) {
|
||||
(texBaseFormat == GL_DEPTH_STENCIL && !texobj->StencilSampling))
|
||||
sampler->compare_mode = PIPE_TEX_COMPARE_R_TO_TEXTURE;
|
||||
sampler->compare_func = st_compare_func_to_pipe(msamp->Attrib.CompareFunc);
|
||||
}
|
||||
}
|
||||
|
||||
/* Only set the seamless cube map texture parameter because the per-context
|
||||
* enable should be ignored and treated as disabled when using texture
|
||||
* handles, as specified by ARB_bindless_texture.
|
||||
*/
|
||||
sampler->seamless_cube_map = msamp->Attrib.CubeMapSeamless;
|
||||
|
||||
sampler->reduction_mode = gl_reduction_mode_to_pipe(msamp->Attrib.ReductionMode);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -1513,94 +1513,71 @@ st_QueryInternalFormat(struct gl_context *ctx, GLenum target,
|
|||
* Similarly for texture border colors.
|
||||
*/
|
||||
void
|
||||
st_translate_color(const union gl_color_union *colorIn,
|
||||
union pipe_color_union *colorOut,
|
||||
st_translate_color(union pipe_color_union *color,
|
||||
GLenum baseFormat, GLboolean is_integer)
|
||||
{
|
||||
if (is_integer) {
|
||||
const int *in = colorIn->i;
|
||||
int *out = colorOut->i;
|
||||
int *ci = color->i;
|
||||
|
||||
switch (baseFormat) {
|
||||
case GL_RED:
|
||||
out[0] = in[0];
|
||||
out[1] = 0;
|
||||
out[2] = 0;
|
||||
out[3] = 1;
|
||||
ci[1] = 0;
|
||||
ci[2] = 0;
|
||||
ci[3] = 1;
|
||||
break;
|
||||
case GL_RG:
|
||||
out[0] = in[0];
|
||||
out[1] = in[1];
|
||||
out[2] = 0;
|
||||
out[3] = 1;
|
||||
ci[2] = 0;
|
||||
ci[3] = 1;
|
||||
break;
|
||||
case GL_RGB:
|
||||
out[0] = in[0];
|
||||
out[1] = in[1];
|
||||
out[2] = in[2];
|
||||
out[3] = 1;
|
||||
ci[3] = 1;
|
||||
break;
|
||||
case GL_ALPHA:
|
||||
out[0] = out[1] = out[2] = 0;
|
||||
out[3] = in[3];
|
||||
ci[0] = ci[1] = ci[2] = 0;
|
||||
break;
|
||||
case GL_LUMINANCE:
|
||||
out[0] = out[1] = out[2] = in[0];
|
||||
out[3] = 1;
|
||||
ci[1] = ci[2] = ci[0];
|
||||
ci[3] = 1;
|
||||
break;
|
||||
case GL_LUMINANCE_ALPHA:
|
||||
out[0] = out[1] = out[2] = in[0];
|
||||
out[3] = in[3];
|
||||
ci[1] = ci[2] = ci[0];
|
||||
break;
|
||||
case GL_INTENSITY:
|
||||
out[0] = out[1] = out[2] = out[3] = in[0];
|
||||
ci[1] = ci[2] = ci[3] = ci[0];
|
||||
break;
|
||||
default:
|
||||
COPY_4V(out, in);
|
||||
}
|
||||
}
|
||||
else {
|
||||
const float *in = colorIn->f;
|
||||
float *out = colorOut->f;
|
||||
float *cf = color->f;
|
||||
|
||||
switch (baseFormat) {
|
||||
case GL_RED:
|
||||
out[0] = in[0];
|
||||
out[1] = 0.0F;
|
||||
out[2] = 0.0F;
|
||||
out[3] = 1.0F;
|
||||
cf[1] = 0.0F;
|
||||
cf[2] = 0.0F;
|
||||
cf[3] = 1.0F;
|
||||
break;
|
||||
case GL_RG:
|
||||
out[0] = in[0];
|
||||
out[1] = in[1];
|
||||
out[2] = 0.0F;
|
||||
out[3] = 1.0F;
|
||||
cf[2] = 0.0F;
|
||||
cf[3] = 1.0F;
|
||||
break;
|
||||
case GL_RGB:
|
||||
out[0] = in[0];
|
||||
out[1] = in[1];
|
||||
out[2] = in[2];
|
||||
out[3] = 1.0F;
|
||||
cf[3] = 1.0F;
|
||||
break;
|
||||
case GL_ALPHA:
|
||||
out[0] = out[1] = out[2] = 0.0F;
|
||||
out[3] = in[3];
|
||||
cf[0] = cf[1] = cf[2] = 0.0F;
|
||||
break;
|
||||
case GL_LUMINANCE:
|
||||
out[0] = out[1] = out[2] = in[0];
|
||||
out[3] = 1.0F;
|
||||
cf[1] = cf[2] = cf[0];
|
||||
cf[3] = 1.0F;
|
||||
break;
|
||||
case GL_LUMINANCE_ALPHA:
|
||||
out[0] = out[1] = out[2] = in[0];
|
||||
out[3] = in[3];
|
||||
cf[1] = cf[2] = cf[0];
|
||||
break;
|
||||
/* Stencil border is tricky on some hw. Help drivers a little here. */
|
||||
case GL_STENCIL_INDEX:
|
||||
case GL_INTENSITY:
|
||||
out[0] = out[1] = out[2] = out[3] = in[0];
|
||||
cf[1] = cf[2] = cf[3] = cf[0];
|
||||
break;
|
||||
default:
|
||||
COPY_4V(out, in);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -76,8 +76,7 @@ st_QueryInternalFormat(struct gl_context *ctx, GLenum target,
|
|||
GLenum internalFormat, GLenum pname, GLint *params);
|
||||
|
||||
extern void
|
||||
st_translate_color(const union gl_color_union *colorIn,
|
||||
union pipe_color_union *colorOut,
|
||||
st_translate_color(union pipe_color_union *color,
|
||||
GLenum baseFormat, GLboolean is_integer);
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
|
@ -776,28 +776,28 @@ get_border_color(const struct gl_sampler_object *samp,
|
|||
{
|
||||
switch (img->_BaseFormat) {
|
||||
case GL_RGB:
|
||||
rgba[0] = samp->Attrib.BorderColor.f[0];
|
||||
rgba[1] = samp->Attrib.BorderColor.f[1];
|
||||
rgba[2] = samp->Attrib.BorderColor.f[2];
|
||||
rgba[0] = samp->Attrib.state.border_color.f[0];
|
||||
rgba[1] = samp->Attrib.state.border_color.f[1];
|
||||
rgba[2] = samp->Attrib.state.border_color.f[2];
|
||||
rgba[3] = 1.0F;
|
||||
break;
|
||||
case GL_ALPHA:
|
||||
rgba[0] = rgba[1] = rgba[2] = 0.0;
|
||||
rgba[3] = samp->Attrib.BorderColor.f[3];
|
||||
rgba[3] = samp->Attrib.state.border_color.f[3];
|
||||
break;
|
||||
case GL_LUMINANCE:
|
||||
rgba[0] = rgba[1] = rgba[2] = samp->Attrib.BorderColor.f[0];
|
||||
rgba[0] = rgba[1] = rgba[2] = samp->Attrib.state.border_color.f[0];
|
||||
rgba[3] = 1.0;
|
||||
break;
|
||||
case GL_LUMINANCE_ALPHA:
|
||||
rgba[0] = rgba[1] = rgba[2] = samp->Attrib.BorderColor.f[0];
|
||||
rgba[3] = samp->Attrib.BorderColor.f[3];
|
||||
rgba[0] = rgba[1] = rgba[2] = samp->Attrib.state.border_color.f[0];
|
||||
rgba[3] = samp->Attrib.state.border_color.f[3];
|
||||
break;
|
||||
case GL_INTENSITY:
|
||||
rgba[0] = rgba[1] = rgba[2] = rgba[3] = samp->Attrib.BorderColor.f[0];
|
||||
rgba[0] = rgba[1] = rgba[2] = rgba[3] = samp->Attrib.state.border_color.f[0];
|
||||
break;
|
||||
default:
|
||||
COPY_4V(rgba, samp->Attrib.BorderColor.f);
|
||||
COPY_4V(rgba, samp->Attrib.state.border_color.f);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -2875,7 +2875,7 @@ sample_2d_array_linear(struct gl_context *ctx,
|
|||
array = tex_array_slice(texcoord[2], depth);
|
||||
|
||||
if (array < 0 || array >= depth) {
|
||||
COPY_4V(rgba, samp->Attrib.BorderColor.f);
|
||||
COPY_4V(rgba, samp->Attrib.state.border_color.f);
|
||||
}
|
||||
else {
|
||||
if (img->Border) {
|
||||
|
@ -3584,7 +3584,7 @@ sample_depth_texture( struct gl_context *ctx,
|
|||
swImg->FetchTexel(swImg, col, row, slice, &depthSample);
|
||||
}
|
||||
else {
|
||||
depthSample = samp->Attrib.BorderColor.f[0];
|
||||
depthSample = samp->Attrib.state.border_color.f[0];
|
||||
}
|
||||
|
||||
depthRef = CLAMP(texcoords[i][compare_coord], 0.0F, 1.0F);
|
||||
|
@ -3624,21 +3624,21 @@ sample_depth_texture( struct gl_context *ctx,
|
|||
}
|
||||
|
||||
if (slice < 0 || slice >= (GLint) depth) {
|
||||
depth00 = samp->Attrib.BorderColor.f[0];
|
||||
depth01 = samp->Attrib.BorderColor.f[0];
|
||||
depth10 = samp->Attrib.BorderColor.f[0];
|
||||
depth11 = samp->Attrib.BorderColor.f[0];
|
||||
depth00 = samp->Attrib.state.border_color.f[0];
|
||||
depth01 = samp->Attrib.state.border_color.f[0];
|
||||
depth10 = samp->Attrib.state.border_color.f[0];
|
||||
depth11 = samp->Attrib.state.border_color.f[0];
|
||||
}
|
||||
else {
|
||||
/* get four depth samples from the texture */
|
||||
if (useBorderTexel & (I0BIT | J0BIT)) {
|
||||
depth00 = samp->Attrib.BorderColor.f[0];
|
||||
depth00 = samp->Attrib.state.border_color.f[0];
|
||||
}
|
||||
else {
|
||||
swImg->FetchTexel(swImg, i0, j0, slice, &depth00);
|
||||
}
|
||||
if (useBorderTexel & (I1BIT | J0BIT)) {
|
||||
depth10 = samp->Attrib.BorderColor.f[0];
|
||||
depth10 = samp->Attrib.state.border_color.f[0];
|
||||
}
|
||||
else {
|
||||
swImg->FetchTexel(swImg, i1, j0, slice, &depth10);
|
||||
|
@ -3646,13 +3646,13 @@ sample_depth_texture( struct gl_context *ctx,
|
|||
|
||||
if (tObj->Target != GL_TEXTURE_1D_ARRAY_EXT) {
|
||||
if (useBorderTexel & (I0BIT | J1BIT)) {
|
||||
depth01 = samp->Attrib.BorderColor.f[0];
|
||||
depth01 = samp->Attrib.state.border_color.f[0];
|
||||
}
|
||||
else {
|
||||
swImg->FetchTexel(swImg, i0, j1, slice, &depth01);
|
||||
}
|
||||
if (useBorderTexel & (I1BIT | J1BIT)) {
|
||||
depth11 = samp->Attrib.BorderColor.f[0];
|
||||
depth11 = samp->Attrib.state.border_color.f[0];
|
||||
}
|
||||
else {
|
||||
swImg->FetchTexel(swImg, i1, j1, slice, &depth11);
|
||||
|
|
Loading…
Reference in New Issue