#include "util/u_inlines.h"
#include "util/u_transfer.h"
#include "intel/compiler/brw_compiler.h"
+#include "iris_batch.h"
#include "iris_context.h"
#include "iris_resource.h"
__genxml_cmd_pack(cmd)(NULL, (void *)_dst, &name), \
_dst = NULL)
+#define iris_emit_cmd(batch, cmd, name) \
+ iris_require_command_space(batch, 4 * __genxml_cmd_length(cmd)); \
+ iris_pack_command(cmd, batch->cmdbuf.map_next, name)
+
#include "genxml/genX_pack.h"
#include "genxml/gen_macros.h"
return cso;
}
+static void
+iris_bind_blend_state(struct pipe_context *ctx, void *state)
+{
+ struct iris_context *ice = (struct iris_context *) ctx;
+ ice->state.cso_blend = state;
+ ice->state.dirty |= IRIS_DIRTY_CC_VIEWPORT;
+ ice->state.dirty |= IRIS_DIRTY_WM_DEPTH_STENCIL;
+}
+
struct iris_depth_stencil_alpha_state {
uint32_t wmds[GENX(3DSTATE_WM_DEPTH_STENCIL_length)];
uint32_t cc_vp[GENX(CC_VIEWPORT_length)];
};
static void *
-iris_create_dsa_state(struct pipe_context *ctx,
+iris_create_zsa_state(struct pipe_context *ctx,
const struct pipe_depth_stencil_alpha_state *state)
{
struct iris_depth_stencil_alpha_state *cso =
return cso;
}
+static void
+iris_bind_zsa_state(struct pipe_context *ctx, void *state)
+{
+ struct iris_context *ice = (struct iris_context *) ctx;
+ ice->state.cso_zsa = state;
+ ice->state.dirty |= IRIS_DIRTY_CC_VIEWPORT;
+ ice->state.dirty |= IRIS_DIRTY_WM_DEPTH_STENCIL;
+}
+
struct iris_rasterizer_state {
uint32_t sf[GENX(3DSTATE_SF_length)];
uint32_t clip[GENX(3DSTATE_CLIP_length)];
free(surface);
}
-static void
-iris_bind_state(struct pipe_context *ctx, void *state)
-{
-}
-
static void
iris_delete_state(struct pipe_context *ctx, void *state)
{
{
}
+void
+iris_upload_render_state(struct iris_context *ice, struct iris_batch *batch)
+{
+ const uint64_t dirty = ice->state.dirty;
+
+ if (dirty & IRIS_DIRTY_WM_DEPTH_STENCIL) {
+ // XXX: import stencil ref...
+ struct iris_depth_stencil_alpha_state *cso = ice->state.cso_zsa;
+ iris_batch_emit(batch, cso->wmds, sizeof(cso->wmds));
+ }
+
+ if (dirty & IRIS_DIRTY_CC_VIEWPORT) {
+ struct iris_depth_stencil_alpha_state *cso = ice->state.cso_zsa;
+ iris_emit_cmd(batch, GENX(3DSTATE_VIEWPORT_STATE_POINTERS_CC), ptr) {
+ ptr.CCViewportPointer =
+ iris_emit_state(batch, cso->cc_vp, sizeof(cso->cc_vp), 32);
+ }
+ }
+
+ if (dirty & IRIS_DIRTY_PS_BLEND) {
+ struct iris_blend_state *cso = ice->state.cso_blend;
+ iris_batch_emit(batch, cso->ps_blend, sizeof(cso->ps_blend));
+ }
+
+ if (dirty & IRIS_DIRTY_BLEND_STATE) {
+ struct iris_blend_state *cso = ice->state.cso_blend;
+ // XXX: 3DSTATE_BLEND_STATE_POINTERS - BLEND_STATE
+ // -> from iris_blend_state (most) + iris_depth_stencil_alpha_state
+ // (alpha test function/enable) + has writeable RT from ???????
+ }
+
+ if (dirty & IRIS_DIRTY_SF_CL_VIEWPORT) {
+ struct iris_depth_stencil_alpha_state *cso = ice->state.cso_zsa;
+ iris_emit_cmd(batch, GENX(3DSTATE_VIEWPORT_STATE_POINTERS_CC), ptr) {
+ ptr.CCViewportPointer =
+ iris_emit_state(batch, cso->cc_vp, sizeof(cso->cc_vp), 32);
+ }
+ }
+
+#if 0
+ l3 configuration
+
+ 3DSTATE_VIEWPORT_STATE_POINTERS_SF_CL - SF_CLIP_VIEWPORT
+ -> pipe_viewport_state for matrix elements, guardband is calculated
+ from those. can calculate screen space from matrix apparently...
+
+ 3DSTATE_SCISSOR_STATE_POINTERS - SCISSOR_RECT
+ -> from ice->state.scissors
+
+ 3DSTATE_PUSH_CONSTANT_ALLOC_*
+ 3DSTATE_URB_*
+ -> TODO
+
+ 3DSTATE_CC_STATE_POINTERS - COLOR_CALC_STATE
+ -> from ice->state.blend_color + iris_depth_stencil_alpha_state
+ (ref_value)
+
+ 3DSTATE_CONSTANT_* - push constants
+ -> TODO
+
+ Surfaces:
+ - pull constants
+ - ubos/ssbos/abos
+ - images
+ - textures
+ - render targets - write and read
+ 3DSTATE_BINDING_TABLE_POINTERS_*
+ -> TODO
+
+ 3DSTATE_SAMPLER_STATE_POINTERS_*
+ -> TODO
+
+ 3DSTATE_MULTISAMPLE
+ 3DSTATE_SAMPLE_MASK
+
+ 3DSTATE_VS
+ 3DSTATE_HS
+ 3DSTATE_TE
+ 3DSTATE_DS
+ 3DSTATE_GS
+ 3DSTATE_PS_EXTRA
+ 3DSTATE_PS
+ 3DSTATE_STREAMOUT
+ 3DSTATE_SO_BUFFER
+ 3DSTATE_SO_DECL_LIST
+
+ 3DSTATE_CLIP
+ -> iris_raster_state + ??? (Non-perspective Bary, ForceZeroRTAIndex)
+
+ 3DSTATE_RASTER
+ 3DSTATE_SF
+ -> iris_raster_state
+
+ 3DSTATE_WM
+ -> iris_raster_state + FS state (barycentric, EDSC)
+ 3DSTATE_SBE
+ -> iris_raster_state (point sprite texture coordinate origin)
+ -> bunch of shader state...
+ 3DSTATE_SBE_SWIZ
+ -> FS state
+
+ 3DSTATE_DEPTH_BUFFER
+ 3DSTATE_HIER_DEPTH_BUFFER
+ 3DSTATE_STENCIL_BUFFER
+ 3DSTATE_CLEAR_PARAMS
+ -> iris_framebuffer_state?
+
+ 3DSTATE_VF_TOPOLOGY
+ -> pipe_draw_info (prim_mode)
+ 3DSTATE_VF
+ -> pipe_draw_info (restart_index, primitive_restart)
+
+ 3DSTATE_INDEX_BUFFER
+ -> pipe_draw_info (index)
+ 3DSTATE_VERTEX_BUFFERS
+ -> pipe_vertex_buffer (set_vertex_buffer hook)
+ 3DSTATE_VERTEX_ELEMENTS
+ -> iris_vertex_element
+ 3DSTATE_VF_INSTANCING
+ -> iris_vertex_element
+ 3DSTATE_VF_SGVS
+ -> TODO ???
+ 3DSTATE_VF_COMPONENT_PACKING
+ -> TODO ???
+
+ 3DPRIMITIVE
+ -> pipe_draw_info
+
+ rare:
+ 3DSTATE_POLY_STIPPLE_OFFSET
+ 3DSTATE_POLY_STIPPLE_PATTERN
+ -> ice->state.poly_stipple
+ 3DSTATE_LINE_STIPPLE
+ -> iris_raster_state
+
+ once:
+ 3DSTATE_AA_LINE_PARAMETERS
+ 3DSTATE_WM_CHROMAKEY
+ 3DSTATE_SAMPLE_PATTERN
+ 3DSTATE_DRAWING_RECTANGLE
+ 3DSTATE_WM_HZ_OP
+#endif
+}
+
+static void
+iris_bind_state(struct pipe_context *ctx, void *state)
+{
+}
+
void
iris_init_state_functions(struct pipe_context *ctx)
{
ctx->create_blend_state = iris_create_blend_state;
- ctx->create_depth_stencil_alpha_state = iris_create_dsa_state;
+ ctx->create_depth_stencil_alpha_state = iris_create_zsa_state;
ctx->create_rasterizer_state = iris_create_rasterizer_state;
ctx->create_sampler_state = iris_create_sampler_state;
ctx->create_sampler_view = iris_create_sampler_view;
ctx->create_surface = iris_create_surface;
ctx->create_vertex_elements_state = iris_create_vertex_elements;
ctx->create_compute_state = iris_create_compute_state;
- ctx->bind_blend_state = iris_bind_state;
- ctx->bind_depth_stencil_alpha_state = iris_bind_state;
+ ctx->bind_blend_state = iris_bind_blend_state;
+ ctx->bind_depth_stencil_alpha_state = iris_bind_zsa_state;
ctx->bind_sampler_states = iris_bind_sampler_states;
ctx->bind_fs_state = iris_bind_state;
ctx->bind_rasterizer_state = iris_bind_state;