diff options
author | Eric Anholt <[email protected]> | 2014-06-19 08:19:38 +0100 |
---|---|---|
committer | Eric Anholt <[email protected]> | 2014-08-08 18:59:46 -0700 |
commit | 1850d0a1cbf044dc4d29b7a9ede2c634f667d853 (patch) | |
tree | 80af7674f5160d9ae740958aad047786b2646539 /src/gallium/drivers/vc4/vc4_context.h | |
parent | f017e32c0add05b588f5f6a4bea16b84b8a051eb (diff) |
vc4: Initial skeleton driver import.
This mostly just takes every draw call and turns it into a sequence of
commands that clear the FBO and draw a single shaded triangle to it,
regardless of the actual input vertices or shaders. I copied the initial
driver skeleton mostly from freedreno, and I've preserved Rob Clark's
copyright for those. I also based my initial hardcoded shaders and
command lists on Scott Mansell (phire)'s "hackdriver" project, though the
bit patterns of the shaders emitted end up being different.
v2: Rebase on gallium megadrivers changes.
v3: Rebase on PIPE_SHADER_CAP_MAX_CONSTS change.
v4: Rely on simpenrose actually being installed when building for
simulation.
v5: Add more header duplicate-include guards.
v6: Apply Emil's review (protection against vc4 sim and ilo at the same
time, and dropping the dricommon drm bits) and fix a copyright header
(thanks, Roland)
Diffstat (limited to 'src/gallium/drivers/vc4/vc4_context.h')
-rw-r--r-- | src/gallium/drivers/vc4/vc4_context.h | 177 |
1 files changed, 177 insertions, 0 deletions
diff --git a/src/gallium/drivers/vc4/vc4_context.h b/src/gallium/drivers/vc4/vc4_context.h new file mode 100644 index 00000000000..73bf05bce19 --- /dev/null +++ b/src/gallium/drivers/vc4/vc4_context.h @@ -0,0 +1,177 @@ +/* + * Copyright © 2014 Broadcom + * Copyright (C) 2012 Rob Clark <[email protected]> + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + */ + +#ifndef VC4_CONTEXT_H +#define VC4_CONTEXT_H + +#include "pipe/p_context.h" +#include "pipe/p_state.h" +#include "util/u_slab.h" + +#include "vc4_bufmgr.h" +#include "vc4_resource.h" +#include "vc4_cl.h" + +#define VC4_DIRTY_BLEND (1 << 0) +#define VC4_DIRTY_RASTERIZER (1 << 1) +#define VC4_DIRTY_ZSA (1 << 2) +#define VC4_DIRTY_FRAGTEX (1 << 3) +#define VC4_DIRTY_VERTTEX (1 << 4) +#define VC4_DIRTY_TEXSTATE (1 << 5) +#define VC4_DIRTY_PROG (1 << 6) +#define VC4_DIRTY_BLEND_COLOR (1 << 7) +#define VC4_DIRTY_STENCIL_REF (1 << 8) +#define VC4_DIRTY_SAMPLE_MASK (1 << 9) +#define VC4_DIRTY_FRAMEBUFFER (1 << 10) +#define VC4_DIRTY_STIPPLE (1 << 11) +#define VC4_DIRTY_VIEWPORT (1 << 12) +#define VC4_DIRTY_CONSTBUF (1 << 13) +#define VC4_DIRTY_VTXSTATE (1 << 14) +#define VC4_DIRTY_VTXBUF (1 << 15) +#define VC4_DIRTY_INDEXBUF (1 << 16) +#define VC4_DIRTY_SCISSOR (1 << 17) + +#define VC4_SHADER_DIRTY_VP (1 << 0) +#define VC4_SHADER_DIRTY_FP (1 << 1) + +struct vc4_texture_stateobj { + struct pipe_sampler_view *textures[PIPE_MAX_SAMPLERS]; + unsigned num_textures; + struct pipe_sampler_state *samplers[PIPE_MAX_SAMPLERS]; + unsigned num_samplers; + unsigned dirty_samplers; +}; + +struct vc4_shader_state { + struct pipe_shader_state base; + struct vc4_bo *bo; +}; + +struct vc4_program_stateobj { + struct vc4_shader_state *vs, *fs; + uint32_t dirty; + uint8_t num_exports; + /* Indexed by semantic name or TGSI_SEMANTIC_COUNT + semantic index + * for TGSI_SEMANTIC_GENERIC. Special vs exports (position and point- + * size) are not included in this + */ + uint8_t export_linkage[63]; +}; + +struct vc4_constbuf_stateobj { + struct pipe_constant_buffer cb[PIPE_MAX_CONSTANT_BUFFERS]; + uint32_t enabled_mask; + uint32_t dirty_mask; +}; + +struct vc4_vertexbuf_stateobj { + struct pipe_vertex_buffer vb[PIPE_MAX_ATTRIBS]; + unsigned count; + uint32_t enabled_mask; + uint32_t dirty_mask; +}; + +struct vc4_vertex_stateobj { + struct pipe_vertex_element pipe[PIPE_MAX_ATTRIBS]; + unsigned num_elements; +}; + +struct vc4_context { + struct pipe_context base; + + int fd; + struct vc4_screen *screen; + + struct vc4_cl bcl; + struct vc4_cl rcl; + struct vc4_cl shader_rec; + struct vc4_cl bo_handles; + uint32_t shader_rec_count; + + struct util_slab_mempool transfer_pool; + struct blitter_context *blitter; + + /** bitfield of VC4_DIRTY_* */ + uint32_t dirty; + + /** + * Set if some drawing (triangles, blits, or just a glClear()) has + * been done to the FBO, meaning that we need to + * DRM_IOCTL_VC4_SUBMIT_CL. + */ + bool needs_flush; + + /** @{ Current pipeline state objects */ + struct pipe_scissor_state scissor; + struct pipe_blend_state *blend; + struct vc4_rasterizer_state *rasterizer; + struct pipe_depth_stencil_alpha_state *zsa; + + struct vc4_texture_stateobj verttex, fragtex; + + struct vc4_program_stateobj prog; + + struct vc4_vertex_stateobj *vtx; + + struct pipe_blend_color blend_color; + struct pipe_stencil_ref stencil_ref; + unsigned sample_mask; + struct pipe_framebuffer_state framebuffer; + struct pipe_poly_stipple stipple; + struct pipe_viewport_state viewport; + struct vc4_constbuf_stateobj constbuf[PIPE_SHADER_TYPES]; + struct vc4_vertexbuf_stateobj vertexbuf; + struct pipe_index_buffer indexbuf; + /** @} */ +}; + +struct vc4_rasterizer_state { + struct pipe_rasterizer_state base; + + /* VC4_CONFIGURATION_BITS */ + uint8_t config_bits[3]; + + float point_size; +}; + +static inline struct vc4_context * +vc4_context(struct pipe_context *pcontext) +{ + return (struct vc4_context *)pcontext; +} + +struct pipe_context *vc4_context_create(struct pipe_screen *pscreen, + void *priv); +void vc4_draw_init(struct pipe_context *pctx); +void vc4_state_init(struct pipe_context *pctx); +void vc4_program_init(struct pipe_context *pctx); +void vc4_simulator_init(struct vc4_screen *screen); +void vc4_simulator_flush(struct vc4_context *vc4, + struct vc4_surface *color_surf); +void *vc4_simulator_alloc(struct vc4_screen *screen, uint32_t size); + +void vc4_flush(struct pipe_context *pctx); +void vc4_emit_state(struct pipe_context *pctx); + +#endif /* VC4_CONTEXT_H */ |