#include "arrayobj.h"
#include "macros.h"
#include "mtypes.h"
+#include "state.h"
#include "varray.h"
#include "main/dispatch.h"
#include "util/bitscan.h"
* deleted.
*/
_mesa_set_drawing_arrays(ctx, NULL);
+ _mesa_set_draw_vao(ctx, ctx->Array._EmptyVAO, 0);
ctx->NewState |= _NEW_ARRAY;
_mesa_reference_vao(ctx, &ctx->Array.VAO, newObj);
if (ctx->Array.LastLookedUpVAO == obj)
_mesa_reference_vao(ctx, &ctx->Array.LastLookedUpVAO, NULL);
+ if (ctx->Array._DrawVAO == obj)
+ _mesa_set_draw_vao(ctx, ctx->Array._EmptyVAO, 0);
/* Unreference the array object.
* If refcount hits zero, the object will be deleted.
#include "viewport.h"
#include "mtypes.h"
#include "main/dispatch.h"
+#include "state.h"
#include "hash.h"
#include <stdbool.h>
/* Invalidate array state. It will be updated during the next draw. */
_mesa_set_drawing_arrays(ctx, NULL);
+ _mesa_set_draw_vao(ctx, ctx->Array._EmptyVAO, 0);
}
/**
_mesa_reference_vao(ctx, &ctx->Array.VAO, NULL);
_mesa_reference_vao(ctx, &ctx->Array.DefaultVAO, NULL);
+ _mesa_reference_vao(ctx, &ctx->Array._EmptyVAO, NULL);
+ _mesa_reference_vao(ctx, &ctx->Array._DrawVAO, NULL);
_mesa_free_attrib_data(ctx);
_mesa_free_buffer_objects(ctx);
struct gl_buffer_object *ArrayBufferObj;
/**
+ * Vertex array object that is used with the currently active draw command.
+ * The _DrawVAO is either set to the currently bound VAO for array type
+ * draws or to internal VAO's set up by the vbo module to execute immediate
+ * mode or display list draws.
+ */
+ struct gl_vertex_array_object *_DrawVAO;
+ /**
+ * The VERT_BIT_* bits effectively enabled from the current _DrawVAO.
+ * This is always a subset of _mesa_get_vao_vp_inputs(_DrawVAO)
+ * but may omit those arrays that shall not be referenced by the current
+ * gl_vertex_program_state::_VPMode. For example the generic attributes are
+ * maked out form the _DrawVAO's enabled arrays when a fixed function
+ * array draw is executed.
+ */
+ GLbitfield _DrawVAOEnabledAttribs;
+ /**
+ * Initially or if the VAO referenced by _DrawVAO is deleted the _DrawVAO
+ * pointer is set to the _EmptyVAO which is just an empty VAO all the time.
+ */
+ struct gl_vertex_array_object *_EmptyVAO;
+
+ /**
* Vertex arrays as consumed by a driver.
* The array pointer is set up only by the VBO module.
*/
else
ctx->VertexProgram._VPMode = VP_MODE_FF;
}
+
+
+/**
+ * Set the _DrawVAO and the net enabled arrays.
+ * The vao->_Enabled bitmask is transformed due to position/generic0
+ * as stored in vao->_AttributeMapMode. Then the filter bitmask is applied
+ * to filter out arrays unwanted for the currently executed draw operation.
+ * For example, the generic attributes are masked out form the _DrawVAO's
+ * enabled arrays when a fixed function array draw is executed.
+ */
+void
+_mesa_set_draw_vao(struct gl_context *ctx, struct gl_vertex_array_object *vao,
+ GLbitfield filter)
+{
+ struct gl_vertex_array_object **ptr = &ctx->Array._DrawVAO;
+ if (*ptr != vao) {
+ _mesa_reference_vao_(ctx, ptr, vao);
+ ctx->NewDriverState |= ctx->DriverFlags.NewArray;
+ } else if (vao->NewArrays) {
+ ctx->NewDriverState |= ctx->DriverFlags.NewArray;
+ }
+
+ /* May shuffle the position and generic0 bits around, filter out unwanted */
+ const GLbitfield enabled = filter & _mesa_get_vao_vp_inputs(vao);
+ if (ctx->Array._DrawVAOEnabledAttribs != enabled)
+ ctx->NewDriverState |= ctx->DriverFlags.NewArray;
+ ctx->Array._DrawVAOEnabledAttribs = enabled;
+ _mesa_set_varying_vp_inputs(ctx, enabled);
+}
_mesa_update_vertex_processing_mode(struct gl_context *ctx);
+/**
+ * Set the _DrawVAO and the net enabled arrays.
+ */
+void
+_mesa_set_draw_vao(struct gl_context *ctx, struct gl_vertex_array_object *vao,
+ GLbitfield filter);
+
+
static inline bool
_mesa_ati_fragment_shader_enabled(const struct gl_context *ctx)
{
{
ctx->Array.DefaultVAO = _mesa_new_vao(ctx, 0);
_mesa_reference_vao(ctx, &ctx->Array.VAO, ctx->Array.DefaultVAO);
+ ctx->Array._EmptyVAO = _mesa_new_vao(ctx, ~0u);
+ _mesa_reference_vao(ctx, &ctx->Array._DrawVAO, ctx->Array._EmptyVAO);
ctx->Array.ActiveTexture = 0; /* GL_ARB_multitexture */
ctx->Array.Objects = _mesa_NewHashTable();