#include "util/ralloc.h"
static void
-assign_fs_binding_table_offsets(const struct brw_device_info *devinfo,
+assign_fs_binding_table_offsets(const struct gen_device_info *devinfo,
const struct gl_shader_program *shader_prog,
const struct gl_program *prog,
const struct brw_wm_prog_key *key,
prog_data->binding_table.render_target_start = next_binding_table_offset;
next_binding_table_offset += MAX2(key->nr_color_regions, 1);
- brw_assign_common_binding_table_offsets(MESA_SHADER_FRAGMENT, devinfo,
- shader_prog, prog, &prog_data->base,
- next_binding_table_offset);
+ next_binding_table_offset =
+ brw_assign_common_binding_table_offsets(MESA_SHADER_FRAGMENT, devinfo,
+ shader_prog, prog, &prog_data->base,
+ next_binding_table_offset);
+
+ if (prog->nir->info.outputs_read && !key->coherent_fb_fetch) {
+ prog_data->binding_table.render_target_read_start =
+ next_binding_table_offset;
+ next_binding_table_offset += key->nr_color_regions;
+ }
}
/**
}
}
- if (prog_data.base.total_scratch) {
- brw_get_scratch_bo(brw, &brw->wm.base.scratch_bo,
- prog_data.base.total_scratch * brw->max_wm_threads);
- }
+ brw_alloc_stage_scratch(brw, &brw->wm.base,
+ prog_data.base.total_scratch,
+ brw->max_wm_threads);
if (unlikely(INTEL_DEBUG & DEBUG_WM))
fprintf(stderr, "\n");
void
brw_populate_sampler_prog_key_data(struct gl_context *ctx,
const struct gl_program *prog,
- unsigned sampler_count,
struct brw_sampler_prog_key_data *key)
{
struct brw_context *brw = brw_context(ctx);
+ GLbitfield mask = prog->SamplersUsed;
- for (int s = 0; s < sampler_count; s++) {
- key->swizzles[s] = SWIZZLE_NOOP;
+ while (mask) {
+ const int s = u_bit_scan(&mask);
- if (!(prog->SamplersUsed & (1 << s)))
- continue;
+ key->swizzles[s] = SWIZZLE_NOOP;
int unit_id = prog->SamplerUnits[s];
const struct gl_texture_unit *unit = &ctx->Texture.Unit[unit_id];
key->clamp_fragment_color = ctx->Color._ClampFragmentColor;
/* _NEW_TEXTURE */
- brw_populate_sampler_prog_key_data(ctx, prog, brw->wm.base.sampler_count,
- &key->tex);
+ brw_populate_sampler_prog_key_data(ctx, prog, &key->tex);
/* _NEW_BUFFERS */
key->nr_color_regions = ctx->DrawBuffer->_NumColorDrawBuffers;
/* The unique fragment program ID */
key->program_string_id = fp->id;
+
+ /* Whether reads from the framebuffer should behave coherently. */
+ key->coherent_fb_fetch = ctx->Extensions.MESA_shader_framebuffer_fetch;
}
void
key.nr_color_regions = _mesa_bitcount_64(fp->Base.OutputsWritten &
~(BITFIELD64_BIT(FRAG_RESULT_DEPTH) |
- BITFIELD64_BIT(FRAG_RESULT_SAMPLE_MASK)));
+ BITFIELD64_BIT(FRAG_RESULT_STENCIL) |
+ BITFIELD64_BIT(FRAG_RESULT_SAMPLE_MASK)));
key.program_string_id = bfp->id;
+ /* Whether reads from the framebuffer should behave coherently. */
+ key.coherent_fb_fetch = ctx->Extensions.MESA_shader_framebuffer_fetch;
+
uint32_t old_prog_offset = brw->wm.base.prog_offset;
struct brw_wm_prog_data *old_prog_data = brw->wm.prog_data;