From f8e35ebbe71eed74ccf68af8ccda4182f1edc7f0 Mon Sep 17 00:00:00 2001 From: marha Date: Tue, 7 Aug 2012 07:51:02 +0200 Subject: mesa xserver xkeyboard-config git update 7 Aug 2012 --- mesalib/docs/GL3.txt | 30 ++++ mesalib/docs/helpwanted.html | 6 +- mesalib/docs/shading.html | 2 +- mesalib/include/EGL/eglext.h | 157 +++++++++++++++++++-- mesalib/src/gallium/auxiliary/util/u_blit.c | 53 ++++--- mesalib/src/gallium/auxiliary/util/u_blitter.c | 134 +++++++++++------- mesalib/src/gallium/auxiliary/util/u_blitter.h | 40 ++++-- .../src/gallium/auxiliary/util/u_format_tests.c | 13 +- mesalib/src/gallium/auxiliary/util/u_gen_mipmap.c | 17 ++- mesalib/src/gallium/auxiliary/util/u_surface.c | 6 +- mesalib/src/mesa/drivers/dri/common/dri_util.c | 23 ++- mesalib/src/mesa/program/nvfragparse.c | 2 +- mesalib/src/mesa/state_tracker/st_atom_sampler.c | 106 +++++++------- mesalib/src/mesa/state_tracker/st_atom_texture.c | 99 +++++++------ mesalib/src/mesa/state_tracker/st_cb_bitmap.c | 25 ++-- mesalib/src/mesa/state_tracker/st_cb_clear.c | 4 +- mesalib/src/mesa/state_tracker/st_cb_drawpixels.c | 16 +-- mesalib/src/mesa/state_tracker/st_context.c | 10 +- mesalib/src/mesa/state_tracker/st_context.h | 12 +- mesalib/src/mesa/state_tracker/st_glsl_to_tgsi.cpp | 3 +- 20 files changed, 499 insertions(+), 259 deletions(-) (limited to 'mesalib') diff --git a/mesalib/docs/GL3.txt b/mesalib/docs/GL3.txt index 7c6874568..ecc5a21a7 100644 --- a/mesalib/docs/GL3.txt +++ b/mesalib/docs/GL3.txt @@ -130,5 +130,35 @@ GL_ARB_internalformat_query not started GL_ARB_map_buffer_alignment not started +GL 4.3: + +GLSL 4.3 not started +ARB_arrays_of_arrays not started +ARB_ES3_compatibility not started +ARB_clear_buffer_object not started +ARB_compute_shader started (gallium) +ARB_copy_image not started +ARB_debug_group not started +ARB_debug_label not started +ARB_debug_output DONE +ARB_debug_output2 not started +ARB_explicit_uniform_location not started +ARB_fragment_layer_viewport not started +ARB_framebuffer_no_attachments not started +ARB_internalformat_query2 not started +ARB_invalidate_subdata not started +ARB_multi_draw_indirect not started +ARB_program_interface_query not started +ARB_robust_buffer_access_behavior not started +ARB_shader_image_size not started +ARB_shader_storage_buffer_object not started +ARB_stencil_texturing not started +ARB_texture_buffer_range not started +ARB_texture_query_levels not started +ARB_texture_storage_multisample not started +ARB_texture_view not started +ARB_vertex_attrib_binding not started + + More info about these features and the work involved can be found at http://dri.freedesktop.org/wiki/MissingFunctionality diff --git a/mesalib/docs/helpwanted.html b/mesalib/docs/helpwanted.html index 6d6058eb5..e452689ac 100644 --- a/mesalib/docs/helpwanted.html +++ b/mesalib/docs/helpwanted.html @@ -37,7 +37,7 @@ deprecated starting in Mesa 8.0.
They have to be ported to DRI2 to be accepted in mesa master again.
  • Contribute more tests to -Piglit. +Piglit.
  • Automatic testing. @@ -56,8 +56,12 @@ You can find some further To-do lists here: target="_parent">LLVMpipe - todo
  • MissingFunctionality
  • +
  • R600ToDo
  • R300ToDo
  • +
  • i915g TODO
  • diff --git a/mesalib/docs/shading.html b/mesalib/docs/shading.html index a9b7cfc4b..17cf35c22 100644 --- a/mesalib/docs/shading.html +++ b/mesalib/docs/shading.html @@ -243,7 +243,7 @@ regressions.

    -The Piglit project +The Piglit project has many GLSL tests and the Glean glsl1 test tests GLSL features. diff --git a/mesalib/include/EGL/eglext.h b/mesalib/include/EGL/eglext.h index a7ea2ea2f..815859d8e 100644 --- a/mesalib/include/EGL/eglext.h +++ b/mesalib/include/EGL/eglext.h @@ -6,7 +6,7 @@ extern "C" { #endif /* -** Copyright (c) 2007-2010 The Khronos Group Inc. +** Copyright (c) 2007-2012 The Khronos Group Inc. ** ** Permission is hereby granted, free of charge, to any person obtaining a ** copy of this software and/or associated documentation files (the @@ -34,8 +34,8 @@ extern "C" { /* Header file version number */ /* Current version at http://www.khronos.org/registry/egl/ */ -/* $Revision: 15052 $ on $Date: 2011-07-06 17:43:46 -0700 (Wed, 06 Jul 2011) $ */ -#define EGL_EGLEXT_VERSION 10 +/* $Revision: 18699 $ on $Date: 2012-07-31 03:04:59 -0700 (Tue, 31 Jul 2012) $ */ +#define EGL_EGLEXT_VERSION 14 #ifndef EGL_KHR_config_attribs #define EGL_KHR_config_attribs 1 @@ -178,15 +178,15 @@ typedef EGLBoolean (EGLAPIENTRYP PFNEGLGETSYNCATTRIBKHRPROC) (EGLDisplay dpy, EG #ifndef EGL_NV_coverage_sample #define EGL_NV_coverage_sample 1 -#define EGL_COVERAGE_BUFFERS_NV 0x30E0 -#define EGL_COVERAGE_SAMPLES_NV 0x30E1 +#define EGL_COVERAGE_BUFFERS_NV 0x30E0 +#define EGL_COVERAGE_SAMPLES_NV 0x30E1 #endif #ifndef EGL_NV_depth_nonlinear #define EGL_NV_depth_nonlinear 1 -#define EGL_DEPTH_ENCODING_NV 0x30E2 +#define EGL_DEPTH_ENCODING_NV 0x30E2 #define EGL_DEPTH_ENCODING_NONE_NV 0 -#define EGL_DEPTH_ENCODING_NONLINEAR_NV 0x30E3 +#define EGL_DEPTH_ENCODING_NONLINEAR_NV 0x30E3 #endif #if KHRONOS_SUPPORT_INT64 /* EGLTimeNV requires 64-bit uint support */ @@ -208,12 +208,12 @@ typedef EGLBoolean (EGLAPIENTRYP PFNEGLGETSYNCATTRIBKHRPROC) (EGLDisplay dpy, EG typedef void* EGLSyncNV; typedef khronos_utime_nanoseconds_t EGLTimeNV; #ifdef EGL_EGLEXT_PROTOTYPES -EGLSyncNV eglCreateFenceSyncNV (EGLDisplay dpy, EGLenum condition, const EGLint *attrib_list); -EGLBoolean eglDestroySyncNV (EGLSyncNV sync); -EGLBoolean eglFenceNV (EGLSyncNV sync); -EGLint eglClientWaitSyncNV (EGLSyncNV sync, EGLint flags, EGLTimeNV timeout); -EGLBoolean eglSignalSyncNV (EGLSyncNV sync, EGLenum mode); -EGLBoolean eglGetSyncAttribNV (EGLSyncNV sync, EGLint attribute, EGLint *value); +EGLAPI EGLSyncNV EGLAPIENTRY eglCreateFenceSyncNV (EGLDisplay dpy, EGLenum condition, const EGLint *attrib_list); +EGLAPI EGLBoolean EGLAPIENTRY eglDestroySyncNV (EGLSyncNV sync); +EGLAPI EGLBoolean EGLAPIENTRY eglFenceNV (EGLSyncNV sync); +EGLAPI EGLint EGLAPIENTRY eglClientWaitSyncNV (EGLSyncNV sync, EGLint flags, EGLTimeNV timeout); +EGLAPI EGLBoolean EGLAPIENTRY eglSignalSyncNV (EGLSyncNV sync, EGLenum mode); +EGLAPI EGLBoolean EGLAPIENTRY eglGetSyncAttribNV (EGLSyncNV sync, EGLint attribute, EGLint *value); #endif /* EGL_EGLEXT_PROTOTYPES */ typedef EGLSyncNV (EGLAPIENTRYP PFNEGLCREATEFENCESYNCNVPROC) (EGLDisplay dpy, EGLenum condition, const EGLint *attrib_list); typedef EGLBoolean (EGLAPIENTRYP PFNEGLDESTROYSYNCNVPROC) (EGLSyncNV sync); @@ -313,7 +313,7 @@ typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYSURFACEPOINTERANGLEPROC) (EGLDisplay #define EGL_COVERAGE_SAMPLE_RESOLVE_NONE_NV 0x3133 #endif -#if KHRONOS_SUPPORT_INT64 /* EGLTimeKHR requires 64-bit uint support */ +#if KHRONOS_SUPPORT_INT64 /* EGLuint64NV requires 64-bit uint support */ #ifndef EGL_NV_system_time #define EGL_NV_system_time 1 @@ -328,6 +328,135 @@ typedef EGLuint64NV (EGLAPIENTRYP PFNEGLGETSYSTEMTIMENVPROC) (void); #endif #endif +#if KHRONOS_SUPPORT_INT64 /* EGLuint64KHR requires 64-bit uint support */ +#ifndef EGL_KHR_stream +#define EGL_KHR_stream 1 +typedef void* EGLStreamKHR; +typedef khronos_uint64_t EGLuint64KHR; +#define EGL_NO_STREAM_KHR ((EGLStreamKHR)0) +#define EGL_CONSUMER_LATENCY_USEC_KHR 0x3210 +#define EGL_PRODUCER_FRAME_KHR 0x3212 +#define EGL_CONSUMER_FRAME_KHR 0x3213 +#define EGL_STREAM_STATE_KHR 0x3214 +#define EGL_STREAM_STATE_CREATED_KHR 0x3215 +#define EGL_STREAM_STATE_CONNECTING_KHR 0x3216 +#define EGL_STREAM_STATE_EMPTY_KHR 0x3217 +#define EGL_STREAM_STATE_NEW_FRAME_AVAILABLE_KHR 0x3218 +#define EGL_STREAM_STATE_OLD_FRAME_AVAILABLE_KHR 0x3219 +#define EGL_STREAM_STATE_DISCONNECTED_KHR 0x321A +#define EGL_BAD_STREAM_KHR 0x321B +#define EGL_BAD_STATE_KHR 0x321C +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLStreamKHR EGLAPIENTRY eglCreateStreamKHR(EGLDisplay dpy, const EGLint *attrib_list); +EGLAPI EGLBoolean EGLAPIENTRY eglDestroyStreamKHR(EGLDisplay dpy, EGLStreamKHR stream); +EGLAPI EGLBoolean EGLAPIENTRY eglStreamAttribKHR(EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLint value); +EGLAPI EGLBoolean EGLAPIENTRY eglQueryStreamKHR(EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLint *value); +EGLAPI EGLBoolean EGLAPIENTRY eglQueryStreamu64KHR(EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLuint64KHR *value); +#endif /* EGL_EGLEXT_PROTOTYPES */ +typedef EGLStreamKHR (EGLAPIENTRYP PFNEGLCREATESTREAMKHRPROC)(EGLDisplay dpy, const EGLint *attrib_list); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLDESTROYSTREAMKHRPROC)(EGLDisplay dpy, EGLStreamKHR stream); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLSTREAMATTRIBKHRPROC)(EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLint value); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYSTREAMKHRPROC)(EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLint *value); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYSTREAMU64KHRPROC)(EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLuint64KHR *value); +#endif +#endif + +#ifdef EGL_KHR_stream /* Requires KHR_stream extension */ +#ifndef EGL_KHR_stream_consumer_gltexture +#define EGL_KHR_stream_consumer_gltexture 1 +#define EGL_CONSUMER_ACQUIRE_TIMEOUT_USEC_KHR 0x321E +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLBoolean EGLAPIENTRY eglStreamConsumerGLTextureExternalKHR(EGLDisplay dpy, EGLStreamKHR stream); +EGLAPI EGLBoolean EGLAPIENTRY eglStreamConsumerAcquireKHR(EGLDisplay dpy, EGLStreamKHR stream); +EGLAPI EGLBoolean EGLAPIENTRY eglStreamConsumerReleaseKHR(EGLDisplay dpy, EGLStreamKHR stream); +#endif /* EGL_EGLEXT_PROTOTYPES */ +typedef EGLBoolean (EGLAPIENTRYP PFNEGLSTREAMCONSUMERGLTEXTUREEXTERNALKHRPROC)(EGLDisplay dpy, EGLStreamKHR stream); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLSTREAMCONSUMERACQUIREKHRPROC)(EGLDisplay dpy, EGLStreamKHR stream); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLSTREAMCONSUMERRELEASEKHRPROC)(EGLDisplay dpy, EGLStreamKHR stream); +#endif +#endif + +#ifdef EGL_KHR_stream /* Requires KHR_stream extension */ +#ifndef EGL_KHR_stream_producer_eglsurface +#define EGL_KHR_stream_producer_eglsurface 1 +#define EGL_STREAM_BIT_KHR 0x0800 +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLSurface EGLAPIENTRY eglCreateStreamProducerSurfaceKHR(EGLDisplay dpy, EGLConfig config, EGLStreamKHR stream, const EGLint *attrib_list); +#endif /* EGL_EGLEXT_PROTOTYPES */ +typedef EGLSurface (EGLAPIENTRYP PFNEGLCREATESTREAMPRODUCERSURFACEKHRPROC)(EGLDisplay dpy, EGLConfig config, EGLStreamKHR stream, const EGLint *attrib_list); +#endif +#endif + +#ifdef EGL_KHR_stream /* Requires KHR_stream extension */ +#ifndef EGL_KHR_stream_producer_aldatalocator +#define EGL_KHR_stream_producer_aldatalocator 1 +#endif +#endif + +#ifdef EGL_KHR_stream /* Requires KHR_stream extension */ +#ifndef EGL_KHR_stream_fifo +#define EGL_KHR_stream_fifo 1 +/* reuse EGLTimeKHR */ +#define EGL_STREAM_FIFO_LENGTH_KHR 0x31FC +#define EGL_STREAM_TIME_NOW_KHR 0x31FD +#define EGL_STREAM_TIME_CONSUMER_KHR 0x31FE +#define EGL_STREAM_TIME_PRODUCER_KHR 0x31FF +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLBoolean EGLAPIENTRY eglQueryStreamTimeKHR(EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLTimeKHR *value); +#endif /* EGL_EGLEXT_PROTOTYPES */ +typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYSTREAMTIMEKHRPROC)(EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLTimeKHR *value); +#endif +#endif + +#ifndef EGL_EXT_create_context_robustness +#define EGL_EXT_create_context_robustness 1 +#define EGL_CONTEXT_OPENGL_ROBUST_ACCESS_EXT 0x30BF +#define EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_EXT 0x3138 +#define EGL_NO_RESET_NOTIFICATION_EXT 0x31BE +#define EGL_LOSE_CONTEXT_ON_RESET_EXT 0x31BF +#endif + +#ifndef EGL_ANGLE_d3d_share_handle_client_buffer +#define EGL_ANGLE_d3d_share_handle_client_buffer 1 +/* reuse EGL_D3D_TEXTURE_2D_SHARE_HANDLE_ANGLE */ +#endif + +#ifndef EGL_KHR_create_context +#define EGL_KHR_create_context 1 +#define EGL_CONTEXT_MAJOR_VERSION_KHR EGL_CONTEXT_CLIENT_VERSION +#define EGL_CONTEXT_MINOR_VERSION_KHR 0x30FB +#define EGL_CONTEXT_FLAGS_KHR 0x30FC +#define EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR 0x30FD +#define EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_KHR 0x31BD +#define EGL_NO_RESET_NOTIFICATION_KHR 0x31BE +#define EGL_LOSE_CONTEXT_ON_RESET_KHR 0x31BF +#define EGL_CONTEXT_OPENGL_DEBUG_BIT_KHR 0x00000001 +#define EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR 0x00000002 +#define EGL_CONTEXT_OPENGL_ROBUST_ACCESS_BIT_KHR 0x00000004 +#define EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT_KHR 0x00000001 +#define EGL_CONTEXT_OPENGL_COMPATIBILITY_PROFILE_BIT_KHR 0x00000002 +#endif + +#ifndef EGL_KHR_surfaceless_context +#define EGL_KHR_surfaceless_context 1 +/* No tokens/entry points, just relaxes an error condition */ +#endif + +#ifdef EGL_KHR_stream /* Requires KHR_stream extension */ +#ifndef EGL_KHR_stream_cross_process_fd +#define EGL_KHR_stream_cross_process_fd 1 +typedef int EGLNativeFileDescriptorKHR; +#define EGL_NO_FILE_DESCRIPTOR_KHR ((EGLNativeFileDescriptorKHR)(-1)) +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLNativeFileDescriptorKHR EGLAPIENTRY eglGetStreamFileDescriptorKHR(EGLDisplay dpy, EGLStreamKHR stream); +EGLAPI EGLStreamKHR EGLAPIENTRY eglCreateStreamFromFileDescriptorKHR(EGLDisplay dpy, EGLNativeFileDescriptorKHR file_descriptor); +#endif /* EGL_EGLEXT_PROTOTYPES */ +typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYSTREAMTIMEKHRPROC)(EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLTimeKHR *value); +typedef EGLNativeFileDescriptorKHR (EGLAPIENTRYP PFNEGLGETSTREAMFILEDESCRIPTORKHRPROC)(EGLDisplay dpy, EGLStreamKHR stream); +typedef EGLStreamKHR (EGLAPIENTRYP PFNEGLCREATESTREAMFROMFILEDESCRIPTORKHRPROC)(EGLDisplay dpy, EGLNativeFileDescriptorKHR file_descriptor); +#endif +#endif + #include #ifdef __cplusplus diff --git a/mesalib/src/gallium/auxiliary/util/u_blit.c b/mesalib/src/gallium/auxiliary/util/u_blit.c index b52f4c092..3887e65fb 100644 --- a/mesalib/src/gallium/auxiliary/util/u_blit.c +++ b/mesalib/src/gallium/auxiliary/util/u_blit.c @@ -478,10 +478,11 @@ util_blit_pixels(struct blit_state *ctx, /* * Check for simple case: no format conversion, no flipping, no stretching, - * no overlapping. + * no overlapping, same number of samples. * Filter mode should not matter since there's no stretching. */ if (formats_compatible(src_format, dst_format) && + src_tex->nr_samples == dst->texture->nr_samples && is_stencil == blit_stencil && is_depth == blit_depth && srcX0 < srcX1 && @@ -506,6 +507,12 @@ util_blit_pixels(struct blit_state *ctx, return; } + /* XXX Reading multisample textures is unimplemented. */ + assert(src_tex->nr_samples <= 1); + if (src_tex->nr_samples > 1) { + return; + } + /* It's a mistake to call this function with a stencil format and * without shader stencil export. We don't do software fallbacks here. * Ignore stencil and only copy depth. @@ -648,8 +655,9 @@ util_blit_pixels(struct blit_state *ctx, cso_save_blend(ctx->cso); cso_save_depth_stencil_alpha(ctx->cso); cso_save_rasterizer(ctx->cso); - cso_save_samplers(ctx->cso); - cso_save_fragment_sampler_views(ctx->cso); + cso_save_sample_mask(ctx->cso); + cso_save_samplers(ctx->cso, PIPE_SHADER_FRAGMENT); + cso_save_sampler_views(ctx->cso, PIPE_SHADER_FRAGMENT); cso_save_stream_outputs(ctx->cso); cso_save_viewport(ctx->cso); cso_save_framebuffer(ctx->cso); @@ -665,6 +673,7 @@ util_blit_pixels(struct blit_state *ctx, else cso_set_blend(ctx->cso, &ctx->blend_keep_color); + cso_set_sample_mask(ctx->cso, ~0); cso_set_rasterizer(ctx->cso, &ctx->rasterizer); cso_set_vertex_elements(ctx->cso, 2, ctx->velem); cso_set_stream_outputs(ctx->cso, 0, NULL, 0); @@ -680,17 +689,17 @@ util_blit_pixels(struct blit_state *ctx, * we blit. */ if (blit_depth && blit_stencil) { - cso_single_sampler(ctx->cso, 0, &ctx->sampler); + cso_single_sampler(ctx->cso, PIPE_SHADER_FRAGMENT, 0, &ctx->sampler); /* don't filter stencil */ ctx->sampler.min_img_filter = PIPE_TEX_FILTER_NEAREST; ctx->sampler.mag_img_filter = PIPE_TEX_FILTER_NEAREST; - cso_single_sampler(ctx->cso, 1, &ctx->sampler); + cso_single_sampler(ctx->cso, PIPE_SHADER_FRAGMENT, 1, &ctx->sampler); cso_set_depth_stencil_alpha(ctx->cso, &ctx->dsa_write_depthstencil); set_depthstencil_fragment_shader(ctx, sampler_view->texture->target); } else if (blit_depth) { - cso_single_sampler(ctx->cso, 0, &ctx->sampler); + cso_single_sampler(ctx->cso, PIPE_SHADER_FRAGMENT, 0, &ctx->sampler); cso_set_depth_stencil_alpha(ctx->cso, &ctx->dsa_write_depth); set_depth_fragment_shader(ctx, sampler_view->texture->target); } @@ -698,17 +707,17 @@ util_blit_pixels(struct blit_state *ctx, /* don't filter stencil */ ctx->sampler.min_img_filter = PIPE_TEX_FILTER_NEAREST; ctx->sampler.mag_img_filter = PIPE_TEX_FILTER_NEAREST; - cso_single_sampler(ctx->cso, 0, &ctx->sampler); + cso_single_sampler(ctx->cso, PIPE_SHADER_FRAGMENT, 0, &ctx->sampler); cso_set_depth_stencil_alpha(ctx->cso, &ctx->dsa_write_stencil); set_stencil_fragment_shader(ctx, sampler_view->texture->target); } else { /* color */ - cso_single_sampler(ctx->cso, 0, &ctx->sampler); + cso_single_sampler(ctx->cso, PIPE_SHADER_FRAGMENT, 0, &ctx->sampler); cso_set_depth_stencil_alpha(ctx->cso, &ctx->dsa_keep_depthstencil); set_fragment_shader(ctx, writemask, sampler_view->texture->target); } - cso_single_sampler_done(ctx->cso); + cso_single_sampler_done(ctx->cso, PIPE_SHADER_FRAGMENT); /* textures */ if (blit_depth && blit_stencil) { @@ -722,12 +731,12 @@ util_blit_pixels(struct blit_state *ctx, views[0] = sampler_view; views[1] = pipe->create_sampler_view(pipe, views[0]->texture, &templ); - cso_set_fragment_sampler_views(ctx->cso, 2, views); + cso_set_sampler_views(ctx->cso, PIPE_SHADER_FRAGMENT, 2, views); pipe_sampler_view_reference(&views[1], NULL); } else { - cso_set_fragment_sampler_views(ctx->cso, 1, &sampler_view); + cso_set_sampler_views(ctx->cso, PIPE_SHADER_FRAGMENT, 1, &sampler_view); } /* viewport */ @@ -777,8 +786,9 @@ util_blit_pixels(struct blit_state *ctx, cso_restore_blend(ctx->cso); cso_restore_depth_stencil_alpha(ctx->cso); cso_restore_rasterizer(ctx->cso); - cso_restore_samplers(ctx->cso); - cso_restore_fragment_sampler_views(ctx->cso); + cso_restore_sample_mask(ctx->cso); + cso_restore_samplers(ctx->cso, PIPE_SHADER_FRAGMENT); + cso_restore_sampler_views(ctx->cso, PIPE_SHADER_FRAGMENT); cso_restore_viewport(ctx->cso); cso_restore_framebuffer(ctx->cso); cso_restore_fragment_shader(ctx->cso); @@ -849,8 +859,9 @@ util_blit_pixels_tex(struct blit_state *ctx, cso_save_blend(ctx->cso); cso_save_depth_stencil_alpha(ctx->cso); cso_save_rasterizer(ctx->cso); - cso_save_samplers(ctx->cso); - cso_save_fragment_sampler_views(ctx->cso); + cso_save_sample_mask(ctx->cso); + cso_save_samplers(ctx->cso, PIPE_SHADER_FRAGMENT); + cso_save_sampler_views(ctx->cso, PIPE_SHADER_FRAGMENT); cso_save_stream_outputs(ctx->cso); cso_save_viewport(ctx->cso); cso_save_framebuffer(ctx->cso); @@ -863,6 +874,7 @@ util_blit_pixels_tex(struct blit_state *ctx, /* set misc state we care about */ cso_set_blend(ctx->cso, &ctx->blend_write_color); cso_set_depth_stencil_alpha(ctx->cso, &ctx->dsa_keep_depthstencil); + cso_set_sample_mask(ctx->cso, ~0); cso_set_rasterizer(ctx->cso, &ctx->rasterizer); cso_set_vertex_elements(ctx->cso, 2, ctx->velem); cso_set_stream_outputs(ctx->cso, 0, NULL, 0); @@ -871,8 +883,8 @@ util_blit_pixels_tex(struct blit_state *ctx, ctx->sampler.normalized_coords = normalized; ctx->sampler.min_img_filter = filter; ctx->sampler.mag_img_filter = filter; - cso_single_sampler(ctx->cso, 0, &ctx->sampler); - cso_single_sampler_done(ctx->cso); + cso_single_sampler(ctx->cso, PIPE_SHADER_FRAGMENT, 0, &ctx->sampler); + cso_single_sampler_done(ctx->cso, PIPE_SHADER_FRAGMENT); /* viewport */ ctx->viewport.scale[0] = 0.5f * dst->width; @@ -886,7 +898,7 @@ util_blit_pixels_tex(struct blit_state *ctx, cso_set_viewport(ctx->cso, &ctx->viewport); /* texture */ - cso_set_fragment_sampler_views(ctx->cso, 1, &src_sampler_view); + cso_set_sampler_views(ctx->cso, PIPE_SHADER_FRAGMENT, 1, &src_sampler_view); /* shaders */ set_fragment_shader(ctx, TGSI_WRITEMASK_XYZW, @@ -921,8 +933,9 @@ util_blit_pixels_tex(struct blit_state *ctx, cso_restore_blend(ctx->cso); cso_restore_depth_stencil_alpha(ctx->cso); cso_restore_rasterizer(ctx->cso); - cso_restore_samplers(ctx->cso); - cso_restore_fragment_sampler_views(ctx->cso); + cso_restore_sample_mask(ctx->cso); + cso_restore_samplers(ctx->cso, PIPE_SHADER_FRAGMENT); + cso_restore_sampler_views(ctx->cso, PIPE_SHADER_FRAGMENT); cso_restore_viewport(ctx->cso); cso_restore_framebuffer(ctx->cso); cso_restore_fragment_shader(ctx->cso); diff --git a/mesalib/src/gallium/auxiliary/util/u_blitter.c b/mesalib/src/gallium/auxiliary/util/u_blitter.c index b31ac2d5c..fa71f25ea 100644 --- a/mesalib/src/gallium/auxiliary/util/u_blitter.c +++ b/mesalib/src/gallium/auxiliary/util/u_blitter.c @@ -439,6 +439,12 @@ static void blitter_restore_fragment_states(struct blitter_context_priv *ctx) pipe->bind_blend_state(pipe, ctx->base.saved_blend_state); ctx->base.saved_blend_state = INVALID_PTR; + /* Sample mask. */ + if (ctx->base.is_sample_mask_saved) { + pipe->set_sample_mask(pipe, ctx->base.saved_sample_mask); + ctx->base.is_sample_mask_saved = FALSE; + } + /* Miscellaneous states. */ /* XXX check whether these are saved and whether they need to be restored * (depending on the operation) */ @@ -848,6 +854,7 @@ static void util_blitter_clear_custom(struct blitter_context *blitter, pipe->bind_vertex_elements_state(pipe, ctx->velem_state); } pipe->bind_fs_state(pipe, blitter_get_fs_col(ctx, num_cbufs, int_format)); + pipe->set_sample_mask(pipe, ~0); blitter_set_common_draw_rect_state(ctx); blitter_set_dst_dimensions(ctx, width, height); @@ -925,66 +932,89 @@ void util_blitter_default_src_texture(struct pipe_sampler_view *src_templ, src_templ->swizzle_a = PIPE_SWIZZLE_ALPHA; } +boolean util_blitter_is_copy_supported(struct blitter_context *blitter, + const struct pipe_resource *dst, + const struct pipe_resource *src, + unsigned mask) +{ + struct blitter_context_priv *ctx = (struct blitter_context_priv*)blitter; + struct pipe_screen *screen = ctx->base.pipe->screen; + + if (dst) { + unsigned bind; + boolean is_stencil; + const struct util_format_description *desc = + util_format_description(dst->format); + + is_stencil = util_format_has_stencil(desc); + + /* Stencil export must be supported for stencil copy. */ + if ((mask & PIPE_MASK_S) && is_stencil && !ctx->has_stencil_export) { + return FALSE; + } + + if (is_stencil || util_format_has_depth(desc)) + bind = PIPE_BIND_DEPTH_STENCIL; + else + bind = PIPE_BIND_RENDER_TARGET; + + if (!screen->is_format_supported(screen, dst->format, dst->target, + dst->nr_samples, bind)) { + return FALSE; + } + } + + if (src) { + if (!screen->is_format_supported(screen, src->format, src->target, + src->nr_samples, PIPE_BIND_SAMPLER_VIEW)) { + return FALSE; + } + + /* Check stencil sampler support for stencil copy. */ + if (util_format_has_stencil(util_format_description(src->format))) { + enum pipe_format stencil_format = + util_format_stencil_only(src->format); + assert(stencil_format != PIPE_FORMAT_NONE); + + if (stencil_format != src->format && + !screen->is_format_supported(screen, stencil_format, src->target, + src->nr_samples, PIPE_BIND_SAMPLER_VIEW)) { + return FALSE; + } + } + } + + return TRUE; +} + void util_blitter_copy_texture(struct blitter_context *blitter, struct pipe_resource *dst, - unsigned dstlevel, + unsigned dst_level, unsigned dstx, unsigned dsty, unsigned dstz, struct pipe_resource *src, - unsigned srclevel, - const struct pipe_box *srcbox, - boolean ignore_stencil) + unsigned src_level, + const struct pipe_box *srcbox) { struct blitter_context_priv *ctx = (struct blitter_context_priv*)blitter; struct pipe_context *pipe = ctx->base.pipe; - struct pipe_screen *screen = pipe->screen; struct pipe_surface *dst_view, dst_templ; struct pipe_sampler_view src_templ, *src_view; - unsigned bind; - boolean is_stencil, is_depth; - const struct util_format_description *src_desc = - util_format_description(src->format); - /* Give up if textures are not set. */ assert(dst && src); - if (!dst || !src) - return; - assert(src->target < PIPE_MAX_TEXTURE_TYPES); - /* Is this a ZS format? */ - is_depth = util_format_has_depth(src_desc); - is_stencil = util_format_has_stencil(src_desc); - - if (is_depth || is_stencil) - bind = PIPE_BIND_DEPTH_STENCIL; - else - bind = PIPE_BIND_RENDER_TARGET; - - /* Check if we can sample from and render to the surfaces. */ - /* (assuming copying a stencil buffer is not possible) */ - if ((!ignore_stencil && is_stencil && !ctx->has_stencil_export) || - !screen->is_format_supported(screen, dst->format, dst->target, - dst->nr_samples, bind) || - !screen->is_format_supported(screen, src->format, src->target, - src->nr_samples, PIPE_BIND_SAMPLER_VIEW)) { - blitter_set_running_flag(ctx); - util_resource_copy_region(pipe, dst, dstlevel, dstx, dsty, dstz, - src, srclevel, srcbox); - blitter_unset_running_flag(ctx); - return; - } - /* Initialize the surface. */ - util_blitter_default_dst_texture(&dst_templ, dst, dstlevel, dstz, srcbox); + util_blitter_default_dst_texture(&dst_templ, dst, dst_level, dstz, srcbox); dst_view = pipe->create_surface(pipe, dst, &dst_templ); /* Initialize the sampler view. */ - util_blitter_default_src_texture(&src_templ, src, srclevel); + util_blitter_default_src_texture(&src_templ, src, src_level); src_view = pipe->create_sampler_view(pipe, src, &src_templ); /* Copy. */ util_blitter_copy_texture_view(blitter, dst_view, dstx, dsty, src_view, - srcbox, src->width0, src->height0); + srcbox, src->width0, src->height0, + PIPE_MASK_RGBAZS); pipe_surface_reference(&dst_view, NULL); pipe_sampler_view_reference(&src_view, NULL); @@ -995,7 +1025,8 @@ void util_blitter_copy_texture_view(struct blitter_context *blitter, unsigned dstx, unsigned dsty, struct pipe_sampler_view *src, const struct pipe_box *srcbox, - unsigned src_width0, unsigned src_height0) + unsigned src_width0, unsigned src_height0, + unsigned mask) { struct blitter_context_priv *ctx = (struct blitter_context_priv*)blitter; struct pipe_context *pipe = ctx->base.pipe; @@ -1003,19 +1034,19 @@ void util_blitter_copy_texture_view(struct blitter_context *blitter, enum pipe_texture_target src_target = src->texture->target; unsigned width = srcbox->width; unsigned height = srcbox->height; - boolean is_stencil, is_depth; + boolean blit_stencil, blit_depth; const struct util_format_description *src_desc = util_format_description(src->format); - is_depth = util_format_has_depth(src_desc); - is_stencil = util_format_has_stencil(src_desc); + blit_depth = util_format_has_depth(src_desc) && (mask & PIPE_MASK_Z); + blit_stencil = util_format_has_stencil(src_desc) && (mask & PIPE_MASK_S); /* If you want a fallback for stencil copies, * use util_blitter_copy_texture. */ - if (is_stencil && !ctx->has_stencil_export) { - is_stencil = FALSE; + if (blit_stencil && !ctx->has_stencil_export) { + blit_stencil = FALSE; - if (!is_depth) + if (!blit_depth) return; } @@ -1039,15 +1070,15 @@ void util_blitter_copy_texture_view(struct blitter_context *blitter, fb_state.width = dst->width; fb_state.height = dst->height; - if (is_depth || is_stencil) { + if (blit_depth || blit_stencil) { pipe->bind_blend_state(pipe, ctx->blend_keep_color); - if (is_depth && is_stencil) { + if (blit_depth && blit_stencil) { pipe->bind_depth_stencil_alpha_state(pipe, ctx->dsa_write_depth_stencil); pipe->bind_fs_state(pipe, blitter_get_fs_texfetch_depthstencil(ctx, src_target)); - } else if (is_depth) { + } else if (blit_depth) { pipe->bind_depth_stencil_alpha_state(pipe, ctx->dsa_write_depth_keep_stencil); pipe->bind_fs_state(pipe, @@ -1072,7 +1103,7 @@ void util_blitter_copy_texture_view(struct blitter_context *blitter, fb_state.zsbuf = 0; } - if (is_depth && is_stencil) { + if (blit_depth && blit_stencil) { /* Setup two samplers, one for depth and the other one for stencil. */ struct pipe_sampler_view templ; struct pipe_sampler_view *views[2]; @@ -1096,6 +1127,7 @@ void util_blitter_copy_texture_view(struct blitter_context *blitter, pipe->bind_vertex_elements_state(pipe, ctx->velem_state); pipe->set_framebuffer_state(pipe, &fb_state); + pipe->set_sample_mask(pipe, ~0); blitter_set_common_draw_rect_state(ctx); blitter_set_dst_dimensions(ctx, dst->width, dst->height); @@ -1183,6 +1215,7 @@ void util_blitter_clear_render_target(struct blitter_context *blitter, fb_state.cbufs[0] = dstsurf; fb_state.zsbuf = 0; pipe->set_framebuffer_state(pipe, &fb_state); + pipe->set_sample_mask(pipe, ~0); blitter_set_common_draw_rect_state(ctx); blitter_set_dst_dimensions(ctx, dstsurf->width, dstsurf->height); @@ -1248,6 +1281,7 @@ void util_blitter_clear_depth_stencil(struct blitter_context *blitter, fb_state.cbufs[0] = 0; fb_state.zsbuf = dstsurf; pipe->set_framebuffer_state(pipe, &fb_state); + pipe->set_sample_mask(pipe, ~0); blitter_set_common_draw_rect_state(ctx); blitter_set_dst_dimensions(ctx, dstsurf->width, dstsurf->height); diff --git a/mesalib/src/gallium/auxiliary/util/u_blitter.h b/mesalib/src/gallium/auxiliary/util/u_blitter.h index 2db984c8a..7600391c5 100644 --- a/mesalib/src/gallium/auxiliary/util/u_blitter.h +++ b/mesalib/src/gallium/auxiliary/util/u_blitter.h @@ -94,6 +94,8 @@ struct blitter_context struct pipe_framebuffer_state saved_fb_state; /**< framebuffer state */ struct pipe_stencil_ref saved_stencil_ref; /**< stencil ref */ struct pipe_viewport_state saved_viewport; + boolean is_sample_mask_saved; + unsigned saved_sample_mask; int saved_num_sampler_states; void *saved_sampler_states[PIPE_MAX_SAMPLERS]; @@ -158,6 +160,16 @@ void util_blitter_clear_depth_custom(struct blitter_context *blitter, unsigned width, unsigned height, double depth, void *custom_dsa); +/** + * Check if the blitter (with the help of the driver) can blit between + * the two resources. + * The mask is a combination of the PIPE_MASK_* flags. + * Set to PIPE_MASK_RGBAZS if unsure. + */ +boolean util_blitter_is_copy_supported(struct blitter_context *blitter, + const struct pipe_resource *dst, + const struct pipe_resource *src, + unsigned mask); /** * Copy a block of pixels from one surface to another. * @@ -166,13 +178,6 @@ void util_blitter_clear_depth_custom(struct blitter_context *blitter, * a software fallback path is taken and both surfaces must be of the same * format. * - * The same holds for depth-stencil formats with the exception that stencil - * cannot be copied unless you set ignore_stencil to FALSE. In that case, - * a software fallback path is taken and both surfaces must be of the same - * format. If the shader stencil export is supported, stencil copy is always - * accelerated. - * - * Use pipe_screen->is_format_supported to know your options. * * These states must be saved in the blitter in addition to the state objects * already required to be saved: @@ -185,12 +190,11 @@ void util_blitter_clear_depth_custom(struct blitter_context *blitter, */ void util_blitter_copy_texture(struct blitter_context *blitter, struct pipe_resource *dst, - unsigned dstlevel, + unsigned dst_level, unsigned dstx, unsigned dsty, unsigned dstz, struct pipe_resource *src, - unsigned srclevel, - const struct pipe_box *srcbox, - boolean ignore_stencil); + unsigned src_level, + const struct pipe_box *srcbox); /** * Same as util_blitter_copy_texture, but dst and src are pipe_surface and @@ -207,6 +211,9 @@ void util_blitter_copy_texture(struct blitter_context *blitter, * coordinates. The dst dimensions are supplied through pipe_surface::width * and height. * + * The mask is a combination of the PIPE_MASK_* flags. + * Set to PIPE_MASK_RGBAZS if unsure. + * * NOTE: There are no checks whether the blit is actually supported. */ void util_blitter_copy_texture_view(struct blitter_context *blitter, @@ -214,7 +221,8 @@ void util_blitter_copy_texture_view(struct blitter_context *blitter, unsigned dstx, unsigned dsty, struct pipe_sampler_view *src, const struct pipe_box *srcbox, - unsigned src_width0, unsigned src_height0); + unsigned src_width0, unsigned src_height0, + unsigned mask); /** * Helper function to initialize a view for copy_texture_view. @@ -418,6 +426,14 @@ util_blitter_save_so_targets(struct blitter_context *blitter, targets[i]); } +static INLINE void +util_blitter_save_sample_mask(struct blitter_context *blitter, + unsigned sample_mask) +{ + blitter->is_sample_mask_saved = TRUE; + blitter->saved_sample_mask = sample_mask; +} + #ifdef __cplusplus } #endif diff --git a/mesalib/src/gallium/auxiliary/util/u_format_tests.c b/mesalib/src/gallium/auxiliary/util/u_format_tests.c index d34860886..26e7acb62 100644 --- a/mesalib/src/gallium/auxiliary/util/u_format_tests.c +++ b/mesalib/src/gallium/auxiliary/util/u_format_tests.c @@ -26,6 +26,7 @@ **************************************************************************/ +#include #include #include "pipe/p_config.h" @@ -66,14 +67,6 @@ {{ 0, 0, 0, 0}, { 0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}}} -#ifdef __GNUC__ -#define NAN __builtin_nan("") -#define INF __builtin_inf() -#else -#define NAN (0.0 / 0.0) -#define INF (1.0 / 0.0) -#endif - /** * Test cases. * @@ -911,8 +904,8 @@ util_format_test_cases[] = {PIPE_FORMAT_R16_FLOAT, PACKED_1x16(0xffff), PACKED_1x16(0xffff), UNPACKED_1x1( -NAN, 0.0, 0.0, 1.0)}, /* Inf */ - {PIPE_FORMAT_R16_FLOAT, PACKED_1x16(0xffff), PACKED_1x16(0x7c00), UNPACKED_1x1( INF, 0.0, 0.0, 1.0)}, - {PIPE_FORMAT_R16_FLOAT, PACKED_1x16(0xffff), PACKED_1x16(0xfc00), UNPACKED_1x1( -INF, 0.0, 0.0, 1.0)}, + {PIPE_FORMAT_R16_FLOAT, PACKED_1x16(0xffff), PACKED_1x16(0x7c00), UNPACKED_1x1( INFINITY, 0.0, 0.0, 1.0)}, + {PIPE_FORMAT_R16_FLOAT, PACKED_1x16(0xffff), PACKED_1x16(0xfc00), UNPACKED_1x1( -INFINITY, 0.0, 0.0, 1.0)}, #endif diff --git a/mesalib/src/gallium/auxiliary/util/u_gen_mipmap.c b/mesalib/src/gallium/auxiliary/util/u_gen_mipmap.c index a96cf6a30..c82c52c84 100644 --- a/mesalib/src/gallium/auxiliary/util/u_gen_mipmap.c +++ b/mesalib/src/gallium/auxiliary/util/u_gen_mipmap.c @@ -1573,8 +1573,9 @@ util_gen_mipmap(struct gen_mipmap_state *ctx, cso_save_blend(ctx->cso); cso_save_depth_stencil_alpha(ctx->cso); cso_save_rasterizer(ctx->cso); - cso_save_samplers(ctx->cso); - cso_save_fragment_sampler_views(ctx->cso); + cso_save_sample_mask(ctx->cso); + cso_save_samplers(ctx->cso, PIPE_SHADER_FRAGMENT); + cso_save_sampler_views(ctx->cso, PIPE_SHADER_FRAGMENT); cso_save_stream_outputs(ctx->cso); cso_save_framebuffer(ctx->cso); cso_save_fragment_shader(ctx->cso); @@ -1590,6 +1591,7 @@ util_gen_mipmap(struct gen_mipmap_state *ctx, cso_set_depth_stencil_alpha(ctx->cso, is_depth ? &ctx->dsa_write_depth : &ctx->dsa_keep_depth); cso_set_rasterizer(ctx->cso, &ctx->rasterizer); + cso_set_sample_mask(ctx->cso, ~0); cso_set_vertex_elements(ctx->cso, 2, ctx->velem); cso_set_stream_outputs(ctx->cso, 0, NULL, 0); @@ -1675,10 +1677,10 @@ util_gen_mipmap(struct gen_mipmap_state *ctx, */ ctx->sampler.min_lod = ctx->sampler.max_lod = (float) srcLevel; ctx->sampler.lod_bias = (float) srcLevel; - cso_single_sampler(ctx->cso, 0, &ctx->sampler); - cso_single_sampler_done(ctx->cso); + cso_single_sampler(ctx->cso, PIPE_SHADER_FRAGMENT, 0, &ctx->sampler); + cso_single_sampler_done(ctx->cso, PIPE_SHADER_FRAGMENT); - cso_set_fragment_sampler_views(ctx->cso, 1, &psv); + cso_set_sampler_views(ctx->cso, PIPE_SHADER_FRAGMENT, 1, &psv); /* quad coords in clip coords */ offset = set_vertex_data(ctx, @@ -1703,8 +1705,9 @@ util_gen_mipmap(struct gen_mipmap_state *ctx, cso_restore_blend(ctx->cso); cso_restore_depth_stencil_alpha(ctx->cso); cso_restore_rasterizer(ctx->cso); - cso_restore_samplers(ctx->cso); - cso_restore_fragment_sampler_views(ctx->cso); + cso_restore_sample_mask(ctx->cso); + cso_restore_samplers(ctx->cso, PIPE_SHADER_FRAGMENT); + cso_restore_sampler_views(ctx->cso, PIPE_SHADER_FRAGMENT); cso_restore_framebuffer(ctx->cso); cso_restore_fragment_shader(ctx->cso); cso_restore_vertex_shader(ctx->cso); diff --git a/mesalib/src/gallium/auxiliary/util/u_surface.c b/mesalib/src/gallium/auxiliary/util/u_surface.c index a541a38ff..fcfff148f 100644 --- a/mesalib/src/gallium/auxiliary/util/u_surface.c +++ b/mesalib/src/gallium/auxiliary/util/u_surface.c @@ -160,12 +160,12 @@ util_resource_copy_region(struct pipe_context *pipe, unsigned h = src_box->height; assert(src && dst); - assert((src->target == PIPE_BUFFER && dst->target == PIPE_BUFFER) || - (src->target != PIPE_BUFFER && dst->target != PIPE_BUFFER)); - if (!src || !dst) return; + assert((src->target == PIPE_BUFFER && dst->target == PIPE_BUFFER) || + (src->target != PIPE_BUFFER && dst->target != PIPE_BUFFER)); + src_format = src->format; dst_format = dst->format; diff --git a/mesalib/src/mesa/drivers/dri/common/dri_util.c b/mesalib/src/mesa/drivers/dri/common/dri_util.c index f9b2a73b2..91ae186fe 100644 --- a/mesalib/src/mesa/drivers/dri/common/dri_util.c +++ b/mesalib/src/mesa/drivers/dri/common/dri_util.c @@ -197,12 +197,6 @@ dri2CreateContextAttribs(__DRIscreen *screen, int api, return NULL; } - if (mesa_api != API_OPENGL && num_attribs != 0) { - *error = __DRI_CTX_ERROR_UNKNOWN_ATTRIBUTE; - assert(!"Should not get here."); - return NULL; - } - for (unsigned i = 0; i < num_attribs; i++) { switch (attribs[i * 2]) { case __DRI_CTX_ATTRIB_MAJOR_VERSION: @@ -224,6 +218,23 @@ dri2CreateContextAttribs(__DRIscreen *screen, int api, } } + /* The EGL_KHR_create_context spec says: + * + * "Flags are only defined for OpenGL context creation, and specifying + * a flags value other than zero for other types of contexts, + * including OpenGL ES contexts, will generate an error." + * + * The GLX_EXT_create_context_es2_profile specification doesn't say + * anything specific about this case. However, none of the known flags + * have any meaning in an ES context, so this seems safe. + */ + if (mesa_api != __DRI_API_OPENGL + && mesa_api != __DRI_API_OPENGL_CORE + && flags != 0) { + *error = __DRI_CTX_ERROR_BAD_FLAG; + return NULL; + } + /* There are no forward-compatible contexts before OpenGL 3.0. The * GLX_ARB_create_context spec says: * diff --git a/mesalib/src/mesa/program/nvfragparse.c b/mesalib/src/mesa/program/nvfragparse.c index bcc553a9b..20c8579b0 100644 --- a/mesalib/src/mesa/program/nvfragparse.c +++ b/mesalib/src/mesa/program/nvfragparse.c @@ -582,7 +582,7 @@ Parse_TextureImageId(struct parse_state *parseState, RETURN_ERROR1("Expected TEX# source"); } unit = atoi((const char *) imageSrc + 3); - if ((unit < 0 || unit > MAX_TEXTURE_IMAGE_UNITS) || + if ((unit < 0 || unit >= MAX_TEXTURE_IMAGE_UNITS) || (unit == 0 && (imageSrc[3] != '0' || imageSrc[4] != 0))) { RETURN_ERROR1("Invalied TEX# source index"); } diff --git a/mesalib/src/mesa/state_tracker/st_atom_sampler.c b/mesalib/src/mesa/state_tracker/st_atom_sampler.c index dc0c789c5..f39fd7551 100644 --- a/mesalib/src/mesa/state_tracker/st_atom_sampler.c +++ b/mesalib/src/mesa/state_tracker/st_atom_sampler.c @@ -195,84 +195,82 @@ convert_sampler(struct st_context *st, } +/** + * Update the gallium driver's sampler state for fragment, vertex or + * geometry shader stage. + */ static void -update_vertex_samplers(struct st_context *st) +update_shader_samplers(struct st_context *st, + unsigned shader_stage, + const struct gl_program *prog, + unsigned max_units, + struct pipe_sampler_state *samplers, + unsigned *num_samplers) { - const struct gl_context *ctx = st->ctx; - struct gl_vertex_program *vprog = ctx->VertexProgram._Current; - GLuint su; - - if (st->state.num_vertex_samplers == 0 && vprog->Base.SamplersUsed == 0) - return; - st->state.num_vertex_samplers = 0; - - /* loop over sampler units (aka tex image units) */ - for (su = 0; su < ctx->Const.MaxVertexTextureImageUnits; su++) { - struct pipe_sampler_state *sampler = st->state.vertex_samplers + su; - - if (vprog->Base.SamplersUsed & (1 << su)) { - GLuint texUnit; - - texUnit = vprog->Base.SamplerUnits[su]; + GLuint unit; + GLbitfield samplers_used; + const GLuint old_max = *num_samplers; - convert_sampler(st, sampler, texUnit); + samplers_used = prog->SamplersUsed; - st->state.num_vertex_samplers = su + 1; - - cso_single_vertex_sampler(st->cso_context, su, sampler); - } else { - cso_single_vertex_sampler(st->cso_context, su, NULL); - } - } - cso_single_vertex_sampler_done(st->cso_context); -} - - -static void -update_fragment_samplers(struct st_context *st) -{ - const struct gl_context *ctx = st->ctx; - struct gl_fragment_program *fprog = ctx->FragmentProgram._Current; - GLuint su; - GLuint samplers_used = fprog->Base.SamplersUsed; - GLuint old_max = st->state.num_samplers; + if (*num_samplers == 0 && samplers_used == 0x0) + return; - st->state.num_samplers = 0; + *num_samplers = 0; /* loop over sampler units (aka tex image units) */ - for (su = 0; su < ctx->Const.MaxTextureImageUnits; su++, samplers_used >>= 1) { - struct pipe_sampler_state *sampler = st->state.samplers + su; + for (unit = 0; unit < max_units; unit++, samplers_used >>= 1) { + struct pipe_sampler_state *sampler = samplers + unit; if (samplers_used & 1) { - GLuint texUnit; - - texUnit = fprog->Base.SamplerUnits[su]; + const GLuint texUnit = prog->SamplerUnits[unit]; convert_sampler(st, sampler, texUnit); - st->state.num_samplers = su + 1; + *num_samplers = unit + 1; - /*printf("%s su=%u non-null\n", __FUNCTION__, su);*/ - cso_single_sampler(st->cso_context, su, sampler); + cso_single_sampler(st->cso_context, shader_stage, unit, sampler); + } + else if (samplers_used != 0 || unit < old_max) { + cso_single_sampler(st->cso_context, shader_stage, unit, NULL); } - else if (samplers_used != 0 || su < old_max) { - /*printf("%s su=%u null\n", __FUNCTION__, su);*/ - cso_single_sampler(st->cso_context, su, NULL); - } else { - /* if we've reset all the old views and we have no more new ones */ + else { + /* if we've reset all the old samplers and we have no more new ones */ break; } } - cso_single_sampler_done(st->cso_context); + cso_single_sampler_done(st->cso_context, shader_stage); } static void update_samplers(struct st_context *st) { - update_fragment_samplers(st); - update_vertex_samplers(st); + const struct gl_context *ctx = st->ctx; + + update_shader_samplers(st, + PIPE_SHADER_FRAGMENT, + &ctx->FragmentProgram._Current->Base, + ctx->Const.MaxTextureImageUnits, + st->state.fragment_samplers, + &st->state.num_fragment_samplers); + + update_shader_samplers(st, + PIPE_SHADER_VERTEX, + &ctx->VertexProgram._Current->Base, + ctx->Const.MaxVertexTextureImageUnits, + st->state.vertex_samplers, + &st->state.num_vertex_samplers); + +/* + update_shader_samplers(st, + PIPE_SHADER_GEOMETRY, + &ctx->GeometryProgram._Current->Base, + ctx->Const.MaxGeometryTextureImageUnits, + st->state.geometry_samplers, + &st->state.num_geometry_samplers); +*/ } diff --git a/mesalib/src/mesa/state_tracker/st_atom_texture.c b/mesalib/src/mesa/state_tracker/st_atom_texture.c index fefa59860..e88675d4e 100644 --- a/mesalib/src/mesa/state_tracker/st_atom_texture.c +++ b/mesalib/src/mesa/state_tracker/st_atom_texture.c @@ -254,84 +254,81 @@ update_single_texture(struct st_context *st, } + static void -update_vertex_textures(struct st_context *st) +update_textures(struct st_context *st, + unsigned shader_stage, + const struct gl_program *prog, + unsigned max_units, + struct pipe_sampler_view **sampler_views, + unsigned *num_textures) { - const struct gl_context *ctx = st->ctx; - struct gl_vertex_program *vprog = ctx->VertexProgram._Current; - GLuint su; + const GLuint old_max = *num_textures; + GLbitfield samplers_used = prog->SamplersUsed; + GLuint unit; - if (!vprog->Base.SamplersUsed && st->state.num_vertex_textures == 0) + if (samplers_used == 0x0 && old_max == 0) return; - st->state.num_vertex_textures = 0; + *num_textures = 0; /* loop over sampler units (aka tex image units) */ - for (su = 0; su < ctx->Const.MaxTextureImageUnits; su++) { + for (unit = 0; unit < max_units; unit++, samplers_used >>= 1) { struct pipe_sampler_view *sampler_view = NULL; - if (vprog->Base.SamplersUsed & (1 << su)) { - GLboolean retval; - GLuint texUnit; - texUnit = vprog->Base.SamplerUnits[su]; + if (samplers_used & 1) { + const GLuint texUnit = prog->SamplerUnits[unit]; + GLboolean retval; retval = update_single_texture(st, &sampler_view, texUnit); if (retval == GL_FALSE) continue; - st->state.num_vertex_textures = su + 1; + *num_textures = unit + 1; + } + else if (samplers_used == 0 && unit >= old_max) { + /* if we've reset all the old views and we have no more new ones */ + break; } - pipe_sampler_view_reference(&st->state.sampler_vertex_views[su], - sampler_view); - } - if (ctx->Const.MaxVertexTextureImageUnits > 0) { - GLuint numUnits = MIN2(st->state.num_vertex_textures, - ctx->Const.MaxVertexTextureImageUnits); - cso_set_vertex_sampler_views(st->cso_context, - numUnits, - st->state.sampler_vertex_views); + pipe_sampler_view_reference(&(sampler_views[unit]), sampler_view); } + + cso_set_sampler_views(st->cso_context, + shader_stage, + MIN2(*num_textures, max_units), + sampler_views); } + static void -update_fragment_textures(struct st_context *st) +update_vertex_textures(struct st_context *st) { const struct gl_context *ctx = st->ctx; - struct gl_fragment_program *fprog = ctx->FragmentProgram._Current; - GLuint su; - int old_max = st->state.num_textures; - GLbitfield samplers_used = fprog->Base.SamplersUsed; - - st->state.num_textures = 0; - - /* loop over sampler units (aka tex image units) */ - for (su = 0; su < ctx->Const.MaxTextureImageUnits; su++, samplers_used >>= 1) { - struct pipe_sampler_view *sampler_view = NULL; - - if (samplers_used & 1) { - GLboolean retval; - GLuint texUnit; - texUnit = fprog->Base.SamplerUnits[su]; - - retval = update_single_texture(st, &sampler_view, texUnit); - if (retval == GL_FALSE) - continue; + if (ctx->Const.MaxVertexTextureImageUnits > 0) { + update_textures(st, + PIPE_SHADER_VERTEX, + &ctx->VertexProgram._Current->Base, + ctx->Const.MaxVertexTextureImageUnits, + st->state.vertex_sampler_views, + &st->state.num_vertex_textures); + } +} - st->state.num_textures = su + 1; - } else if (samplers_used == 0 && su >= old_max) { - /* if we've reset all the old views and we have no more new ones */ - break; - } - pipe_sampler_view_reference(&st->state.sampler_views[su], sampler_view); - } +static void +update_fragment_textures(struct st_context *st) +{ + const struct gl_context *ctx = st->ctx; - cso_set_fragment_sampler_views(st->cso_context, - st->state.num_textures, - st->state.sampler_views); + update_textures(st, + PIPE_SHADER_FRAGMENT, + &ctx->FragmentProgram._Current->Base, + ctx->Const.MaxTextureImageUnits, + st->state.fragment_sampler_views, + &st->state.num_fragment_textures); } diff --git a/mesalib/src/mesa/state_tracker/st_cb_bitmap.c b/mesalib/src/mesa/state_tracker/st_cb_bitmap.c index c26058874..3c17bd6c3 100644 --- a/mesalib/src/mesa/state_tracker/st_cb_bitmap.c +++ b/mesalib/src/mesa/state_tracker/st_cb_bitmap.c @@ -454,8 +454,8 @@ draw_bitmap_quad(struct gl_context *ctx, GLint x, GLint y, GLfloat z, assert(height <= (GLsizei)maxSize); cso_save_rasterizer(cso); - cso_save_samplers(cso); - cso_save_fragment_sampler_views(cso); + cso_save_samplers(cso, PIPE_SHADER_FRAGMENT); + cso_save_sampler_views(cso, PIPE_SHADER_FRAGMENT); cso_save_viewport(cso); cso_save_fragment_shader(cso); cso_save_stream_outputs(cso); @@ -480,23 +480,26 @@ draw_bitmap_quad(struct gl_context *ctx, GLint x, GLint y, GLfloat z, /* user samplers, plus our bitmap sampler */ { struct pipe_sampler_state *samplers[PIPE_MAX_SAMPLERS]; - uint num = MAX2(fpv->bitmap_sampler + 1, st->state.num_samplers); + uint num = MAX2(fpv->bitmap_sampler + 1, st->state.num_fragment_samplers); uint i; - for (i = 0; i < st->state.num_samplers; i++) { - samplers[i] = &st->state.samplers[i]; + for (i = 0; i < st->state.num_fragment_samplers; i++) { + samplers[i] = &st->state.fragment_samplers[i]; } samplers[fpv->bitmap_sampler] = &st->bitmap.samplers[sv->texture->target != PIPE_TEXTURE_RECT]; - cso_set_samplers(cso, num, (const struct pipe_sampler_state **) samplers); + cso_set_samplers(cso, PIPE_SHADER_FRAGMENT, num, + (const struct pipe_sampler_state **) samplers); } /* user textures, plus the bitmap texture */ { struct pipe_sampler_view *sampler_views[PIPE_MAX_SAMPLERS]; - uint num = MAX2(fpv->bitmap_sampler + 1, st->state.num_textures); - memcpy(sampler_views, st->state.sampler_views, sizeof(sampler_views)); + uint num = MAX2(fpv->bitmap_sampler + 1, + st->state.num_fragment_textures); + memcpy(sampler_views, st->state.fragment_sampler_views, + sizeof(sampler_views)); sampler_views[fpv->bitmap_sampler] = sv; - cso_set_fragment_sampler_views(cso, num, sampler_views); + cso_set_sampler_views(cso, PIPE_SHADER_FRAGMENT, num, sampler_views); } /* viewport state: viewport matching window dims */ @@ -535,8 +538,8 @@ draw_bitmap_quad(struct gl_context *ctx, GLint x, GLint y, GLfloat z, /* restore state */ cso_restore_rasterizer(cso); - cso_restore_samplers(cso); - cso_restore_fragment_sampler_views(cso); + cso_restore_samplers(cso, PIPE_SHADER_FRAGMENT); + cso_restore_sampler_views(cso, PIPE_SHADER_FRAGMENT); cso_restore_viewport(cso); cso_restore_fragment_shader(cso); cso_restore_vertex_shader(cso); diff --git a/mesalib/src/mesa/state_tracker/st_cb_clear.c b/mesalib/src/mesa/state_tracker/st_cb_clear.c index 3cd8756f2..e731b6b5e 100644 --- a/mesalib/src/mesa/state_tracker/st_cb_clear.c +++ b/mesalib/src/mesa/state_tracker/st_cb_clear.c @@ -217,6 +217,7 @@ clear_with_quad(struct gl_context *ctx, cso_save_stencil_ref(st->cso_context); cso_save_depth_stencil_alpha(st->cso_context); cso_save_rasterizer(st->cso_context); + cso_save_sample_mask(st->cso_context); cso_save_viewport(st->cso_context); cso_save_fragment_shader(st->cso_context); cso_save_stream_outputs(st->cso_context); @@ -277,7 +278,7 @@ clear_with_quad(struct gl_context *ctx, cso_set_vertex_elements(st->cso_context, 2, st->velems_util_draw); cso_set_stream_outputs(st->cso_context, 0, NULL, 0); - + cso_set_sample_mask(st->cso_context, ~0); cso_set_rasterizer(st->cso_context, &st->clear.raster); /* viewport state: viewport matching window dims */ @@ -313,6 +314,7 @@ clear_with_quad(struct gl_context *ctx, cso_restore_stencil_ref(st->cso_context); cso_restore_depth_stencil_alpha(st->cso_context); cso_restore_rasterizer(st->cso_context); + cso_restore_sample_mask(st->cso_context); cso_restore_viewport(st->cso_context); cso_restore_fragment_shader(st->cso_context); cso_restore_vertex_shader(st->cso_context); diff --git a/mesalib/src/mesa/state_tracker/st_cb_drawpixels.c b/mesalib/src/mesa/state_tracker/st_cb_drawpixels.c index f288a9632..88068ac60 100644 --- a/mesalib/src/mesa/state_tracker/st_cb_drawpixels.c +++ b/mesalib/src/mesa/state_tracker/st_cb_drawpixels.c @@ -679,8 +679,8 @@ draw_textured_quad(struct gl_context *ctx, GLint x, GLint y, GLfloat z, cso_save_rasterizer(cso); cso_save_viewport(cso); - cso_save_samplers(cso); - cso_save_fragment_sampler_views(cso); + cso_save_samplers(cso, PIPE_SHADER_FRAGMENT); + cso_save_sampler_views(cso, PIPE_SHADER_FRAGMENT); cso_save_fragment_shader(cso); cso_save_stream_outputs(cso); cso_save_vertex_shader(cso); @@ -751,11 +751,11 @@ draw_textured_quad(struct gl_context *ctx, GLint x, GLint y, GLfloat z, sampler.mag_img_filter = PIPE_TEX_FILTER_NEAREST; sampler.normalized_coords = normalized; - cso_single_sampler(cso, 0, &sampler); + cso_single_sampler(cso, PIPE_SHADER_FRAGMENT, 0, &sampler); if (num_sampler_view > 1) { - cso_single_sampler(cso, 1, &sampler); + cso_single_sampler(cso, PIPE_SHADER_FRAGMENT, 1, &sampler); } - cso_single_sampler_done(cso); + cso_single_sampler_done(cso, PIPE_SHADER_FRAGMENT); } /* viewport state: viewport matching window dims */ @@ -778,7 +778,7 @@ draw_textured_quad(struct gl_context *ctx, GLint x, GLint y, GLfloat z, cso_set_stream_outputs(st->cso_context, 0, NULL, 0); /* texture state: */ - cso_set_fragment_sampler_views(cso, num_sampler_view, sv); + cso_set_sampler_views(cso, PIPE_SHADER_FRAGMENT, num_sampler_view, sv); /* Compute Gallium window coords (y=0=top) with pixel zoom. * Recall that these coords are transformed by the current @@ -804,8 +804,8 @@ draw_textured_quad(struct gl_context *ctx, GLint x, GLint y, GLfloat z, /* restore state */ cso_restore_rasterizer(cso); cso_restore_viewport(cso); - cso_restore_samplers(cso); - cso_restore_fragment_sampler_views(cso); + cso_restore_samplers(cso, PIPE_SHADER_FRAGMENT); + cso_restore_sampler_views(cso, PIPE_SHADER_FRAGMENT); cso_restore_fragment_shader(cso); cso_restore_vertex_shader(cso); cso_restore_geometry_shader(cso); diff --git a/mesalib/src/mesa/state_tracker/st_context.c b/mesalib/src/mesa/state_tracker/st_context.c index 6b7c047ed..2f9516178 100644 --- a/mesalib/src/mesa/state_tracker/st_context.c +++ b/mesalib/src/mesa/state_tracker/st_context.c @@ -248,8 +248,14 @@ static void st_destroy_context_priv( struct st_context *st ) st_destroy_drawpix(st); st_destroy_drawtex(st); - for (i = 0; i < Elements(st->state.sampler_views); i++) { - pipe_sampler_view_release(st->pipe, &st->state.sampler_views[i]); + for (i = 0; i < Elements(st->state.fragment_sampler_views); i++) { + pipe_sampler_view_release(st->pipe, + &st->state.fragment_sampler_views[i]); + } + + for (i = 0; i < Elements(st->state.vertex_sampler_views); i++) { + pipe_sampler_view_release(st->pipe, + &st->state.vertex_sampler_views[i]); } if (st->default_texture) { diff --git a/mesalib/src/mesa/state_tracker/st_context.h b/mesalib/src/mesa/state_tracker/st_context.h index cdac5a1c7..0dfd81c1b 100644 --- a/mesalib/src/mesa/state_tracker/st_context.h +++ b/mesalib/src/mesa/state_tracker/st_context.h @@ -98,23 +98,23 @@ struct st_context struct pipe_blend_state blend; struct pipe_depth_stencil_alpha_state depth_stencil; struct pipe_rasterizer_state rasterizer; - struct pipe_sampler_state samplers[PIPE_MAX_SAMPLERS]; - struct pipe_sampler_state vertex_samplers[PIPE_MAX_VERTEX_SAMPLERS]; + struct pipe_sampler_state fragment_samplers[PIPE_MAX_SAMPLERS]; + struct pipe_sampler_state vertex_samplers[PIPE_MAX_VERTEX_SAMPLERS]; struct pipe_clip_state clip; struct { void *ptr; unsigned size; } constants[PIPE_SHADER_TYPES]; struct pipe_framebuffer_state framebuffer; - struct pipe_sampler_view *sampler_views[PIPE_MAX_SAMPLERS]; - struct pipe_sampler_view *sampler_vertex_views[PIPE_MAX_VERTEX_SAMPLERS]; + struct pipe_sampler_view *fragment_sampler_views[PIPE_MAX_SAMPLERS]; + struct pipe_sampler_view *vertex_sampler_views[PIPE_MAX_VERTEX_SAMPLERS]; struct pipe_scissor_state scissor; struct pipe_viewport_state viewport; unsigned sample_mask; - GLuint num_samplers; + GLuint num_fragment_samplers; GLuint num_vertex_samplers; - GLuint num_textures; + GLuint num_fragment_textures; GLuint num_vertex_textures; GLuint poly_stipple[32]; /**< In OpenGL's bottom-to-top order */ diff --git a/mesalib/src/mesa/state_tracker/st_glsl_to_tgsi.cpp b/mesalib/src/mesa/state_tracker/st_glsl_to_tgsi.cpp index fcd69b18d..66627acb6 100644 --- a/mesalib/src/mesa/state_tracker/st_glsl_to_tgsi.cpp +++ b/mesalib/src/mesa/state_tracker/st_glsl_to_tgsi.cpp @@ -4790,7 +4790,7 @@ get_mesa_program(struct gl_context *ctx, struct gl_shader_program *shader_program, struct gl_shader *shader) { - glsl_to_tgsi_visitor* v = new glsl_to_tgsi_visitor(); + glsl_to_tgsi_visitor* v; struct gl_program *prog; GLenum target; const char *target_string; @@ -4822,6 +4822,7 @@ get_mesa_program(struct gl_context *ctx, if (!prog) return NULL; prog->Parameters = _mesa_new_parameter_list(); + v = new glsl_to_tgsi_visitor(); v->ctx = ctx; v->prog = prog; v->shader_program = shader_program; -- cgit v1.2.3