summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--hw/xquartz/GL/capabilities.c90
-rw-r--r--hw/xquartz/GL/capabilities.h6
-rw-r--r--hw/xquartz/GL/visualConfigs.c158
3 files changed, 179 insertions, 75 deletions
diff --git a/hw/xquartz/GL/capabilities.c b/hw/xquartz/GL/capabilities.c
index 23d7c25c8..bc3966f4b 100644
--- a/hw/xquartz/GL/capabilities.c
+++ b/hw/xquartz/GL/capabilities.c
@@ -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);
@@ -323,7 +372,34 @@ static CGLError handleRendererDescriptions(CGLRendererInfoObj info, GLint r,
return err;
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) {
diff --git a/hw/xquartz/GL/capabilities.h b/hw/xquartz/GL/capabilities.h
index 20be30dce..361856b07 100644
--- a/hw/xquartz/GL/capabilities.h
+++ b/hw/xquartz/GL/capabilities.h
@@ -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;
diff --git a/hw/xquartz/GL/visualConfigs.c b/hw/xquartz/GL/visualConfigs.c
index f7f253f05..2f5c508e2 100644
--- a/hw/xquartz/GL/visualConfigs.c
+++ b/hw/xquartz/GL/visualConfigs.c
@@ -63,9 +63,9 @@ 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)) {
ErrorF("error from getGlCapabilities()!\n");
return;
@@ -86,7 +86,12 @@ void setVisualConfigs(void) {
conf->total_color_buffers indicates the RGB/RGBA color depths.
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,79 +140,84 @@ 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) {
- visualConfigs[i].vid = (VisualID)(-1);
- visualConfigs[i].class = TrueColor;
-
- visualConfigs[i].rgba = true;
- visualConfigs[i].redSize = conf->color_buffers[color].r;
- visualConfigs[i].greenSize = conf->color_buffers[color].g;
- visualConfigs[i].blueSize = conf->color_buffers[color].b;
- visualConfigs[i].alphaSize = conf->color_buffers[color].a;
+ 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;
+
+ visualConfigs[i].rgba = true;
+ visualConfigs[i].redSize = conf->color_buffers[color].r;
+ visualConfigs[i].greenSize = conf->color_buffers[color].g;
+ visualConfigs[i].blueSize = conf->color_buffers[color].b;
+ visualConfigs[i].alphaSize = conf->color_buffers[color].a;
+
+ visualConfigs[i].bufferSize = conf->color_buffers[color].r +
+ conf->color_buffers[color].g + conf->color_buffers[color].b +
+ conf->color_buffers[color].a;
+
+ /*
+ * I'm uncertain about these masks.
+ * I don't think we actually care what the values are in our
+ * libGL, so it doesn't seem to make a difference.
+ */
+ visualConfigs[i].redMask = -1;
+ visualConfigs[i].greenMask = -1;
+ visualConfigs[i].blueMask = -1;
+ visualConfigs[i].alphaMask = -1;
+
+ if(conf->total_accum_buffers > 0) {
+ visualConfigs[i].accumRedSize = conf->accum_buffers[accum].r;
+ visualConfigs[i].accumGreenSize = conf->accum_buffers[accum].g;
+ visualConfigs[i].accumBlueSize = conf->accum_buffers[accum].b;
+ if(GLCAPS_COLOR_BUF_INVALID_VALUE != conf->accum_buffers[accum].a) {
+ visualConfigs[i].accumAlphaSize = conf->accum_buffers[accum].a;
+ } else {
+ visualConfigs[i].accumAlphaSize = 0;
+ }
+ } else {
+ visualConfigs[i].accumRedSize = 0;
+ visualConfigs[i].accumGreenSize = 0;
+ visualConfigs[i].accumBlueSize = 0;
+ visualConfigs[i].accumAlphaSize = 0;
+ }
+
+ visualConfigs[i].doubleBuffer = buffers ? TRUE : FALSE;
+ visualConfigs[i].stereo = stereo ? TRUE : FALSE;
+
+ visualConfigs[i].depthSize = conf->depth_buffers[depth];
- visualConfigs[i].bufferSize = conf->color_buffers[color].r +
- conf->color_buffers[color].g + conf->color_buffers[color].b +
- conf->color_buffers[color].a;
+ if(conf->total_stencil_bit_depths > 0) {
+ visualConfigs[i].stencilSize = conf->stencil_bit_depths[stencil];
+ } else {
+ visualConfigs[i].stencilSize = 0;
+ }
+ visualConfigs[i].auxBuffers = aux ? conf->aux_buffers : 0;
+ visualConfigs[i].level = 0;
- /*
- * I'm uncertain about these masks.
- * I don't think we actually care what the values are in our
- * libGL, so it doesn't seem to make a difference.
- */
- visualConfigs[i].redMask = -1;
- visualConfigs[i].greenMask = -1;
- visualConfigs[i].blueMask = -1;
- visualConfigs[i].alphaMask = -1;
-
- if(conf->total_accum_buffers > 0) {
- visualConfigs[i].accumRedSize = conf->accum_buffers[accum].r;
- visualConfigs[i].accumGreenSize = conf->accum_buffers[accum].g;
- visualConfigs[i].accumBlueSize = conf->accum_buffers[accum].b;
- if(GLCAPS_COLOR_BUF_INVALID_VALUE != conf->accum_buffers[accum].a) {
- visualConfigs[i].accumAlphaSize = conf->accum_buffers[accum].a;
- } else {
- visualConfigs[i].accumAlphaSize = 0;
+ if(conf->accelerated) {
+ visualConfigs[i].visualRating = GLX_NONE;
+ } else {
+ visualConfigs[i].visualRating = GLX_SLOW_VISUAL_EXT;
+ }
+
+ visualConfigs[i].transparentPixel = GLX_NONE;
+ visualConfigs[i].transparentRed = GLX_NONE;
+ visualConfigs[i].transparentGreen = GLX_NONE;
+ visualConfigs[i].transparentBlue = GLX_NONE;
+ visualConfigs[i].transparentAlpha = GLX_NONE;
+ visualConfigs[i].transparentIndex = GLX_NONE;
+
+ 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;
}
- } else {
- visualConfigs[i].accumRedSize = 0;
- visualConfigs[i].accumGreenSize = 0;
- visualConfigs[i].accumBlueSize = 0;
- visualConfigs[i].accumAlphaSize = 0;
- }
-
- visualConfigs[i].doubleBuffer = buffers ? TRUE : FALSE;
- visualConfigs[i].stereo = stereo ? TRUE : FALSE;
-
- visualConfigs[i].depthSize = 24;
-
- if(conf->total_stencil_bit_depths > 0) {
- visualConfigs[i].stencilSize = conf->stencil_bit_depths[stencil];
- } else {
- visualConfigs[i].stencilSize = 0;
- }
- visualConfigs[i].auxBuffers = aux ? conf->aux_buffers : 0;
- visualConfigs[i].level = 0;
-
- if(conf->accelerated) {
- visualConfigs[i].visualRating = GLX_NONE;
- } else {
- visualConfigs[i].visualRating = GLX_SLOW_VISUAL_EXT;
}
-
- visualConfigs[i].transparentPixel = GLX_NONE;
- visualConfigs[i].transparentRed = GLX_NONE;
- visualConfigs[i].transparentGreen = GLX_NONE;
- visualConfigs[i].transparentBlue = GLX_NONE;
- visualConfigs[i].transparentAlpha = GLX_NONE;
- visualConfigs[i].transparentIndex = GLX_NONE;
-
- /*
- TODO possibly handle:
- multiSampleSize;
- nMultiSampleBuffers;
- visualSelectGroup;
- */
-
- ++i;
}
}
}