summaryrefslogtreecommitdiff
path: root/src/mesa/drivers/dri/i965/brw_draw.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/mesa/drivers/dri/i965/brw_draw.c')
-rw-r--r--src/mesa/drivers/dri/i965/brw_draw.c117
1 files changed, 43 insertions, 74 deletions
diff --git a/src/mesa/drivers/dri/i965/brw_draw.c b/src/mesa/drivers/dri/i965/brw_draw.c
index 471fda9f7e..63cb079ec9 100644
--- a/src/mesa/drivers/dri/i965/brw_draw.c
+++ b/src/mesa/drivers/dri/i965/brw_draw.c
@@ -35,7 +35,6 @@
#include "brw_draw.h"
#include "brw_defines.h"
-#include "brw_attrib.h"
#include "brw_context.h"
#include "brw_aub.h"
#include "brw_state.h"
@@ -45,7 +44,8 @@
#include "intel_batchbuffer.h"
#include "intel_buffer_objects.h"
-
+#include "tnl/tnl.h"
+#include "vbo/vbo_context.h"
@@ -143,7 +143,7 @@ static void brw_emit_cliprect( struct brw_context *brw,
static void brw_emit_prim( struct brw_context *brw,
- const struct brw_draw_prim *prim )
+ const struct _mesa_prim *prim )
{
struct brw_3d_primitive prim_packet;
@@ -170,34 +170,9 @@ static void brw_emit_prim( struct brw_context *brw,
}
}
-
-
-static void update_current_size( struct gl_client_array *array)
-{
- const GLfloat *ptr = (const GLfloat *)array->Ptr;
-
- assert(array->StrideB == 0);
- assert(array->Type == GL_FLOAT || array->Type == GL_UNSIGNED_BYTE);
-
- if (ptr[3] != 1.0)
- array->Size = 4;
- else if (ptr[2] != 0.0)
- array->Size = 3;
- else if (ptr[1] != 0.0)
- array->Size = 2;
- else
- array->Size = 1;
-}
-
-
-
-/* Fill in any gaps in passed arrays with pointers to current
- * attributes:
- */
static void brw_merge_inputs( struct brw_context *brw,
const struct gl_client_array *arrays[])
{
- struct gl_client_array *current_values = brw->vb.current_values;
struct brw_vertex_element *inputs = brw->vb.inputs;
struct brw_vertex_info old = brw->vb.info;
GLuint i;
@@ -205,17 +180,11 @@ static void brw_merge_inputs( struct brw_context *brw,
memset(inputs, 0, sizeof(*inputs));
memset(&brw->vb.info, 0, sizeof(brw->vb.info));
- for (i = 0; i < BRW_ATTRIB_MAX; i++) {
- if (arrays[i] && arrays[i]->Enabled)
- {
- brw->vb.inputs[i].glarray = arrays[i];
- brw->vb.info.varying |= (GLuint64EXT) 1 << i;
- }
- else
- {
- brw->vb.inputs[i].glarray = &current_values[i];
- update_current_size(&current_values[i]);
- }
+ for (i = 0; i < VERT_ATTRIB_MAX; i++) {
+ brw->vb.inputs[i].glarray = arrays[i];
+
+ if (arrays[i]->StrideB != 0)
+ brw->vb.info.varying |= 1 << i;
brw->vb.info.sizes[i/16] |= (inputs[i].glarray->Size - 1) << ((i%16) * 2);
}
@@ -229,8 +198,9 @@ static void brw_merge_inputs( struct brw_context *brw,
brw->state.dirty.brw |= BRW_NEW_INPUT_VARYING;
}
+
static GLboolean check_fallbacks( struct brw_context *brw,
- const struct brw_draw_prim *prim,
+ const struct _mesa_prim *prim,
GLuint nr_prims )
{
GLuint i;
@@ -284,12 +254,11 @@ static GLboolean check_fallbacks( struct brw_context *brw,
static GLboolean brw_try_draw_prims( GLcontext *ctx,
const struct gl_client_array *arrays[],
- const struct brw_draw_prim *prim,
+ const struct _mesa_prim *prim,
GLuint nr_prims,
- const struct brw_draw_index_buffer *ib,
+ const struct _mesa_index_buffer *ib,
GLuint min_index,
- GLuint max_index,
- GLuint flags )
+ GLuint max_index )
{
struct intel_context *intel = intel_context(ctx);
struct brw_context *brw = brw_context(ctx);
@@ -298,11 +267,11 @@ static GLboolean brw_try_draw_prims( GLcontext *ctx,
if (ctx->NewState)
_mesa_update_state( ctx );
-
+
/* Bind all inputs, derive varying and size information:
*/
brw_merge_inputs( brw, arrays );
-
+
/* Have to validate state quite late. Will rebuild tnl_program,
* which depends on varying information.
*
@@ -319,10 +288,6 @@ static GLboolean brw_try_draw_prims( GLcontext *ctx,
}
{
- assert(intel->locked);
-
-
-
/* Set the first primitive early, ahead of validate_state:
*/
brw_set_prim(brw, prim[0].mode);
@@ -412,43 +377,45 @@ static GLboolean brw_try_draw_prims( GLcontext *ctx,
}
-GLboolean brw_draw_prims( GLcontext *ctx,
- const struct gl_client_array *arrays[],
- const struct brw_draw_prim *prim,
- GLuint nr_prims,
- const struct brw_draw_index_buffer *ib,
- GLuint min_index,
- GLuint max_index,
- GLuint flags )
+void brw_draw_prims( GLcontext *ctx,
+ const struct gl_client_array *arrays[],
+ const struct _mesa_prim *prim,
+ GLuint nr_prims,
+ const struct _mesa_index_buffer *ib,
+ GLuint min_index,
+ GLuint max_index )
{
struct intel_context *intel = intel_context(ctx);
GLboolean retval;
- retval = brw_try_draw_prims(ctx, arrays, prim, nr_prims, ib, min_index, max_index, flags);
+ retval = brw_try_draw_prims(ctx, arrays, prim, nr_prims, ib, min_index, max_index);
- if (!retval && bmError(intel)) {
-
+ /* This looks like out-of-memory but potentially we have
+ * situation where there is enough memory but it has become
+ * fragmented. Clear out all heaps and start from scratch by
+ * faking a contended lock event: (done elsewhere)
+ */
+ if (!retval && !intel->Fallback && bmError(intel)) {
DBG("retrying\n");
- /* This looks like out-of-memory but potentially we have
- * situation where there is enough memory but it has become
- * fragmented. Clear out all heaps and start from scratch by
- * faking a contended lock event: (done elsewhere)
- */
-
/* Then try a second time only to upload textures and draw the
* primitives:
*/
- retval = brw_try_draw_prims(ctx, arrays, prim, nr_prims, ib, min_index, max_index, flags);
+ retval = brw_try_draw_prims(ctx, arrays, prim, nr_prims, ib, min_index, max_index);
+ }
+
+ /* Otherwise, we really are out of memory. Pass the drawing
+ * command to the software tnl module and which will in turn call
+ * swrast to do the drawing.
+ */
+ if (!retval) {
+ _tnl_draw_prims(ctx, arrays, prim, nr_prims, ib, min_index, max_index);
}
if (intel->aub_file && (INTEL_DEBUG & DEBUG_SYNC)) {
intelFinish( &intel->ctx );
intel->aub_wrap = 1;
}
-
-
- return retval;
}
@@ -461,8 +428,13 @@ static void brw_invalidate_vbo_cb( struct intel_context *intel, void *ptr )
void brw_draw_init( struct brw_context *brw )
{
GLcontext *ctx = &brw->intel.ctx;
+ struct vbo_context *vbo = vbo_context(ctx);
GLuint i;
+ /* Register our drawing function:
+ */
+ vbo->draw_prims = brw_draw_prims;
+
brw->vb.upload.size = BRW_UPLOAD_INIT_SIZE;
for (i = 0; i < BRW_NR_UPLOAD_BUFS; i++) {
@@ -484,9 +456,6 @@ void brw_draw_init( struct brw_context *brw )
NULL,
GL_DYNAMIC_DRAW_ARB,
brw->vb.upload.vbo[0] );
-
-
- brw_init_current_values(ctx, brw->vb.current_values);
}
void brw_draw_destroy( struct brw_context *brw )