#include "intel_span.h"
#include "i830_context.h"
#include "i830_reg.h"
+#include "i915_context.h"
static void intelRenderPrimitive(struct gl_context * ctx, GLenum prim);
static void intelRasterPrimitive(struct gl_context * ctx, GLenum rprim,
intel->vtbl.emit_state(intel);
- intel->no_batch_wrap = GL_TRUE;
+ intel->no_batch_wrap = true;
/*printf("%s *", __progname);*/
OUT_BATCH(0);
ADVANCE_BATCH();
- intel->no_batch_wrap = GL_FALSE;
+ intel->no_batch_wrap = false;
/* printf(">"); */
}
offset = intel->prim.start_offset;
intel->prim.start_offset = intel->prim.current_offset;
if (intel->gen < 3)
- intel->prim.start_offset = ALIGN(intel->prim.start_offset, 128);
+ intel->prim.current_offset = intel->prim.start_offset = ALIGN(intel->prim.start_offset, 128);
intel->prim.flush = NULL;
intel->vtbl.emit_state(intel);
* depends on the state just emitted. emit_state should be making sure we
* have the space for this.
*/
- intel->no_batch_wrap = GL_TRUE;
+ intel->no_batch_wrap = true;
#if 0
printf("emitting %d..%d=%d vertices size %d\n", offset,
#endif
if (intel->gen >= 3) {
- BEGIN_BATCH(5);
- OUT_BATCH(_3DSTATE_LOAD_STATE_IMMEDIATE_1 |
- I1_LOAD_S(0) | I1_LOAD_S(1) | 1);
- assert((offset & ~S0_VB_OFFSET_MASK) == 0);
- OUT_RELOC(vb_bo, I915_GEM_DOMAIN_VERTEX, 0, offset);
- OUT_BATCH((intel->vertex_size << S1_VERTEX_WIDTH_SHIFT) |
- (intel->vertex_size << S1_VERTEX_PITCH_SHIFT));
+ struct i915_context *i915 = i915_context(&intel->ctx);
+ unsigned int cmd = 0, len = 0;
+
+ if (vb_bo != i915->current_vb_bo) {
+ cmd |= I1_LOAD_S(0);
+ len++;
+ }
+ if (intel->vertex_size != i915->current_vertex_size) {
+ cmd |= I1_LOAD_S(1);
+ len++;
+ }
+ if (len)
+ len++;
+
+ BEGIN_BATCH(2+len);
+ if (cmd)
+ OUT_BATCH(_3DSTATE_LOAD_STATE_IMMEDIATE_1 | cmd | (len - 2));
+ if (vb_bo != i915->current_vb_bo) {
+ OUT_RELOC(vb_bo, I915_GEM_DOMAIN_VERTEX, 0, 0);
+ i915->current_vb_bo = vb_bo;
+ }
+ if (intel->vertex_size != i915->current_vertex_size) {
+ OUT_BATCH((intel->vertex_size << S1_VERTEX_WIDTH_SHIFT) |
+ (intel->vertex_size << S1_VERTEX_PITCH_SHIFT));
+ i915->current_vertex_size = intel->vertex_size;
+ }
OUT_BATCH(_3DPRIMITIVE |
PRIM_INDIRECT |
PRIM_INDIRECT_SEQUENTIAL |
intel->prim.primitive |
count);
- OUT_BATCH(0); /* Beginning vertex index */
+ OUT_BATCH(offset / (intel->vertex_size * 4));
ADVANCE_BATCH();
} else {
struct i830_context *i830 = i830_context(&intel->ctx);
ADVANCE_BATCH();
}
- intel->no_batch_wrap = GL_FALSE;
+ intel->no_batch_wrap = false;
drm_intel_bo_unreference(vb_bo);
}
* Fixup for I915 WPOS texture coordinate *
***********************************************************************/
-
-
static void
-intel_wpos_triangle(struct intel_context *intel,
- intelVertexPtr v0, intelVertexPtr v1, intelVertexPtr v2)
+intel_emit_fragcoord(struct intel_context *intel, intelVertexPtr v)
{
+ struct gl_context *ctx = &intel->ctx;
+ struct gl_framebuffer *fb = ctx->DrawBuffer;
GLuint offset = intel->wpos_offset;
- GLuint size = intel->wpos_size;
- GLfloat *v0_wpos = (GLfloat *)((char *)v0 + offset);
- GLfloat *v1_wpos = (GLfloat *)((char *)v1 + offset);
- GLfloat *v2_wpos = (GLfloat *)((char *)v2 + offset);
+ float *vertex_position = (float *)v;
+ float *fragcoord = (float *)((char *)v + offset);
- __memcpy(v0_wpos, v0, size);
- __memcpy(v1_wpos, v1, size);
- __memcpy(v2_wpos, v2, size);
+ fragcoord[0] = vertex_position[0];
- v0_wpos[1] = -v0_wpos[1] + intel->ctx.DrawBuffer->Height;
- v1_wpos[1] = -v1_wpos[1] + intel->ctx.DrawBuffer->Height;
- v2_wpos[1] = -v2_wpos[1] + intel->ctx.DrawBuffer->Height;
+ if (fb->Name)
+ fragcoord[1] = vertex_position[1];
+ else
+ fragcoord[1] = fb->Height - vertex_position[1];
+ fragcoord[2] = vertex_position[2];
+ fragcoord[3] = vertex_position[3];
+}
+
+static void
+intel_wpos_triangle(struct intel_context *intel,
+ intelVertexPtr v0, intelVertexPtr v1, intelVertexPtr v2)
+{
+ intel_emit_fragcoord(intel, v0);
+ intel_emit_fragcoord(intel, v1);
+ intel_emit_fragcoord(intel, v2);
intel_draw_triangle(intel, v0, v1, v2);
}
intel_wpos_line(struct intel_context *intel,
intelVertexPtr v0, intelVertexPtr v1)
{
- GLuint offset = intel->wpos_offset;
- GLuint size = intel->wpos_size;
- GLfloat *v0_wpos = (GLfloat *)((char *)v0 + offset);
- GLfloat *v1_wpos = (GLfloat *)((char *)v1 + offset);
-
- __memcpy(v0_wpos, v0, size);
- __memcpy(v1_wpos, v1, size);
-
- v0_wpos[1] = -v0_wpos[1] + intel->ctx.DrawBuffer->Height;
- v1_wpos[1] = -v1_wpos[1] + intel->ctx.DrawBuffer->Height;
-
+ intel_emit_fragcoord(intel, v0);
+ intel_emit_fragcoord(intel, v1);
intel_draw_line(intel, v0, v1);
}
static void
intel_wpos_point(struct intel_context *intel, intelVertexPtr v0)
{
- GLuint offset = intel->wpos_offset;
- GLuint size = intel->wpos_size;
- GLfloat *v0_wpos = (GLfloat *)((char *)v0 + offset);
-
- __memcpy(v0_wpos, v0, size);
- v0_wpos[1] = -v0_wpos[1] + intel->ctx.DrawBuffer->Height;
-
+ intel_emit_fragcoord(intel, v0);
intel_draw_point(intel, v0);
}
struct intel_context *intel = intel_context(ctx); \
GLuint color[n] = { 0, }, spec[n] = { 0, }; \
GLuint coloroffset = intel->coloroffset; \
- GLboolean specoffset = intel->specoffset; \
+ bool specoffset = intel->specoffset; \
(void) color; (void) spec; (void) coloroffset; (void) specoffset;
struct intel_context *intel = intel_context(ctx);
GLuint flags = ctx->_TriangleCaps;
const struct gl_fragment_program *fprog = ctx->FragmentProgram._Current;
- GLboolean have_wpos = (fprog && (fprog->Base.InputsRead & FRAG_BIT_WPOS));
+ bool have_wpos = (fprog && (fprog->Base.InputsRead & FRAG_BIT_WPOS));
GLuint index = 0;
if (INTEL_DEBUG & DEBUG_STATE)
if (ctx->NewState)
_mesa_update_state_locked(ctx);
+ /* We need to get this done before we start the pipeline, or a
+ * change in the INTEL_FALLBACK() of its intel_draw_buffers() call
+ * while the pipeline is running will result in mismatched swrast
+ * map/unmaps, and later assertion failures.
+ */
+ intel_prepare_render(intel);
+
if (intel->NewGLState) {
if (intel->NewGLState & _NEW_TEXTURE) {
intel->vtbl.update_texture_state(intel);
}
intel_map_vertex_shader_textures(ctx);
+ intel->tnl_pipeline_running = true;
_tnl_run_pipeline(ctx);
+ intel->tnl_pipeline_running = false;
intel_unmap_vertex_shader_textures(ctx);
_mesa_unlock_context_textures(ctx);
*/
intel->render_primitive = prim;
- /* Shortcircuit this when called from t_dd_rendertmp.h for unfilled
- * triangles. The rasterized primitive will always be reset by
- * lower level functions in that case, potentially pingponging the
- * state:
+ /* Shortcircuit this when called for unfilled triangles. The rasterized
+ * primitive will always be reset by lower level functions in that case,
+ * potentially pingponging the state:
*/
if (reduced_prim[prim] == GL_TRIANGLES &&
(ctx->_TriangleCaps & DD_TRI_UNFILLED))
* \param bit one of INTEL_FALLBACK_x flags.
*/
void
-intelFallback(struct intel_context *intel, GLbitfield bit, GLboolean mode)
+intelFallback(struct intel_context *intel, GLbitfield bit, bool mode)
{
struct gl_context *ctx = &intel->ctx;
TNLcontext *tnl = TNL_CONTEXT(ctx);
if (mode) {
intel->Fallback |= bit;
if (oldfallback == 0) {
+ assert(!intel->tnl_pipeline_running);
+
intel_flush(ctx);
if (INTEL_DEBUG & DEBUG_FALLBACKS)
fprintf(stderr, "ENTER FALLBACK %x: %s\n",
else {
intel->Fallback &= ~bit;
if (oldfallback == bit) {
+ assert(!intel->tnl_pipeline_running);
+
_swrast_flush(ctx);
if (INTEL_DEBUG & DEBUG_FALLBACKS)
fprintf(stderr, "LEAVE FALLBACK %s\n", getFallbackString(bit));