XQuartz: GL: Add capability detection for depth buffers, and multisampling.
GL/capabilities.c: Add handleDepthModes(), and extend handleRendererDescription() for the various depth and multisampling flags. Add initialization of the new config options to initConfig(). GL/capabilities.h: Add depth and multisample config members. GL/visualConfigs.c: Add depth and multisampling support to the visual config setup.
This commit is contained in:
parent
1e5f63f15e
commit
f527381eea
@ -295,11 +295,60 @@ static void handleAccumulationModes(struct glCapabilitiesConfig *c, GLint cmodes
|
||||
assert(c->total_accum_buffers < GLCAPS_COLOR_BUFFERS);
|
||||
}
|
||||
|
||||
static void handleDepthModes(struct glCapabilitiesConfig *c, GLint dmodes) {
|
||||
int offset = 0;
|
||||
#define DEPTH(flag,value) do { \
|
||||
if(dmodes & flag) { \
|
||||
c->depth_buffers[offset++] = value; \
|
||||
} \
|
||||
} while(0)
|
||||
|
||||
/*1*/
|
||||
DEPTH(kCGL0Bit, 0);
|
||||
/*2*/
|
||||
DEPTH(kCGL1Bit, 1);
|
||||
/*3*/
|
||||
DEPTH(kCGL2Bit, 2);
|
||||
/*4*/
|
||||
DEPTH(kCGL3Bit, 3);
|
||||
/*5*/
|
||||
DEPTH(kCGL4Bit, 4);
|
||||
/*6*/
|
||||
DEPTH(kCGL5Bit, 5);
|
||||
/*7*/
|
||||
DEPTH(kCGL6Bit, 6);
|
||||
/*8*/
|
||||
DEPTH(kCGL8Bit, 8);
|
||||
/*9*/
|
||||
DEPTH(kCGL10Bit, 10);
|
||||
/*10*/
|
||||
DEPTH(kCGL12Bit, 12);
|
||||
/*11*/
|
||||
DEPTH(kCGL16Bit, 16);
|
||||
/*12*/
|
||||
DEPTH(kCGL24Bit, 24);
|
||||
/*13*/
|
||||
DEPTH(kCGL32Bit, 32);
|
||||
/*14*/
|
||||
DEPTH(kCGL48Bit, 48);
|
||||
/*15*/
|
||||
DEPTH(kCGL64Bit, 64);
|
||||
/*16*/
|
||||
DEPTH(kCGL96Bit, 96);
|
||||
/*17*/
|
||||
DEPTH(kCGL128Bit, 128);
|
||||
|
||||
#undef DEPTH
|
||||
|
||||
c->total_depth_buffer_depths = offset;
|
||||
assert(c->total_depth_buffer_depths < GLCAPS_DEPTH_BUFFERS);
|
||||
}
|
||||
|
||||
/* Return non-zero if an error occured. */
|
||||
static CGLError handleRendererDescriptions(CGLRendererInfoObj info, GLint r,
|
||||
struct glCapabilitiesConfig *c) {
|
||||
CGLError err;
|
||||
GLint accelerated = 0, flags = 0, aux = 0;
|
||||
GLint accelerated = 0, flags = 0, aux = 0, samplebufs = 0, samples = 0;
|
||||
|
||||
err = CGLDescribeRenderer (info, r, kCGLRPAccelerated, &accelerated);
|
||||
|
||||
@ -325,6 +374,33 @@ static CGLError handleRendererDescriptions(CGLRendererInfoObj info, GLint r,
|
||||
c->aux_buffers = aux;
|
||||
|
||||
|
||||
/* Depth buffer size */
|
||||
err = CGLDescribeRenderer(info, r, kCGLRPDepthModes, &flags);
|
||||
|
||||
if(err)
|
||||
return err;
|
||||
|
||||
handleDepthModes(c, flags);
|
||||
|
||||
|
||||
/* Multisample buffers */
|
||||
err = CGLDescribeRenderer(info, r, kCGLRPMaxSampleBuffers, &samplebufs);
|
||||
|
||||
if(err)
|
||||
return err;
|
||||
|
||||
c->multisample_buffers = samplebufs;
|
||||
|
||||
|
||||
/* Multisample samples per multisample buffer */
|
||||
err = CGLDescribeRenderer(info, r, kCGLRPMaxSamples, &samples);
|
||||
|
||||
if(err)
|
||||
return err;
|
||||
|
||||
c->multisample_samples = samples;
|
||||
|
||||
|
||||
/* Stencil bit depths */
|
||||
err = CGLDescribeRenderer(info, r, kCGLRPStencilModes, &flags);
|
||||
|
||||
@ -362,8 +438,18 @@ static void initConfig(struct glCapabilitiesConfig *c) {
|
||||
|
||||
c->accelerated = false;
|
||||
c->stereo = false;
|
||||
c->buffers = 0;
|
||||
c->aux_buffers = 0;
|
||||
c->buffers = 0;
|
||||
|
||||
c->total_depth_buffer_depths = 0;
|
||||
|
||||
for(i = 0; i < GLCAPS_DEPTH_BUFFERS; ++i) {
|
||||
c->depth_buffers[i] = GLCAPS_INVALID_DEPTH_VALUE;
|
||||
}
|
||||
|
||||
c->multisample_buffers = 0;
|
||||
c->multisample_samples = 0;
|
||||
|
||||
c->total_stencil_bit_depths = 0;
|
||||
|
||||
for(i = 0; i < GLCAPS_STENCIL_BIT_DEPTH_BUFFERS; ++i) {
|
||||
|
@ -29,6 +29,8 @@ enum { GLCAPS_INVALID_STENCIL_DEPTH = -1 };
|
||||
enum { GLCAPS_COLOR_BUF_INVALID_VALUE = -1 };
|
||||
enum { GLCAPS_COLOR_BUFFERS = 20 };
|
||||
enum { GLCAPS_STENCIL_BIT_DEPTH_BUFFERS = 20 };
|
||||
enum { GLCAPS_DEPTH_BUFFERS = 20 };
|
||||
enum { GLCAPS_INVALID_DEPTH_VALUE = 1 };
|
||||
|
||||
struct glColorBufCapabilities {
|
||||
char r, g, b, a;
|
||||
@ -40,6 +42,10 @@ struct glCapabilitiesConfig {
|
||||
bool stereo;
|
||||
int aux_buffers;
|
||||
int buffers;
|
||||
int total_depth_buffer_depths;
|
||||
int depth_buffers[GLCAPS_DEPTH_BUFFERS];
|
||||
int multisample_buffers;
|
||||
int multisample_samples;
|
||||
int total_stencil_bit_depths;
|
||||
char stencil_bit_depths[GLCAPS_STENCIL_BIT_DEPTH_BUFFERS];
|
||||
int total_color_buffers;
|
||||
|
@ -63,7 +63,7 @@ void setVisualConfigs(void) {
|
||||
void **visualPrivates = NULL;
|
||||
struct glCapabilities caps;
|
||||
struct glCapabilitiesConfig *conf = NULL;
|
||||
int stereo, depth, aux, buffers, stencil, accum, color;
|
||||
int stereo, depth, aux, buffers, stencil, accum, color, msample;
|
||||
int i = 0;
|
||||
|
||||
if(getGlCapabilities(&caps)) {
|
||||
@ -87,6 +87,11 @@ void setVisualConfigs(void) {
|
||||
|
||||
conf->total_accum_buffers iterations for accum (with at least 1 if equal to 0)
|
||||
|
||||
conf->total_depth_buffer_depths
|
||||
|
||||
conf->multisample_buffers iterations (with at least 1 if equal to 0). We add 1
|
||||
for the 0 multisampling config.
|
||||
|
||||
*/
|
||||
|
||||
assert(NULL != caps.configurations);
|
||||
@ -103,7 +108,9 @@ void setVisualConfigs(void) {
|
||||
* conf->buffers
|
||||
* ((conf->total_stencil_bit_depths > 0) ? conf->total_stencil_bit_depths : 1)
|
||||
* conf->total_color_buffers
|
||||
* ((conf->total_accum_buffers > 0) ? conf->total_accum_buffers : 1);
|
||||
* ((conf->total_accum_buffers > 0) ? conf->total_accum_buffers : 1)
|
||||
* conf->total_depth_buffer_depths
|
||||
* (conf->multisample_buffers + 1);
|
||||
}
|
||||
|
||||
visualConfigs = xcalloc(sizeof(*visualConfigs), numConfigs);
|
||||
@ -133,6 +140,8 @@ void setVisualConfigs(void) {
|
||||
for(color = 0; color < conf->total_color_buffers; ++color) {
|
||||
for(accum = 0; accum < ((conf->total_accum_buffers > 0) ?
|
||||
conf->total_accum_buffers : 1); ++accum) {
|
||||
for(depth = 0; depth < conf->total_depth_buffer_depths; ++depth) {
|
||||
for(msample = 0; msample < (conf->multisample_buffers + 1); ++msample) {
|
||||
visualConfigs[i].vid = (VisualID)(-1);
|
||||
visualConfigs[i].class = TrueColor;
|
||||
|
||||
@ -175,7 +184,7 @@ void setVisualConfigs(void) {
|
||||
visualConfigs[i].doubleBuffer = buffers ? TRUE : FALSE;
|
||||
visualConfigs[i].stereo = stereo ? TRUE : FALSE;
|
||||
|
||||
visualConfigs[i].depthSize = 24;
|
||||
visualConfigs[i].depthSize = conf->depth_buffers[depth];
|
||||
|
||||
if(conf->total_stencil_bit_depths > 0) {
|
||||
visualConfigs[i].stencilSize = conf->stencil_bit_depths[stencil];
|
||||
@ -198,12 +207,13 @@ void setVisualConfigs(void) {
|
||||
visualConfigs[i].transparentAlpha = GLX_NONE;
|
||||
visualConfigs[i].transparentIndex = GLX_NONE;
|
||||
|
||||
/*
|
||||
TODO possibly handle:
|
||||
multiSampleSize;
|
||||
nMultiSampleBuffers;
|
||||
visualSelectGroup;
|
||||
*/
|
||||
if(msample > 0) {
|
||||
visualConfigs[i].multiSampleSize = conf->multisample_samples;
|
||||
visualConfigs[i].nMultiSampleBuffers = conf->multisample_buffers;
|
||||
} else {
|
||||
visualConfigs[i].multiSampleSize = 0;
|
||||
visualConfigs[i].nMultiSampleBuffers = 0;
|
||||
}
|
||||
|
||||
++i;
|
||||
}
|
||||
@ -213,6 +223,8 @@ void setVisualConfigs(void) {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (i != numConfigs) {
|
||||
ErrorF("numConfigs calculation error in setVisualConfigs! numConfigs is %d i is %d\n", numConfigs, i);
|
||||
|
Loading…
Reference in New Issue
Block a user