mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-06 07:18:17 +02:00
Additional login in intel_draw_buffer() to check if any needed renderbuffers
are software/fallback cases. The hardware's combined depth/stencil buffer is now treated as such (ala GL_EXT_packed_depth_stencil). So the depth/stencil span functions are effectively merged. Renderbuffers wrappers will extract the depth or stencil values when needed.
This commit is contained in:
parent
fe37adfde3
commit
a7cdbf5c38
6 changed files with 87 additions and 50 deletions
|
|
@ -503,14 +503,19 @@ void intelSwapBuffers( __DRIdrawablePrivate *dPriv )
|
|||
|
||||
/**
|
||||
* Update the hardware state for drawing into a window or framebuffer object.
|
||||
*
|
||||
* Called by glDrawBuffer, glBindFramebufferEXT, MakeCurrent, and other
|
||||
* places within the driver.
|
||||
*
|
||||
* Basically, this needs to be called any time the current framebuffer
|
||||
* changes, the renderbuffers change, or we need to draw into different
|
||||
* color buffers.
|
||||
*/
|
||||
void
|
||||
intel_draw_buffer(GLcontext *ctx, struct gl_framebuffer *fb)
|
||||
{
|
||||
struct intel_context *intel = intel_context(ctx);
|
||||
struct intel_renderbuffer *irb;
|
||||
struct intel_renderbuffer *irb, *irbDepth, *irbStencil;
|
||||
struct intel_region *colorRegion, *depthRegion;
|
||||
int front = 0; /* drawing to front color buffer? */
|
||||
|
||||
|
|
@ -586,9 +591,9 @@ intel_draw_buffer(GLcontext *ctx, struct gl_framebuffer *fb)
|
|||
ASSERT(irb);
|
||||
}
|
||||
|
||||
/*
|
||||
* Get color buffer region.
|
||||
*/
|
||||
/***
|
||||
*** Get color buffer region.
|
||||
***/
|
||||
if (irb && irb->region)
|
||||
colorRegion = irb->region;
|
||||
else
|
||||
|
|
@ -602,14 +607,27 @@ intel_draw_buffer(GLcontext *ctx, struct gl_framebuffer *fb)
|
|||
intel_region_reference(&intel->draw_region, colorRegion);
|
||||
}
|
||||
|
||||
/*
|
||||
* Get depth buffer region
|
||||
*/
|
||||
irb = intel_renderbuffer(fb->_DepthBuffer);
|
||||
if (irb && irb->region)
|
||||
depthRegion = irb->region;
|
||||
else
|
||||
|
||||
/***
|
||||
*** Get depth buffer region and check if we need a software fallback.
|
||||
*** Note the BUFFER_DEPTH attachment is usually a DEPTH_STENCIL buffer.
|
||||
***/
|
||||
irbDepth = intel_renderbuffer(fb->Attachment[BUFFER_DEPTH].Renderbuffer);
|
||||
if (irbDepth) {
|
||||
if (irbDepth->region) {
|
||||
FALLBACK(intel, INTEL_FALLBACK_DEPTH_BUFFER, GL_FALSE);
|
||||
depthRegion = irbDepth->region;
|
||||
}
|
||||
else {
|
||||
FALLBACK(intel, INTEL_FALLBACK_DEPTH_BUFFER, GL_TRUE);
|
||||
depthRegion = NULL;
|
||||
}
|
||||
}
|
||||
else {
|
||||
/* not using depth buffer */
|
||||
FALLBACK(intel, INTEL_FALLBACK_DEPTH_BUFFER, GL_FALSE);
|
||||
depthRegion = NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* Unbind old depth region, bind new region
|
||||
|
|
@ -619,6 +637,23 @@ intel_draw_buffer(GLcontext *ctx, struct gl_framebuffer *fb)
|
|||
intel_region_reference(&intel->depth_region, depthRegion);
|
||||
}
|
||||
|
||||
|
||||
/***
|
||||
*** Stencil buffer
|
||||
*** This can only be hardware accelerated if we're using a
|
||||
*** combined DEPTH_STENCIL buffer (for now anyway).
|
||||
***/
|
||||
irbStencil =intel_renderbuffer(fb->Attachment[BUFFER_STENCIL].Renderbuffer);
|
||||
if (irbStencil) {
|
||||
if (irbStencil == irbDepth && irbStencil->region)
|
||||
FALLBACK(intel, INTEL_FALLBACK_STENCIL_BUFFER, GL_FALSE);
|
||||
else
|
||||
FALLBACK(intel, INTEL_FALLBACK_STENCIL_BUFFER, GL_TRUE);
|
||||
}
|
||||
else {
|
||||
FALLBACK(intel, INTEL_FALLBACK_STENCIL_BUFFER, GL_FALSE);
|
||||
}
|
||||
|
||||
intel->vtbl.set_draw_region( intel, colorRegion, depthRegion );
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -532,8 +532,9 @@ GLboolean intelMakeCurrent(__DRIcontextPrivate *driContextPriv,
|
|||
|
||||
_mesa_make_current(&intel->ctx, drawFb, readFb);
|
||||
|
||||
intel->ctx.Driver.DrawBuffer( &intel->ctx, intel->ctx.Color.DrawBuffer[0] );
|
||||
} else {
|
||||
intel_draw_buffer(&intel->ctx, drawFb);
|
||||
}
|
||||
else {
|
||||
_mesa_make_current(NULL, NULL, NULL);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -57,8 +57,10 @@ typedef void (*intel_point_func)(struct intel_context *, intelVertex *);
|
|||
|
||||
#define INTEL_FALLBACK_DRAW_BUFFER 0x1
|
||||
#define INTEL_FALLBACK_READ_BUFFER 0x2
|
||||
#define INTEL_FALLBACK_USER 0x4
|
||||
#define INTEL_FALLBACK_RENDERMODE 0x8
|
||||
#define INTEL_FALLBACK_DEPTH_BUFFER 0x4
|
||||
#define INTEL_FALLBACK_STENCIL_BUFFER 0x8
|
||||
#define INTEL_FALLBACK_USER 0x10
|
||||
#define INTEL_FALLBACK_RENDERMODE 0x20
|
||||
|
||||
extern void intelFallback( struct intel_context *intel, GLuint bit, GLboolean mode );
|
||||
#define FALLBACK( intel, bit, mode ) intelFallback( intel, bit, mode )
|
||||
|
|
|
|||
|
|
@ -35,6 +35,7 @@
|
|||
#include "texformat.h"
|
||||
|
||||
#include "intel_context.h"
|
||||
#include "intel_buffers.h"
|
||||
#include "intel_bufmgr.h"
|
||||
#include "intel_fbo.h"
|
||||
#include "intel_mipmap_tree.h"
|
||||
|
|
@ -190,14 +191,14 @@ intel_alloc_renderbuffer_storage(GLcontext *ctx, struct gl_renderbuffer *rb,
|
|||
case GL_DEPTH_COMPONENT24:
|
||||
case GL_DEPTH_COMPONENT32:
|
||||
rb->InternalFormat = GL_DEPTH24_STENCIL8_EXT;
|
||||
rb->DataType = GL_UNSIGNED_INT;
|
||||
rb->DataType = GL_UNSIGNED_INT_24_8_EXT;
|
||||
rb->DepthBits = 24;
|
||||
cpp = 4;
|
||||
break;
|
||||
case GL_DEPTH_STENCIL_EXT:
|
||||
case GL_DEPTH24_STENCIL8_EXT:
|
||||
rb->InternalFormat = GL_DEPTH24_STENCIL8_EXT;
|
||||
rb->DataType = GL_UNSIGNED_INT;
|
||||
rb->DataType = GL_UNSIGNED_INT_24_8_EXT;
|
||||
rb->DepthBits = 24;
|
||||
rb->StencilBits = 8;
|
||||
cpp = 4;
|
||||
|
|
@ -336,7 +337,7 @@ intel_create_renderbuffer(GLenum intFormat, GLsizei width, GLsizei height,
|
|||
irb->Base._BaseFormat = GL_DEPTH_STENCIL_EXT;
|
||||
irb->Base.DepthBits = 24;
|
||||
irb->Base.StencilBits = 8;
|
||||
irb->Base.DataType = GL_UNSIGNED_INT;
|
||||
irb->Base.DataType = GL_UNSIGNED_INT_24_8_EXT;
|
||||
cpp = 4;
|
||||
break;
|
||||
default:
|
||||
|
|
@ -409,7 +410,7 @@ intel_bind_framebuffer(GLcontext *ctx, GLenum target,
|
|||
_mesa_debug(ctx, "%s %d\n", __FUNCTION__, fb->Name);
|
||||
|
||||
if (target == GL_FRAMEBUFFER_EXT || target == GL_DRAW_FRAMEBUFFER_EXT) {
|
||||
ctx->Driver.DrawBuffer(ctx, 0); /* second param is ignored */
|
||||
intel_draw_buffer(ctx, fb);
|
||||
/* Integer depth range depends on depth buffer bits */
|
||||
ctx->Driver.DepthRange(ctx, ctx->Viewport.Near, ctx->Viewport.Far);
|
||||
}
|
||||
|
|
@ -432,7 +433,7 @@ intel_framebuffer_renderbuffer(GLcontext *ctx,
|
|||
fb->Name, rb->Name);
|
||||
|
||||
_mesa_framebuffer_renderbuffer(ctx, fb, attachment, rb);
|
||||
ctx->Driver.DrawBuffer(ctx, 0); /* second param is ignored */
|
||||
intel_draw_buffer(ctx, fb);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -531,7 +532,7 @@ intel_renderbuffer_texture(GLcontext *ctx,
|
|||
intel_image = intel_texture_image(newImage);
|
||||
intel_region_reference(&irb->region, intel_image->mt->region);
|
||||
|
||||
ctx->Driver.DrawBuffer(ctx, 0); /* second param is ignored */
|
||||
intel_draw_buffer(ctx, fb);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -270,8 +270,8 @@ static GLboolean intelCreateBuffer( __DRIscreenPrivate *driScrnPriv,
|
|||
if (mesaVis->depthBits == 24 && mesaVis->stencilBits == 8) {
|
||||
/* combined depth/stencil buffer */
|
||||
struct intel_renderbuffer *depthStencilRb
|
||||
= intel_create_renderbuffer(/**GL_DEPTH24_STENCIL8_EXT,**/
|
||||
GL_DEPTH_COMPONENT24,
|
||||
= intel_create_renderbuffer(
|
||||
GL_DEPTH24_STENCIL8_EXT,
|
||||
screen->width, screen->height,
|
||||
screen->depth.offset,
|
||||
screen->depth.pitch,
|
||||
|
|
@ -280,17 +280,6 @@ static GLboolean intelCreateBuffer( __DRIscreenPrivate *driScrnPriv,
|
|||
intel_set_span_functions(&depthStencilRb->Base);
|
||||
/* note: bind RB to two attachment points */
|
||||
_mesa_add_renderbuffer(fb, BUFFER_DEPTH, &depthStencilRb->Base);
|
||||
#if 1
|
||||
/* XXX TEMP: separate stencil */
|
||||
depthStencilRb
|
||||
= intel_create_renderbuffer(GL_STENCIL_INDEX8_EXT,
|
||||
screen->width, screen->height,
|
||||
screen->depth.offset,
|
||||
screen->depth.pitch,
|
||||
screen->cpp, /* 4! */
|
||||
screen->depth.map);
|
||||
intel_set_span_functions(&depthStencilRb->Base);
|
||||
#endif
|
||||
_mesa_add_renderbuffer(fb, BUFFER_STENCIL, &depthStencilRb->Base);
|
||||
}
|
||||
else if (mesaVis->depthBits == 16) {
|
||||
|
|
|
|||
|
|
@ -110,8 +110,9 @@
|
|||
|
||||
#define LOCAL_STENCIL_VARS LOCAL_DEPTH_VARS
|
||||
|
||||
/* 16 bit depthbuffer functions.
|
||||
*/
|
||||
/**
|
||||
** 16-bit depthbuffer functions.
|
||||
**/
|
||||
#define WRITE_DEPTH( _x, _y, d ) \
|
||||
((GLushort *)buf)[(_x) + (_y) * pitch] = d;
|
||||
|
||||
|
|
@ -123,22 +124,31 @@
|
|||
#include "depthtmp.h"
|
||||
|
||||
|
||||
/* 24/8 bit interleaved depth/stencil functions
|
||||
*/
|
||||
/**
|
||||
** 24/8-bit interleaved depth/stencil functions
|
||||
** Note: we're actually reading back combined depth+stencil values.
|
||||
** The wrappers in main/depthstencil.c are used to extract the depth
|
||||
** and stencil values.
|
||||
**/
|
||||
/* Change ZZZS -> SZZZ */
|
||||
#define WRITE_DEPTH( _x, _y, d ) { \
|
||||
GLuint tmp = ((GLuint *)buf)[(_x) + (_y) * pitch]; \
|
||||
tmp &= 0xff000000; \
|
||||
tmp |= (d) & 0xffffff; \
|
||||
GLuint tmp = ((d) >> 8) | ((d) << 24); \
|
||||
((GLuint *)buf)[(_x) + (_y) * pitch] = tmp; \
|
||||
}
|
||||
|
||||
#define READ_DEPTH( d, _x, _y ) \
|
||||
d = ((GLuint *)buf)[(_x) + (_y) * pitch] & 0xffffff;
|
||||
|
||||
/* Change SZZZ -> ZZZS */
|
||||
#define READ_DEPTH( d, _x, _y ) { \
|
||||
GLuint tmp = ((GLuint *)buf)[(_x) + (_y) * pitch]; \
|
||||
d = (tmp << 8) | (tmp >> 24); \
|
||||
}
|
||||
|
||||
#define TAG(x) intel##x##_z24_s8
|
||||
#include "depthtmp.h"
|
||||
|
||||
|
||||
/**
|
||||
** 8-bit stencil function (XXX FBO: This is obsolete)
|
||||
**/
|
||||
#define WRITE_STENCIL( _x, _y, d ) { \
|
||||
GLuint tmp = ((GLuint *)buf)[(_x) + (_y) * pitch]; \
|
||||
tmp &= 0xffffff; \
|
||||
|
|
@ -278,10 +288,7 @@ void intelSpanRenderStart( GLcontext *ctx )
|
|||
}
|
||||
}
|
||||
|
||||
#if 1
|
||||
/* XXX FBO: enable this code when old DRI screen mappings go away */
|
||||
intel_map_unmap_buffers(intel, GL_TRUE);
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -310,14 +317,12 @@ void intelSpanRenderFinish( GLcontext *ctx )
|
|||
}
|
||||
}
|
||||
|
||||
#if 1
|
||||
/* XXX FBO: enable this code when old DRI screen mappings go away */
|
||||
intel_map_unmap_buffers(intel, GL_FALSE);
|
||||
#endif
|
||||
|
||||
UNLOCK_HARDWARE( intel );
|
||||
}
|
||||
|
||||
|
||||
void intelInitSpanFuncs( GLcontext *ctx )
|
||||
{
|
||||
struct swrast_device_driver *swdd = _swrast_GetDeviceDriverReference(ctx);
|
||||
|
|
@ -326,6 +331,10 @@ void intelInitSpanFuncs( GLcontext *ctx )
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* Plug in appropriate span read/write functions for the given renderbuffer.
|
||||
* These are used for the software fallbacks.
|
||||
*/
|
||||
void
|
||||
intel_set_span_functions(struct gl_renderbuffer *rb)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue