#include "brw_state.h"
#include "brw_defines.h"
#include "intel_batchbuffer.h"
+#include "intel_mipmap_tree.h"
#include "main/macros.h"
#include "main/samplerobj.h"
struct gl_context *ctx = &brw->ctx;
struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit];
struct gl_texture_object *texObj = texUnit->_Current;
+ struct intel_texture_image *intel_image =
+ intel_texture_image(texObj->Image[0][texObj->BaseLevel]);
struct gl_sampler_object *gl_sampler = _mesa_get_samplerobj(ctx, unit);
bool using_nearest = false;
*/
if (texObj->Target == GL_TEXTURE_CUBE_MAP ||
texObj->Target == GL_TEXTURE_CUBE_MAP_ARRAY) {
- if (ctx->Texture.CubeMapSeamless &&
+ if ((ctx->Texture.CubeMapSeamless || gl_sampler->CubeMapSeamless) &&
(gl_sampler->MinFilter != GL_NEAREST ||
gl_sampler->MagFilter != GL_NEAREST)) {
sampler->ss3.r_wrap_mode = BRW_TEXCOORDMODE_CUBE;
sampler->ss0.lod_preclamp = 1; /* OpenGL mode */
sampler->ss0.default_color_mode = 0; /* OpenGL/DX10 mode */
- /* Set BaseMipLevel, MaxLOD, MinLOD:
- *
- * XXX: I don't think that using firstLevel, lastLevel works,
- * because we always setup the surface state as if firstLevel ==
- * level zero. Probably have to subtract firstLevel from each of
- * these:
- */
- sampler->ss0.base_level = U_FIXED(0, 1);
+ int baselevel = texObj->BaseLevel - intel_image->mt->first_level;
+ sampler->ss0.base_level = U_FIXED(baselevel, 1);
- sampler->ss1.max_lod = U_FIXED(CLAMP(gl_sampler->MaxLod, 0, 13), 8);
- sampler->ss1.min_lod = U_FIXED(CLAMP(gl_sampler->MinLod, 0, 13), 8);
+ sampler->ss1.max_lod = U_FIXED(CLAMP(baselevel +
+ gl_sampler->MaxLod, 0, 13), 8);
+ sampler->ss1.min_lod = U_FIXED(CLAMP(baselevel +
+ gl_sampler->MinLod, 0, 13), 8);
/* The sampler can handle non-normalized texture rectangle coordinates
* natively
static void
gen7_upload_sampler_state_table(struct brw_context *brw,
struct gl_program *prog,
- uint32_t *sampler_count,
+ uint32_t sampler_count,
uint32_t *sst_offset,
uint32_t *sdc_offset)
{
GLbitfield SamplersUsed = prog->SamplersUsed;
- *sampler_count = _mesa_fls(SamplersUsed);
-
- if (*sampler_count == 0)
+ if (sampler_count == 0)
return;
samplers = brw_state_batch(brw, AUB_TRACE_SAMPLER_STATE,
- *sampler_count * sizeof(*samplers),
+ sampler_count * sizeof(*samplers),
32, sst_offset);
- memset(samplers, 0, *sampler_count * sizeof(*samplers));
+ memset(samplers, 0, sampler_count * sizeof(*samplers));
- for (unsigned s = 0; s < *sampler_count; s++) {
+ for (unsigned s = 0; s < sampler_count; s++) {
if (SamplersUsed & (1 << s)) {
const unsigned unit = prog->SamplerUnits[s];
if (ctx->Texture.Unit[unit]._ReallyEnabled)