29
29
#include "brw_state.h"
30
30
#include "brw_defines.h"
31
31
#include "brw_util.h"
32
#include "shader/prog_parameter.h"
33
#include "shader/prog_statevars.h"
32
#include "program/prog_parameter.h"
33
#include "program/prog_statevars.h"
34
34
#include "intel_batchbuffer.h"
37
prepare_wm_constants(struct brw_context *brw)
39
struct intel_context *intel = &brw->intel;
40
GLcontext *ctx = &intel->ctx;
41
const struct brw_fragment_program *fp =
42
brw_fragment_program_const(brw->fragment_program);
44
drm_intel_bo_unreference(brw->wm.push_const_bo);
45
brw->wm.push_const_bo = NULL;
47
/* Updates the ParamaterValues[i] pointers for all parameters of the
48
* basic type of PROGRAM_STATE_VAR.
50
/* XXX: Should this happen somewhere before to get our state flag set? */
51
_mesa_load_state_parameters(ctx, fp->program.Base.Parameters);
53
if (brw->wm.prog_data->nr_params != 0) {
57
brw->wm.push_const_bo = drm_intel_bo_alloc(intel->bufmgr,
59
brw->wm.prog_data->nr_params *
62
drm_intel_gem_bo_map_gtt(brw->wm.push_const_bo);
63
constants = brw->wm.push_const_bo->virtual;
64
for (i = 0; i < brw->wm.prog_data->nr_params; i++) {
65
constants[i] = *brw->wm.prog_data->param[i];
67
drm_intel_gem_bo_unmap_gtt(brw->wm.push_const_bo);
71
const struct brw_tracked_state gen6_wm_constants = {
73
.mesa = _NEW_PROGRAM_CONSTANTS,
77
.prepare = prepare_wm_constants,
37
81
upload_wm_state(struct brw_context *brw)
39
83
struct intel_context *intel = &brw->intel;
40
84
GLcontext *ctx = &intel->ctx;
41
85
const struct brw_fragment_program *fp =
42
86
brw_fragment_program_const(brw->fragment_program);
43
unsigned int nr_params = fp->program.Base.Parameters->NumParameters;
44
drm_intel_bo *constant_bo;
46
87
uint32_t dw2, dw4, dw5, dw6;
48
if (fp->use_const_buffer || nr_params == 0) {
89
if (fp->use_const_buffer || brw->wm.prog_data->nr_params == 0) {
49
90
/* Disable the push constant buffers. */
51
92
OUT_BATCH(CMD_3D_CONSTANT_PS_STATE << 16 | (5 - 2));
58
/* Updates the ParamaterValues[i] pointers for all parameters of the
59
* basic type of PROGRAM_STATE_VAR.
61
_mesa_load_state_parameters(ctx, fp->program.Base.Parameters);
63
constant_bo = drm_intel_bo_alloc(intel->bufmgr, "WM constant_bo",
64
nr_params * 4 * sizeof(float),
66
drm_intel_gem_bo_map_gtt(constant_bo);
67
for (i = 0; i < nr_params; i++) {
68
memcpy((char *)constant_bo->virtual + i * 4 * sizeof(float),
69
fp->program.Base.Parameters->ParameterValues[i],
72
drm_intel_gem_bo_unmap_gtt(constant_bo);
75
100
OUT_BATCH(CMD_3D_CONSTANT_PS_STATE << 16 |
76
101
GEN6_CONSTANT_BUFFER_0_ENABLE |
78
OUT_RELOC(constant_bo,
103
OUT_RELOC(brw->wm.push_const_bo,
79
104
I915_GEM_DOMAIN_RENDER, 0, /* XXX: bad domain */
80
ALIGN(nr_params, 2) / 2 - 1);
105
ALIGN(brw->wm.prog_data->nr_params, 8) / 8 - 1);
86
drm_intel_bo_unreference(constant_bo);
89
112
intel_batchbuffer_emit_mi_flush(intel->batch);
99
122
/* CACHE_NEW_SAMPLER */
100
123
dw2 |= (ALIGN(brw->wm.sampler_count, 4) / 4) << GEN6_WM_SAMPLER_COUNT_SHIFT;
101
dw4 |= (1 << GEN6_WM_DISPATCH_START_GRF_SHIFT_0);
124
dw4 |= (brw->wm.prog_data->first_curbe_grf <<
125
GEN6_WM_DISPATCH_START_GRF_SHIFT_0);
103
127
dw5 |= (40 - 1) << GEN6_WM_MAX_THREADS_SHIFT;
104
128
dw5 |= GEN6_WM_DISPATCH_ENABLE;