#include "main/fbobject.h"
#include "main/framebuffer.h"
#include "main/imports.h"
-#include "main/points.h"
#include "main/renderbuffer.h"
#include "swrast/swrast.h"
#include "intel_buffers.h"
#include "intel_tex.h"
#include "intel_batchbuffer.h"
-#include "intel_clear.h"
-#include "intel_extensions.h"
#include "intel_pixel.h"
#include "intel_regions.h"
#include "intel_buffer_objects.h"
switch (intel->intelScreen->deviceID) {
#undef CHIPSET
#define CHIPSET(id, symbol, str) case id: chipset = str; break;
-#include "pci_ids/i915_pci_ids.h"
#include "pci_ids/i965_pci_ids.h"
default:
chipset = "Unknown Intel Chipset";
}
void
-intel_resolve_for_dri2_flush(struct intel_context *intel,
+intel_resolve_for_dri2_flush(struct brw_context *brw,
__DRIdrawable *drawable)
{
+ struct intel_context *intel = &brw->intel;
if (intel->gen < 6) {
/* MSAA and fast color clear are not supported, so don't waste time
* checking whether a resolve is needed.
if (rb == NULL || rb->mt == NULL)
continue;
if (rb->mt->num_samples <= 1)
- intel_miptree_resolve_color(intel, rb->mt);
+ intel_miptree_resolve_color(brw, rb->mt);
else
- intel_miptree_downsample(intel, rb->mt);
+ intel_miptree_downsample(brw, rb->mt);
}
}
static void
intel_flush_front(struct gl_context *ctx)
{
+ struct brw_context *brw = brw_context(ctx);
struct intel_context *intel = intel_context(ctx);
__DRIcontext *driContext = intel->driContext;
__DRIdrawable *driDrawable = driContext->driDrawablePriv;
__DRIscreen *const screen = intel->intelScreen->driScrnPriv;
- if (intel->front_buffer_dirty && _mesa_is_winsys_fbo(ctx->DrawBuffer)) {
+ if (brw->front_buffer_dirty && _mesa_is_winsys_fbo(ctx->DrawBuffer)) {
if (screen->dri2.loader->flushFrontBuffer != NULL &&
driDrawable &&
driDrawable->loaderPrivate) {
* performance. And no one cares about front-buffer render
* performance.
*/
- intel_resolve_for_dri2_flush(intel, driDrawable);
+ intel_resolve_for_dri2_flush(brw, driDrawable);
screen->dri2.loader->flushFrontBuffer(driDrawable,
driDrawable->loaderPrivate);
/* We set the dirty bit in intel_prepare_render() if we're
* front buffer rendering once we get there.
*/
- intel->front_buffer_dirty = false;
+ brw->front_buffer_dirty = false;
}
}
}
}
static void
-intel_query_dri2_buffers(struct intel_context *intel,
+intel_query_dri2_buffers(struct brw_context *brw,
__DRIdrawable *drawable,
__DRIbuffer **buffers,
int *count);
static void
-intel_process_dri2_buffer(struct intel_context *intel,
+intel_process_dri2_buffer(struct brw_context *brw,
__DRIdrawable *drawable,
__DRIbuffer *buffer,
struct intel_renderbuffer *rb,
{
struct gl_framebuffer *fb = drawable->driverPrivate;
struct intel_renderbuffer *rb;
- struct intel_context *intel = context->driverPrivate;
+ struct brw_context *brw = context->driverPrivate;
+ struct intel_context *intel = &brw->intel;
__DRIbuffer *buffers = NULL;
int i, count;
const char *region_name;
if (unlikely(INTEL_DEBUG & DEBUG_DRI))
fprintf(stderr, "enter %s, drawable %p\n", __func__, drawable);
- intel_query_dri2_buffers(intel, drawable, &buffers, &count);
+ intel_query_dri2_buffers(brw, drawable, &buffers, &count);
if (buffers == NULL)
return;
return;
}
- intel_process_dri2_buffer(intel, drawable, &buffers[i], rb, region_name);
+ intel_process_dri2_buffer(brw, drawable, &buffers[i], rb, region_name);
}
driUpdateFramebufferSize(&intel->ctx, drawable);
* state is required.
*/
void
-intel_prepare_render(struct intel_context *intel)
+intel_prepare_render(struct brw_context *brw)
{
+ struct intel_context *intel = &brw->intel;
__DRIcontext *driContext = intel->driContext;
__DRIdrawable *drawable;
if (drawable && drawable->dri2.stamp != driContext->dri2.draw_stamp) {
if (drawable->lastStamp != drawable->dri2.stamp)
intel_update_renderbuffers(driContext, drawable);
- intel_draw_buffer(&intel->ctx);
driContext->dri2.draw_stamp = drawable->dri2.stamp;
}
* that will happen next will probably dirty the front buffer. So
* mark it as dirty here.
*/
- if (intel->is_front_buffer_rendering)
- intel->front_buffer_dirty = true;
+ if (brw->is_front_buffer_rendering)
+ brw->front_buffer_dirty = true;
/* Wait for the swapbuffers before the one we just emitted, so we
* don't get too many swaps outstanding for apps that are GPU-heavy
}
}
-static void
-intel_viewport(struct gl_context *ctx, GLint x, GLint y, GLsizei w, GLsizei h)
-{
- struct intel_context *intel = intel_context(ctx);
- __DRIcontext *driContext = intel->driContext;
-
- if (intel->saved_viewport)
- intel->saved_viewport(ctx, x, y, w, h);
-
- if (_mesa_is_winsys_fbo(ctx->DrawBuffer)) {
- dri2InvalidateDrawable(driContext->driDrawablePriv);
- dri2InvalidateDrawable(driContext->driReadablePriv);
- }
-}
-
static const struct dri_debug_control debug_control[] = {
{ "tex", DEBUG_TEXTURE},
{ "state", DEBUG_STATE},
_vbo_InvalidateState(ctx, new_state);
intel->NewGLState |= new_state;
-
- if (intel->vtbl.invalidate_state)
- intel->vtbl.invalidate_state( intel, new_state );
-}
-
-void
-intel_flush_rendering_to_batch(struct gl_context *ctx)
-{
- struct intel_context *intel = intel_context(ctx);
-
- if (intel->Fallback)
- _swrast_flush(ctx);
}
void
_intel_flush(struct gl_context *ctx, const char *file, int line)
{
+ struct brw_context *brw = brw_context(ctx);
struct intel_context *intel = intel_context(ctx);
- intel_flush_rendering_to_batch(ctx);
-
if (intel->batch.used)
- _intel_batchbuffer_flush(intel, file, line);
+ _intel_batchbuffer_flush(brw, file, line);
}
static void
intel_glFlush(struct gl_context *ctx)
{
+ struct brw_context *brw = brw_context(ctx);
struct intel_context *intel = intel_context(ctx);
intel_flush(ctx);
intel_flush_front(ctx);
- if (intel->is_front_buffer_rendering)
+ if (brw->is_front_buffer_rendering)
intel->need_throttle = true;
}
}
bool
-intelInitContext(struct intel_context *intel,
+intelInitContext(struct brw_context *brw,
int api,
unsigned major_version,
unsigned minor_version,
struct dd_function_table *functions,
unsigned *dri_ctx_error)
{
+ struct intel_context *intel = &brw->intel;
struct gl_context *ctx = &intel->ctx;
struct gl_context *shareCtx = (struct gl_context *) sharedContextPrivate;
__DRIscreen *sPriv = driContextPriv->driScreenPriv;
dri_ctx_error))
return false;
- /* Can't rely on invalidate events, fall back to glViewport hack */
- if (!driContextPriv->driScreenPriv->dri2.useInvalidate) {
- intel->saved_viewport = functions->Viewport;
- functions->Viewport = intel_viewport;
- }
-
if (mesaVis == NULL) {
memset(&visual, 0, sizeof visual);
mesaVis = &visual;
intel->gt = 1;
} else if (IS_G4X(devID)) {
intel->is_g4x = true;
- } else if (IS_945(devID)) {
- intel->is_945 = true;
- }
-
- if (intel->gen >= 5) {
- intel->needs_ff_sync = true;
}
intel->has_separate_stencil = intel->intelScreen->hw_has_separate_stencil;
memset(&ctx->TextureFormatSupported,
0, sizeof(ctx->TextureFormatSupported));
- driParseConfigFiles(&intel->optionCache, &intelScreen->optionCache,
+ driParseConfigFiles(&brw->optionCache, &intelScreen->optionCache,
sPriv->myNum, "i965");
- intel->maxBatchSize = BATCH_SZ;
/* Estimate the size of the mappable aperture into the GTT. There's an
* ioctl to get the whole GTT size, but not one to get the mappable subset.
intel->bufmgr = intelScreen->bufmgr;
- bo_reuse_mode = driQueryOptioni(&intel->optionCache, "bo_reuse");
+ bo_reuse_mode = driQueryOptioni(&brw->optionCache, "bo_reuse");
switch (bo_reuse_mode) {
case DRI_CONF_BO_REUSE_DISABLED:
break;
break;
}
- ctx->Const.MinLineWidth = 1.0;
- ctx->Const.MinLineWidthAA = 1.0;
- ctx->Const.MaxLineWidth = 5.0;
- ctx->Const.MaxLineWidthAA = 5.0;
- ctx->Const.LineWidthGranularity = 0.5;
-
- ctx->Const.MinPointSize = 1.0;
- ctx->Const.MinPointSizeAA = 1.0;
- ctx->Const.MaxPointSize = 255.0;
- ctx->Const.MaxPointSizeAA = 3.0;
- ctx->Const.PointSizeGranularity = 1.0;
-
- if (intel->gen >= 6)
- ctx->Const.MaxClipPlanes = 8;
-
- ctx->Const.StripTextureBorder = GL_TRUE;
-
- /* reinitialize the context point state.
- * It depend on constants in __struct gl_contextRec::Const
- */
- _mesa_init_point(ctx);
-
- ctx->Const.MaxRenderbufferSize = 8192;
-
/* Initialize the software rasterizer and helper modules.
*
* As of GL 3.1 core, the gen4+ driver doesn't need the swrast context for
_mesa_meta_init(ctx);
- intel->hw_stencil = mesaVis->stencilBits && mesaVis->depthBits == 24;
- intel->hw_stipple = 1;
-
- intel->RenderIndex = ~0;
-
intelInitExtensions(ctx);
INTEL_DEBUG = driParseDebugString(getenv("INTEL_DEBUG"), debug_control);
if (INTEL_DEBUG & DEBUG_AUB)
drm_intel_bufmgr_gem_set_aub_dump(intel->bufmgr, true);
- intel_batchbuffer_init(intel);
+ intel_batchbuffer_init(brw);
- intel_fbo_init(intel);
+ intel_fbo_init(brw);
- intel->use_early_z = driQueryOptionb(&intel->optionCache, "early_z");
-
- if (!driQueryOptionb(&intel->optionCache, "hiz")) {
+ if (!driQueryOptionb(&brw->optionCache, "hiz")) {
intel->has_hiz = false;
/* On gen6, you can only do separate stencil with HIZ. */
if (intel->gen == 6)
intel->has_separate_stencil = false;
}
- intel->prim.primitive = ~0;
-
- /* Force all software fallbacks */
-#ifdef I915
- if (driQueryOptionb(&intel->optionCache, "no_rast")) {
- fprintf(stderr, "disabling 3D rasterization\n");
- intel->no_rast = 1;
- }
-#endif
-
- if (driQueryOptionb(&intel->optionCache, "always_flush_batch")) {
+ if (driQueryOptionb(&brw->optionCache, "always_flush_batch")) {
fprintf(stderr, "flushing batchbuffer before/after each draw call\n");
intel->always_flush_batch = 1;
}
- if (driQueryOptionb(&intel->optionCache, "always_flush_cache")) {
+ if (driQueryOptionb(&brw->optionCache, "always_flush_cache")) {
fprintf(stderr, "flushing GPU caches before/after each draw call\n");
intel->always_flush_cache = 1;
}
- if (driQueryOptionb(&intel->optionCache, "disable_throttling")) {
+ if (driQueryOptionb(&brw->optionCache, "disable_throttling")) {
fprintf(stderr, "disabling flush throttling\n");
intel->disable_throttling = 1;
}
void
intelDestroyContext(__DRIcontext * driContextPriv)
{
- struct intel_context *intel =
- (struct intel_context *) driContextPriv->driverPrivate;
+ struct brw_context *brw =
+ (struct brw_context *) driContextPriv->driverPrivate;
+ struct intel_context *intel = &brw->intel;
struct gl_context *ctx = &intel->ctx;
assert(intel); /* should never be null */
if (intel) {
- INTEL_FIREVERTICES(intel);
-
/* Dump a final BMP in case the application doesn't call SwapBuffers */
if (INTEL_DEBUG & DEBUG_AUB) {
- intel_batchbuffer_flush(intel);
+ intel_batchbuffer_flush(brw);
aub_dump_bmp(&intel->ctx);
}
_mesa_meta_free(&intel->ctx);
- intel->vtbl.destroy(intel);
+ brw->vtbl.destroy(brw);
if (ctx->swrast_context) {
_swsetup_DestroyContext(&intel->ctx);
if (ctx->swrast_context)
_swrast_DestroyContext(&intel->ctx);
- intel->Fallback = 0x0; /* don't call _swrast_Flush later */
- intel_batchbuffer_free(intel);
+ intel_batchbuffer_free(brw);
- free(intel->prim.vb);
- intel->prim.vb = NULL;
- drm_intel_bo_unreference(intel->prim.vb_bo);
- intel->prim.vb_bo = NULL;
drm_intel_bo_unreference(intel->first_post_swapbuffers_batch);
intel->first_post_swapbuffers_batch = NULL;
- driDestroyOptionCache(&intel->optionCache);
+ driDestroyOptionCache(&brw->optionCache);
/* free the Mesa context */
_mesa_free_context_data(&intel->ctx);
- _math_matrix_dtr(&intel->ViewportMatrix);
-
ralloc_free(intel);
driContextPriv->driverPrivate = NULL;
}
* yet), we go turn that back off before anyone finds out.
*/
static void
-intel_gles3_srgb_workaround(struct intel_context *intel,
+intel_gles3_srgb_workaround(struct brw_context *brw,
struct gl_framebuffer *fb)
{
+ struct intel_context *intel = &brw->intel;
struct gl_context *ctx = &intel->ctx;
if (_mesa_is_desktop_gl(ctx) || !fb->Visual.sRGBCapable)
__DRIdrawable * driDrawPriv,
__DRIdrawable * driReadPriv)
{
- struct intel_context *intel;
+ struct brw_context *brw;
GET_CURRENT_CONTEXT(curCtx);
if (driContextPriv)
- intel = (struct intel_context *) driContextPriv->driverPrivate;
+ brw = (struct brw_context *) driContextPriv->driverPrivate;
else
- intel = NULL;
+ brw = NULL;
/* According to the glXMakeCurrent() man page: "Pending commands to
* the previous context, if any, are flushed before it is released."
* But only flush if we're actually changing contexts.
*/
- if (intel_context(curCtx) && intel_context(curCtx) != intel) {
+ if (brw_context(curCtx) && brw_context(curCtx) != brw) {
_mesa_flush(curCtx);
}
+ struct intel_context *intel = &brw->intel;
+
if (driContextPriv) {
struct gl_context *ctx = &intel->ctx;
struct gl_framebuffer *fb, *readFb;
driContextPriv->dri2.read_stamp = driReadPriv->dri2.stamp - 1;
}
- intel_prepare_render(intel);
+ intel_prepare_render(brw);
_mesa_make_current(ctx, fb, readFb);
- intel_gles3_srgb_workaround(intel, ctx->WinSysDrawBuffer);
- intel_gles3_srgb_workaround(intel, ctx->WinSysReadBuffer);
-
- /* We do this in intel_prepare_render() too, but intel->ctx.DrawBuffer
- * is NULL at that point. We can't call _mesa_makecurrent()
- * first, since we need the buffer size for the initial
- * viewport. So just call intel_draw_buffer() again here. */
- intel_draw_buffer(ctx);
+ intel_gles3_srgb_workaround(brw, ctx->WinSysDrawBuffer);
+ intel_gles3_srgb_workaround(brw, ctx->WinSysReadBuffer);
}
else {
_mesa_make_current(NULL, NULL, NULL);
* \see DRI2GetBuffersWithFormat()
*/
static void
-intel_query_dri2_buffers(struct intel_context *intel,
+intel_query_dri2_buffers(struct brw_context *brw,
__DRIdrawable *drawable,
__DRIbuffer **buffers,
int *buffer_count)
{
+ struct intel_context *intel = &brw->intel;
__DRIscreen *screen = intel->intelScreen->driScrnPriv;
struct gl_framebuffer *fb = drawable->driverPrivate;
int i = 0;
back_rb = intel_get_renderbuffer(fb, BUFFER_BACK_LEFT);
memset(attachments, 0, sizeof(attachments));
- if ((intel->is_front_buffer_rendering ||
- intel->is_front_buffer_reading ||
+ if ((brw->is_front_buffer_rendering ||
+ brw->is_front_buffer_reading ||
!back_rb) && front_rb) {
/* If a fake front buffer is in use, then querying for
* __DRI_BUFFER_FRONT_LEFT will cause the server to copy the image from
attachments[i++] = __DRI_BUFFER_FRONT_LEFT;
attachments[i++] = intel_bits_per_pixel(front_rb);
- } else if (front_rb && intel->front_buffer_dirty) {
+ } else if (front_rb && brw->front_buffer_dirty) {
/* We have pending front buffer rendering, but we aren't querying for a
* front buffer. If the front buffer we have is a fake front buffer,
* the X server is going to throw it away when it processes the query.
* \see intel_region_alloc_for_handle()
*/
static void
-intel_process_dri2_buffer(struct intel_context *intel,
+intel_process_dri2_buffer(struct brw_context *brw,
__DRIdrawable *drawable,
__DRIbuffer *buffer,
struct intel_renderbuffer *rb,
const char *buffer_name)
{
+ struct intel_context *intel = &brw->intel;
struct intel_region *region = NULL;
if (!rb)
if (!region)
return;
- rb->mt = intel_miptree_create_for_dri2_buffer(intel,
+ rb->mt = intel_miptree_create_for_dri2_buffer(brw,
buffer->attachment,
intel_rb_format(rb),
num_samples,