gallium: handle msaa
This commit is contained in:
parent
a1fb565ea7
commit
429a08384c
|
@ -276,7 +276,7 @@ struct pipe_surface
|
|||
unsigned layout; /**< PIPE_SURFACE_LAYOUT_x */
|
||||
unsigned offset; /**< offset from start of buffer, in bytes */
|
||||
unsigned refcount;
|
||||
unsigned usage; /**< PIPE_BUFFER_USAGE_* */
|
||||
unsigned usage; /**< PIPE_BUFFER_USAGE_* */
|
||||
|
||||
struct pipe_winsys *winsys; /**< winsys which owns/created the surface */
|
||||
|
||||
|
@ -311,7 +311,9 @@ struct pipe_texture
|
|||
|
||||
unsigned last_level:8; /**< Index of last mipmap level present/defined */
|
||||
unsigned compressed:1;
|
||||
|
||||
|
||||
unsigned nr_samples:8; /**< for multisampled surfaces, nr of samples */
|
||||
|
||||
unsigned tex_usage; /* PIPE_TEXTURE_USAGE_* */
|
||||
|
||||
/* These are also refcounted:
|
||||
|
|
|
@ -483,11 +483,13 @@ intelFillInModes(unsigned pixel_bits, unsigned depth_bits,
|
|||
|
||||
uint8_t depth_bits_array[3];
|
||||
uint8_t stencil_bits_array[3];
|
||||
uint8_t msaa_samples_array[1];
|
||||
|
||||
|
||||
depth_bits_array[0] = 0;
|
||||
depth_bits_array[1] = depth_bits;
|
||||
depth_bits_array[2] = depth_bits;
|
||||
msaa_samples_array[0] = 0;
|
||||
|
||||
/* Just like with the accumulation buffer, always provide some modes
|
||||
* with a stencil buffer. It will be a sw fallback, but some apps won't
|
||||
|
@ -521,7 +523,7 @@ intelFillInModes(unsigned pixel_bits, unsigned depth_bits,
|
|||
if (!driFillInModes(&m, fb_format, fb_type,
|
||||
depth_bits_array, stencil_bits_array,
|
||||
depth_buffer_factor, back_buffer_modes,
|
||||
back_buffer_factor, GLX_TRUE_COLOR)) {
|
||||
back_buffer_factor, msaa_samples_array, 1, GLX_TRUE_COLOR)) {
|
||||
fprintf(stderr, "[%s:%u] Error creating FBConfig!\n", __func__,
|
||||
__LINE__);
|
||||
return NULL;
|
||||
|
@ -529,7 +531,7 @@ intelFillInModes(unsigned pixel_bits, unsigned depth_bits,
|
|||
if (!driFillInModes(&m, fb_format, fb_type,
|
||||
depth_bits_array, stencil_bits_array,
|
||||
depth_buffer_factor, back_buffer_modes,
|
||||
back_buffer_factor, GLX_DIRECT_COLOR)) {
|
||||
back_buffer_factor, msaa_samples_array, 1, GLX_DIRECT_COLOR)) {
|
||||
fprintf(stderr, "[%s:%u] Error creating FBConfig!\n", __func__,
|
||||
__LINE__);
|
||||
return NULL;
|
||||
|
|
|
@ -521,6 +521,9 @@ GLboolean driClipRectToFramebuffer( const GLframebuffer *buffer,
|
|||
* \c GLX_SWAP_UNDEFINED_OML. See the
|
||||
* GLX_OML_swap_method extension spec for more details.
|
||||
* \param num_db_modes Number of entries in \c db_modes.
|
||||
* \param msaa_samples Array of msaa sample count. 0 represents a visual
|
||||
* without a multisample buffer.
|
||||
* \param num_msaa_modes Number of entries in \c msaa_samples.
|
||||
* \param visType GLX visual type. Usually either \c GLX_TRUE_COLOR or
|
||||
* \c GLX_DIRECT_COLOR.
|
||||
*
|
||||
|
@ -542,6 +545,7 @@ driFillInModes( __GLcontextModes ** ptr_to_modes,
|
|||
const uint8_t * depth_bits, const uint8_t * stencil_bits,
|
||||
unsigned num_depth_stencil_bits,
|
||||
const GLenum * db_modes, unsigned num_db_modes,
|
||||
const u_int8_t * msaa_samples, unsigned num_msaa_modes,
|
||||
int visType )
|
||||
{
|
||||
static const uint8_t bits_table[3][4] = {
|
||||
|
@ -607,9 +611,7 @@ driFillInModes( __GLcontextModes ** ptr_to_modes,
|
|||
const uint32_t * masks;
|
||||
const int index = fb_type & 0x07;
|
||||
__GLcontextModes * modes = *ptr_to_modes;
|
||||
unsigned i;
|
||||
unsigned j;
|
||||
unsigned k;
|
||||
unsigned i, j, k, h;
|
||||
|
||||
|
||||
if ( bytes_per_pixel[ index ] == 0 ) {
|
||||
|
@ -659,49 +661,54 @@ driFillInModes( __GLcontextModes ** ptr_to_modes,
|
|||
|
||||
for ( k = 0 ; k < num_depth_stencil_bits ; k++ ) {
|
||||
for ( i = 0 ; i < num_db_modes ; i++ ) {
|
||||
for ( j = 0 ; j < 2 ; j++ ) {
|
||||
for ( h = 0 ; h < num_msaa_modes; h++ ) {
|
||||
for ( j = 0 ; j < 2 ; j++ ) {
|
||||
|
||||
modes->redBits = bits[0];
|
||||
modes->greenBits = bits[1];
|
||||
modes->blueBits = bits[2];
|
||||
modes->alphaBits = bits[3];
|
||||
modes->redMask = masks[0];
|
||||
modes->greenMask = masks[1];
|
||||
modes->blueMask = masks[2];
|
||||
modes->alphaMask = masks[3];
|
||||
modes->rgbBits = modes->redBits + modes->greenBits
|
||||
+ modes->blueBits + modes->alphaBits;
|
||||
modes->redBits = bits[0];
|
||||
modes->greenBits = bits[1];
|
||||
modes->blueBits = bits[2];
|
||||
modes->alphaBits = bits[3];
|
||||
modes->redMask = masks[0];
|
||||
modes->greenMask = masks[1];
|
||||
modes->blueMask = masks[2];
|
||||
modes->alphaMask = masks[3];
|
||||
modes->rgbBits = modes->redBits + modes->greenBits
|
||||
+ modes->blueBits + modes->alphaBits;
|
||||
|
||||
modes->accumRedBits = 16 * j;
|
||||
modes->accumGreenBits = 16 * j;
|
||||
modes->accumBlueBits = 16 * j;
|
||||
modes->accumAlphaBits = (masks[3] != 0) ? 16 * j : 0;
|
||||
modes->visualRating = (j == 0) ? GLX_NONE : GLX_SLOW_CONFIG;
|
||||
modes->accumRedBits = 16 * j;
|
||||
modes->accumGreenBits = 16 * j;
|
||||
modes->accumBlueBits = 16 * j;
|
||||
modes->accumAlphaBits = (masks[3] != 0) ? 16 * j : 0;
|
||||
modes->visualRating = (j == 0) ? GLX_NONE : GLX_SLOW_CONFIG;
|
||||
|
||||
modes->stencilBits = stencil_bits[k];
|
||||
modes->depthBits = depth_bits[k];
|
||||
modes->stencilBits = stencil_bits[k];
|
||||
modes->depthBits = depth_bits[k];
|
||||
|
||||
modes->visualType = visType;
|
||||
modes->renderType = GLX_RGBA_BIT;
|
||||
modes->drawableType = GLX_WINDOW_BIT;
|
||||
modes->rgbMode = GL_TRUE;
|
||||
modes->visualType = visType;
|
||||
modes->renderType = GLX_RGBA_BIT;
|
||||
modes->drawableType = GLX_WINDOW_BIT;
|
||||
modes->rgbMode = GL_TRUE;
|
||||
|
||||
if ( db_modes[i] == GLX_NONE ) {
|
||||
modes->doubleBufferMode = GL_FALSE;
|
||||
if ( db_modes[i] == GLX_NONE ) {
|
||||
modes->doubleBufferMode = GL_FALSE;
|
||||
}
|
||||
else {
|
||||
modes->doubleBufferMode = GL_TRUE;
|
||||
modes->swapMethod = db_modes[i];
|
||||
}
|
||||
|
||||
modes->samples = msaa_samples[h];
|
||||
modes->sampleBuffers = modes->samples ? 1 : 0;
|
||||
|
||||
modes->haveAccumBuffer = ((modes->accumRedBits +
|
||||
modes->accumGreenBits +
|
||||
modes->accumBlueBits +
|
||||
modes->accumAlphaBits) > 0);
|
||||
modes->haveDepthBuffer = (modes->depthBits > 0);
|
||||
modes->haveStencilBuffer = (modes->stencilBits > 0);
|
||||
|
||||
modes = modes->next;
|
||||
}
|
||||
else {
|
||||
modes->doubleBufferMode = GL_TRUE;
|
||||
modes->swapMethod = db_modes[i];
|
||||
}
|
||||
|
||||
modes->haveAccumBuffer = ((modes->accumRedBits +
|
||||
modes->accumGreenBits +
|
||||
modes->accumBlueBits +
|
||||
modes->accumAlphaBits) > 0);
|
||||
modes->haveDepthBuffer = (modes->depthBits > 0);
|
||||
modes->haveStencilBuffer = (modes->stencilBits > 0);
|
||||
|
||||
modes = modes->next;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -115,6 +115,7 @@ extern GLboolean driFillInModes( __GLcontextModes ** modes,
|
|||
GLenum fb_format, GLenum fb_type,
|
||||
const uint8_t * depth_bits, const uint8_t * stencil_bits,
|
||||
unsigned num_depth_stencil_bits,
|
||||
const GLenum * db_modes, unsigned num_db_modes, int visType );
|
||||
const GLenum * db_modes, unsigned num_db_modes,
|
||||
const u_int8_t * msaa_samples, unsigned num_msaa_modes, int visType );
|
||||
|
||||
#endif /* DRI_DEBUG_H */
|
||||
|
|
|
@ -2269,6 +2269,7 @@ struct gl_renderbuffer
|
|||
GLubyte IndexBits;
|
||||
GLubyte DepthBits;
|
||||
GLubyte StencilBits;
|
||||
GLubyte Samples; /**< Number of samples - 0 if not multisampled */
|
||||
GLvoid *Data; /**< This may not be used by some kinds of RBs */
|
||||
|
||||
/* Used to wrap one renderbuffer around another: */
|
||||
|
|
|
@ -118,6 +118,7 @@ st_renderbuffer_alloc_storage(GLcontext * ctx, struct gl_renderbuffer *rb,
|
|||
template.height[0] = height;
|
||||
template.depth[0] = 1;
|
||||
template.last_level = 0;
|
||||
template.nr_samples = rb->Samples;
|
||||
|
||||
if (pf_is_depth_stencil(template.format)) {
|
||||
template.tex_usage = PIPE_TEXTURE_USAGE_DEPTH_STENCIL;
|
||||
|
@ -249,7 +250,7 @@ st_new_renderbuffer(GLcontext *ctx, GLuint name)
|
|||
* renderbuffer). The window system code determines the format.
|
||||
*/
|
||||
struct gl_renderbuffer *
|
||||
st_new_renderbuffer_fb(enum pipe_format format)
|
||||
st_new_renderbuffer_fb(enum pipe_format format, int samples)
|
||||
{
|
||||
struct st_renderbuffer *strb;
|
||||
|
||||
|
@ -261,6 +262,7 @@ st_new_renderbuffer_fb(enum pipe_format format)
|
|||
|
||||
_mesa_init_renderbuffer(&strb->Base, 0);
|
||||
strb->Base.ClassID = 0x4242; /* just a unique value */
|
||||
strb->Base.Samples = samples;
|
||||
strb->format = format;
|
||||
|
||||
switch (format) {
|
||||
|
|
|
@ -58,7 +58,7 @@ st_renderbuffer(struct gl_renderbuffer *rb)
|
|||
|
||||
|
||||
extern struct gl_renderbuffer *
|
||||
st_new_renderbuffer_fb(enum pipe_format format);
|
||||
st_new_renderbuffer_fb(enum pipe_format format, int samples);
|
||||
|
||||
extern void
|
||||
st_init_fbo_functions(struct dd_function_table *functions);
|
||||
|
|
|
@ -51,27 +51,29 @@ st_create_framebuffer( const __GLcontextModes *visual,
|
|||
{
|
||||
struct st_framebuffer *stfb = CALLOC_STRUCT(st_framebuffer);
|
||||
if (stfb) {
|
||||
int samples = 0;
|
||||
_mesa_initialize_framebuffer(&stfb->Base, visual);
|
||||
if (visual->sampleBuffers) samples = visual->samples;
|
||||
|
||||
{
|
||||
/* fake frontbuffer */
|
||||
/* XXX allocation should only happen in the unusual case
|
||||
it's actually needed */
|
||||
struct gl_renderbuffer *rb
|
||||
= st_new_renderbuffer_fb(colorFormat);
|
||||
= st_new_renderbuffer_fb(colorFormat, samples);
|
||||
_mesa_add_renderbuffer(&stfb->Base, BUFFER_FRONT_LEFT, rb);
|
||||
}
|
||||
|
||||
if (visual->doubleBufferMode) {
|
||||
struct gl_renderbuffer *rb
|
||||
= st_new_renderbuffer_fb(colorFormat);
|
||||
= st_new_renderbuffer_fb(colorFormat, samples);
|
||||
_mesa_add_renderbuffer(&stfb->Base, BUFFER_BACK_LEFT, rb);
|
||||
}
|
||||
|
||||
if (visual->depthBits == 24 && visual->stencilBits == 8) {
|
||||
/* combined depth/stencil buffer */
|
||||
struct gl_renderbuffer *depthStencilRb
|
||||
= st_new_renderbuffer_fb(depthFormat);
|
||||
= st_new_renderbuffer_fb(depthFormat, samples);
|
||||
/* note: bind RB to two attachment points */
|
||||
_mesa_add_renderbuffer(&stfb->Base, BUFFER_DEPTH, depthStencilRb);
|
||||
_mesa_add_renderbuffer(&stfb->Base, BUFFER_STENCIL, depthStencilRb);
|
||||
|
@ -82,26 +84,26 @@ st_create_framebuffer( const __GLcontextModes *visual,
|
|||
if (visual->depthBits == 32) {
|
||||
/* 32-bit depth buffer */
|
||||
struct gl_renderbuffer *depthRb
|
||||
= st_new_renderbuffer_fb(depthFormat);
|
||||
= st_new_renderbuffer_fb(depthFormat, samples);
|
||||
_mesa_add_renderbuffer(&stfb->Base, BUFFER_DEPTH, depthRb);
|
||||
}
|
||||
else if (visual->depthBits == 24) {
|
||||
/* 24-bit depth buffer, ignore stencil bits */
|
||||
struct gl_renderbuffer *depthRb
|
||||
= st_new_renderbuffer_fb(depthFormat);
|
||||
= st_new_renderbuffer_fb(depthFormat, samples);
|
||||
_mesa_add_renderbuffer(&stfb->Base, BUFFER_DEPTH, depthRb);
|
||||
}
|
||||
else if (visual->depthBits > 0) {
|
||||
/* 16-bit depth buffer */
|
||||
struct gl_renderbuffer *depthRb
|
||||
= st_new_renderbuffer_fb(depthFormat);
|
||||
= st_new_renderbuffer_fb(depthFormat, samples);
|
||||
_mesa_add_renderbuffer(&stfb->Base, BUFFER_DEPTH, depthRb);
|
||||
}
|
||||
|
||||
if (visual->stencilBits > 0) {
|
||||
/* 8-bit stencil */
|
||||
struct gl_renderbuffer *stencilRb
|
||||
= st_new_renderbuffer_fb(stencilFormat);
|
||||
= st_new_renderbuffer_fb(stencilFormat, samples);
|
||||
_mesa_add_renderbuffer(&stfb->Base, BUFFER_STENCIL, stencilRb);
|
||||
}
|
||||
}
|
||||
|
@ -109,7 +111,7 @@ st_create_framebuffer( const __GLcontextModes *visual,
|
|||
if (visual->accumRedBits > 0) {
|
||||
/* 16-bit/channel accum */
|
||||
struct gl_renderbuffer *accumRb
|
||||
= st_new_renderbuffer_fb(DEFAULT_ACCUM_PIPE_FORMAT);
|
||||
= st_new_renderbuffer_fb(DEFAULT_ACCUM_PIPE_FORMAT, 0); /* XXX accum isn't multisampled right? */
|
||||
_mesa_add_renderbuffer(&stfb->Base, BUFFER_ACCUM, accumRb);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue