ilo_render_dynamic.c \
ilo_render_gen6.c \
ilo_render_gen7.c \
- ilo_render_gen7.h \
ilo_render_surface.c \
ilo_screen.c \
ilo_screen.h \
ilo_draw_set_owner(ilo);
/* make sure there is enough room first */
- max_len = ilo_render_estimate_size(ilo->render,
- ILO_RENDER_DRAW, vec);
+ max_len = ilo_render_get_draw_len(ilo->render, vec);
if (need_flush)
max_len += ilo_render_get_flush_len(ilo->render);
*/
#include "genhw/genhw.h"
+#include "util/u_prim.h"
#include "intel_winsys.h"
#include "ilo_builder.h"
#include "ilo_builder_render.h"
#include "ilo_query.h"
#include "ilo_render_gen.h"
-#include "ilo_render_gen7.h"
#include "ilo_render.h"
/* in U0.4 */
render->dev = builder->dev;
render->builder = builder;
- switch (ilo_dev_gen(render->dev)) {
- case ILO_GEN(6):
- ilo_render_init_gen6(render);
- break;
- case ILO_GEN(7):
- case ILO_GEN(7.5):
- ilo_render_init_gen7(render);
- break;
- default:
- assert(!"unsupported GEN");
- FREE(render);
- return NULL;
- break;
- }
-
render->workaround_bo = intel_winsys_alloc_buffer(builder->winsys,
"PIPE_CONTROL workaround", 4096, false);
if (!render->workaround_bo) {
ilo_render_emit_rectlist_dynamic_states(render, blitter);
ilo_render_emit_rectlist_commands(render, blitter);
}
+
+int
+ilo_render_get_draw_len(const struct ilo_render *render,
+ const struct ilo_state_vector *vec)
+{
+ ILO_DEV_ASSERT(render->dev, 6, 7.5);
+
+ return ilo_render_get_draw_dynamic_states_len(render, vec) +
+ ilo_render_get_draw_surface_states_len(render, vec) +
+ ilo_render_get_draw_commands_len(render, vec);
+}
+
+static void
+gen6_draw_prepare(struct ilo_render *render,
+ const struct ilo_state_vector *vec,
+ struct gen6_draw_session *session)
+{
+ memset(session, 0, sizeof(*session));
+ session->pipe_dirty = vec->dirty;
+ session->reduced_prim = u_reduced_prim(vec->draw->mode);
+
+ if (render->hw_ctx_changed) {
+ /* these should be enough to make everything uploaded */
+ render->batch_bo_changed = true;
+ render->state_bo_changed = true;
+ render->instruction_bo_changed = true;
+
+ session->prim_changed = true;
+ session->primitive_restart_changed = true;
+ } else {
+ session->prim_changed =
+ (render->state.reduced_prim != session->reduced_prim);
+ session->primitive_restart_changed =
+ (render->state.primitive_restart != vec->draw->primitive_restart);
+ }
+}
+
+static void
+gen6_draw_end(struct ilo_render *render,
+ const struct ilo_state_vector *vec,
+ struct gen6_draw_session *session)
+{
+ render->hw_ctx_changed = false;
+
+ render->batch_bo_changed = false;
+ render->state_bo_changed = false;
+ render->instruction_bo_changed = false;
+
+ render->state.reduced_prim = session->reduced_prim;
+ render->state.primitive_restart = vec->draw->primitive_restart;
+}
+
+void
+ilo_render_emit_draw(struct ilo_render *render,
+ const struct ilo_state_vector *vec)
+{
+ struct gen6_draw_session session;
+
+ ILO_DEV_ASSERT(render->dev, 6, 7.5);
+
+ gen6_draw_prepare(render, vec, &session);
+
+ /* force all states to be uploaded if the state bo changed */
+ if (render->state_bo_changed)
+ session.pipe_dirty = ILO_DIRTY_ALL;
+ else
+ session.pipe_dirty = vec->dirty;
+
+ ilo_render_emit_draw_dynamic_states(render, vec, &session);
+ ilo_render_emit_draw_surface_states(render, vec, &session);
+
+ /* force all commands to be uploaded if the HW context changed */
+ if (render->hw_ctx_changed)
+ session.pipe_dirty = ILO_DIRTY_ALL;
+ else
+ session.pipe_dirty = vec->dirty;
+
+ ilo_render_emit_draw_commands(render, vec, &session);
+
+ gen6_draw_end(render, vec, &session);
+}
struct ilo_query;
struct ilo_state_vector;
-enum ilo_render_action {
- ILO_RENDER_DRAW,
-};
-
/**
* Render Engine.
*/
uint32_t packed_sample_position_4x;
uint32_t packed_sample_position_8x[2];
- int (*estimate_size)(struct ilo_render *render,
- enum ilo_render_action action,
- const void *arg);
-
- void (*emit_draw)(struct ilo_render *render,
- const struct ilo_state_vector *vec);
-
bool hw_ctx_changed;
/*
/**
* Estimate the size of an action.
*/
-static inline int
-ilo_render_estimate_size(struct ilo_render *render,
- enum ilo_render_action action,
- const void *arg)
-{
- return render->estimate_size(render, action, arg);
-}
-
-/**
- * Emit context states and 3DPRIMITIVE.
- */
-static inline void
-ilo_render_emit_draw(struct ilo_render *render,
- const struct ilo_state_vector *vec)
-{
- render->emit_draw(render, vec);
-}
-
void
ilo_render_get_sample_position(const struct ilo_render *render,
unsigned sample_count,
ilo_render_emit_rectlist(struct ilo_render *render,
const struct ilo_blitter *blitter);
+int
+ilo_render_get_draw_len(const struct ilo_render *render,
+ const struct ilo_state_vector *vec);
+
+void
+ilo_render_emit_draw(struct ilo_render *render,
+ const struct ilo_state_vector *vec);
+
#endif /* ILO_RENDER_H */
bool prim_changed;
bool primitive_restart_changed;
- void (*emit_draw_commands)(struct ilo_render *render,
- const struct ilo_state_vector *ilo,
- struct gen6_draw_session *session);
-
/* dynamic states */
bool viewport_changed;
bool scissor_changed;
int num_surfaces[PIPE_SHADER_TYPES];
};
+int
+ilo_render_get_draw_commands_len_gen6(const struct ilo_render *render,
+ const struct ilo_state_vector *vec);
+
+int
+ilo_render_get_draw_commands_len_gen7(const struct ilo_render *render,
+ const struct ilo_state_vector *vec);
+
+static inline int
+ilo_render_get_draw_commands_len(const struct ilo_render *render,
+ const struct ilo_state_vector *vec)
+{
+ if (ilo_dev_gen(render->dev) >= ILO_GEN(7))
+ return ilo_render_get_draw_commands_len_gen7(render, vec);
+ else
+ return ilo_render_get_draw_commands_len_gen6(render, vec);
+}
+
+void
+ilo_render_emit_draw_commands_gen6(struct ilo_render *render,
+ const struct ilo_state_vector *vec,
+ struct gen6_draw_session *session);
+
+void
+ilo_render_emit_draw_commands_gen7(struct ilo_render *render,
+ const struct ilo_state_vector *vec,
+ struct gen6_draw_session *session);
+
+static inline void
+ilo_render_emit_draw_commands(struct ilo_render *render,
+ const struct ilo_state_vector *vec,
+ struct gen6_draw_session *session)
+{
+ const unsigned batch_used = ilo_builder_batch_used(render->builder);
+
+ if (ilo_dev_gen(render->dev) >= ILO_GEN(7))
+ ilo_render_emit_draw_commands_gen7(render, vec, session);
+ else
+ ilo_render_emit_draw_commands_gen6(render, vec, session);
+
+ assert(ilo_builder_batch_used(render->builder) <= batch_used +
+ ilo_render_get_draw_commands_len(render, vec));
+}
+
int
ilo_render_get_rectlist_commands_len_gen6(const struct ilo_render *render,
const struct ilo_blitter *blitter);
void
gen6_wa_pre_pipe_control(struct ilo_render *r, uint32_t dw1);
-void
-gen6_draw_prepare(struct ilo_render *r,
- const struct ilo_state_vector *ilo,
- struct gen6_draw_session *session);
-
-void
-gen6_draw_emit(struct ilo_render *r,
- const struct ilo_state_vector *ilo,
- struct gen6_draw_session *session);
-
-void
-gen6_draw_end(struct ilo_render *r,
- const struct ilo_state_vector *ilo,
- struct gen6_draw_session *session);
-
void
gen6_draw_common_select(struct ilo_render *r,
const struct ilo_state_vector *ilo,
const struct ilo_state_vector *ilo,
struct gen6_draw_session *session);
-void
-ilo_render_init_gen6(struct ilo_render *render);
-
#endif /* ILO_RENDER_GEN_H */
#undef DIRTY
-static void
-gen6_draw_commands(struct ilo_render *render,
- const struct ilo_state_vector *vec,
- struct gen6_draw_session *session)
+void
+ilo_render_emit_draw_commands_gen6(struct ilo_render *render,
+ const struct ilo_state_vector *vec,
+ struct gen6_draw_session *session)
{
+ ILO_DEV_ASSERT(render->dev, 6, 6);
+
/*
* We try to keep the order of the commands match, as closely as possible,
* that of the classic i965 driver. It allows us to compare the command
gen6_draw_vf_draw(render, vec, session);
}
-void
-gen6_draw_prepare(struct ilo_render *render,
- const struct ilo_state_vector *vec,
- struct gen6_draw_session *session)
-{
- memset(session, 0, sizeof(*session));
- session->pipe_dirty = vec->dirty;
- session->reduced_prim = u_reduced_prim(vec->draw->mode);
-
- if (render->hw_ctx_changed) {
- /* these should be enough to make everything uploaded */
- render->batch_bo_changed = true;
- render->state_bo_changed = true;
- render->instruction_bo_changed = true;
-
- session->prim_changed = true;
- session->primitive_restart_changed = true;
- } else {
- session->prim_changed =
- (render->state.reduced_prim != session->reduced_prim);
- session->primitive_restart_changed =
- (render->state.primitive_restart != vec->draw->primitive_restart);
- }
-}
-
-void
-gen6_draw_emit(struct ilo_render *render,
- const struct ilo_state_vector *vec,
- struct gen6_draw_session *session)
-{
- /* force all states to be uploaded if the state bo changed */
- if (render->state_bo_changed)
- session->pipe_dirty = ILO_DIRTY_ALL;
- else
- session->pipe_dirty = vec->dirty;
-
- ilo_render_emit_draw_dynamic_states(render, vec, session);
- ilo_render_emit_draw_surface_states(render, vec, session);
-
- /* force all commands to be uploaded if the HW context changed */
- if (render->hw_ctx_changed)
- session->pipe_dirty = ILO_DIRTY_ALL;
- else
- session->pipe_dirty = vec->dirty;
-
- session->emit_draw_commands(render, vec, session);
-}
-
-void
-gen6_draw_end(struct ilo_render *render,
- const struct ilo_state_vector *vec,
- struct gen6_draw_session *session)
-{
- render->hw_ctx_changed = false;
-
- render->batch_bo_changed = false;
- render->state_bo_changed = false;
- render->instruction_bo_changed = false;
-
- render->state.reduced_prim = session->reduced_prim;
- render->state.primitive_restart = vec->draw->primitive_restart;
-}
-
-static void
-ilo_render_emit_draw_gen6(struct ilo_render *render,
- const struct ilo_state_vector *vec)
-{
- struct gen6_draw_session session;
-
- gen6_draw_prepare(render, vec, &session);
-
- session.emit_draw_commands = gen6_draw_commands;
-
- gen6_draw_emit(render, vec, &session);
- gen6_draw_end(render, vec, &session);
-}
-
static void
gen6_rectlist_vs_to_sf(struct ilo_render *r,
const struct ilo_blitter *blitter)
gen6_3DPRIMITIVE(r->builder, &blitter->draw, NULL);
}
-static int
-gen6_render_max_command_size(const struct ilo_render *render)
+int
+ilo_render_get_draw_commands_len_gen6(const struct ilo_render *render,
+ const struct ilo_state_vector *vec)
{
- static int size;
+ static int len;
+
+ ILO_DEV_ASSERT(render->dev, 6, 6);
- if (!size) {
- size += GEN6_3DSTATE_CONSTANT_ANY__SIZE * 3;
- size += GEN6_3DSTATE_GS_SVB_INDEX__SIZE * 4;
- size += GEN6_PIPE_CONTROL__SIZE * 5;
+ if (!len) {
+ len += GEN6_3DSTATE_CONSTANT_ANY__SIZE * 3;
+ len += GEN6_3DSTATE_GS_SVB_INDEX__SIZE * 4;
+ len += GEN6_PIPE_CONTROL__SIZE * 5;
- size +=
+ len +=
GEN6_STATE_BASE_ADDRESS__SIZE +
GEN6_STATE_SIP__SIZE +
GEN6_3DSTATE_VF_STATISTICS__SIZE +
GEN6_3DPRIMITIVE__SIZE;
}
- return size;
-}
-
-static int
-ilo_render_estimate_size_gen6(struct ilo_render *render,
- enum ilo_render_action action,
- const void *arg)
-{
- int size;
-
- switch (action) {
- case ILO_RENDER_DRAW:
- {
- const struct ilo_state_vector *vec = arg;
-
- size = gen6_render_max_command_size(render) +
- ilo_render_get_draw_dynamic_states_len(render, vec) +
- ilo_render_get_draw_surface_states_len(render, vec);
- }
- break;
- default:
- assert(!"unknown render action");
- size = 0;
- break;
- }
-
- return size;
-}
-
-void
-ilo_render_init_gen6(struct ilo_render *render)
-{
- render->estimate_size = ilo_render_estimate_size_gen6;
- render->emit_draw = ilo_render_emit_draw_gen6;
+ return len;
}
#include "ilo_state.h"
#include "ilo_render.h"
#include "ilo_render_gen.h"
-#include "ilo_render_gen7.h"
/**
* A wrapper for gen6_PIPE_CONTROL().
r->state.deferred_pipe_control_dw1 = 0;
}
-static void
-gen7_draw_commands(struct ilo_render *render,
- const struct ilo_state_vector *vec,
- struct gen6_draw_session *session)
+void
+ilo_render_emit_draw_commands_gen7(struct ilo_render *render,
+ const struct ilo_state_vector *vec,
+ struct gen6_draw_session *session)
{
+ ILO_DEV_ASSERT(render->dev, 7, 7.5);
+
/*
* We try to keep the order of the commands match, as closely as possible,
* that of the classic i965 driver. It allows us to compare the command
gen7_draw_vf_draw(render, vec, session);
}
-static void
-ilo_render_emit_draw_gen7(struct ilo_render *render,
- const struct ilo_state_vector *vec)
-{
- struct gen6_draw_session session;
-
- gen6_draw_prepare(render, vec, &session);
-
- session.emit_draw_commands = gen7_draw_commands;
-
- gen6_draw_emit(render, vec, &session);
- gen6_draw_end(render, vec, &session);
-}
-
static void
gen7_rectlist_pcb_alloc(struct ilo_render *r,
const struct ilo_blitter *blitter)
gen7_3DPRIMITIVE(r->builder, &blitter->draw, NULL);
}
-static int
-gen7_render_max_command_size(const struct ilo_render *render)
+int
+ilo_render_get_draw_commands_len_gen7(const struct ilo_render *render,
+ const struct ilo_state_vector *vec)
{
- static int size;
+ static int len;
- if (!size) {
- size += GEN7_3DSTATE_URB_ANY__SIZE * 4;
- size += GEN7_3DSTATE_PUSH_CONSTANT_ALLOC_ANY__SIZE * 5;
- size += GEN6_3DSTATE_CONSTANT_ANY__SIZE * 5;
- size += GEN7_3DSTATE_POINTERS_ANY__SIZE * (5 + 5 + 4);
- size += GEN7_3DSTATE_SO_BUFFER__SIZE * 4;
- size += GEN6_PIPE_CONTROL__SIZE * 5;
+ ILO_DEV_ASSERT(render->dev, 7, 7.5);
- size +=
+ if (!len) {
+ len += GEN7_3DSTATE_URB_ANY__SIZE * 4;
+ len += GEN7_3DSTATE_PUSH_CONSTANT_ALLOC_ANY__SIZE * 5;
+ len += GEN6_3DSTATE_CONSTANT_ANY__SIZE * 5;
+ len += GEN7_3DSTATE_POINTERS_ANY__SIZE * (5 + 5 + 4);
+ len += GEN7_3DSTATE_SO_BUFFER__SIZE * 4;
+ len += GEN6_PIPE_CONTROL__SIZE * 5;
+
+ len +=
GEN6_STATE_BASE_ADDRESS__SIZE +
GEN6_STATE_SIP__SIZE +
GEN6_3DSTATE_VF_STATISTICS__SIZE +
GEN6_3DPRIMITIVE__SIZE;
}
- return size;
-}
-
-static int
-ilo_render_estimate_size_gen7(struct ilo_render *render,
- enum ilo_render_action action,
- const void *arg)
-{
- int size;
-
- switch (action) {
- case ILO_RENDER_DRAW:
- {
- const struct ilo_state_vector *vec = arg;
-
- size = gen7_render_max_command_size(render) +
- ilo_render_get_draw_dynamic_states_len(render, vec) +
- ilo_render_get_draw_surface_states_len(render, vec);
- }
- break;
- default:
- assert(!"unknown render action");
- size = 0;
- break;
- }
-
- return size;
-}
-
-void
-ilo_render_init_gen7(struct ilo_render *render)
-{
- render->estimate_size = ilo_render_estimate_size_gen7;
- render->emit_draw = ilo_render_emit_draw_gen7;
+ return len;
}
+++ /dev/null
-/*
- * Mesa 3-D graphics library
- *
- * Copyright (C) 2013 LunarG, Inc.
- *
- * 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 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.
- *
- * Authors:
- * Chia-I Wu <olv@lunarg.com>
- */
-
-#ifndef ILO_RENDER_GEN7_H
-#define ILO_RENDER_GEN7_H
-
-#include "ilo_common.h"
-
-struct ilo_render;
-
-void
-ilo_render_init_gen7(struct ilo_render *render);
-
-#endif /* ILO_RENDER_GEN7_H */