vbo_exec_context and vbo_save_context are inside gl_context.
Reviewed-by: Eric Anholt <eric@anholt.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7901>
#endif
struct gl_context;
-struct vbo_module;
/**
* Max number of primitives (number of glBegin/End pairs) per VBO.
struct vbo_exec_context
{
- struct gl_context *ctx;
GLvertexformat vtxfmt;
GLvertexformat vtxfmt_noop;
};
struct vbo_save_context {
- struct gl_context *ctx;
GLvertexformat vtxfmt;
GLvertexformat vtxfmt_noop; /**< Used if out_of_memory is true */
{
struct vbo_exec_context *exec = &vbo_context(ctx)->exec;
- exec->ctx = ctx;
-
vbo_exec_vtx_init(exec, use_buffer_objects);
ctx->Driver.NeedFlush = 0;
exec->vtx.buffer_ptr = exec->vtx.buffer_map;
}
else {
+ struct gl_context *ctx = gl_context_from_vbo_exec(exec);
struct _mesa_prim *last_prim = &exec->vtx.prim[exec->vtx.prim_count - 1];
const GLuint last_begin = last_prim->begin;
GLuint last_count;
- if (_mesa_inside_begin_end(exec->ctx)) {
+ if (_mesa_inside_begin_end(ctx)) {
last_prim->count = exec->vtx.vert_count - last_prim->start;
}
*/
assert(exec->vtx.prim_count == 0);
- if (_mesa_inside_begin_end(exec->ctx)) {
- exec->vtx.prim[0].mode = exec->ctx->Driver.CurrentExecPrimitive;
+ if (_mesa_inside_begin_end(ctx)) {
+ exec->vtx.prim[0].mode = ctx->Driver.CurrentExecPrimitive;
exec->vtx.prim[0].begin = 0;
exec->vtx.prim[0].end = 0;
exec->vtx.prim[0].start = 0;
static void
vbo_exec_copy_to_current(struct vbo_exec_context *exec)
{
- struct gl_context *ctx = exec->ctx;
+ struct gl_context *ctx = gl_context_from_vbo_exec(exec);
struct vbo_context *vbo = vbo_context(ctx);
GLbitfield64 enabled = exec->vtx.enabled & (~BITFIELD64_BIT(VBO_ATTRIB_POS));
vbo_exec_wrap_upgrade_vertex(struct vbo_exec_context *exec,
GLuint attr, GLuint newSize, GLenum newType)
{
- struct gl_context *ctx = exec->ctx;
+ struct gl_context *ctx = gl_context_from_vbo_exec(exec);
struct vbo_context *vbo = vbo_context(ctx);
const GLint lastcount = exec->vtx.vert_count;
fi_type *old_attrptr[VBO_ATTRIB_MAX];
static void
vbo_exec_FlushVertices_internal(struct vbo_exec_context *exec, unsigned flags)
{
- struct gl_context *ctx = exec->ctx;
+ struct gl_context *ctx = gl_context_from_vbo_exec(exec);
if (flags & FLUSH_STORED_VERTICES) {
if (exec->vtx.vert_count) {
vbo_try_prim_conversion(cur);
if (exec->vtx.prim_count >= 2) {
+ struct gl_context *ctx = gl_context_from_vbo_exec(exec);
struct _mesa_prim *prev = &exec->vtx.prim[exec->vtx.prim_count - 2];
assert(prev == cur - 1);
- if (vbo_merge_draws(exec->ctx, false, prev, cur))
+ if (vbo_merge_draws(ctx, false, prev, cur))
exec->vtx.prim_count--; /* drop the last primitive */
}
}
static void
vbo_exec_vtxfmt_init(struct vbo_exec_context *exec)
{
- struct gl_context *ctx = exec->ctx;
+ struct gl_context *ctx = gl_context_from_vbo_exec(exec);
GLvertexformat *vfmt = &exec->vtxfmt;
#define NAME_AE(x) _ae_##x
void
vbo_exec_vtx_init(struct vbo_exec_context *exec, bool use_buffer_objects)
{
- struct gl_context *ctx = exec->ctx;
+ struct gl_context *ctx = gl_context_from_vbo_exec(exec);
if (use_buffer_objects) {
/* Use buffer objects for immediate mode. */
vbo_exec_vtx_destroy(struct vbo_exec_context *exec)
{
/* using a real VBO for vertex data */
- struct gl_context *ctx = exec->ctx;
+ struct gl_context *ctx = gl_context_from_vbo_exec(exec);
/* True VBOs should already be unmapped
*/
static GLuint
vbo_exec_copy_vertices(struct vbo_exec_context *exec)
{
+ struct gl_context *ctx = gl_context_from_vbo_exec(exec);
struct _mesa_prim *last_prim = &exec->vtx.prim[exec->vtx.prim_count - 1];
const GLuint sz = exec->vtx.vertex_size;
fi_type *dst = exec->vtx.copied.buffer;
const fi_type *src = exec->vtx.buffer_map + last_prim->start * sz;
- return vbo_copy_vertices(exec->ctx, exec->ctx->Driver.CurrentExecPrimitive,
+ return vbo_copy_vertices(ctx, ctx->Driver.CurrentExecPrimitive,
last_prim, sz, false, dst, src);
}
vbo_exec_vtx_unmap(struct vbo_exec_context *exec)
{
if (exec->vtx.bufferobj) {
- struct gl_context *ctx = exec->ctx;
+ struct gl_context *ctx = gl_context_from_vbo_exec(exec);
if (ctx->Driver.FlushMappedBufferRange &&
!ctx->Extensions.ARB_buffer_storage) {
exec->vtx.buffer_used += (exec->vtx.buffer_ptr -
exec->vtx.buffer_map) * sizeof(float);
- assert(exec->vtx.buffer_used <= exec->ctx->Const.glBeginEndBufferSize);
+ assert(exec->vtx.buffer_used <= ctx->Const.glBeginEndBufferSize);
assert(exec->vtx.buffer_ptr != NULL);
ctx->Driver.UnmapBuffer(ctx, exec->vtx.bufferobj, MAP_INTERNAL);
static bool
vbo_exec_buffer_has_space(struct vbo_exec_context *exec)
{
- return exec->ctx->Const.glBeginEndBufferSize > exec->vtx.buffer_used + 1024;
+ struct gl_context *ctx = gl_context_from_vbo_exec(exec);
+
+ return ctx->Const.glBeginEndBufferSize > exec->vtx.buffer_used + 1024;
}
void
vbo_exec_vtx_map(struct vbo_exec_context *exec)
{
- struct gl_context *ctx = exec->ctx;
+ struct gl_context *ctx = gl_context_from_vbo_exec(exec);
const GLenum usage = GL_STREAM_DRAW_ARB;
GLenum accessRange = GL_MAP_WRITE_BIT | /* for MapBufferRange */
GL_MAP_UNSYNCHRONIZED_BIT;
void
vbo_exec_vtx_flush(struct vbo_exec_context *exec)
{
+ struct gl_context *ctx = gl_context_from_vbo_exec(exec);
+
/* Only unmap if persistent mappings are unsupported. */
- bool persistent_mapping = exec->ctx->Extensions.ARB_buffer_storage &&
+ bool persistent_mapping = ctx->Extensions.ARB_buffer_storage &&
exec->vtx.bufferobj &&
exec->vtx.buffer_map;
exec->vtx.copied.nr = vbo_exec_copy_vertices(exec);
if (exec->vtx.copied.nr != exec->vtx.vert_count) {
- struct gl_context *ctx = exec->ctx;
-
/* Prepare and set the exec draws internal VAO for drawing. */
vbo_exec_bind_arrays(ctx);
#include "math/m_eval.h"
#include "main/dispatch.h"
#include "vbo_exec.h"
+#include "vbo_private.h"
static void clear_active_eval1( struct vbo_exec_context *exec, GLuint attr )
void vbo_exec_eval_update( struct vbo_exec_context *exec )
{
- struct gl_context *ctx = exec->ctx;
+ struct gl_context *ctx = gl_context_from_vbo_exec(exec);
GLuint attr;
/* Vertex program maps have priority over conventional attribs */
void vbo_exec_do_EvalCoord1f(struct vbo_exec_context *exec, GLfloat u)
{
+ struct gl_context *ctx = gl_context_from_vbo_exec(exec);
GLuint attr;
for (attr = 1; attr <= VBO_ATTRIB_TEX7; attr++) {
map->Order);
if (exec->eval.map1[0].sz == 4)
- CALL_Vertex4fv(exec->ctx->CurrentServerDispatch, ( vertex ));
+ CALL_Vertex4fv(ctx->CurrentServerDispatch, ( vertex ));
else
- CALL_Vertex3fv(exec->ctx->CurrentServerDispatch, ( vertex ));
+ CALL_Vertex3fv(ctx->CurrentServerDispatch, ( vertex ));
}
}
void vbo_exec_do_EvalCoord2f( struct vbo_exec_context *exec,
GLfloat u, GLfloat v )
{
+ struct gl_context *ctx = gl_context_from_vbo_exec(exec);
GLuint attr;
for (attr = 1; attr <= VBO_ATTRIB_TEX7; attr++) {
ASSIGN_4V(vertex, 0, 0, 0, 1);
- if (exec->ctx->Eval.AutoNormal) {
+ if (ctx->Eval.AutoNormal) {
fi_type normal[4];
GLfloat du[4], dv[4];
}
if (exec->vtx.attr[VBO_ATTRIB_POS].size == 4)
- CALL_Vertex4fv(exec->ctx->CurrentServerDispatch, ( vertex ));
+ CALL_Vertex4fv(ctx->CurrentServerDispatch, ( vertex ));
else
- CALL_Vertex3fv(exec->ctx->CurrentServerDispatch, ( vertex ));
+ CALL_Vertex3fv(ctx->CurrentServerDispatch, ( vertex ));
}
}
}
+static inline struct gl_context *
+gl_context_from_vbo_exec(struct vbo_exec_context *exec)
+{
+ struct gl_context *ctx = NULL;
+ return container_of(exec, ctx, vbo_context.exec);
+}
+
+
+static inline const struct gl_context *
+gl_context_from_vbo_exec_const(const struct vbo_exec_context *exec)
+{
+ struct gl_context *ctx = NULL;
+ return container_of(exec, ctx, vbo_context.exec);
+}
+
+
+static inline struct gl_context *
+gl_context_from_vbo_save(struct vbo_save_context *save)
+{
+ struct gl_context *ctx = NULL;
+ return container_of(save, ctx, vbo_context.save);
+}
+
+
/**
* Array to apply the fixed function material aliasing map to
* an attribute value used in vbo processing inputs to an attribute
static inline unsigned
vbo_compute_max_verts(const struct vbo_exec_context *exec)
{
- unsigned n = (exec->ctx->Const.glBeginEndBufferSize -
+ unsigned n = (gl_context_from_vbo_exec_const(exec)->Const.glBeginEndBufferSize -
exec->vtx.buffer_used) /
(exec->vtx.vertex_size * sizeof(GLfloat));
if (n == 0)
struct vbo_context *vbo = vbo_context(ctx);
struct vbo_save_context *save = &vbo->save;
- save->ctx = ctx;
-
vbo_save_api_init( save );
for (gl_vertex_processing_mode vpm = VP_MODE_FF; vpm < VP_MODE_MAX; ++vpm)
void
vbo_save_api_init(struct vbo_save_context *save)
{
- struct gl_context *ctx = save->ctx;
+ struct gl_context *ctx = gl_context_from_vbo_save(save);
save->opcode_vertex_list =
_mesa_dlist_alloc_opcode(ctx,