Also upload separate sampler default/texture border color entries.
At the moment, this is completely idiotic: both tables contain exactly
the same contents, so we're simply wasting batch space and CPU time.
However, soon we'll only upload data for textures actually /used/ in
a particular stage, which will usually make the VS table empty and
very likely eliminate all redundancy. This is just a stepping stone.
Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Paul Berry <stereotype441@gmail.com>
GLuint last_bufsz;
} curbe;
- /** SAMPLER_STATE count and offset */
- struct {
- uint32_t offset;
- } sampler;
-
/**
* Layout of vertex data exiting the geometry portion of the pipleine.
* This comes from the geometry shader if one exists, otherwise from the
uint32_t bind_bo_offset;
uint32_t surf_offset[BRW_MAX_VS_SURFACES];
+ /** SAMPLER_STATE count and table offset */
uint32_t sampler_count;
+ uint32_t sampler_offset;
+
+ /** Offsets in the batch to sampler default colors (texture border color)
+ */
+ uint32_t sdc_offset[BRW_MAX_TEX_UNIT];
} vs;
struct {
struct {
struct brw_wm_prog_data *prog_data;
- /** offsets in the batch to sampler default colors (texture border color)
- */
- uint32_t sdc_offset[BRW_MAX_TEX_UNIT];
-
GLuint render_surf;
drm_intel_bo *scratch_bo;
uint32_t bind_bo_offset;
uint32_t surf_offset[BRW_MAX_WM_SURFACES];
+ /** SAMPLER_STATE count and table offset */
uint32_t sampler_count;
+ uint32_t sampler_offset;
+
+ /** Offsets in the batch to sampler default colors (texture border color)
+ */
+ uint32_t sdc_offset[BRW_MAX_TEX_UNIT];
struct {
struct ra_regs *regs;
*/
if (brw->vs.sampler_count) {
vs->vs5.sampler_state_pointer =
- (brw->batch.bo->offset + brw->sampler.offset) >> 5;
+ (brw->batch.bo->offset + brw->vs.sampler_offset) >> 5;
drm_intel_bo_emit_reloc(brw->batch.bo,
brw->vs.state_offset +
offsetof(struct brw_vs_unit_state, vs5),
brw->batch.bo,
- brw->sampler.offset | vs->vs5.sampler_count,
+ brw->vs.sampler_offset | vs->vs5.sampler_count,
I915_GEM_DOMAIN_INSTRUCTION, 0);
}
int unit,
int ss_index,
struct brw_sampler_state *sampler,
+ uint32_t sampler_state_table_offset,
uint32_t *sdc_offset)
{
struct gl_context *ctx = &brw->ctx;
*sdc_offset) >> 5;
drm_intel_bo_emit_reloc(brw->batch.bo,
- brw->sampler.offset +
+ sampler_state_table_offset +
ss_index * sizeof(struct brw_sampler_state) +
offsetof(struct brw_sampler_state, ss2),
brw->batch.bo, *sdc_offset,
static void
-brw_upload_samplers(struct brw_context *brw)
+brw_upload_sampler_state_table(struct brw_context *brw,
+ uint32_t *sampler_count,
+ uint32_t *sst_offset,
+ uint32_t *sdc_offset)
{
struct gl_context *ctx = &brw->ctx;
struct brw_sampler_state *samplers;
/* ARB programs use the texture unit number as the sampler index, so we
* need to find the highest unit used. A bit-count will not work.
*/
- brw->wm.sampler_count = _mesa_fls(SamplersUsed);
- /* Currently we only use one sampler state table. Mirror the count. */
- brw->vs.sampler_count = brw->wm.sampler_count;
+ *sampler_count = _mesa_fls(SamplersUsed);
- if (brw->wm.sampler_count == 0)
+ if (*sampler_count == 0)
return;
samplers = brw_state_batch(brw, AUB_TRACE_SAMPLER_STATE,
- brw->wm.sampler_count * sizeof(*samplers),
- 32, &brw->sampler.offset);
- memset(samplers, 0, brw->wm.sampler_count * sizeof(*samplers));
+ *sampler_count * sizeof(*samplers),
+ 32, sst_offset);
+ memset(samplers, 0, *sampler_count * sizeof(*samplers));
for (unsigned s = 0; s < brw->wm.sampler_count; s++) {
if (SamplersUsed & (1 << s)) {
fs->SamplerUnits[s] : vs->SamplerUnits[s];
if (ctx->Texture.Unit[unit]._ReallyEnabled)
brw_update_sampler_state(brw, unit, s, &samplers[s],
- &brw->wm.sdc_offset[s]);
+ *sst_offset, &sdc_offset[s]);
}
}
brw->state.dirty.cache |= CACHE_NEW_SAMPLER;
}
+static void
+brw_upload_samplers(struct brw_context *brw)
+{
+ brw_upload_sampler_state_table(brw,
+ &brw->wm.sampler_count,
+ &brw->wm.sampler_offset,
+ brw->wm.sdc_offset);
+
+ brw_upload_sampler_state_table(brw,
+ &brw->vs.sampler_count,
+ &brw->vs.sampler_offset,
+ brw->vs.sdc_offset);
+}
+
const struct brw_tracked_state brw_samplers = {
.dirty = {
.mesa = _NEW_TEXTURE,
if (brw->wm.sampler_count) {
/* reloc */
wm->wm4.sampler_state_pointer = (brw->batch.bo->offset +
- brw->sampler.offset) >> 5;
+ brw->wm.sampler_offset) >> 5;
} else {
wm->wm4.sampler_state_pointer = 0;
}
drm_intel_bo_emit_reloc(brw->batch.bo,
brw->wm.state_offset +
offsetof(struct brw_wm_unit_state, wm4),
- brw->batch.bo, (brw->sampler.offset |
- wm->wm4.stats_enable |
- (wm->wm4.sampler_count << 2)),
+ brw->batch.bo, (brw->wm.sampler_offset |
+ wm->wm4.stats_enable |
+ (wm->wm4.sampler_count << 2)),
I915_GEM_DOMAIN_INSTRUCTION, 0);
}
GS_SAMPLER_STATE_CHANGE |
PS_SAMPLER_STATE_CHANGE |
(4 - 2));
- OUT_BATCH(brw->sampler.offset); /* VS */
+ OUT_BATCH(brw->vs.sampler_offset); /* VS */
OUT_BATCH(0); /* GS */
- OUT_BATCH(brw->sampler.offset);
+ OUT_BATCH(brw->wm.sampler_offset);
ADVANCE_BATCH();
}
static void
-gen7_upload_samplers(struct brw_context *brw)
+gen7_upload_sampler_state_table(struct brw_context *brw,
+ uint32_t *sampler_count,
+ uint32_t *sst_offset,
+ uint32_t *sdc_offset)
{
struct gl_context *ctx = &brw->ctx;
struct gen7_sampler_state *samplers;
GLbitfield SamplersUsed = vs->SamplersUsed | fs->SamplersUsed;
- brw->wm.sampler_count = _mesa_fls(SamplersUsed);
- /* Currently we only use one sampler state table. Mirror the count. */
- brw->vs.sampler_count = brw->wm.sampler_count;
+ *sampler_count = _mesa_fls(SamplersUsed);
- if (brw->wm.sampler_count == 0)
+ if (*sampler_count == 0)
return;
samplers = brw_state_batch(brw, AUB_TRACE_SAMPLER_STATE,
- brw->wm.sampler_count * sizeof(*samplers),
- 32, &brw->sampler.offset);
- memset(samplers, 0, brw->wm.sampler_count * sizeof(*samplers));
+ *sampler_count * sizeof(*samplers),
+ 32, sst_offset);
+ memset(samplers, 0, *sampler_count * sizeof(*samplers));
for (unsigned s = 0; s < brw->wm.sampler_count; s++) {
if (SamplersUsed & (1 << s)) {
fs->SamplerUnits[s] : vs->SamplerUnits[s];
if (ctx->Texture.Unit[unit]._ReallyEnabled)
gen7_update_sampler_state(brw, unit, s, &samplers[s],
- &brw->wm.sdc_offset[s]);
+ &sdc_offset[s]);
}
}
brw->state.dirty.cache |= CACHE_NEW_SAMPLER;
}
+static void
+gen7_upload_samplers(struct brw_context *brw)
+{
+ gen7_upload_sampler_state_table(brw,
+ &brw->wm.sampler_count,
+ &brw->wm.sampler_offset,
+ brw->wm.sdc_offset);
+
+ gen7_upload_sampler_state_table(brw,
+ &brw->vs.sampler_count,
+ &brw->vs.sampler_offset,
+ brw->vs.sdc_offset);
+}
+
const struct brw_tracked_state gen7_samplers = {
.dirty = {
.mesa = _NEW_TEXTURE,
/* CACHE_NEW_SAMPLER */
BEGIN_BATCH(2);
OUT_BATCH(_3DSTATE_SAMPLER_STATE_POINTERS_VS << 16 | (2 - 2));
- OUT_BATCH(brw->sampler.offset);
+ OUT_BATCH(brw->vs.sampler_offset);
ADVANCE_BATCH();
if (brw->vs.push_const_size == 0) {
/* CACHE_NEW_SAMPLER */
BEGIN_BATCH(2);
OUT_BATCH(_3DSTATE_SAMPLER_STATE_POINTERS_PS << 16 | (2 - 2));
- OUT_BATCH(brw->sampler.offset);
+ OUT_BATCH(brw->wm.sampler_offset);
ADVANCE_BATCH();
/* CACHE_NEW_WM_PROG */