summaryrefslogtreecommitdiffstats
path: root/src/gallium/drivers/ilo
diff options
context:
space:
mode:
authorChia-I Wu <[email protected]>2013-05-29 15:43:38 +0800
committerChia-I Wu <[email protected]>2013-06-07 11:13:15 +0800
commit4228cf37467688dc4f6a10c8d2c42c6243f789e9 (patch)
tree9daae59bbb3b813cbae041e3954ed7839596e0e8 /src/gallium/drivers/ilo
parent94212915ee8f7bf98c8adfe248a05a382d00c191 (diff)
ilo: switch to ilo states for shaders and resources
Define and use struct ilo_sampler_state; struct ilo_view_state; struct ilo_cbuf_state; struct ilo_resource_state; struct ilo_global_binding; in ilo_context.
Diffstat (limited to 'src/gallium/drivers/ilo')
-rw-r--r--src/gallium/drivers/ilo/ilo_3d_pipeline_gen6.c30
-rw-r--r--src/gallium/drivers/ilo/ilo_3d_pipeline_gen7.c9
-rw-r--r--src/gallium/drivers/ilo/ilo_blit.c8
-rw-r--r--src/gallium/drivers/ilo/ilo_context.h65
-rw-r--r--src/gallium/drivers/ilo/ilo_gpe.h42
-rw-r--r--src/gallium/drivers/ilo/ilo_shader.c6
-rw-r--r--src/gallium/drivers/ilo/ilo_state.c68
7 files changed, 114 insertions, 114 deletions
diff --git a/src/gallium/drivers/ilo/ilo_3d_pipeline_gen6.c b/src/gallium/drivers/ilo/ilo_3d_pipeline_gen6.c
index 301f8dd3069..cc1b2985bc4 100644
--- a/src/gallium/drivers/ilo/ilo_3d_pipeline_gen6.c
+++ b/src/gallium/drivers/ilo/ilo_3d_pipeline_gen6.c
@@ -477,7 +477,7 @@ gen6_pipeline_vs(struct ilo_3d_pipeline *p,
/* 3DSTATE_VS */
if (emit_3dstate_vs) {
const struct ilo_shader *vs = (ilo->vs)? ilo->vs->shader : NULL;
- const int num_samplers = ilo->samplers[PIPE_SHADER_VERTEX].num_samplers;
+ const int num_samplers = ilo->sampler[PIPE_SHADER_VERTEX].count;
p->gen6_3DSTATE_VS(p->dev, vs, num_samplers, p->cp);
}
@@ -667,8 +667,7 @@ gen6_pipeline_wm(struct ilo_3d_pipeline *p,
DIRTY(BLEND) || DIRTY(DEPTH_STENCIL_ALPHA) ||
DIRTY(RASTERIZER)) {
const struct ilo_shader *fs = (ilo->fs)? ilo->fs->shader : NULL;
- const int num_samplers =
- ilo->samplers[PIPE_SHADER_FRAGMENT].num_samplers;
+ const int num_samplers = ilo->sampler[PIPE_SHADER_FRAGMENT].count;
const bool dual_blend =
(!ilo->blend->state.logicop_enable &&
ilo->blend->state.rt[0].blend_enable &&
@@ -943,9 +942,8 @@ gen6_pipeline_state_surfaces_view(struct ilo_3d_pipeline *p,
struct gen6_pipeline_session *session)
{
const struct pipe_sampler_view **views =
- (const struct pipe_sampler_view **)
- ilo->sampler_views[shader_type].views;
- const int num_views = ilo->sampler_views[shader_type].num_views;
+ (const struct pipe_sampler_view **) ilo->view[shader_type].states;
+ const int num_views = ilo->view[shader_type].count;
uint32_t *surface_state;
int offset, i;
bool skip = false;
@@ -1005,8 +1003,8 @@ gen6_pipeline_state_surfaces_const(struct ilo_3d_pipeline *p,
struct gen6_pipeline_session *session)
{
const struct pipe_constant_buffer *buffers =
- ilo->constant_buffers[shader_type].buffers;
- const int num_buffers = ilo->constant_buffers[shader_type].num_buffers;
+ ilo->cbuf[shader_type].states;
+ const int num_buffers = ilo->cbuf[shader_type].count;
uint32_t *surface_state;
int offset, i;
bool skip = false;
@@ -1125,13 +1123,11 @@ gen6_pipeline_state_samplers(struct ilo_3d_pipeline *p,
struct gen6_pipeline_session *session)
{
const struct pipe_sampler_state **samplers =
- (const struct pipe_sampler_state **)
- ilo->samplers[shader_type].samplers;
+ (const struct pipe_sampler_state **) ilo->sampler[shader_type].states;
const struct pipe_sampler_view **views =
- (const struct pipe_sampler_view **)
- ilo->sampler_views[shader_type].views;
- const int num_samplers = ilo->samplers[shader_type].num_samplers;
- const int num_views = ilo->sampler_views[shader_type].num_views;
+ (const struct pipe_sampler_view **) ilo->view[shader_type].states;
+ const int num_samplers = ilo->sampler[shader_type].count;
+ const int num_views = ilo->view[shader_type].count;
uint32_t *sampler_state, *border_color_state;
bool emit_border_color = false;
bool skip = false;
@@ -1519,8 +1515,8 @@ gen6_pipeline_estimate_states(const struct ilo_3d_pipeline *p,
count += ilo->vs->info.stream_output.num_outputs;
for (shader_type = 0; shader_type < PIPE_SHADER_TYPES; shader_type++) {
- count += ilo->sampler_views[shader_type].num_views;
- count += ilo->constant_buffers[shader_type].num_buffers;
+ count += ilo->view[shader_type].count;
+ count += ilo->cbuf[shader_type].count;
}
if (count) {
@@ -1530,7 +1526,7 @@ gen6_pipeline_estimate_states(const struct ilo_3d_pipeline *p,
/* samplers (vs, fs) */
for (shader_type = 0; shader_type < PIPE_SHADER_TYPES; shader_type++) {
- count = ilo->samplers[shader_type].num_samplers;
+ count = ilo->sampler[shader_type].count;
if (count) {
size += gen6->estimate_state_size(p->dev,
ILO_GPE_GEN6_SAMPLER_BORDER_COLOR_STATE, count);
diff --git a/src/gallium/drivers/ilo/ilo_3d_pipeline_gen7.c b/src/gallium/drivers/ilo/ilo_3d_pipeline_gen7.c
index 916d40cf4e3..33f5a759984 100644
--- a/src/gallium/drivers/ilo/ilo_3d_pipeline_gen7.c
+++ b/src/gallium/drivers/ilo/ilo_3d_pipeline_gen7.c
@@ -495,8 +495,7 @@ gen7_pipeline_wm(struct ilo_3d_pipeline *p,
if (DIRTY(FS) || DIRTY(FRAGMENT_SAMPLERS) ||
DIRTY(BLEND)) {
const struct ilo_shader *fs = (ilo->fs)? ilo->fs->shader : NULL;
- const int num_samplers =
- ilo->samplers[PIPE_SHADER_FRAGMENT].num_samplers;
+ const int num_samplers = ilo->sampler[PIPE_SHADER_FRAGMENT].count;
const bool dual_blend =
(!ilo->blend->state.logicop_enable &&
ilo->blend->state.rt[0].blend_enable &&
@@ -732,8 +731,8 @@ gen7_pipeline_estimate_states(const struct ilo_3d_pipeline *p,
*/
count = ilo->fb.state.nr_cbufs;
for (shader_type = 0; shader_type < PIPE_SHADER_TYPES; shader_type++) {
- count += ilo->sampler_views[shader_type].num_views;
- count += ilo->constant_buffers[shader_type].num_buffers;
+ count += ilo->view[shader_type].count;
+ count += ilo->cbuf[shader_type].count;
}
if (count) {
@@ -743,7 +742,7 @@ gen7_pipeline_estimate_states(const struct ilo_3d_pipeline *p,
/* samplers (vs, fs) */
for (shader_type = 0; shader_type < PIPE_SHADER_TYPES; shader_type++) {
- count = ilo->samplers[shader_type].num_samplers;
+ count = ilo->sampler[shader_type].count;
if (count) {
size += gen7->estimate_state_size(p->dev,
ILO_GPE_GEN7_SAMPLER_BORDER_COLOR_STATE, count);
diff --git a/src/gallium/drivers/ilo/ilo_blit.c b/src/gallium/drivers/ilo/ilo_blit.c
index 29097e9cf59..fda30de1ead 100644
--- a/src/gallium/drivers/ilo/ilo_blit.c
+++ b/src/gallium/drivers/ilo/ilo_blit.c
@@ -569,12 +569,12 @@ ilo_blitter_begin(struct ilo_context *ilo, enum ilo_blitter_op op)
util_blitter_save_framebuffer(ilo->blitter, &ilo->fb.state);
util_blitter_save_fragment_sampler_states(ilo->blitter,
- ilo->samplers[PIPE_SHADER_FRAGMENT].num_samplers,
- (void **) ilo->samplers[PIPE_SHADER_FRAGMENT].samplers);
+ ilo->sampler[PIPE_SHADER_FRAGMENT].count,
+ (void **) ilo->sampler[PIPE_SHADER_FRAGMENT].states);
util_blitter_save_fragment_sampler_views(ilo->blitter,
- ilo->sampler_views[PIPE_SHADER_FRAGMENT].num_views,
- ilo->sampler_views[PIPE_SHADER_FRAGMENT].views);
+ ilo->view[PIPE_SHADER_FRAGMENT].count,
+ ilo->view[PIPE_SHADER_FRAGMENT].states);
/* disable render condition? */
break;
diff --git a/src/gallium/drivers/ilo/ilo_context.h b/src/gallium/drivers/ilo/ilo_context.h
index 56ef8bef5c7..b05ffe4ad93 100644
--- a/src/gallium/drivers/ilo/ilo_context.h
+++ b/src/gallium/drivers/ilo/ilo_context.h
@@ -60,6 +60,9 @@ struct ilo_context {
const struct ilo_ve_state *ve;
struct ilo_ib_state ib;
+ struct ilo_shader_state *vs;
+ struct ilo_shader_state *gs;
+
struct ilo_so_state so;
struct pipe_clip_state clip;
@@ -70,64 +73,24 @@ struct ilo_context {
struct pipe_poly_stipple poly_stipple;
unsigned sample_mask;
+ struct ilo_shader_state *fs;
+
const struct ilo_dsa_state *dsa;
struct pipe_stencil_ref stencil_ref;
const struct ilo_blend_state *blend;
struct pipe_blend_color blend_color;
struct ilo_fb_state fb;
- struct ilo_shader_state *fs;
- struct ilo_shader_state *vs;
- struct ilo_shader_state *gs;
+ /* shader resources */
+ struct ilo_sampler_state sampler[PIPE_SHADER_TYPES];
+ struct ilo_view_state view[PIPE_SHADER_TYPES];
+ struct ilo_cbuf_state cbuf[PIPE_SHADER_TYPES];
+ struct ilo_resource_state resource;
- struct {
- struct pipe_sampler_state *samplers[ILO_MAX_SAMPLERS];
- unsigned num_samplers;
- } samplers[PIPE_SHADER_TYPES];
-
- struct {
- struct pipe_sampler_view *views[ILO_MAX_SAMPLER_VIEWS];
- unsigned num_views;
- } sampler_views[PIPE_SHADER_TYPES];
-
- struct {
- struct pipe_constant_buffer buffers[ILO_MAX_CONST_BUFFERS];
- unsigned num_buffers;
- } constant_buffers[PIPE_SHADER_TYPES];
-
- struct {
- struct pipe_surface *surfaces[PIPE_MAX_SHADER_RESOURCES];
- unsigned num_surfaces;
- } shader_resources;
-
- struct ilo_shader_state *compute;
-
- struct {
- struct pipe_surface *surfaces[PIPE_MAX_SHADER_RESOURCES];
- unsigned num_surfaces;
- } compute_resources;
-
- struct {
- /*
- * XXX These should not be treated as real resources (and there could be
- * thousands of them). They should be treated as regions in GLOBAL
- * resource, which is the only real resource.
- *
- * That is, a resource here should instead be
- *
- * struct ilo_global_region {
- * struct pipe_resource base;
- * int offset;
- * int size;
- * };
- *
- * and it describes the region [offset, offset + size) in GLOBAL
- * resource.
- */
- struct pipe_resource *resources[PIPE_MAX_SHADER_RESOURCES];
- uint32_t *handles[PIPE_MAX_SHADER_RESOURCES];
- unsigned num_resources;
- } global_binding;
+ /* GPGPU */
+ struct ilo_shader_state *cs;
+ struct ilo_resource_state cs_resource;
+ struct ilo_global_binding global_binding;
};
static inline struct ilo_context *
diff --git a/src/gallium/drivers/ilo/ilo_gpe.h b/src/gallium/drivers/ilo/ilo_gpe.h
index 8bb1ddf3a7b..903d654f051 100644
--- a/src/gallium/drivers/ilo/ilo_gpe.h
+++ b/src/gallium/drivers/ilo/ilo_gpe.h
@@ -96,10 +96,52 @@ struct ilo_blend_state {
struct pipe_blend_state state;
};
+struct ilo_sampler_state {
+ struct pipe_sampler_state *states[ILO_MAX_SAMPLERS];
+ unsigned count;
+};
+
+struct ilo_view_state {
+ struct pipe_sampler_view *states[ILO_MAX_SAMPLER_VIEWS];
+ unsigned count;
+};
+
+struct ilo_cbuf_state {
+ struct pipe_constant_buffer states[ILO_MAX_CONST_BUFFERS];
+ unsigned count;
+};
+
+struct ilo_resource_state {
+ struct pipe_surface *states[PIPE_MAX_SHADER_RESOURCES];
+ unsigned count;
+};
+
struct ilo_fb_state {
struct pipe_framebuffer_state state;
unsigned num_samples;
};
+struct ilo_global_binding {
+ /*
+ * XXX These should not be treated as real resources (and there could be
+ * thousands of them). They should be treated as regions in GLOBAL
+ * resource, which is the only real resource.
+ *
+ * That is, a resource here should instead be
+ *
+ * struct ilo_global_region {
+ * struct pipe_resource base;
+ * int offset;
+ * int size;
+ * };
+ *
+ * and it describes the region [offset, offset + size) in GLOBAL
+ * resource.
+ */
+ struct pipe_resource *resources[PIPE_MAX_SHADER_RESOURCES];
+ uint32_t *handles[PIPE_MAX_SHADER_RESOURCES];
+ unsigned count;
+};
+
#endif /* ILO_GPE_H */
diff --git a/src/gallium/drivers/ilo/ilo_shader.c b/src/gallium/drivers/ilo/ilo_shader.c
index 86268b1a9f0..76ba7f04c66 100644
--- a/src/gallium/drivers/ilo/ilo_shader.c
+++ b/src/gallium/drivers/ilo/ilo_shader.c
@@ -72,15 +72,15 @@ ilo_shader_variant_init(struct ilo_shader_variant *variant,
break;
}
- num_views = ilo->sampler_views[info->type].num_views;
+ num_views = ilo->view[info->type].count;
assert(info->num_samplers <= num_views);
variant->num_sampler_views = info->num_samplers;
for (i = 0; i < info->num_samplers; i++) {
const struct pipe_sampler_view *view =
- ilo->sampler_views[info->type].views[i];
+ ilo->view[info->type].states[i];
const struct pipe_sampler_state *sampler =
- ilo->samplers[info->type].samplers[i];
+ ilo->sampler[info->type].states[i];
if (view) {
variant->sampler_view_swizzles[i].r = view->swizzle_r;
diff --git a/src/gallium/drivers/ilo/ilo_state.c b/src/gallium/drivers/ilo/ilo_state.c
index 0048a1541f0..1151242ea57 100644
--- a/src/gallium/drivers/ilo/ilo_state.c
+++ b/src/gallium/drivers/ilo/ilo_state.c
@@ -130,14 +130,14 @@ finalize_constant_buffers(struct ilo_context *ilo)
return;
for (sh = 0; sh < PIPE_SHADER_TYPES; sh++) {
- int last_cbuf = Elements(ilo->constant_buffers[sh].buffers) - 1;
+ int last_cbuf = Elements(ilo->cbuf[sh].states) - 1;
/* find the last cbuf */
while (last_cbuf >= 0 &&
- !ilo->constant_buffers[sh].buffers[last_cbuf].buffer)
+ !ilo->cbuf[sh].states[last_cbuf].buffer)
last_cbuf--;
- ilo->constant_buffers[sh].num_buffers = last_cbuf + 1;
+ ilo->cbuf[sh].count = last_cbuf + 1;
}
}
@@ -201,10 +201,10 @@ bind_samplers(struct ilo_context *ilo,
unsigned shader, unsigned start, unsigned count,
void **samplers, bool unbind_old)
{
- struct pipe_sampler_state **dst = ilo->samplers[shader].samplers;
+ struct pipe_sampler_state **dst = ilo->sampler[shader].states;
unsigned i;
- assert(start + count <= Elements(ilo->samplers[shader].samplers));
+ assert(start + count <= Elements(ilo->sampler[shader].states));
if (unbind_old) {
if (!samplers) {
@@ -216,10 +216,10 @@ bind_samplers(struct ilo_context *ilo,
dst[i] = NULL;
for (; i < start + count; i++)
dst[i] = samplers[i - start];
- for (; i < ilo->samplers[shader].num_samplers; i++)
+ for (; i < ilo->sampler[shader].count; i++)
dst[i] = NULL;
- ilo->samplers[shader].num_samplers = start + count;
+ ilo->sampler[shader].count = start + count;
return;
}
@@ -234,13 +234,13 @@ bind_samplers(struct ilo_context *ilo,
dst[i] = NULL;
}
- if (ilo->samplers[shader].num_samplers <= start + count) {
+ if (ilo->sampler[shader].count <= start + count) {
count += start;
- while (count > 0 && !ilo->samplers[shader].samplers[count - 1])
+ while (count > 0 && !ilo->sampler[shader].states[count - 1])
count--;
- ilo->samplers[shader].num_samplers = count;
+ ilo->sampler[shader].count = count;
}
}
@@ -517,10 +517,10 @@ ilo_set_constant_buffer(struct pipe_context *pipe,
struct ilo_context *ilo = ilo_context(pipe);
struct pipe_constant_buffer *cbuf;
- assert(shader < Elements(ilo->constant_buffers));
- assert(index < Elements(ilo->constant_buffers[shader].buffers));
+ assert(shader < Elements(ilo->cbuf));
+ assert(index < Elements(ilo->cbuf[shader].states));
- cbuf = &ilo->constant_buffers[shader].buffers[index];
+ cbuf = &ilo->cbuf[shader].states[index];
pipe_resource_reference(&cbuf->buffer, NULL);
@@ -537,7 +537,7 @@ ilo_set_constant_buffer(struct pipe_context *pipe,
}
/* the correct value will be set in ilo_finalize_states() */
- ilo->constant_buffers[shader].num_buffers = 0;
+ ilo->cbuf[shader].count = 0;
ilo->dirty |= ILO_DIRTY_CONSTANT_BUFFER;
}
@@ -620,10 +620,10 @@ set_sampler_views(struct ilo_context *ilo,
unsigned shader, unsigned start, unsigned count,
struct pipe_sampler_view **views, bool unset_old)
{
- struct pipe_sampler_view **dst = ilo->sampler_views[shader].views;
+ struct pipe_sampler_view **dst = ilo->view[shader].states;
unsigned i;
- assert(start + count <= Elements(ilo->sampler_views[shader].views));
+ assert(start + count <= Elements(ilo->view[shader].states));
if (unset_old) {
if (!views) {
@@ -635,10 +635,10 @@ set_sampler_views(struct ilo_context *ilo,
pipe_sampler_view_reference(&dst[i], NULL);
for (; i < start + count; i++)
pipe_sampler_view_reference(&dst[i], views[i - start]);
- for (; i < ilo->sampler_views[shader].num_views; i++)
+ for (; i < ilo->view[shader].count; i++)
pipe_sampler_view_reference(&dst[i], NULL);
- ilo->sampler_views[shader].num_views = start + count;
+ ilo->view[shader].count = start + count;
return;
}
@@ -653,13 +653,13 @@ set_sampler_views(struct ilo_context *ilo,
pipe_sampler_view_reference(&dst[i], NULL);
}
- if (ilo->sampler_views[shader].num_views <= start + count) {
+ if (ilo->view[shader].count <= start + count) {
count += start;
- while (count > 0 && !ilo->sampler_views[shader].views[count - 1])
+ while (count > 0 && !ilo->view[shader].states[count - 1])
count--;
- ilo->sampler_views[shader].num_views = count;
+ ilo->view[shader].count = count;
}
}
@@ -715,10 +715,10 @@ ilo_set_shader_resources(struct pipe_context *pipe,
struct pipe_surface **surfaces)
{
struct ilo_context *ilo = ilo_context(pipe);
- struct pipe_surface **dst = ilo->shader_resources.surfaces;
+ struct pipe_surface **dst = ilo->resource.states;
unsigned i;
- assert(start + count <= Elements(ilo->shader_resources.surfaces));
+ assert(start + count <= Elements(ilo->resource.states));
dst += start;
if (surfaces) {
@@ -730,13 +730,13 @@ ilo_set_shader_resources(struct pipe_context *pipe,
pipe_surface_reference(&dst[i], NULL);
}
- if (ilo->shader_resources.num_surfaces <= start + count) {
+ if (ilo->resource.count <= start + count) {
count += start;
- while (count > 0 && !ilo->shader_resources.surfaces[count - 1])
+ while (count > 0 && !ilo->resource.states[count - 1])
count--;
- ilo->shader_resources.num_surfaces = count;
+ ilo->resource.count = count;
}
ilo->dirty |= ILO_DIRTY_SHADER_RESOURCES;
@@ -902,7 +902,7 @@ ilo_bind_compute_state(struct pipe_context *pipe, void *state)
{
struct ilo_context *ilo = ilo_context(pipe);
- ilo->compute = state;
+ ilo->cs = state;
ilo->dirty |= ILO_DIRTY_COMPUTE;
}
@@ -920,10 +920,10 @@ ilo_set_compute_resources(struct pipe_context *pipe,
struct pipe_surface **surfaces)
{
struct ilo_context *ilo = ilo_context(pipe);
- struct pipe_surface **dst = ilo->compute_resources.surfaces;
+ struct pipe_surface **dst = ilo->cs_resource.states;
unsigned i;
- assert(start + count <= Elements(ilo->compute_resources.surfaces));
+ assert(start + count <= Elements(ilo->cs_resource.states));
dst += start;
if (surfaces) {
@@ -935,13 +935,13 @@ ilo_set_compute_resources(struct pipe_context *pipe,
pipe_surface_reference(&dst[i], NULL);
}
- if (ilo->compute_resources.num_surfaces <= start + count) {
+ if (ilo->cs_resource.count <= start + count) {
count += start;
- while (count > 0 && !ilo->compute_resources.surfaces[count - 1])
+ while (count > 0 && !ilo->cs_resource.states[count - 1])
count--;
- ilo->compute_resources.num_surfaces = count;
+ ilo->cs_resource.count = count;
}
ilo->dirty |= ILO_DIRTY_COMPUTE_RESOURCES;
@@ -969,13 +969,13 @@ ilo_set_global_binding(struct pipe_context *pipe,
pipe_resource_reference(&dst[i], NULL);
}
- if (ilo->global_binding.num_resources <= start + count) {
+ if (ilo->global_binding.count <= start + count) {
count += start;
while (count > 0 && !ilo->global_binding.resources[count - 1])
count--;
- ilo->global_binding.num_resources = count;
+ ilo->global_binding.count = count;
}
ilo->dirty |= ILO_DIRTY_GLOBAL_BINDING;