static void
emit_textures(struct fd_ringbuffer *ring, struct fd_context *ctx)
{
+ struct fd_texture_stateobj *fragtex = &ctx->tex[PIPE_SHADER_FRAGMENT];
+ struct fd_texture_stateobj *verttex = &ctx->tex[PIPE_SHADER_VERTEX];
texmask emitted = 0;
unsigned i;
- for (i = 0; i < ctx->verttex.num_samplers; i++)
- if (ctx->verttex.samplers[i])
- emitted |= emit_texture(ring, ctx, &ctx->verttex, i, emitted);
+ for (i = 0; i < verttex->num_samplers; i++)
+ if (verttex->samplers[i])
+ emitted |= emit_texture(ring, ctx, verttex, i, emitted);
- for (i = 0; i < ctx->fragtex.num_samplers; i++)
- if (ctx->fragtex.samplers[i])
- emitted |= emit_texture(ring, ctx, &ctx->fragtex, i, emitted);
+ for (i = 0; i < fragtex->num_samplers; i++)
+ if (fragtex->samplers[i])
+ emitted |= emit_texture(ring, ctx, fragtex, i, emitted);
}
void
/* if necessary, fix up texture fetch instructions: */
if (ctx->dirty & (FD_DIRTY_TEXSTATE | FD_DIRTY_PROG)) {
- patch_tex_fetches(ctx, prog->vp, &ctx->verttex);
- patch_tex_fetches(ctx, prog->fp, &ctx->fragtex);
+ patch_tex_fetches(ctx, prog->vp, &ctx->tex[PIPE_SHADER_VERTEX]);
+ patch_tex_fetches(ctx, prog->fp, &ctx->tex[PIPE_SHADER_FRAGMENT]);
}
}
* a change in # of fragment textures/samplers will trigger patching and
* re-emitting the vertex shader:
*/
- if (nr != ctx->fragtex.num_samplers)
+ if (nr != ctx->tex[PIPE_SHADER_FRAGMENT].num_samplers)
ctx->dirty |= FD_DIRTY_TEXSTATE;
}
fd2_get_const_idx(struct fd_context *ctx, struct fd_texture_stateobj *tex,
unsigned samp_id)
{
- if (tex == &ctx->fragtex)
+ if (tex == &ctx->tex[PIPE_SHADER_FRAGMENT])
return samp_id;
- return samp_id + ctx->fragtex.num_samplers;
+ return samp_id + ctx->tex[PIPE_SHADER_FRAGMENT].num_samplers;
}
void
if (dirty & FD_DIRTY_VERTTEX) {
if (vp->has_samp)
- emit_textures(ctx, ring, SB_VERT_TEX, &ctx->verttex);
+ emit_textures(ctx, ring, SB_VERT_TEX, &ctx->tex[PIPE_SHADER_VERTEX]);
else
dirty &= ~FD_DIRTY_VERTTEX;
}
if (dirty & FD_DIRTY_FRAGTEX) {
if (fp->has_samp)
- emit_textures(ctx, ring, SB_FRAG_TEX, &ctx->fragtex);
+ emit_textures(ctx, ring, SB_FRAG_TEX, &ctx->tex[PIPE_SHADER_FRAGMENT]);
else
dirty &= ~FD_DIRTY_FRAGTEX;
}
if (dirty & FD_DIRTY_VERTTEX) {
if (vp->has_samp)
- emit_textures(ctx, ring, SB4_VS_TEX, &ctx->verttex, vp);
+ emit_textures(ctx, ring, SB4_VS_TEX, &ctx->tex[PIPE_SHADER_VERTEX], vp);
else
dirty &= ~FD_DIRTY_VERTTEX;
}
if (dirty & FD_DIRTY_FRAGTEX) {
if (fp->has_samp)
- emit_textures(ctx, ring, SB4_FS_TEX, &ctx->fragtex, fp);
+ emit_textures(ctx, ring, SB4_FS_TEX, &ctx->tex[PIPE_SHADER_FRAGMENT], fp);
else
dirty &= ~FD_DIRTY_FRAGTEX;
}
entries = ptr;
- setup_border_colors(&ctx->verttex, &entries[0]);
- setup_border_colors(&ctx->fragtex, &entries[ctx->verttex.num_samplers]);
+ setup_border_colors(&ctx->tex[PIPE_SHADER_VERTEX], &entries[0]);
+ setup_border_colors(&ctx->tex[PIPE_SHADER_FRAGMENT],
+ &entries[ctx->tex[PIPE_SHADER_VERTEX].num_samplers]);
OUT_PKT4(ring, REG_A5XX_TPL1_TP_BORDER_COLOR_BASE_ADDR_LO, 2);
OUT_RELOC(ring, fd_resource(fd5_ctx->border_color_buf)->bo, off, 0, 0);
enum a4xx_state_block sb, struct fd_texture_stateobj *tex)
{
bool needs_border = false;
- unsigned bcolor_offset = (sb == SB4_FS_TEX) ? ctx->verttex.num_samplers : 0;
+ unsigned bcolor_offset = (sb == SB4_FS_TEX) ? ctx->tex[PIPE_SHADER_VERTEX].num_samplers : 0;
unsigned i;
if (tex->num_samplers > 0) {
if (dirty & FD_DIRTY_VERTTEX) {
if (vp->has_samp) {
- needs_border |= emit_textures(ctx, ring, SB4_VS_TEX, &ctx->verttex);
+ needs_border |= emit_textures(ctx, ring, SB4_VS_TEX,
+ &ctx->tex[PIPE_SHADER_VERTEX]);
OUT_PKT4(ring, REG_A5XX_TPL1_VS_TEX_COUNT, 1);
- OUT_RING(ring, ctx->verttex.num_textures);
+ OUT_RING(ring, ctx->tex[PIPE_SHADER_VERTEX].num_textures);
} else {
dirty &= ~FD_DIRTY_VERTTEX;
}
if (dirty & FD_DIRTY_FRAGTEX) {
if (fp->has_samp) {
- needs_border |= emit_textures(ctx, ring, SB4_FS_TEX, &ctx->fragtex);
+ needs_border |= emit_textures(ctx, ring, SB4_FS_TEX,
+ &ctx->tex[PIPE_SHADER_FRAGMENT]);
OUT_PKT4(ring, REG_A5XX_TPL1_FS_TEX_COUNT, 1);
- OUT_RING(ring, ctx->fragtex.num_textures);
+ OUT_RING(ring, ctx->tex[PIPE_SHADER_FRAGMENT].num_textures);
} else {
dirty &= ~FD_DIRTY_FRAGTEX;
}
struct pipe_rasterizer_state *rasterizer;
struct pipe_depth_stencil_alpha_state *zsa;
- struct fd_texture_stateobj verttex, fragtex;
+ struct fd_texture_stateobj tex[PIPE_SHADER_TYPES];
struct fd_program_stateobj prog;
resource_read(batch, ctx->indexbuf.buffer);
/* Mark textures as being read */
- foreach_bit(i, ctx->verttex.valid_textures)
- resource_read(batch, ctx->verttex.textures[i]->texture);
- foreach_bit(i, ctx->fragtex.valid_textures)
- resource_read(batch, ctx->fragtex.textures[i]->texture);
+ foreach_bit(i, ctx->tex[PIPE_SHADER_VERTEX].valid_textures)
+ resource_read(batch, ctx->tex[PIPE_SHADER_VERTEX].textures[i]->texture);
+ foreach_bit(i, ctx->tex[PIPE_SHADER_FRAGMENT].valid_textures)
+ resource_read(batch, ctx->tex[PIPE_SHADER_FRAGMENT].textures[i]->texture);
/* Mark streamout buffers as being written.. */
for (i = 0; i < ctx->streamout.num_targets; i++)
ctx->dirty |= FD_DIRTY_INDEXBUF;
/* Textures */
- for (i = 0; i < ctx->verttex.num_textures && !(ctx->dirty & FD_DIRTY_VERTTEX); i++) {
- if (ctx->verttex.textures[i] && (ctx->verttex.textures[i]->texture == prsc))
+ for (i = 0; i < ctx->tex[PIPE_SHADER_VERTEX].num_textures && !(ctx->dirty & FD_DIRTY_VERTTEX); i++) {
+ if (ctx->tex[PIPE_SHADER_VERTEX].textures[i] && (ctx->tex[PIPE_SHADER_VERTEX].textures[i]->texture == prsc))
ctx->dirty |= FD_DIRTY_VERTTEX;
}
- for (i = 0; i < ctx->fragtex.num_textures && !(ctx->dirty & FD_DIRTY_FRAGTEX); i++) {
- if (ctx->fragtex.textures[i] && (ctx->fragtex.textures[i]->texture == prsc))
+ for (i = 0; i < ctx->tex[PIPE_SHADER_FRAGMENT].num_textures && !(ctx->dirty & FD_DIRTY_FRAGTEX); i++) {
+ if (ctx->tex[PIPE_SHADER_FRAGMENT].textures[i] && (ctx->tex[PIPE_SHADER_FRAGMENT].textures[i]->texture == prsc))
ctx->dirty |= FD_DIRTY_FRAGTEX;
}
}
util_blitter_save_framebuffer(ctx->blitter,
ctx->batch ? &ctx->batch->framebuffer : NULL);
util_blitter_save_fragment_sampler_states(ctx->blitter,
- ctx->fragtex.num_samplers,
- (void **)ctx->fragtex.samplers);
+ ctx->tex[PIPE_SHADER_FRAGMENT].num_samplers,
+ (void **)ctx->tex[PIPE_SHADER_FRAGMENT].samplers);
util_blitter_save_fragment_sampler_views(ctx->blitter,
- ctx->fragtex.num_textures, ctx->fragtex.textures);
+ ctx->tex[PIPE_SHADER_FRAGMENT].num_textures,
+ ctx->tex[PIPE_SHADER_FRAGMENT].textures);
if (!render_cond)
util_blitter_save_render_condition(ctx->blitter,
ctx->cond_query, ctx->cond_cond, ctx->cond_mode);
{
struct fd_context *ctx = fd_context(pctx);
+ bind_sampler_states(&ctx->tex[shader], start, nr, hwcso);
+
if (shader == PIPE_SHADER_FRAGMENT) {
- bind_sampler_states(&ctx->fragtex, start, nr, hwcso);
ctx->dirty |= FD_DIRTY_FRAGTEX;
}
else if (shader == PIPE_SHADER_VERTEX) {
- bind_sampler_states(&ctx->verttex, start, nr, hwcso);
ctx->dirty |= FD_DIRTY_VERTTEX;
}
}
{
struct fd_context *ctx = fd_context(pctx);
+ set_sampler_views(&ctx->tex[shader], start, nr, views);
+
switch (shader) {
case PIPE_SHADER_FRAGMENT:
/* on a2xx, since there is a flat address space for textures/samplers,
*
* (note: later gen's ignore FD_DIRTY_TEXSTATE so fine to set it)
*/
- if (nr != ctx->fragtex.num_textures)
+ if (nr != ctx->tex[PIPE_SHADER_FRAGMENT].num_textures)
ctx->dirty |= FD_DIRTY_TEXSTATE;
- set_sampler_views(&ctx->fragtex, start, nr, views);
ctx->dirty |= FD_DIRTY_FRAGTEX;
break;
case PIPE_SHADER_VERTEX:
- set_sampler_views(&ctx->verttex, start, nr, views);
ctx->dirty |= FD_DIRTY_VERTTEX;
break;
default: