diff options
Diffstat (limited to 'mesalib/src/mesa/drivers')
-rw-r--r-- | mesalib/src/mesa/drivers/common/meta.c | 142 | ||||
-rw-r--r-- | mesalib/src/mesa/drivers/common/meta.h | 17 | ||||
-rw-r--r-- | mesalib/src/mesa/drivers/dri/Android.mk | 6 | ||||
-rw-r--r-- | mesalib/src/mesa/drivers/dri/common/Android.mk | 4 | ||||
-rw-r--r-- | mesalib/src/mesa/drivers/dri/common/utils.c | 4 | ||||
-rw-r--r-- | mesalib/src/mesa/drivers/dri/swrast/swrast.c | 73 | ||||
-rw-r--r-- | mesalib/src/mesa/drivers/haiku/swrast/SConscript | 1 |
7 files changed, 170 insertions, 77 deletions
diff --git a/mesalib/src/mesa/drivers/common/meta.c b/mesalib/src/mesa/drivers/common/meta.c index a1d06d412..90befd42d 100644 --- a/mesalib/src/mesa/drivers/common/meta.c +++ b/mesalib/src/mesa/drivers/common/meta.c @@ -1527,12 +1527,12 @@ meta_glsl_clear_init(struct gl_context *ctx, struct clear_state *clear) { const char *vs_source = "#extension GL_AMD_vertex_shader_layer : enable\n" + "#extension GL_ARB_draw_instanced : enable\n" "attribute vec4 position;\n" - "uniform int layer;\n" "void main()\n" "{\n" "#ifdef GL_AMD_vertex_shader_layer\n" - " gl_Layer = layer;\n" + " gl_Layer = gl_InstanceID;\n" "#endif\n" " gl_Position = position;\n" "}\n"; @@ -1568,7 +1568,6 @@ meta_glsl_clear_init(struct gl_context *ctx, struct clear_state *clear) _mesa_LinkProgram(clear->ShaderProg); clear->ColorLocation = _mesa_GetUniformLocation(clear->ShaderProg, "color"); - clear->LayerLocation = _mesa_GetUniformLocation(clear->ShaderProg, "layer"); has_integer_textures = _mesa_is_gles3(ctx) || (_mesa_is_desktop_gl(ctx) && ctx->Const.GLSLVersion >= 130); @@ -1579,12 +1578,12 @@ meta_glsl_clear_init(struct gl_context *ctx, struct clear_state *clear) ralloc_asprintf(shader_source_mem_ctx, "#version 130\n" "#extension GL_AMD_vertex_shader_layer : enable\n" + "#extension GL_ARB_draw_instanced : enable\n" "in vec4 position;\n" - "uniform int layer;\n" "void main()\n" "{\n" "#ifdef GL_AMD_vertex_shader_layer\n" - " gl_Layer = layer;\n" + " gl_Layer = gl_InstanceID;\n" "#endif\n" " gl_Position = position;\n" "}\n"); @@ -1623,8 +1622,6 @@ meta_glsl_clear_init(struct gl_context *ctx, struct clear_state *clear) clear->IntegerColorLocation = _mesa_GetUniformLocation(clear->IntegerShaderProg, "color"); - clear->IntegerLayerLocation = - _mesa_GetUniformLocation(clear->IntegerShaderProg, "layer"); } } @@ -1653,8 +1650,8 @@ meta_glsl_clear_cleanup(struct clear_state *clear) * Since the bitfield has no associated order, the assignment of draw buffer * indices to color attachment indices is rather arbitrary. */ -static void -drawbuffers_from_bitfield(GLbitfield bits) +void +_mesa_meta_drawbuffers_from_bitfield(GLbitfield bits) { GLenum enums[MAX_DRAW_BUFFERS]; int i = 0; @@ -1767,7 +1764,7 @@ meta_clear(struct gl_context *ctx, GLbitfield buffers, bool glsl) /* GL_COLOR_BUFFER_BIT */ if (buffers & BUFFER_BITS_COLOR) { /* Only draw to the buffers we were asked to clear. */ - drawbuffers_from_bitfield(buffers & BUFFER_BITS_COLOR); + _mesa_meta_drawbuffers_from_bitfield(buffers & BUFFER_BITS_COLOR); /* leave colormask state as-is */ @@ -1832,15 +1829,7 @@ meta_clear(struct gl_context *ctx, GLbitfield buffers, bool glsl) /* draw quad(s) */ if (fb->MaxNumLayers > 0) { - unsigned layer; - assert(glsl && clear->LayerLocation != -1); - for (layer = 0; layer < fb->MaxNumLayers; layer++) { - if (fb->_IntegerColor) - _mesa_Uniform1i(clear->IntegerLayerLocation, layer); - else - _mesa_Uniform1i(clear->LayerLocation, layer); - _mesa_DrawArrays(GL_TRIANGLE_FAN, 0, 4); - } + _mesa_DrawArraysInstanced(GL_TRIANGLE_FAN, 0, 4, fb->MaxNumLayers); } else { _mesa_DrawArrays(GL_TRIANGLE_FAN, 0, 4); } @@ -2784,7 +2773,6 @@ copytexsubimage_using_blit_framebuffer(struct gl_context *ctx, GLuint dims, GLint x, GLint y, GLsizei width, GLsizei height) { - struct gl_texture_object *texObj = texImage->TexObject; GLuint fbo; bool success = false; GLbitfield mask; @@ -2793,8 +2781,6 @@ copytexsubimage_using_blit_framebuffer(struct gl_context *ctx, GLuint dims, if (!ctx->Extensions.ARB_framebuffer_object) return false; - _mesa_unlock_texture(ctx, texObj); - _mesa_meta_begin(ctx, MESA_META_ALL & ~MESA_META_DRAW_BUFFERS); _mesa_GenFramebuffers(1, &fbo); @@ -2845,7 +2831,6 @@ copytexsubimage_using_blit_framebuffer(struct gl_context *ctx, GLuint dims, success = mask == 0x0; out: - _mesa_lock_texture(ctx, texObj); _mesa_DeleteFramebuffers(1, &fbo); _mesa_meta_end(ctx); return success; @@ -2863,7 +2848,6 @@ _mesa_meta_CopyTexSubImage(struct gl_context *ctx, GLuint dims, GLint x, GLint y, GLsizei width, GLsizei height) { - struct gl_texture_object *texObj = texImage->TexObject; GLenum format, type; GLint bpp; void *buf; @@ -2908,8 +2892,6 @@ _mesa_meta_CopyTexSubImage(struct gl_context *ctx, GLuint dims, return; } - _mesa_unlock_texture(ctx, texObj); /* need to unlock first */ - /* * Read image from framebuffer (disable pixel transfer ops) */ @@ -2938,19 +2920,25 @@ _mesa_meta_CopyTexSubImage(struct gl_context *ctx, GLuint dims, _mesa_meta_end(ctx); - _mesa_lock_texture(ctx, texObj); /* re-lock */ - free(buf); } +static void +meta_decompress_fbo_cleanup(struct decompress_fbo_state *decompress_fbo) +{ + if (decompress_fbo->FBO != 0) { + _mesa_DeleteFramebuffers(1, &decompress_fbo->FBO); + _mesa_DeleteRenderbuffers(1, &decompress_fbo->RBO); + } + + memset(decompress_fbo, 0, sizeof(*decompress_fbo)); +} static void meta_decompress_cleanup(struct decompress_state *decompress) { - if (decompress->FBO != 0) { - _mesa_DeleteFramebuffers(1, &decompress->FBO); - _mesa_DeleteRenderbuffers(1, &decompress->RBO); - } + meta_decompress_fbo_cleanup(&decompress->byteFBO); + meta_decompress_fbo_cleanup(&decompress->floatFBO); if (decompress->VAO != 0) { _mesa_DeleteVertexArrays(1, &decompress->VAO); @@ -2972,7 +2960,7 @@ meta_decompress_cleanup(struct decompress_state *decompress) * \param dest destination buffer * \param destRowLength dest image rowLength (ala GL_PACK_ROW_LENGTH) */ -static void +static bool decompress_texture_image(struct gl_context *ctx, struct gl_texture_image *texImage, GLuint slice, @@ -2980,17 +2968,33 @@ decompress_texture_image(struct gl_context *ctx, GLvoid *dest) { struct decompress_state *decompress = &ctx->Meta->Decompress; + struct decompress_fbo_state *decompress_fbo; struct gl_texture_object *texObj = texImage->TexObject; const GLint width = texImage->Width; const GLint height = texImage->Height; const GLint depth = texImage->Height; const GLenum target = texObj->Target; + GLenum rbFormat; GLenum faceTarget; struct vertex verts[4]; GLuint samplerSave; + GLenum status; const bool use_glsl_version = ctx->Extensions.ARB_vertex_shader && ctx->Extensions.ARB_fragment_shader; + switch (_mesa_get_format_datatype(texImage->TexFormat)) { + case GL_FLOAT: + decompress_fbo = &decompress->floatFBO; + rbFormat = GL_RGBA32F; + break; + case GL_UNSIGNED_NORMALIZED: + decompress_fbo = &decompress->byteFBO; + rbFormat = GL_RGBA; + break; + default: + return false; + } + if (slice > 0) { assert(target == GL_TEXTURE_3D || target == GL_TEXTURE_2D_ARRAY || @@ -3001,11 +3005,11 @@ decompress_texture_image(struct gl_context *ctx, case GL_TEXTURE_1D: case GL_TEXTURE_1D_ARRAY: assert(!"No compressed 1D textures."); - return; + return false; case GL_TEXTURE_3D: assert(!"No compressed 3D textures."); - return; + return false; case GL_TEXTURE_CUBE_MAP_ARRAY: faceTarget = GL_TEXTURE_CUBE_MAP_POSITIVE_X + (slice % 6); @@ -3027,27 +3031,35 @@ decompress_texture_image(struct gl_context *ctx, ctx->Texture.Unit[ctx->Texture.CurrentUnit].Sampler->Name : 0; /* Create/bind FBO/renderbuffer */ - if (decompress->FBO == 0) { - _mesa_GenFramebuffers(1, &decompress->FBO); - _mesa_GenRenderbuffers(1, &decompress->RBO); - _mesa_BindFramebuffer(GL_FRAMEBUFFER_EXT, decompress->FBO); - _mesa_BindRenderbuffer(GL_RENDERBUFFER_EXT, decompress->RBO); + if (decompress_fbo->FBO == 0) { + _mesa_GenFramebuffers(1, &decompress_fbo->FBO); + _mesa_GenRenderbuffers(1, &decompress_fbo->RBO); + _mesa_BindFramebuffer(GL_FRAMEBUFFER_EXT, decompress_fbo->FBO); + _mesa_BindRenderbuffer(GL_RENDERBUFFER_EXT, decompress_fbo->RBO); _mesa_FramebufferRenderbuffer(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_RENDERBUFFER_EXT, - decompress->RBO); + decompress_fbo->RBO); } else { - _mesa_BindFramebuffer(GL_FRAMEBUFFER_EXT, decompress->FBO); + _mesa_BindFramebuffer(GL_FRAMEBUFFER_EXT, decompress_fbo->FBO); } /* alloc dest surface */ - if (width > decompress->Width || height > decompress->Height) { - _mesa_BindRenderbuffer(GL_RENDERBUFFER_EXT, decompress->RBO); - _mesa_RenderbufferStorage(GL_RENDERBUFFER_EXT, GL_RGBA, - width, height); - decompress->Width = width; - decompress->Height = height; + if (width > decompress_fbo->Width || height > decompress_fbo->Height) { + _mesa_BindRenderbuffer(GL_RENDERBUFFER_EXT, decompress_fbo->RBO); + _mesa_RenderbufferStorage(GL_RENDERBUFFER_EXT, rbFormat, + width, height); + status = _mesa_CheckFramebufferStatus(GL_DRAW_FRAMEBUFFER); + if (status != GL_FRAMEBUFFER_COMPLETE) { + /* If the framebuffer isn't complete then we'll leave + * decompress_fbo->Width as zero so that it will fail again next time + * too */ + _mesa_meta_end(ctx); + return false; + } + decompress_fbo->Width = width; + decompress_fbo->Height = height; } if (use_glsl_version) { @@ -3169,6 +3181,8 @@ decompress_texture_image(struct gl_context *ctx, _mesa_BindSampler(ctx->Texture.CurrentUnit, samplerSave); _mesa_meta_end(ctx); + + return true; } @@ -3182,17 +3196,10 @@ _mesa_meta_GetTexImage(struct gl_context *ctx, GLenum format, GLenum type, GLvoid *pixels, struct gl_texture_image *texImage) { - /* We can only use the decompress-with-blit method here if the texels are - * unsigned, normalized values. We could handle signed and unnormalized - * with floating point renderbuffers... - */ - if (_mesa_is_format_compressed(texImage->TexFormat) && - _mesa_get_format_datatype(texImage->TexFormat) - == GL_UNSIGNED_NORMALIZED) { - struct gl_texture_object *texObj = texImage->TexObject; + if (_mesa_is_format_compressed(texImage->TexFormat)) { GLuint slice; - /* Need to unlock the texture here to prevent deadlock... */ - _mesa_unlock_texture(ctx, texObj); + bool result; + for (slice = 0; slice < texImage->Depth; slice++) { void *dst; if (texImage->TexObject->Target == GL_TEXTURE_2D_ARRAY @@ -3212,14 +3219,17 @@ _mesa_meta_GetTexImage(struct gl_context *ctx, else { dst = pixels; } - decompress_texture_image(ctx, texImage, slice, format, type, dst); + result = decompress_texture_image(ctx, texImage, slice, + format, type, dst); + if (!result) + break; } - /* ... and relock it */ - _mesa_lock_texture(ctx, texObj); - } - else { - _mesa_get_teximage(ctx, format, type, pixels, texImage); + + if (result) + return; } + + _mesa_get_teximage(ctx, format, type, pixels, texImage); } @@ -3515,15 +3525,11 @@ _mesa_meta_ClearTexSubImage(struct gl_context *ctx, { bool res; - _mesa_unlock_texture(ctx, texImage->TexObject); - res = cleartexsubimage_using_fbo(ctx, texImage, xoffset, yoffset, zoffset, width, height, depth, clearValue); - _mesa_lock_texture(ctx, texImage->TexObject); - if (res) return; diff --git a/mesalib/src/mesa/drivers/common/meta.h b/mesalib/src/mesa/drivers/common/meta.h index e2da2f427..56ba9bc65 100644 --- a/mesalib/src/mesa/drivers/common/meta.h +++ b/mesalib/src/mesa/drivers/common/meta.h @@ -343,13 +343,23 @@ struct gen_mipmap_state }; /** + * One of the FBO states for decompress_state. There will be one for each + * required renderbuffer format. + */ +struct decompress_fbo_state +{ + GLuint FBO, RBO; + GLint Width, Height; +}; + +/** * State for texture decompression */ struct decompress_state { GLuint VAO; - GLuint VBO, FBO, RBO, Sampler; - GLint Width, Height; + struct decompress_fbo_state byteFBO, floatFBO; + GLuint VBO, Sampler; struct blit_shader_table shaders; }; @@ -501,6 +511,9 @@ _mesa_meta_DrawTex(struct gl_context *ctx, GLfloat x, GLfloat y, GLfloat z, GLfloat width, GLfloat height); /* meta-internal functions */ +void +_mesa_meta_drawbuffers_from_bitfield(GLbitfield bits); + GLuint _mesa_meta_compile_shader_with_debug(struct gl_context *ctx, GLenum target, const GLcharARB *source); diff --git a/mesalib/src/mesa/drivers/dri/Android.mk b/mesalib/src/mesa/drivers/dri/Android.mk index e0cf51c58..935722c53 100644 --- a/mesalib/src/mesa/drivers/dri/Android.mk +++ b/mesalib/src/mesa/drivers/dri/Android.mk @@ -35,15 +35,15 @@ MESA_DRI_CFLAGS := \ -DHAVE_ANDROID_PLATFORM MESA_DRI_C_INCLUDES := \ + $(MESA_TOP)/src \ $(call intermediates-dir-for,STATIC_LIBRARIES,libmesa_dri_common) \ $(addprefix $(MESA_TOP)/, $(mesa_dri_common_INCLUDES)) \ - $(DRM_TOP) \ - $(DRM_TOP)/include/drm \ + $(TARGET_OUT_HEADERS)/libdrm \ external/expat/lib MESA_DRI_WHOLE_STATIC_LIBRARIES := \ libmesa_glsl \ - libmegadriver_stub \ + libmesa_megadriver_stub \ libmesa_dri_common \ libmesa_dricore diff --git a/mesalib/src/mesa/drivers/dri/common/Android.mk b/mesalib/src/mesa/drivers/dri/common/Android.mk index a172a0bc6..b95feb679 100644 --- a/mesalib/src/mesa/drivers/dri/common/Android.mk +++ b/mesalib/src/mesa/drivers/dri/common/Android.mk @@ -88,13 +88,13 @@ include $(MESA_COMMON_MK) include $(BUILD_STATIC_LIBRARY) # -# Build libmegadriver_stub +# Build libmesa_megadriver_stub # include $(CLEAR_VARS) include $(LOCAL_PATH)/Makefile.sources -LOCAL_MODULE := libmegadriver_stub +LOCAL_MODULE := libmesa_megadriver_stub LOCAL_MODULE_CLASS := STATIC_LIBRARIES LOCAL_C_INCLUDES := \ $(MESA_DRI_C_INCLUDES) diff --git a/mesalib/src/mesa/drivers/dri/common/utils.c b/mesalib/src/mesa/drivers/dri/common/utils.c index eee77ec69..e0b3db8cf 100644 --- a/mesalib/src/mesa/drivers/dri/common/utils.c +++ b/mesalib/src/mesa/drivers/dri/common/utils.c @@ -519,6 +519,10 @@ driQueryRendererIntegerCommon(__DRIscreen *psp, int param, unsigned int *value) value[2] = v[2]; return 0; } + case __DRI2_RENDERER_PREFERRED_PROFILE: + value[0] = (psp->max_gl_core_version != 0) + ? (1U << __DRI_API_OPENGL_CORE) : (1U << __DRI_API_OPENGL); + return 0; case __DRI2_RENDERER_OPENGL_CORE_PROFILE_VERSION: value[0] = psp->max_gl_core_version / 10; value[1] = psp->max_gl_core_version % 10; diff --git a/mesalib/src/mesa/drivers/dri/swrast/swrast.c b/mesalib/src/mesa/drivers/dri/swrast/swrast.c index 888138115..e28991b0c 100644 --- a/mesalib/src/mesa/drivers/dri/swrast/swrast.c +++ b/mesalib/src/mesa/drivers/dri/swrast/swrast.c @@ -61,6 +61,9 @@ const __DRIextension **__driDriverGetExtensions_swrast(void); +const char const *swrast_vendor_string = "Mesa Project"; +const char const *swrast_renderer_string = "Software Rasterizer"; + /** * Screen and config-related functions */ @@ -117,8 +120,74 @@ static const __DRItexBufferExtension swrastTexBufferExtension = { .releaseTexBuffer = NULL, }; + +static int +swrast_query_renderer_integer(__DRIscreen *psp, int param, + unsigned int *value) +{ + switch (param) { + case __DRI2_RENDERER_VENDOR_ID: + case __DRI2_RENDERER_DEVICE_ID: + /* Return 0xffffffff for both vendor and device id */ + value[0] = 0xffffffff; + return 0; + case __DRI2_RENDERER_ACCELERATED: + value[0] = 0; + return 0; + case __DRI2_RENDERER_VIDEO_MEMORY: { + /* XXX: Do we want to return the full amount of system memory ? */ + const long system_memory_pages = sysconf(_SC_PHYS_PAGES); + const long system_page_size = sysconf(_SC_PAGE_SIZE); + + if (system_memory_pages <= 0 || system_page_size <= 0) + return -1; + + const uint64_t system_memory_bytes = (uint64_t) system_memory_pages + * (uint64_t) system_page_size; + + const unsigned system_memory_megabytes = + (unsigned) (system_memory_bytes / (1024 * 1024)); + + value[0] = system_memory_megabytes; + return 0; + } + case __DRI2_RENDERER_UNIFIED_MEMORY_ARCHITECTURE: + /** + * XXX: Perhaps we should return 1 ? + * See issue #7 from the spec, currently UNRESOLVED. + */ + value[0] = 0; + return 0; + default: + return driQueryRendererIntegerCommon(psp, param, value); + } +} + +static int +swrast_query_renderer_string(__DRIscreen *psp, int param, const char **value) +{ + switch (param) { + case __DRI2_RENDERER_VENDOR_ID: + value[0] = swrast_vendor_string; + return 0; + case __DRI2_RENDERER_DEVICE_ID: + value[0] = swrast_renderer_string; + return 0; + default: + return -1; + } +} + +static const __DRI2rendererQueryExtension swrast_query_renderer_extension = { + .base = { __DRI2_RENDERER_QUERY, 1 }, + + .queryInteger = swrast_query_renderer_integer, + .queryString = swrast_query_renderer_string +}; + static const __DRIextension *dri_screen_extensions[] = { &swrastTexBufferExtension.base, + &swrast_query_renderer_extension.base, NULL }; @@ -599,9 +668,9 @@ get_string(struct gl_context *ctx, GLenum pname) (void) ctx; switch (pname) { case GL_VENDOR: - return (const GLubyte *) "Mesa Project"; + return (const GLubyte *) swrast_vendor_string; case GL_RENDERER: - return (const GLubyte *) "Software Rasterizer"; + return (const GLubyte *) swrast_renderer_string; default: return NULL; } diff --git a/mesalib/src/mesa/drivers/haiku/swrast/SConscript b/mesalib/src/mesa/drivers/haiku/swrast/SConscript index aef730098..2c25f727d 100644 --- a/mesalib/src/mesa/drivers/haiku/swrast/SConscript +++ b/mesalib/src/mesa/drivers/haiku/swrast/SConscript @@ -3,6 +3,7 @@ Import('*') env = env.Clone() env.Append(CPPPATH = [ + '#/src', '#/src/mapi', '#/src/mesa', '#/src/mesa/main', |