ilo: hook up pipe context state functions

This commit is contained in:
Chia-I Wu 2013-04-16 16:27:50 +08:00
parent 520af66797
commit 89d1702b9b
4 changed files with 1145 additions and 58 deletions

View file

@ -34,6 +34,7 @@
#include "ilo_query.h"
#include "ilo_resource.h"
#include "ilo_screen.h"
#include "ilo_shader.h"
#include "ilo_state.h"
#include "ilo_video.h"
#include "ilo_context.h"
@ -99,6 +100,8 @@ ilo_context_destroy(struct pipe_context *pipe)
if (ilo->last_cp_bo)
ilo->last_cp_bo->unreference(ilo->last_cp_bo);
if (ilo->shader_cache)
ilo_shader_cache_destroy(ilo->shader_cache);
if (ilo->cp)
ilo_cp_destroy(ilo->cp);
@ -170,7 +173,9 @@ ilo_context_create(struct pipe_screen *screen, void *priv)
}
ilo->cp = ilo_cp_create(ilo->winsys, is->has_llc);
if (!ilo->cp) {
ilo->shader_cache = ilo_shader_cache_create(ilo->winsys);
if (!ilo->cp || !ilo->shader_cache) {
ilo_context_destroy(&ilo->base);
return NULL;
}
@ -182,6 +187,8 @@ ilo_context_create(struct pipe_screen *screen, void *priv)
ilo_cp_set_hook(ilo->cp, ILO_CP_HOOK_POST_FLUSH,
ilo_context_post_cp_flush, (void *) ilo);
ilo->dirty = ILO_DIRTY_ALL;
ilo->base.screen = screen;
ilo->base.priv = priv;

View file

@ -60,6 +60,11 @@ struct ilo_cp;
struct ilo_screen;
struct ilo_shader_state;
struct ilo_vertex_element {
struct pipe_vertex_element elements[PIPE_MAX_ATTRIBS];
unsigned num_elements;
};
struct ilo_context {
struct pipe_context base;
@ -80,10 +85,32 @@ struct ilo_context {
struct ilo_cp *cp;
struct intel_bo *last_cp_bo;
struct pipe_rasterizer_state *rasterizer;
struct ilo_shader_state *vs;
struct ilo_shader_cache *shader_cache;
uint32_t dirty;
struct pipe_blend_state *blend;
struct pipe_rasterizer_state *rasterizer;
struct pipe_depth_stencil_alpha_state *depth_stencil_alpha;
struct ilo_shader_state *fs;
struct ilo_shader_state *vs;
struct ilo_shader_state *gs;
struct ilo_vertex_element *vertex_elements;
struct pipe_blend_color blend_color;
struct pipe_stencil_ref stencil_ref;
unsigned sample_mask;
struct pipe_clip_state clip;
struct pipe_framebuffer_state framebuffer;
struct pipe_poly_stipple poly_stipple;
struct pipe_scissor_state scissor;
struct pipe_viewport_state viewport;
struct pipe_index_buffer index_buffer;
struct {
struct pipe_vertex_buffer buffers[PIPE_MAX_ATTRIBS];
unsigned num_buffers;
} vertex_buffers;
struct {
struct pipe_sampler_state *samplers[ILO_MAX_SAMPLERS];
@ -95,6 +122,50 @@ struct ilo_context {
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_stream_output_target *targets[ILO_MAX_SO_BUFFERS];
unsigned num_targets;
unsigned append_bitmask;
} stream_output_targets;
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;
};
static inline struct ilo_context *

File diff suppressed because it is too large Load diff

View file

@ -30,9 +30,95 @@
#include "ilo_common.h"
/**
* States that we track.
*
* XXX Do we want to count each sampler or vertex buffer as a state? If that
* is the case, there are simply not enough bits.
*
* XXX We want to treat primitive type and depth clear value as states, but
* there are not enough bits.
*/
enum ilo_state {
ILO_STATE_BLEND,
ILO_STATE_FRAGMENT_SAMPLERS,
ILO_STATE_VERTEX_SAMPLERS,
ILO_STATE_GEOMETRY_SAMPLERS,
ILO_STATE_COMPUTE_SAMPLERS,
ILO_STATE_RASTERIZER,
ILO_STATE_DEPTH_STENCIL_ALPHA,
ILO_STATE_FS,
ILO_STATE_VS,
ILO_STATE_GS,
ILO_STATE_VERTEX_ELEMENTS,
ILO_STATE_BLEND_COLOR,
ILO_STATE_STENCIL_REF,
ILO_STATE_SAMPLE_MASK,
ILO_STATE_CLIP,
ILO_STATE_CONSTANT_BUFFER,
ILO_STATE_FRAMEBUFFER,
ILO_STATE_POLY_STIPPLE,
ILO_STATE_SCISSOR,
ILO_STATE_VIEWPORT,
ILO_STATE_FRAGMENT_SAMPLER_VIEWS,
ILO_STATE_VERTEX_SAMPLER_VIEWS,
ILO_STATE_GEOMETRY_SAMPLER_VIEWS,
ILO_STATE_COMPUTE_SAMPLER_VIEWS,
ILO_STATE_SHADER_RESOURCES,
ILO_STATE_VERTEX_BUFFERS,
ILO_STATE_INDEX_BUFFER,
ILO_STATE_STREAM_OUTPUT_TARGETS,
ILO_STATE_COMPUTE,
ILO_STATE_COMPUTE_RESOURCES,
ILO_STATE_GLOBAL_BINDING,
ILO_STATE_COUNT,
};
/**
* Dirty flags of the states.
*/
enum ilo_dirty_flags {
ILO_DIRTY_BLEND = 1 << ILO_STATE_BLEND,
ILO_DIRTY_FRAGMENT_SAMPLERS = 1 << ILO_STATE_FRAGMENT_SAMPLERS,
ILO_DIRTY_VERTEX_SAMPLERS = 1 << ILO_STATE_VERTEX_SAMPLERS,
ILO_DIRTY_GEOMETRY_SAMPLERS = 1 << ILO_STATE_GEOMETRY_SAMPLERS,
ILO_DIRTY_COMPUTE_SAMPLERS = 1 << ILO_STATE_COMPUTE_SAMPLERS,
ILO_DIRTY_RASTERIZER = 1 << ILO_STATE_RASTERIZER,
ILO_DIRTY_DEPTH_STENCIL_ALPHA = 1 << ILO_STATE_DEPTH_STENCIL_ALPHA,
ILO_DIRTY_FS = 1 << ILO_STATE_FS,
ILO_DIRTY_VS = 1 << ILO_STATE_VS,
ILO_DIRTY_GS = 1 << ILO_STATE_GS,
ILO_DIRTY_VERTEX_ELEMENTS = 1 << ILO_STATE_VERTEX_ELEMENTS,
ILO_DIRTY_BLEND_COLOR = 1 << ILO_STATE_BLEND_COLOR,
ILO_DIRTY_STENCIL_REF = 1 << ILO_STATE_STENCIL_REF,
ILO_DIRTY_SAMPLE_MASK = 1 << ILO_STATE_SAMPLE_MASK,
ILO_DIRTY_CLIP = 1 << ILO_STATE_CLIP,
ILO_DIRTY_CONSTANT_BUFFER = 1 << ILO_STATE_CONSTANT_BUFFER,
ILO_DIRTY_FRAMEBUFFER = 1 << ILO_STATE_FRAMEBUFFER,
ILO_DIRTY_POLY_STIPPLE = 1 << ILO_STATE_POLY_STIPPLE,
ILO_DIRTY_SCISSOR = 1 << ILO_STATE_SCISSOR,
ILO_DIRTY_VIEWPORT = 1 << ILO_STATE_VIEWPORT,
ILO_DIRTY_FRAGMENT_SAMPLER_VIEWS = 1 << ILO_STATE_FRAGMENT_SAMPLER_VIEWS,
ILO_DIRTY_VERTEX_SAMPLER_VIEWS = 1 << ILO_STATE_VERTEX_SAMPLER_VIEWS,
ILO_DIRTY_GEOMETRY_SAMPLER_VIEWS = 1 << ILO_STATE_GEOMETRY_SAMPLER_VIEWS,
ILO_DIRTY_COMPUTE_SAMPLER_VIEWS = 1 << ILO_STATE_COMPUTE_SAMPLER_VIEWS,
ILO_DIRTY_SHADER_RESOURCES = 1 << ILO_STATE_SHADER_RESOURCES,
ILO_DIRTY_VERTEX_BUFFERS = 1 << ILO_STATE_VERTEX_BUFFERS,
ILO_DIRTY_INDEX_BUFFER = 1 << ILO_STATE_INDEX_BUFFER,
ILO_DIRTY_STREAM_OUTPUT_TARGETS = 1 << ILO_STATE_STREAM_OUTPUT_TARGETS,
ILO_DIRTY_COMPUTE = 1 << ILO_STATE_COMPUTE,
ILO_DIRTY_COMPUTE_RESOURCES = 1 << ILO_STATE_COMPUTE_RESOURCES,
ILO_DIRTY_GLOBAL_BINDING = 1 << ILO_STATE_GLOBAL_BINDING,
ILO_DIRTY_ALL = 0xffffffff,
};
struct ilo_context;
void
ilo_init_state_functions(struct ilo_context *ilo);
void
ilo_finalize_states(struct ilo_context *ilo);
#endif /* ILO_STATE_H */