diff options
Diffstat (limited to 'src/gallium/state_trackers')
-rw-r--r-- | src/gallium/state_trackers/dri/dri_drawable.c | 98 | ||||
-rw-r--r-- | src/gallium/state_trackers/dri/dri_drawable.h | 9 | ||||
-rw-r--r-- | src/gallium/state_trackers/dri/dri_extensions.c | 11 | ||||
-rw-r--r-- | src/gallium/state_trackers/dri/dri_screen.c | 85 | ||||
-rw-r--r-- | src/gallium/state_trackers/dri/dri_screen.h | 2 | ||||
-rw-r--r-- | src/gallium/state_trackers/egl/Makefile | 36 | ||||
-rw-r--r-- | src/gallium/state_trackers/glx/xlib/fakeglx.c | 13 | ||||
-rw-r--r-- | src/gallium/state_trackers/glx/xlib/xm_api.c | 21 | ||||
-rw-r--r-- | src/gallium/state_trackers/xorg/Makefile | 37 |
9 files changed, 182 insertions, 130 deletions
diff --git a/src/gallium/state_trackers/dri/dri_drawable.c b/src/gallium/state_trackers/dri/dri_drawable.c index 5846390d02c..815055b15b9 100644 --- a/src/gallium/state_trackers/dri/dri_drawable.c +++ b/src/gallium/state_trackers/dri/dri_drawable.c @@ -138,6 +138,18 @@ dri_get_buffers(__DRIdrawablePrivate * dPriv) dri_drawable->pBackClipRects[0].x2 = dri_drawable->w; dri_drawable->pBackClipRects[0].y2 = dri_drawable->h; + if (drawable->old_num == count && + drawable->old_w == dri_drawable->w && + drawable->old_h == dri_drawable->h && + memcmp(drawable->old, buffers, sizeof(__DRIbuffer) * count) == 0) { + return; + } else { + drawable->old_num = count; + drawable->old_w = dri_drawable->w; + drawable->old_h = dri_drawable->h; + memcpy(drawable->old, buffers, sizeof(__DRIbuffer) * count); + } + for (i = 0; i < count; i++) { enum pipe_format format = 0; int index = 0; @@ -145,29 +157,28 @@ dri_get_buffers(__DRIdrawablePrivate * dPriv) switch (buffers[i].attachment) { case __DRI_BUFFER_FRONT_LEFT: index = ST_SURFACE_FRONT_LEFT; - format = PIPE_FORMAT_A8R8G8B8_UNORM; + format = drawable->color_format; break; case __DRI_BUFFER_FAKE_FRONT_LEFT: index = ST_SURFACE_FRONT_LEFT; - format = PIPE_FORMAT_A8R8G8B8_UNORM; + format = drawable->color_format; break; case __DRI_BUFFER_BACK_LEFT: index = ST_SURFACE_BACK_LEFT; - format = PIPE_FORMAT_A8R8G8B8_UNORM; + format = drawable->color_format; break; case __DRI_BUFFER_DEPTH: index = ST_SURFACE_DEPTH; - format = PIPE_FORMAT_Z24S8_UNORM; + format = drawable->depth_format; break; case __DRI_BUFFER_STENCIL: index = ST_SURFACE_DEPTH; - format = PIPE_FORMAT_Z24S8_UNORM; + format = drawable->stencil_format; break; case __DRI_BUFFER_ACCUM: default: assert(0); } - assert(buffers[i].cpp == 4); if (index == ST_SURFACE_DEPTH) { if (have_depth) @@ -206,10 +217,8 @@ dri_create_buffer(__DRIscreenPrivate * sPriv, __DRIdrawablePrivate * dPriv, const __GLcontextModes * visual, boolean isPixmap) { - enum pipe_format colorFormat, depthFormat, stencilFormat; struct dri_screen *screen = sPriv->private; struct dri_drawable *drawable = NULL; - struct pipe_screen *pscreen = screen->pipe_screen; int i; if (isPixmap) @@ -219,39 +228,52 @@ dri_create_buffer(__DRIscreenPrivate * sPriv, if (drawable == NULL) goto fail; - /* XXX: todo: use the pipe_screen queries to figure out which - * render targets are supportable. - */ - assert(visual->redBits == 8); - assert(visual->depthBits == 24 || visual->depthBits == 0); - assert(visual->stencilBits == 8 || visual->stencilBits == 0); - - colorFormat = PIPE_FORMAT_A8R8G8B8_UNORM; + drawable->color_format = (visual->redBits == 8) ? + PIPE_FORMAT_A8R8G8B8_UNORM : PIPE_FORMAT_R5G6B5_UNORM; + + debug_printf("Red bits is %d\n", visual->redBits); + + switch(visual->depthBits) { + default: + case 0: + debug_printf("Depth buffer 0.\n"); + drawable->depth_format = PIPE_FORMAT_NONE; + break; + case 16: + debug_printf("Depth buffer 16.\n"); + drawable->depth_format = PIPE_FORMAT_Z16_UNORM; + break; + case 24: + if (visual->stencilBits == 0) { + debug_printf("Depth buffer 24. Stencil 0.\n"); + drawable->depth_format = (screen->d_depth_bits_last) ? + PIPE_FORMAT_X8Z24_UNORM: + PIPE_FORMAT_Z24X8_UNORM; + } else { + debug_printf("Combined depth stencil 24 / 8.\n"); + drawable->depth_format = (screen->sd_depth_bits_last) ? + PIPE_FORMAT_S8Z24_UNORM: + PIPE_FORMAT_Z24S8_UNORM; + } + break; + } - if (visual->depthBits) { - if (pscreen->is_format_supported(pscreen, PIPE_FORMAT_Z24S8_UNORM, - PIPE_TEXTURE_2D, - PIPE_TEXTURE_USAGE_DEPTH_STENCIL, 0)) - depthFormat = PIPE_FORMAT_Z24S8_UNORM; - else - depthFormat = PIPE_FORMAT_S8Z24_UNORM; - } else - depthFormat = PIPE_FORMAT_NONE; - - if (visual->stencilBits) { - if (pscreen->is_format_supported(pscreen, PIPE_FORMAT_Z24S8_UNORM, - PIPE_TEXTURE_2D, - PIPE_TEXTURE_USAGE_DEPTH_STENCIL, 0)) - stencilFormat = PIPE_FORMAT_Z24S8_UNORM; - else - stencilFormat = PIPE_FORMAT_S8Z24_UNORM; - } else - stencilFormat = PIPE_FORMAT_NONE; + switch(visual->stencilBits) { + default: + case 0: + drawable->stencil_format = PIPE_FORMAT_NONE; + break; + case 8: + drawable->stencil_format = (screen->sd_depth_bits_last) ? + PIPE_FORMAT_S8Z24_UNORM: + PIPE_FORMAT_Z24S8_UNORM; + break; + } drawable->stfb = st_create_framebuffer(visual, - colorFormat, - depthFormat, - stencilFormat, + drawable->color_format, + drawable->depth_format, + drawable->stencil_format, dPriv->w, dPriv->h, (void *)drawable); if (drawable->stfb == NULL) diff --git a/src/gallium/state_trackers/dri/dri_drawable.h b/src/gallium/state_trackers/dri/dri_drawable.h index 78a66624aaf..2fbd5f1eb7c 100644 --- a/src/gallium/state_trackers/dri/dri_drawable.h +++ b/src/gallium/state_trackers/dri/dri_drawable.h @@ -46,6 +46,11 @@ struct dri_drawable unsigned attachments[8]; unsigned num_attachments; + __DRIbuffer old[8]; + unsigned old_num; + unsigned old_w; + unsigned old_h; + /* gallium */ struct st_framebuffer *stfb; struct pipe_fence_handle *swap_fences[DRI_SWAP_FENCES_MAX]; @@ -53,6 +58,10 @@ struct dri_drawable unsigned int tail; unsigned int desired_fences; unsigned int cur_fences; + + enum pipe_format color_format; + enum pipe_format depth_format; + enum pipe_format stencil_format; }; static INLINE struct dri_drawable * diff --git a/src/gallium/state_trackers/dri/dri_extensions.c b/src/gallium/state_trackers/dri/dri_extensions.c index 0c59d42d5c6..2f48162526b 100644 --- a/src/gallium/state_trackers/dri/dri_extensions.c +++ b/src/gallium/state_trackers/dri/dri_extensions.c @@ -36,9 +36,11 @@ #define need_GL_ARB_multisample #define need_GL_ARB_occlusion_query #define need_GL_ARB_point_parameters +#define need_GL_ARB_shader_objects #define need_GL_ARB_texture_compression #define need_GL_ARB_vertex_buffer_object #define need_GL_ARB_vertex_program +#define need_GL_ARB_vertex_shader #define need_GL_ARB_window_pos #define need_GL_EXT_blend_color #define need_GL_EXT_blend_equation_separate @@ -50,16 +52,23 @@ #define need_GL_EXT_multi_draw_arrays #define need_GL_EXT_secondary_color #define need_GL_NV_vertex_program +#define need_GL_VERSION_2_0 +#define need_GL_VERSION_2_1 #include "extension_helper.h" /** * Extension strings exported by the driver. */ const struct dri_extension card_extensions[] = { + {"GL_ARB_fragment_shader", NULL}, {"GL_ARB_multisample", GL_ARB_multisample_functions}, {"GL_ARB_multitexture", NULL}, {"GL_ARB_occlusion_query", GL_ARB_occlusion_query_functions}, + {"GL_ARB_pixel_buffer_object", NULL}, {"GL_ARB_point_parameters", GL_ARB_point_parameters_functions}, + {"GL_ARB_shading_language_100", GL_VERSION_2_0_functions }, + {"GL_ARB_shading_language_120", GL_VERSION_2_1_functions }, + {"GL_ARB_shader_objects", GL_ARB_shader_objects_functions}, {"GL_ARB_texture_border_clamp", NULL}, {"GL_ARB_texture_compression", GL_ARB_texture_compression_functions}, {"GL_ARB_texture_cube_map", NULL}, @@ -69,7 +78,7 @@ const struct dri_extension card_extensions[] = { {"GL_ARB_texture_mirrored_repeat", NULL}, {"GL_ARB_texture_rectangle", NULL}, {"GL_ARB_vertex_buffer_object", GL_ARB_vertex_buffer_object_functions}, - {"GL_ARB_pixel_buffer_object", NULL}, + {"GL_ARB_vertex_shader", GL_ARB_vertex_shader_functions}, {"GL_ARB_vertex_program", GL_ARB_vertex_program_functions}, {"GL_ARB_window_pos", GL_ARB_window_pos_functions}, {"GL_EXT_blend_color", GL_EXT_blend_color_functions}, diff --git a/src/gallium/state_trackers/dri/dri_screen.c b/src/gallium/state_trackers/dri/dri_screen.c index d3392ee690b..e1e9b507a6d 100644 --- a/src/gallium/state_trackers/dri/dri_screen.c +++ b/src/gallium/state_trackers/dri/dri_screen.c @@ -69,39 +69,65 @@ PUBLIC const char __driConfigOptions[] = struct dri1_api *__dri1_api_hooks = NULL; static const __DRIconfig ** -dri_fill_in_modes(__DRIscreenPrivate * psp, - unsigned pixel_bits, unsigned depth_bits, - unsigned stencil_bits, GLboolean have_back_buffer) +dri_fill_in_modes(struct dri_screen *screen, + unsigned pixel_bits) { __DRIconfig **configs; - __GLcontextModes *m; unsigned num_modes; - uint8_t depth_bits_array[3]; - uint8_t stencil_bits_array[3]; + uint8_t depth_bits_array[4]; + uint8_t stencil_bits_array[4]; uint8_t msaa_samples_array[1]; unsigned depth_buffer_factor; unsigned back_buffer_factor; unsigned msaa_samples_factor; GLenum fb_format; GLenum fb_type; - int i; + struct pipe_screen *p_screen = screen->pipe_screen; static const GLenum back_buffer_modes[] = { GLX_NONE, GLX_SWAP_UNDEFINED_OML, GLX_SWAP_COPY_OML }; - /* TODO probe the hardware of what is supports */ depth_bits_array[0] = 0; - depth_bits_array[1] = 24; - depth_bits_array[2] = 24; - - stencil_bits_array[0] = 0; /* no depth or stencil */ - stencil_bits_array[1] = 0; /* z24x8 */ - stencil_bits_array[2] = 8; /* z24s8 */ + stencil_bits_array[0] = 0; + depth_buffer_factor = 1; + + if (p_screen->is_format_supported(p_screen, PIPE_FORMAT_Z16_UNORM, + PIPE_TEXTURE_2D, + PIPE_TEXTURE_USAGE_DEPTH_STENCIL, 0)) { + depth_bits_array[depth_buffer_factor] = 16; + stencil_bits_array[depth_buffer_factor++] = 0; + } + if (p_screen->is_format_supported(p_screen, PIPE_FORMAT_X8Z24_UNORM, + PIPE_TEXTURE_2D, + PIPE_TEXTURE_USAGE_DEPTH_STENCIL, 0)) { + depth_bits_array[depth_buffer_factor] = 24; + stencil_bits_array[depth_buffer_factor++] = 0; + screen->d_depth_bits_last = TRUE; + } else if (p_screen->is_format_supported(p_screen, PIPE_FORMAT_Z24X8_UNORM, + PIPE_TEXTURE_2D, + PIPE_TEXTURE_USAGE_DEPTH_STENCIL, + 0)) { + depth_bits_array[depth_buffer_factor] = 24; + stencil_bits_array[depth_buffer_factor++] = 0; + screen->d_depth_bits_last = FALSE; + } + if (p_screen->is_format_supported(p_screen, PIPE_FORMAT_S8Z24_UNORM, + PIPE_TEXTURE_2D, + PIPE_TEXTURE_USAGE_DEPTH_STENCIL, 0)) { + depth_bits_array[depth_buffer_factor] = 24; + stencil_bits_array[depth_buffer_factor++] = 8; + screen->sd_depth_bits_last = FALSE; + } else if (p_screen->is_format_supported(p_screen, PIPE_FORMAT_Z24S8_UNORM, + PIPE_TEXTURE_2D, + PIPE_TEXTURE_USAGE_DEPTH_STENCIL, + 0)) { + depth_bits_array[depth_buffer_factor] = 24; + stencil_bits_array[depth_buffer_factor++] = 8; + screen->sd_depth_bits_last = TRUE; + } msaa_samples_array[0] = 0; - - depth_buffer_factor = 3; back_buffer_factor = 3; msaa_samples_factor = 1; @@ -109,9 +135,19 @@ dri_fill_in_modes(__DRIscreenPrivate * psp, depth_buffer_factor * back_buffer_factor * msaa_samples_factor * 4; if (pixel_bits == 16) { + if (!p_screen->is_format_supported(p_screen, + PIPE_FORMAT_R5G6B5_UNORM, + PIPE_TEXTURE_2D, + PIPE_TEXTURE_USAGE_RENDER_TARGET, 0)) + return NULL; fb_format = GL_RGB; fb_type = GL_UNSIGNED_SHORT_5_6_5; } else { + if (!p_screen->is_format_supported(p_screen, + PIPE_FORMAT_A8R8G8B8_UNORM, + PIPE_TEXTURE_2D, + PIPE_TEXTURE_USAGE_RENDER_TARGET, 0)) + return NULL; fb_format = GL_BGRA; fb_type = GL_UNSIGNED_INT_8_8_8_8_REV; } @@ -126,13 +162,6 @@ dri_fill_in_modes(__DRIscreenPrivate * psp, return NULL; } - for (i = 0; configs[i]; i++) { - m = &configs[i]->modes; - if ((m->stencilBits != 0) && (m->stencilBits != stencil_bits)) { - m->visualRating = GLX_SLOW_CONFIG; - } - } - return (const const __DRIconfig **)configs; } @@ -200,7 +229,13 @@ dri_init_screen(__DRIscreenPrivate * sPriv) driParseOptionInfo(&screen->optionCache, __driConfigOptions, __driNConfigOptions); - configs = dri_fill_in_modes(sPriv, sPriv->fbBPP, 24, 8, 1); + /** + * FIXME: If the driver supports format conversion swapbuffer blits, we might + * want to support other color bit depths than the server is currently + * using. + */ + + configs = dri_fill_in_modes(screen, sPriv->fbBPP); if (!configs) goto out_no_configs; @@ -248,7 +283,7 @@ dri_init_screen2(__DRIscreenPrivate * sPriv) driParseOptionInfo(&screen->optionCache, __driConfigOptions, __driNConfigOptions); - return dri_fill_in_modes(sPriv, 4 * 8, 24, 8, 1); + return dri_fill_in_modes(screen, 32); fail: return NULL; } diff --git a/src/gallium/state_trackers/dri/dri_screen.h b/src/gallium/state_trackers/dri/dri_screen.h index 100d9e50e07..090f9fee7c5 100644 --- a/src/gallium/state_trackers/dri/dri_screen.h +++ b/src/gallium/state_trackers/dri/dri_screen.h @@ -62,6 +62,8 @@ struct dri_screen /* gallium */ struct pipe_winsys *pipe_winsys; struct pipe_screen *pipe_screen; + boolean d_depth_bits_last; + boolean sd_depth_bits_last; }; /** cast wrapper */ diff --git a/src/gallium/state_trackers/egl/Makefile b/src/gallium/state_trackers/egl/Makefile index 692a3c8b76f..e825aa718b6 100644 --- a/src/gallium/state_trackers/egl/Makefile +++ b/src/gallium/state_trackers/egl/Makefile @@ -1,29 +1,19 @@ -TARGET = libegldrm.a -CFILES = $(wildcard ./*.c) -OBJECTS = $(patsubst ./%.c,./%.o,$(CFILES)) -GALLIUMDIR = ../.. -TOP = ../../../.. +TOP = ../../../.. +include $(TOP)/configs/current -include ${TOP}/configs/current +LIBNAME = egldrm -CFLAGS := \ - -I${GALLIUMDIR}/include \ - -I${GALLIUMDIR}/auxiliary \ - -I${TOP}/src/mesa/drivers/dri/common \ - -I${TOP}/src/mesa \ - -I$(TOP)/include \ - -I$(TOP)/src/egl/main \ - ${LIBDRM_CFLAGS} \ - ${CFLAGS} +LIBRARY_INCLUDES = \ + -I$(TOP)/src/gallium/include \ + -I$(TOP)/src/gallium/auxiliary \ + -I$(TOP)/src/mesa/drivers/dri/common \ + -I$(TOP)/src/mesa \ + -I$(TOP)/include \ + -I$(TOP)/src/egl/main \ + $(shell pkg-config --cflags-only-I libdrm) -############################################# -.PHONY = all clean +C_SOURCES = $(wildcard ./*.c) -all: ${TARGET} -${TARGET}: ${OBJECTS} - ar rcs $@ $^ - -clean: - rm -rf ${OBJECTS} ${TARGET} +include ../../Makefile.template diff --git a/src/gallium/state_trackers/glx/xlib/fakeglx.c b/src/gallium/state_trackers/glx/xlib/fakeglx.c index 6df4c7d6936..23777c76f6c 100644 --- a/src/gallium/state_trackers/glx/xlib/fakeglx.c +++ b/src/gallium/state_trackers/glx/xlib/fakeglx.c @@ -97,6 +97,9 @@ struct fake_glx_context { +#define DEFAULT_DIRECT GL_TRUE + + /**********************************************************************/ /*** GLX Visual Code ***/ /**********************************************************************/ @@ -1059,7 +1062,7 @@ Fake_glXCreateContext( Display *dpy, XVisualInfo *visinfo, return NULL; } - glxCtx->glxContext.isDirect = GL_FALSE; + glxCtx->glxContext.isDirect = DEFAULT_DIRECT; glxCtx->glxContext.currentDpy = dpy; glxCtx->glxContext.xid = (XID) glxCtx; /* self pointer */ @@ -1296,9 +1299,9 @@ Fake_glXDestroyContext( Display *dpy, GLXContext ctx ) static Bool Fake_glXIsDirect( Display *dpy, GLXContext ctx ) { - (void) dpy; + struct fake_glx_context *glxCtx = (struct fake_glx_context *) ctx; (void) ctx; - return False; + return glxCtx->glxContext.isDirect; } @@ -2055,7 +2058,7 @@ Fake_glXCreateNewContext( Display *dpy, GLXFBConfig config, return NULL; } - glxCtx->glxContext.isDirect = GL_FALSE; + glxCtx->glxContext.isDirect = DEFAULT_DIRECT; glxCtx->glxContext.currentDpy = dpy; glxCtx->glxContext.xid = (XID) glxCtx; /* self pointer */ @@ -2277,7 +2280,7 @@ Fake_glXCreateContextWithConfigSGIX(Display *dpy, GLXFBConfigSGIX config, int re return NULL; } - glxCtx->glxContext.isDirect = GL_FALSE; + glxCtx->glxContext.isDirect = DEFAULT_DIRECT; glxCtx->glxContext.currentDpy = dpy; glxCtx->glxContext.xid = (XID) glxCtx; /* self pointer */ diff --git a/src/gallium/state_trackers/glx/xlib/xm_api.c b/src/gallium/state_trackers/glx/xlib/xm_api.c index a3d16516531..79c2230588f 100644 --- a/src/gallium/state_trackers/glx/xlib/xm_api.c +++ b/src/gallium/state_trackers/glx/xlib/xm_api.c @@ -1100,26 +1100,19 @@ XMesaContext XMesaGetCurrentContext( void ) - - - -/* - * Copy the back buffer to the front buffer. If there's no back buffer - * this is a no-op. +/** + * Swap front and back color buffers and have winsys display front buffer. + * If there's no front color buffer no swap actually occurs. */ PUBLIC void XMesaSwapBuffers( XMesaBuffer b ) { - struct pipe_surface *surf; + struct pipe_surface *frontLeftSurf; - /* If we're swapping the buffer associated with the current context - * we have to flush any pending rendering commands first. - */ - st_notify_swapbuffers(b->stfb); + st_swapbuffers(b->stfb, &frontLeftSurf, NULL); - st_get_framebuffer_surface(b->stfb, ST_SURFACE_BACK_LEFT, &surf); - if (surf) { - driver.display_surface(b, surf); + if (frontLeftSurf) { + driver.display_surface(b, frontLeftSurf); } xmesa_check_and_update_buffer_size(NULL, b); diff --git a/src/gallium/state_trackers/xorg/Makefile b/src/gallium/state_trackers/xorg/Makefile index a00ea3e2a4e..27a1990724d 100644 --- a/src/gallium/state_trackers/xorg/Makefile +++ b/src/gallium/state_trackers/xorg/Makefile @@ -1,29 +1,18 @@ -TARGET = libxorgtracker.a -CFILES = $(wildcard ./*.c) -OBJECTS = $(patsubst ./%.c,./%.o,$(CFILES)) -GALLIUMDIR = ../.. -TOP = ../../../.. - +TOP = ../../../.. include $(TOP)/configs/current -CFLAGS = -DHAVE_CONFIG_H \ - -g -Wall -Wimplicit-function-declaration -fPIC \ - $(shell pkg-config --cflags pixman-1 xorg-server libdrm xproto) \ - -I$(GALLIUMDIR)/include \ - -I$(GALLIUMDIR)/auxiliary \ - -I$(TOP)/src/mesa/drivers/dri/common \ - -I$(TOP)/src/mesa \ - -I$(TOP)/include \ - -I$(TOP)/src/egl/main - -############################################# - -.PHONY = all clean +LIBNAME = xorgtracker -all: $(TARGET) +LIBRARY_INCLUDES = \ + -DHAVE_CONFIG_H \ + $(shell pkg-config --cflags-only-I pixman-1 xorg-server libdrm xproto) \ + -I$(TOP)/src/gallium/include \ + -I$(TOP)/src/gallium/auxiliary \ + -I$(TOP)/include \ + -I$(TOP)/src/mesa \ + -I$(TOP)/src/mesa/drivers/dri/common \ + -I$(TOP)/src/mesa/main -$(TARGET): $(OBJECTS) - ar rcs $(TARGET) $(OBJECTS) +C_SOURCES = $(wildcard ./*.c) -clean: - rm -rf $(OBJECTS) $(TARGET) +include ../../Makefile.template |