diff options
author | Mark Mueller <MarkKMueller@gmail.com> | 2013-11-20 13:41:30 -0800 |
---|---|---|
committer | Mark Mueller <MarkKMueller@gmail.com> | 2014-01-13 09:39:39 -0800 |
commit | e6ed8b3014d0e4f52319a5dc8f05fe789bc310fc (patch) | |
tree | dbfb656ef3933829ce3c0c5d43798d203bfca078 | |
parent | 4f45ddceb173469190c7b87d4938e54697a643dd (diff) |
Starting to see very positive results
-rw-r--r-- | src/mesa/drivers/dri/i965/brw_blorp.cpp | 2 | ||||
-rw-r--r-- | src/mesa/drivers/dri/i965/brw_blorp.h | 16 | ||||
-rw-r--r-- | src/mesa/drivers/dri/i965/brw_blorp_blit.cpp | 440 | ||||
-rw-r--r-- | src/mesa/drivers/dri/i965/brw_context.h | 37 | ||||
-rw-r--r-- | src/mesa/drivers/dri/i965/brw_state.h | 7 | ||||
-rw-r--r-- | src/mesa/drivers/dri/i965/brw_surface_formats.c | 448 | ||||
-rw-r--r-- | src/mesa/drivers/dri/i965/brw_wm_surface_state.c | 6 | ||||
-rw-r--r-- | src/mesa/drivers/dri/i965/gen7_wm_surface_state.c | 1 | ||||
-rw-r--r-- | src/mesa/drivers/dri/i965/intel_mipmap_tree.c | 230 | ||||
-rw-r--r-- | src/mesa/drivers/dri/i965/intel_mipmap_tree.h | 18 | ||||
-rw-r--r-- | src/mesa/drivers/dri/i965/intel_tex_image.c | 52 | ||||
-rw-r--r-- | src/mesa/main/enums.h | 8 | ||||
-rw-r--r-- | src/mesa/main/formats.c | 231 | ||||
-rw-r--r-- | src/mesa/main/formats.h | 46 | ||||
-rw-r--r-- | src/mesa/main/pbo.h | 8 | ||||
-rw-r--r-- | src/mesa/main/texformat.c | 78 |
16 files changed, 1044 insertions, 584 deletions
diff --git a/src/mesa/drivers/dri/i965/brw_blorp.cpp b/src/mesa/drivers/dri/i965/brw_blorp.cpp index 0939a31786..c07104f8ce 100644 --- a/src/mesa/drivers/dri/i965/brw_blorp.cpp +++ b/src/mesa/drivers/dri/i965/brw_blorp.cpp @@ -120,7 +120,7 @@ brw_blorp_surface_info::set(struct brw_context *brw, assert(brw->format_supported_as_render_target[linear_format]); this->brw_surfaceformat = brw->render_target_format[linear_format]; } else { - this->brw_surfaceformat = brw_format_for_mesa_format(linear_format); + this->brw_surfaceformat = brw_format_for_mesa_format(linear_format, &this->process_format_flags); } break; } diff --git a/src/mesa/drivers/dri/i965/brw_blorp.h b/src/mesa/drivers/dri/i965/brw_blorp.h index 6ed7fdb475..be367b7559 100644 --- a/src/mesa/drivers/dri/i965/brw_blorp.h +++ b/src/mesa/drivers/dri/i965/brw_blorp.h @@ -159,6 +159,7 @@ public: * surface. Should correspond to one of the BRW_SURFACEFORMAT_* enums. */ uint32_t brw_surfaceformat; + blorp_process_format process_format_flags; /** * For MSAA surfaces, MSAA layout that should be used when setting up the @@ -297,9 +298,10 @@ struct brw_blorp_blit_prog_key intel_msaa_layout dst_layout; /* Type of the data to be read from the texture (one of - * BRW_REGISTER_TYPE_{UD,D,F}). + * BRW_REGISTER_TYPE_{UD,D,F}), and written to the target. */ - unsigned texture_data_type; + unsigned src_texture_data_type; + unsigned dst_texture_data_type; /* True if the source image is W tiled. If true, the surface state for the * source image must be configured as Y tiled, and tex_samples must be 0. @@ -360,13 +362,15 @@ public: virtual uint32_t get_wm_prog(struct brw_context *brw, brw_blorp_prog_data **prog_data) const; - bool is_valid() { - return valid_parameters; - } + GLuint find_brw_format(struct brw_context *brw, gl_format src_format); + + static bool test_formats(struct brw_context *brw, + gl_format src_format, + gl_format dst_format, + GLint internal_format = 0); private: brw_blorp_blit_prog_key wm_prog_key; - bool valid_parameters; }; /** diff --git a/src/mesa/drivers/dri/i965/brw_blorp_blit.cpp b/src/mesa/drivers/dri/i965/brw_blorp_blit.cpp index 1e495ed148..b2c57bba4b 100644 --- a/src/mesa/drivers/dri/i965/brw_blorp_blit.cpp +++ b/src/mesa/drivers/dri/i965/brw_blorp_blit.cpp @@ -21,8 +21,13 @@ * IN THE SOFTWARE. */ +#include "main/enums.h" +#include "main/glformats.h" +#include "main/image.h" #include "main/teximage.h" +#include "main/texformat.h" #include "main/fbobject.h" +#include "main/pbo.h" #include "main/renderbuffer.h" #include "glsl/ralloc.h" @@ -152,6 +157,10 @@ brw_blorp_blit_miptrees(struct brw_context *brw, dst_level, dst_layer, dst_x0, dst_y0, dst_x1, dst_y1, mirror_x, mirror_y); + if (!brw_blorp_blit_params::test_formats(brw, src_mt->format, dst_mt->format)) { + return false; + } + brw_blorp_blit_params params(brw, src_mt, src_level, src_layer, dst_mt, dst_level, dst_layer, @@ -161,10 +170,6 @@ brw_blorp_blit_miptrees(struct brw_context *brw, dst_x1, dst_y1, filter, mirror_x, mirror_y); - if (!params.is_valid()) { - return false; - } - /* Get ready to blit. This includes depth resolving the src and dst * buffers if necessary. Note: it's not necessary to do a color resolve on * the destination buffer because we use the standard render path to render @@ -181,7 +186,7 @@ brw_blorp_blit_miptrees(struct brw_context *brw, return true; } -static bool +static void do_blorp_blit(struct brw_context *brw, GLbitfield buffer_bit, struct intel_renderbuffer *src_irb, struct intel_renderbuffer *dst_irb, @@ -193,18 +198,20 @@ do_blorp_blit(struct brw_context *brw, GLbitfield buffer_bit, struct intel_mipmap_tree *src_mt = find_miptree(buffer_bit, src_irb); struct intel_mipmap_tree *dst_mt = find_miptree(buffer_bit, dst_irb); - /* Do the blit */ - if (!brw_blorp_blit_miptrees(brw, - src_mt, src_irb->mt_level, src_irb->mt_layer, - dst_mt, dst_irb->mt_level, dst_irb->mt_layer, - srcX0, srcY0, srcX1, srcY1, - dstX0, dstY0, dstX1, dstY1, - filter, mirror_x, mirror_y)) { - return false; + if (!brw_blorp_blit_params::test_formats(brw, src_mt->format, dst_mt->format)) { + _mesa_debug(&brw->ctx, "%s: Failed format test src texture format: %s, dst format: %s\n", + __FUNCTION__, _mesa_get_format_name(src_mt->format), _mesa_get_format_name(dst_mt->format)); } + /* Do the blit */ + brw_blorp_blit_miptrees(brw, + src_mt, src_irb->mt_level, src_irb->mt_layer, + dst_mt, dst_irb->mt_level, dst_irb->mt_layer, + srcX0, srcY0, srcX1, srcY1, + dstX0, dstY0, dstX1, dstY1, + filter, mirror_x, mirror_y); + intel_renderbuffer_set_needs_downsample(dst_irb); - return true; } static bool @@ -311,11 +318,9 @@ try_blorp_blit(struct brw_context *brw, for (unsigned i = 0; i < ctx->DrawBuffer->_NumColorDrawBuffers; ++i) { dst_irb = intel_renderbuffer(ctx->DrawBuffer->_ColorDrawBuffers[i]); if (dst_irb) { - if (!do_blorp_blit(brw, buffer_bit, src_irb, dst_irb, srcX0, srcY0, - srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, - filter, mirror_x, mirror_y)) { - return false; - } + do_blorp_blit(brw, buffer_bit, src_irb, dst_irb, srcX0, srcY0, + srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, + filter, mirror_x, mirror_y); } } break; @@ -326,11 +331,9 @@ try_blorp_blit(struct brw_context *brw, intel_renderbuffer(draw_fb->Attachment[BUFFER_DEPTH].Renderbuffer); if (!formats_match(buffer_bit, src_irb, dst_irb)) return false; - if (!do_blorp_blit(brw, buffer_bit, src_irb, dst_irb, srcX0, srcY0, - srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, - filter, mirror_x, mirror_y)) { - return false; - } + do_blorp_blit(brw, buffer_bit, src_irb, dst_irb, srcX0, srcY0, + srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, + filter, mirror_x, mirror_y); break; case GL_STENCIL_BUFFER_BIT: src_irb = @@ -339,11 +342,9 @@ try_blorp_blit(struct brw_context *brw, intel_renderbuffer(draw_fb->Attachment[BUFFER_STENCIL].Renderbuffer); if (!formats_match(buffer_bit, src_irb, dst_irb)) return false; - if (!do_blorp_blit(brw, buffer_bit, src_irb, dst_irb, srcX0, srcY0, - srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, - filter, mirror_x, mirror_y)) { - return false; - } + do_blorp_blit(brw, buffer_bit, src_irb, dst_irb, srcX0, srcY0, + srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, + filter, mirror_x, mirror_y); break; default: assert(false); @@ -353,6 +354,159 @@ try_blorp_blit(struct brw_context *brw, } bool +brw_blorp_GPUcopytexsubimage(struct brw_context *brw, + GLuint dims, + struct gl_texture_image *dst_image, + GLenum format, GLenum type, + const GLvoid *src_pixels, + const gl_pixelstore_attrib *packing, + GLuint slice, + GLint srcX0, GLint srcY0, + GLint dstX0, GLint dstY0, + GLint width, GLint height) +{ + /* BLORP is not supported before Gen6. */ + if (brw->gen < 6) { + DBG("%s: Older Gen not supported.\n", __FUNCTION__); + return false; + } + + if (!brw->has_llc || + packing->Alignment > 4 || + packing->SkipPixels > 0 || + packing->SkipRows > 0 || + (packing->RowLength != 0 && packing->RowLength != width) || + packing->LsbFirst || + packing->Invert || + dst_image->Width == 0 || + dst_image->Height == 0 || + dst_image->Depth == 0) { + return false; + } + + if (0 != srcX0 || 0 != srcY0 || 0 != dstX0 || 0 != dstY0) { + DBG("%s: Sub image loads not currently supported\n", __FUNCTION__); + return false; + } + + if (!brw->ctx.Driver.AllocTextureImageBuffer(&brw->ctx, dst_image)) { + DBG("%s: AllocTextureImageBuffer failed\n", __FUNCTION__); + return false; + } + + /* get pointer to src pixels (may be in a pbo which we'll map here) */ + const GLvoid *src = + _mesa_validate_pbo_teximage(&brw->ctx, dims, width, height, 1, + format, type, src_pixels, packing, "glTexImage"); + + if (!src) { + return true; + } + + /* Come up with a match to the source format for the texture cache */ + gl_format cacheTexFormat = _mesa_choose_cached_tex_format(&brw->ctx, format, type); + +// _mesa_debug(&brw->ctx, "%s: Cache Texture Format: %s, Target Format: %s, Internal Format: %s\n", +// __FUNCTION__, _mesa_get_format_name(cacheTexFormat), _mesa_get_format_name(dst_image->TexFormat), +// _mesa_lookup_enum_by_nr(dst_image->InternalFormat)); + + if (!brw_blorp_blit_params::test_formats(brw, cacheTexFormat, dst_image->TexFormat, dst_image->InternalFormat)) { + return false; + } + + struct intel_mipmap_tree *src_mt = + intel_miptree_create_for_client_texture_DMA(brw, dst_image->TexObject->Target, + format, cacheTexFormat, type, dst_image->Level, src, + width, height, packing); + + if (!src_mt) { + DBG("%s: Creation of src_mt failed\n", __FUNCTION__); + return false; + } + + _mesa_unmap_teximage_pbo(&brw->ctx, packing); + + struct intel_mipmap_tree *dst_mt = intel_texture_image(dst_image)->mt; + + GLuint numSlices = 1; + GLint depth = 1; + /* compute slice info (and do some sanity checks) */ + switch (dst_image->TexObject->Target) { + case GL_TEXTURE_2D: + case GL_TEXTURE_RECTANGLE: + case GL_TEXTURE_CUBE_MAP: + /* one image slice, nothing special needs to be done */ + break; + case GL_TEXTURE_1D: + break; + case GL_TEXTURE_1D_ARRAY: + numSlices = height; + height = 1; + dstY0 = 0; + break; + case GL_TEXTURE_2D_ARRAY: + numSlices = depth; + depth = 1; + break; + case GL_TEXTURE_3D: + /* we'll store 3D images as a series of slices */ + numSlices = depth; + break; + case GL_TEXTURE_CUBE_MAP_ARRAY: + numSlices = depth; + break; + default: + _mesa_debug(&brw->ctx, "Unexpected target 0x%x in store_texsubimage()", dst_image->TexObject->Target); + } + + /* Source clipping shouldn't be necessary, since copytexsubimage (in + * src/mesa/main/teximage.c) calls _mesa_clip_copytexsubimage() which + * takes care of it. + * + * + * Destination clipping shouldn't be necessary since the restrictions on + * glCopyTexSubImage prevent the user from specifying a destination rectangle + * that falls outside the bounds of the destination texture. + * See error_check_subtexture_dimensions(). + */ + + int srcY1 = srcY0 + height; + int srcX1 = srcX0 + width; + int dstX1 = dstX0 + width; + int dstY1 = dstY0 + height; + + /* Account for the fact that in the system framebuffer, the origin is at + * the lower left. + */ + bool mirror_y = false; + if (!_mesa_is_winsys_fbo(brw->ctx.ReadBuffer)) { + GLint tmp = height - srcY0; + srcY0 = height - srcY1; + srcY1 = tmp; + mirror_y = true; + } + + + for (slice = 0; slice < numSlices; slice++) { + if (false == brw_blorp_blit_miptrees(brw, + src_mt, dst_image->Level, dst_image->Face + slice, + dst_mt, dst_image->Level, dst_image->Face + slice, + srcX0, srcY0, srcX1, srcY1, + dstX0, dstY0, dstX1, dstY1, + GL_NEAREST, false, mirror_y)) { + _mesa_debug(&brw->ctx, "brw_blorp_blit_miptrees failed.\n"); + intel_miptree_release(&src_mt); + return false; + } + + } + + intel_miptree_release(&src_mt); + return true; +} + + +bool brw_blorp_copytexsubimage(struct brw_context *brw, struct gl_renderbuffer *src_rb, struct gl_texture_image *dst_image, @@ -373,15 +527,7 @@ brw_blorp_copytexsubimage(struct brw_context *brw, struct intel_mipmap_tree *src_mt = src_irb->mt; struct intel_mipmap_tree *dst_mt = intel_image->mt; -<<<<<<< HEAD - /* BLORP is not supported before Gen6. */ - if (brw->gen < 6 || brw->gen >= 8) - return false; - -======= ->>>>>>> Allow blorp to make decisions about the formats that it supports where it can - if (_mesa_get_format_base_format(src_mt->format) != - _mesa_get_format_base_format(dst_mt->format)) { + if (!brw_blorp_blit_params::test_formats(brw, src_mt->format, dst_mt->format)) { return false; } @@ -653,6 +799,7 @@ private: void encode_msaa(unsigned num_samples, intel_msaa_layout layout); void decode_msaa(unsigned num_samples, intel_msaa_layout layout); void kill_if_outside_dst_rect(); + void translate_texture_formats(); void translate_dst_to_src(); void clamp_tex_coords(struct brw_reg regX, struct brw_reg regY, struct brw_reg clampX0, struct brw_reg clampY0, @@ -911,9 +1058,12 @@ brw_blorp_blit_program::compile(struct brw_context *brw, if (key->tex_layout == INTEL_MSAA_LAYOUT_CMS) mcs_fetch(); texel_fetch(texture_data[0]); + } } + translate_texture_formats(); + /* Finally, write the fetched (or blended) value to the render target and * terminate the thread. */ @@ -962,7 +1112,7 @@ brw_blorp_blit_program::alloc_regs() reg += BRW_BLORP_NUM_PUSH_CONST_REGS; for (unsigned i = 0; i < ARRAY_SIZE(texture_data); ++i) { this->texture_data[i] = - retype(vec16(brw_vec8_grf(reg, 0)), key->texture_data_type); + retype(vec16(brw_vec8_grf(reg, 0)), key->src_texture_data_type); reg += 8; } this->mcs_data = @@ -1427,6 +1577,24 @@ brw_blorp_blit_program::kill_if_outside_dst_rect() * coordinates. */ void +brw_blorp_blit_program::translate_texture_formats() +{ + /* Move the floats to UD registers. */ +// struct brw_reg reg = offset(texture_data[0], 0); +// brw_MOV(&func, retype(reg, BRW_REGISTER_TYPE_F), reg); +// reg = offset(texture_data[0], 2); +// brw_MOV(&func, retype(reg, BRW_REGISTER_TYPE_F), reg); +// reg = offset(texture_data[0], 4); +// brw_MOV(&func, retype(reg, BRW_REGISTER_TYPE_F), reg); +// reg = offset(texture_data[0], 6); +// brw_MOV(&func, retype(reg, BRW_REGISTER_TYPE_F), reg); +} + +/** + * Emit code to translate from destination (X, Y) coordinates to source (X, Y) + * coordinates. + */ +void brw_blorp_blit_program::translate_dst_to_src() { struct brw_reg X_f = retype(X, BRW_REGISTER_TYPE_F); @@ -1590,7 +1758,7 @@ brw_blorp_blit_program::manual_blend_average(unsigned num_samples) struct brw_reg, struct brw_reg); brw_op2_ptr combine_op = - key->texture_data_type == BRW_REGISTER_TYPE_F ? brw_ADD : brw_AVG; + key->src_texture_data_type == BRW_REGISTER_TYPE_F ? brw_ADD : brw_AVG; unsigned stack_depth = 0; for (unsigned i = 0; i < num_samples; ++i) { assert(stack_depth == _mesa_bitcount(i)); /* Loop invariant */ @@ -1642,7 +1810,7 @@ brw_blorp_blit_program::manual_blend_average(unsigned num_samples) /* We should have just 1 sample on the stack now. */ assert(stack_depth == 1); - if (key->texture_data_type == BRW_REGISTER_TYPE_F) { + if (key->src_texture_data_type == BRW_REGISTER_TYPE_F) { /* Scale the result down by a factor of num_samples */ /* TODO: should use a smaller loop bound for non-RGBA formats */ for (int j = 0; j < 4; ++j) { @@ -1981,7 +2149,7 @@ void brw_blorp_blit_program::render_target_write() { struct brw_reg mrf_rt_write = - retype(vec16(brw_message_reg(base_mrf)), key->texture_data_type); + retype(vec16(brw_message_reg(base_mrf)), key->dst_texture_data_type); int mrf_offset = 0; /* If we may have killed pixels, then we need to send R0 and R1 in a header @@ -2076,63 +2244,147 @@ compute_msaa_layout_for_pipeline(struct brw_context *brw, unsigned num_samples, return true_layout; } +GLuint +brw_blorp_blit_params::find_brw_format(struct brw_context *brw, gl_format src_format) { + unsigned componentCount = _mesa_base_format_component_count(src_format); +} -brw_blorp_blit_params::brw_blorp_blit_params(struct brw_context *brw, - struct intel_mipmap_tree *src_mt, - unsigned src_level, unsigned src_layer, - struct intel_mipmap_tree *dst_mt, - unsigned dst_level, unsigned dst_layer, - GLfloat src_x0, GLfloat src_y0, - GLfloat src_x1, GLfloat src_y1, - GLfloat dst_x0, GLfloat dst_y0, - GLfloat dst_x1, GLfloat dst_y1, - GLenum filter, - bool mirror_x, bool mirror_y) - : valid_parameters(false) +bool +brw_blorp_blit_params::test_formats(struct brw_context *brw, + gl_format src_format, + gl_format dst_format, + GLint internal_format) { struct gl_context *ctx = &brw->ctx; /* BLORP is not supported before Gen6. */ if (brw->gen < 6) - return; + return false; - if (MESA_FORMAT_NONE == src_mt->format || MESA_FORMAT_COUNT <= src_mt->format) { - perf_debug("%s: Blorp doesn't yet support provided source format.\n", __FUNCTION__); - return; + if (MESA_FORMAT_NONE == src_format || MESA_FORMAT_COUNT <= src_format) { + _mesa_debug(ctx, "%s: Blorp doesn't yet support provided source format: %s\n", + __FUNCTION__, _mesa_get_format_name(src_format)); + return false; + } + + if (MESA_FORMAT_NONE == dst_format || MESA_FORMAT_COUNT <= dst_format) { + _mesa_debug(ctx, "%s: Blorp doesn't yet support provided destination format: %s\n", + __FUNCTION__, _mesa_get_format_name(dst_format)); + return false; } /* We can't handle format conversions between Z24 and other formats since * we have to lie about the surface format. See the comments in * brw_blorp_surface_info::set(). */ - if ((src_mt->format == MESA_FORMAT_X8_Z24) != - (dst_mt->format == MESA_FORMAT_X8_Z24)) { - return; + if ((src_format == MESA_FORMAT_X8_Z24) != (dst_format == MESA_FORMAT_X8_Z24)) { + _mesa_debug(ctx, "%s: Blorp requires source and destination to match for MESA_FORMAT_X8_Z24.\n", __FUNCTION__); + return false; } /* blorp lies about some formats to placate the GPU. */ - const GLint srcFormatTranslated = translate_tex_format(brw, src_mt->format, 0, true); - const GLint dstFormatTranslated = translate_tex_format(brw, dst_mt->format, 0, true); - if (0 == srcFormatTranslated || 0 == dstFormatTranslated) { - perf_debug("%s: compatible brw_surface format not found for source or target " - "texture mip tree. Source: %s Target: %s\n", - __FUNCTION__, _mesa_get_format_name(src_mt->format), - _mesa_get_format_name(dst_mt->format)); - return; + blorp_process_format src_process_flags; + const GLint srcFormatTranslated = translate_tex_format(brw, src_format, 0, true, &src_process_flags); + blorp_process_format dst_process_flags; + const GLint dstFormatTranslated = translate_tex_format(brw, dst_format, 0, true, &dst_process_flags); + if ((src_process_flags & supported_mask) || (dst_process_flags & supported_mask)) { + _mesa_debug(ctx, "%s: compatible brw_surface format not found for source or target " + "texture mip tree. Source: %s Target: %s\n", + __FUNCTION__, _mesa_get_format_name(src_format), + _mesa_get_format_name(dst_format)); + return false; } - if (!brw->format_supported_as_render_target[dst_mt->format]) { - perf_debug("%s: The translated target miptree format is not supported as a render target: %s.\n", - __FUNCTION__, _mesa_get_format_name(dst_mt->format)); - return; + if (!brw_format_for_render(brw, dstFormatTranslated)) { + _mesa_debug(ctx, "%s: The translated target miptree format is not supported as a render target: %s.\n", + __FUNCTION__, _mesa_get_format_name(dst_format)); + return false; } if (!brw_format_for_sampling(brw, srcFormatTranslated)) { - perf_debug("%s: The translated source miptree format is not supported for sampling: %s.\n", - __FUNCTION__, _mesa_get_format_name(src_mt->format)); - return; + _mesa_debug(ctx, "%s: The translated source miptree format is not supported for sampling: %s.\n", + __FUNCTION__, _mesa_get_format_name(src_format)); + return false; + } + + if (0 != internal_format) { + GLenum baseSourceFormat = _mesa_get_format_base_format(src_format); + GLenum internalFormat = _mesa_base_tex_format(&brw->ctx, internal_format); + switch (baseSourceFormat) { + case GL_RED: + case GL_RG: + case GL_RGB: + case GL_RGBA: + switch (internalFormat) { + case GL_RED: + case GL_RG: + case GL_RGB: + case GL_RGBA: + case GL_ALPHA: + break; + default: + /* + * Blorp does not properly handle Luminance internalFormat (meanwhile Mesa chooses + * a RGB target, thus blorp never even knows that luminance was requested). + */ + _mesa_debug(&brw->ctx, "%s: Target internal format %s doesn't match cached base: %s\n", + __FUNCTION__, _mesa_lookup_enum_by_nr(internalFormat), _mesa_lookup_enum_by_nr(baseSourceFormat)); + return false; + } + break; + case GL_LUMINANCE: + case GL_LUMINANCE_ALPHA: + switch (internalFormat) { + case GL_RED: + case GL_RG: + case GL_RGB: + case GL_RGBA: + case GL_ALPHA: + case GL_INTENSITY: + case GL_LUMINANCE: + case GL_LUMINANCE_ALPHA: + break; + default: + _mesa_debug(&brw->ctx, "%s: Target base format %s doesn't match cached base: %s\n", + __FUNCTION__, _mesa_lookup_enum_by_nr(internalFormat), _mesa_lookup_enum_by_nr(baseSourceFormat)); + return false; + } + case GL_DEPTH_COMPONENT: + if (GL_DEPTH_COMPONENT == internalFormat) { + break; + } + _mesa_debug(&brw->ctx, "%s: Target base format %s doesn't match cached base: %s\n", + __FUNCTION__, _mesa_lookup_enum_by_nr(internalFormat), _mesa_lookup_enum_by_nr(baseSourceFormat)); + return false; + case GL_STENCIL_INDEX: + case GL_DEPTH_STENCIL: + if (GL_DEPTH_STENCIL == internalFormat || GL_STENCIL_INDEX == internalFormat) { + break; + } + default: + _mesa_debug(&brw->ctx, "%s: Target base format %s doesn't match cached base: %s\n", + __FUNCTION__, _mesa_lookup_enum_by_nr(internalFormat), _mesa_lookup_enum_by_nr(baseSourceFormat)); + return false; + } } + return true; +} + +brw_blorp_blit_params::brw_blorp_blit_params(struct brw_context *brw, + struct intel_mipmap_tree *src_mt, + unsigned src_level, unsigned src_layer, + struct intel_mipmap_tree *dst_mt, + unsigned dst_level, unsigned dst_layer, + GLfloat src_x0, GLfloat src_y0, + GLfloat src_x1, GLfloat src_y1, + GLfloat dst_x0, GLfloat dst_y0, + GLfloat dst_x1, GLfloat dst_y1, + GLenum filter, + bool mirror_x, bool mirror_y) +{ + struct gl_context *ctx = &brw->ctx; + const struct gl_framebuffer *read_fb = ctx->ReadBuffer; src.set(brw, src_mt, src_level, src_layer, false); dst.set(brw, dst_mt, dst_level, dst_layer, true); @@ -2156,7 +2408,8 @@ brw_blorp_blit_params::brw_blorp_blit_params(struct brw_context *brw, _mesa_get_format_color_encoding(dst_mt->format) == GL_SRGB && _mesa_get_srgb_format_linear(src_mt->format) == _mesa_get_srgb_format_linear(dst_mt->format)) { - dst.brw_surfaceformat = brw_format_for_mesa_format(dst_mt->format); + blorp_process_format process_flags; + dst.brw_surfaceformat = brw_format_for_mesa_format(dst_mt->format, &process_flags); src.brw_surfaceformat = dst.brw_surfaceformat; } @@ -2178,25 +2431,47 @@ brw_blorp_blit_params::brw_blorp_blit_params(struct brw_context *brw, use_wm_prog = true; memset(&wm_prog_key, 0, sizeof(wm_prog_key)); - /* texture_data_type indicates the register type that should be used to + /* src_texture_data_type indicates the register type that should be used to * manipulate texture data. */ switch (_mesa_get_format_datatype(src_mt->format)) { case GL_UNSIGNED_NORMALIZED: case GL_SIGNED_NORMALIZED: case GL_FLOAT: - wm_prog_key.texture_data_type = BRW_REGISTER_TYPE_F; + wm_prog_key.src_texture_data_type = BRW_REGISTER_TYPE_F; + break; + case GL_UNSIGNED_INT: + if (src_mt->format == MESA_FORMAT_S8) { + /* We process stencil as though it's an unsigned normalized color */ + wm_prog_key.src_texture_data_type = BRW_REGISTER_TYPE_F; + } else { + wm_prog_key.src_texture_data_type = BRW_REGISTER_TYPE_UD; + } + break; + case GL_INT: + wm_prog_key.src_texture_data_type = BRW_REGISTER_TYPE_D; + break; + default: + _mesa_debug(&brw->ctx, "Unrecognized blorp format"); + break; + } + + switch (_mesa_get_format_datatype(dst_mt->format)) { + case GL_UNSIGNED_NORMALIZED: + case GL_SIGNED_NORMALIZED: + case GL_FLOAT: + wm_prog_key.dst_texture_data_type = BRW_REGISTER_TYPE_F; break; case GL_UNSIGNED_INT: if (src_mt->format == MESA_FORMAT_S8) { /* We process stencil as though it's an unsigned normalized color */ - wm_prog_key.texture_data_type = BRW_REGISTER_TYPE_F; + wm_prog_key.dst_texture_data_type = BRW_REGISTER_TYPE_F; } else { - wm_prog_key.texture_data_type = BRW_REGISTER_TYPE_UD; + wm_prog_key.dst_texture_data_type = BRW_REGISTER_TYPE_UD; } break; case GL_INT: - wm_prog_key.texture_data_type = BRW_REGISTER_TYPE_D; + wm_prog_key.dst_texture_data_type = BRW_REGISTER_TYPE_D; break; default: _mesa_debug(&brw->ctx, "Unrecognized blorp format"); @@ -2400,7 +2675,6 @@ brw_blorp_blit_params::brw_blorp_blit_params(struct brw_context *brw, src.x_offset *= 2; src.y_offset /= 2; } - valid_parameters = true; } uint32_t diff --git a/src/mesa/drivers/dri/i965/brw_context.h b/src/mesa/drivers/dri/i965/brw_context.h index 63dd4a0261..6382fb53b8 100644 --- a/src/mesa/drivers/dri/i965/brw_context.h +++ b/src/mesa/drivers/dri/i965/brw_context.h @@ -183,6 +183,32 @@ enum brw_state_id { BRW_NUM_STATE_BITS }; +typedef enum { + scale_x = 1 << 0, + scale_y = 1 << 1, + scale_z = 1 << 2, + scale_w = 1 << 3, + swizzle_x = 1 << 4, + swizzle_y = 1 << 5, + swizzle_z = 1 << 6, + swizzle_w = 1 << 7, + type_convert = 1 << 8, + + alpha_shadow = 1 << 9, + intensity_shadow = 1 << 10, + luminance_shadow = 1 << 11, + x_shadow = 1 << 12, + + scale_mask = scale_x | scale_y | scale_z | scale_w, + scale_xy = scale_x | scale_y, + swizzle_mask = swizzle_x | swizzle_y | swizzle_z | swizzle_w, + swizzle_all = swizzle_mask, + swizzle_xy = swizzle_x | swizzle_y, + swizzle_xyz = swizzle_x | swizzle_y | swizzle_z, + swizzle_yzw = swizzle_y | swizzle_z | swizzle_w, + supported_mask = scale_mask | swizzle_mask +} blorp_process_format; + #define BRW_NEW_URB_FENCE (1 << BRW_STATE_URB_FENCE) #define BRW_NEW_FRAGMENT_PROGRAM (1 << BRW_STATE_FRAGMENT_PROGRAM) #define BRW_NEW_GEOMETRY_PROGRAM (1 << BRW_STATE_GEOMETRY_PROGRAM) @@ -1704,6 +1730,17 @@ brw_blorp_framebuffer(struct brw_context *brw, GLbitfield mask, GLenum filter); bool +brw_blorp_GPUcopytexsubimage(struct brw_context *brw, + GLuint dims, struct gl_texture_image *dst_image, + GLenum format, GLenum type, + const GLvoid *src_pixels, + const struct gl_pixelstore_attrib *packing, + GLuint slice, + GLint srcX0, GLint srcY0, + GLint dstX0, GLint dstY0, + GLint width, GLint height); + +bool brw_blorp_copytexsubimage(struct brw_context *brw, struct gl_renderbuffer *src_rb, struct gl_texture_image *dst_image, diff --git a/src/mesa/drivers/dri/i965/brw_state.h b/src/mesa/drivers/dri/i965/brw_state.h index 0785456dd7..28db5cf813 100644 --- a/src/mesa/drivers/dri/i965/brw_state.h +++ b/src/mesa/drivers/dri/i965/brw_state.h @@ -132,7 +132,6 @@ extern const struct brw_tracked_state gen7_vs_state; extern const struct brw_tracked_state gen7_wm_state; extern const struct brw_tracked_state haswell_cut_index; - /* brw_misc_state.c */ void brw_upload_invariant_state(struct brw_context *brw); uint32_t @@ -187,7 +186,8 @@ void gen4_init_vtable_surface_functions(struct brw_context *brw); uint32_t brw_get_surface_tiling_bits(uint32_t tiling); uint32_t brw_get_surface_num_multisamples(unsigned num_samples); -uint32_t brw_format_for_mesa_format(gl_format mesa_format); +uint32_t brw_format_for_mesa_format(gl_format mesa_format, blorp_process_format *process_flags); +bool brw_format_for_render(struct brw_context *brw, const unsigned brw_surface_sel); bool brw_format_for_sampling(struct brw_context *brw, const unsigned brw_surface_sel); GLuint translate_tex_target(GLenum target); @@ -195,7 +195,8 @@ GLuint translate_tex_target(GLenum target); GLuint translate_tex_format(struct brw_context *brw, gl_format mesa_format, GLenum srgb_decode, - bool for_render); + bool for_render, + blorp_process_format *process_flags); int brw_get_texture_swizzle(const struct gl_context *ctx, const struct gl_texture_object *t); diff --git a/src/mesa/drivers/dri/i965/brw_surface_formats.c b/src/mesa/drivers/dri/i965/brw_surface_formats.c index 9bd905b711..ee30f73c46 100644 --- a/src/mesa/drivers/dri/i965/brw_surface_formats.c +++ b/src/mesa/drivers/dri/i965/brw_surface_formats.c @@ -308,228 +308,241 @@ const struct surface_format_info surface_formats[] = { }; bool +brw_format_for_render(struct brw_context *brw, const unsigned brw_surface_sel) +{ + return (surface_formats[brw_surface_sel].render_target <= brw->gen * 10); +} + +bool brw_format_for_sampling(struct brw_context *brw, const unsigned brw_surface_sel) { - return (brw_surface_sel && surface_formats[brw_surface_sel].sampling <= brw->gen * 10); + return (surface_formats[brw_surface_sel].sampling <= brw->gen * 10); } #undef x #undef Y +struct format_translator { + u_int16_t brw_format; + blorp_process_format process_flags; +}; + uint32_t -brw_format_for_mesa_format(gl_format mesa_format) +brw_format_for_mesa_format(gl_format mesa_format, blorp_process_format *process_flags) { /* This table is ordered according to the enum ordering in formats.h. We do * expect that enum to be extended without our explicit initialization * staying in sync, so we initialize to 0 even though * BRW_SURFACEFORMAT_R32G32B32A32_FLOAT happens to also be 0. */ - static const uint32_t table[MESA_FORMAT_COUNT] = + static const struct format_translator table[MESA_PRIVATE_FORMAT_COUNT] = { - [MESA_FORMAT_RGBA8888] = 0, - [MESA_FORMAT_RGBA8888_REV] = BRW_SURFACEFORMAT_R8G8B8A8_UNORM, - [MESA_FORMAT_ARGB8888] = BRW_SURFACEFORMAT_B8G8R8A8_UNORM, - [MESA_FORMAT_ARGB8888_REV] = 0, - [MESA_FORMAT_RGBX8888] = 0, - [MESA_FORMAT_RGBX8888_REV] = BRW_SURFACEFORMAT_R8G8B8X8_UNORM, - [MESA_FORMAT_XRGB8888] = BRW_SURFACEFORMAT_B8G8R8X8_UNORM, - [MESA_FORMAT_XRGB8888_REV] = 0, - [MESA_FORMAT_RGB888] = 0, - [MESA_FORMAT_BGR888] = BRW_SURFACEFORMAT_R8G8B8_UNORM, - [MESA_FORMAT_RGB565] = BRW_SURFACEFORMAT_B5G6R5_UNORM, - [MESA_FORMAT_RGB565_REV] = 0, - [MESA_FORMAT_ARGB4444] = BRW_SURFACEFORMAT_B4G4R4A4_UNORM, - [MESA_FORMAT_ARGB4444_REV] = 0, - [MESA_FORMAT_RGBA5551] = 0, - [MESA_FORMAT_ARGB1555] = BRW_SURFACEFORMAT_B5G5R5A1_UNORM, - [MESA_FORMAT_ARGB1555_REV] = 0, - [MESA_FORMAT_AL44] = 0, - [MESA_FORMAT_AL88] = BRW_SURFACEFORMAT_L8A8_UNORM, - [MESA_FORMAT_AL88_REV] = 0, - [MESA_FORMAT_AL1616] = BRW_SURFACEFORMAT_L16A16_UNORM, - [MESA_FORMAT_AL1616_REV] = 0, - [MESA_FORMAT_RGB332] = 0, - [MESA_FORMAT_A8] = BRW_SURFACEFORMAT_A8_UNORM, - [MESA_FORMAT_A16] = BRW_SURFACEFORMAT_A16_UNORM, - [MESA_FORMAT_L8] = BRW_SURFACEFORMAT_L8_UNORM, - [MESA_FORMAT_L16] = BRW_SURFACEFORMAT_L16_UNORM, - [MESA_FORMAT_I8] = BRW_SURFACEFORMAT_I8_UNORM, - [MESA_FORMAT_I16] = BRW_SURFACEFORMAT_I16_UNORM, - [MESA_FORMAT_YCBCR_REV] = BRW_SURFACEFORMAT_YCRCB_NORMAL, - [MESA_FORMAT_YCBCR] = BRW_SURFACEFORMAT_YCRCB_SWAPUVY, - [MESA_FORMAT_R8] = BRW_SURFACEFORMAT_R8_UNORM, - [MESA_FORMAT_GR88] = BRW_SURFACEFORMAT_R8G8_UNORM, - [MESA_FORMAT_RG88] = 0, - [MESA_FORMAT_R16] = BRW_SURFACEFORMAT_R16_UNORM, - [MESA_FORMAT_GR1616] = BRW_SURFACEFORMAT_R16G16_UNORM, - [MESA_FORMAT_RG1616] = 0, - [MESA_FORMAT_ARGB2101010] = BRW_SURFACEFORMAT_B10G10R10A2_UNORM, - [MESA_FORMAT_Z24_S8] = 0, - [MESA_FORMAT_S8_Z24] = 0, - [MESA_FORMAT_Z16] = 0, - [MESA_FORMAT_X8_Z24] = 0, - [MESA_FORMAT_Z24_X8] = 0, - [MESA_FORMAT_Z32] = 0, - [MESA_FORMAT_S8] = 0, - - [MESA_FORMAT_SRGB8] = 0, - [MESA_FORMAT_SRGBA8] = 0, - [MESA_FORMAT_SARGB8] = BRW_SURFACEFORMAT_B8G8R8A8_UNORM_SRGB, - [MESA_FORMAT_SL8] = BRW_SURFACEFORMAT_L8_UNORM_SRGB, - [MESA_FORMAT_SLA8] = BRW_SURFACEFORMAT_L8A8_UNORM_SRGB, - [MESA_FORMAT_SRGB_DXT1] = BRW_SURFACEFORMAT_DXT1_RGB_SRGB, - [MESA_FORMAT_SRGBA_DXT1] = BRW_SURFACEFORMAT_BC1_UNORM_SRGB, - [MESA_FORMAT_SRGBA_DXT3] = BRW_SURFACEFORMAT_BC2_UNORM_SRGB, - [MESA_FORMAT_SRGBA_DXT5] = BRW_SURFACEFORMAT_BC3_UNORM_SRGB, - - [MESA_FORMAT_RGB_FXT1] = BRW_SURFACEFORMAT_FXT1, - [MESA_FORMAT_RGBA_FXT1] = BRW_SURFACEFORMAT_FXT1, - [MESA_FORMAT_RGB_DXT1] = BRW_SURFACEFORMAT_DXT1_RGB, - [MESA_FORMAT_RGBA_DXT1] = BRW_SURFACEFORMAT_BC1_UNORM, - [MESA_FORMAT_RGBA_DXT3] = BRW_SURFACEFORMAT_BC2_UNORM, - [MESA_FORMAT_RGBA_DXT5] = BRW_SURFACEFORMAT_BC3_UNORM, - - [MESA_FORMAT_RGBA_FLOAT32] = BRW_SURFACEFORMAT_R32G32B32A32_FLOAT, - [MESA_FORMAT_RGBA_FLOAT16] = BRW_SURFACEFORMAT_R16G16B16A16_FLOAT, - [MESA_FORMAT_RGB_FLOAT32] = BRW_SURFACEFORMAT_R32G32B32_FLOAT, - [MESA_FORMAT_RGB_FLOAT16] = BRW_SURFACEFORMAT_R16G16B16_FLOAT, - [MESA_FORMAT_ALPHA_FLOAT32] = BRW_SURFACEFORMAT_A32_FLOAT, - [MESA_FORMAT_ALPHA_FLOAT16] = BRW_SURFACEFORMAT_A16_FLOAT, - [MESA_FORMAT_LUMINANCE_FLOAT32] = BRW_SURFACEFORMAT_L32_FLOAT, - [MESA_FORMAT_LUMINANCE_FLOAT16] = BRW_SURFACEFORMAT_L16_FLOAT, - [MESA_FORMAT_LUMINANCE_ALPHA_FLOAT32] = BRW_SURFACEFORMAT_L32A32_FLOAT, - [MESA_FORMAT_LUMINANCE_ALPHA_FLOAT16] = BRW_SURFACEFORMAT_L16A16_FLOAT, - [MESA_FORMAT_INTENSITY_FLOAT32] = BRW_SURFACEFORMAT_I32_FLOAT, - [MESA_FORMAT_INTENSITY_FLOAT16] = BRW_SURFACEFORMAT_I16_FLOAT, - [MESA_FORMAT_R_FLOAT32] = BRW_SURFACEFORMAT_R32_FLOAT, - [MESA_FORMAT_R_FLOAT16] = BRW_SURFACEFORMAT_R16_FLOAT, - [MESA_FORMAT_RG_FLOAT32] = BRW_SURFACEFORMAT_R32G32_FLOAT, - [MESA_FORMAT_RG_FLOAT16] = BRW_SURFACEFORMAT_R16G16_FLOAT, - - [MESA_FORMAT_ALPHA_UINT8] = 0, - [MESA_FORMAT_ALPHA_UINT16] = 0, - [MESA_FORMAT_ALPHA_UINT32] = 0, - [MESA_FORMAT_ALPHA_INT8] = 0, - [MESA_FORMAT_ALPHA_INT16] = 0, - [MESA_FORMAT_ALPHA_INT32] = 0, - - [MESA_FORMAT_INTENSITY_UINT8] = 0, - [MESA_FORMAT_INTENSITY_UINT16] = 0, - [MESA_FORMAT_INTENSITY_UINT32] = 0, - [MESA_FORMAT_INTENSITY_INT8] = 0, - [MESA_FORMAT_INTENSITY_INT16] = 0, - [MESA_FORMAT_INTENSITY_INT32] = 0, - - [MESA_FORMAT_LUMINANCE_UINT8] = 0, - [MESA_FORMAT_LUMINANCE_UINT16] = 0, - [MESA_FORMAT_LUMINANCE_UINT32] = 0, - [MESA_FORMAT_LUMINANCE_INT8] = 0, - [MESA_FORMAT_LUMINANCE_INT16] = 0, - [MESA_FORMAT_LUMINANCE_INT32] = 0, - - [MESA_FORMAT_LUMINANCE_ALPHA_UINT8] = 0, - [MESA_FORMAT_LUMINANCE_ALPHA_UINT16] = 0, - [MESA_FORMAT_LUMINANCE_ALPHA_UINT32] = 0, - [MESA_FORMAT_LUMINANCE_ALPHA_INT8] = 0, - [MESA_FORMAT_LUMINANCE_ALPHA_INT16] = 0, - [MESA_FORMAT_LUMINANCE_ALPHA_INT32] = 0, - - [MESA_FORMAT_R_INT8] = BRW_SURFACEFORMAT_R8_SINT, - [MESA_FORMAT_RG_INT8] = BRW_SURFACEFORMAT_R8G8_SINT, - [MESA_FORMAT_RGB_INT8] = BRW_SURFACEFORMAT_R8G8B8_SINT, - [MESA_FORMAT_RGBA_INT8] = BRW_SURFACEFORMAT_R8G8B8A8_SINT, - [MESA_FORMAT_R_INT16] = BRW_SURFACEFORMAT_R16_SINT, - [MESA_FORMAT_RG_INT16] = BRW_SURFACEFORMAT_R16G16_SINT, - [MESA_FORMAT_RGB_INT16] = BRW_SURFACEFORMAT_R16G16B16_SINT, - [MESA_FORMAT_RGBA_INT16] = BRW_SURFACEFORMAT_R16G16B16A16_SINT, - [MESA_FORMAT_R_INT32] = BRW_SURFACEFORMAT_R32_SINT, - [MESA_FORMAT_RG_INT32] = BRW_SURFACEFORMAT_R32G32_SINT, - [MESA_FORMAT_RGB_INT32] = BRW_SURFACEFORMAT_R32G32B32_SINT, - [MESA_FORMAT_RGBA_INT32] = BRW_SURFACEFORMAT_R32G32B32A32_SINT, - - [MESA_FORMAT_R_UINT8] = BRW_SURFACEFORMAT_R8_UINT, - [MESA_FORMAT_RG_UINT8] = BRW_SURFACEFORMAT_R8G8_UINT, - [MESA_FORMAT_RGB_UINT8] = BRW_SURFACEFORMAT_R8G8B8_UINT, - [MESA_FORMAT_RGBA_UINT8] = BRW_SURFACEFORMAT_R8G8B8A8_UINT, - [MESA_FORMAT_R_UINT16] = BRW_SURFACEFORMAT_R16_UINT, - [MESA_FORMAT_RG_UINT16] = BRW_SURFACEFORMAT_R16G16_UINT, - [MESA_FORMAT_RGB_UINT16] = BRW_SURFACEFORMAT_R16G16B16_UINT, - [MESA_FORMAT_RGBA_UINT16] = BRW_SURFACEFORMAT_R16G16B16A16_UINT, - [MESA_FORMAT_R_UINT32] = BRW_SURFACEFORMAT_R32_UINT, - [MESA_FORMAT_RG_UINT32] = BRW_SURFACEFORMAT_R32G32_UINT, - [MESA_FORMAT_RGB_UINT32] = BRW_SURFACEFORMAT_R32G32B32_UINT, - [MESA_FORMAT_RGBA_UINT32] = BRW_SURFACEFORMAT_R32G32B32A32_UINT, - - [MESA_FORMAT_DUDV8] = BRW_SURFACEFORMAT_R8G8_SNORM, - [MESA_FORMAT_SIGNED_R8] = BRW_SURFACEFORMAT_R8_SNORM, - [MESA_FORMAT_SIGNED_RG88_REV] = BRW_SURFACEFORMAT_R8G8_SNORM, - [MESA_FORMAT_SIGNED_RGBX8888] = 0, - [MESA_FORMAT_SIGNED_RGBA8888] = 0, - [MESA_FORMAT_SIGNED_RGBA8888_REV] = BRW_SURFACEFORMAT_R8G8B8A8_SNORM, - [MESA_FORMAT_SIGNED_R16] = BRW_SURFACEFORMAT_R16_SNORM, - [MESA_FORMAT_SIGNED_GR1616] = BRW_SURFACEFORMAT_R16G16_SNORM, - [MESA_FORMAT_SIGNED_RGB_16] = BRW_SURFACEFORMAT_R16G16B16_SNORM, - [MESA_FORMAT_SIGNED_RGBA_16] = BRW_SURFACEFORMAT_R16G16B16A16_SNORM, - [MESA_FORMAT_RGBA_16] = BRW_SURFACEFORMAT_R16G16B16A16_UNORM, - - [MESA_FORMAT_RED_RGTC1] = BRW_SURFACEFORMAT_BC4_UNORM, - [MESA_FORMAT_SIGNED_RED_RGTC1] = BRW_SURFACEFORMAT_BC4_SNORM, - [MESA_FORMAT_RG_RGTC2] = BRW_SURFACEFORMAT_BC5_UNORM, - [MESA_FORMAT_SIGNED_RG_RGTC2] = BRW_SURFACEFORMAT_BC5_SNORM, - - [MESA_FORMAT_L_LATC1] = 0, - [MESA_FORMAT_SIGNED_L_LATC1] = 0, - [MESA_FORMAT_LA_LATC2] = 0, - [MESA_FORMAT_SIGNED_LA_LATC2] = 0, - - [MESA_FORMAT_ETC1_RGB8] = BRW_SURFACEFORMAT_ETC1_RGB8, - [MESA_FORMAT_ETC2_RGB8] = BRW_SURFACEFORMAT_ETC2_RGB8, - [MESA_FORMAT_ETC2_SRGB8] = BRW_SURFACEFORMAT_ETC2_SRGB8, - [MESA_FORMAT_ETC2_RGBA8_EAC] = BRW_SURFACEFORMAT_ETC2_EAC_RGBA8, - [MESA_FORMAT_ETC2_SRGB8_ALPHA8_EAC] = BRW_SURFACEFORMAT_ETC2_EAC_SRGB8_A8, - [MESA_FORMAT_ETC2_R11_EAC] = BRW_SURFACEFORMAT_EAC_R11, - [MESA_FORMAT_ETC2_RG11_EAC] = BRW_SURFACEFORMAT_EAC_RG11, - [MESA_FORMAT_ETC2_SIGNED_R11_EAC] = BRW_SURFACEFORMAT_EAC_SIGNED_R11, - [MESA_FORMAT_ETC2_SIGNED_RG11_EAC] = BRW_SURFACEFORMAT_EAC_SIGNED_RG11, - [MESA_FORMAT_ETC2_RGB8_PUNCHTHROUGH_ALPHA1] = BRW_SURFACEFORMAT_ETC2_RGB8_PTA, - [MESA_FORMAT_ETC2_SRGB8_PUNCHTHROUGH_ALPHA1] = BRW_SURFACEFORMAT_ETC2_SRGB8_PTA, - - [MESA_FORMAT_SIGNED_A8] = 0, - [MESA_FORMAT_SIGNED_L8] = 0, - [MESA_FORMAT_SIGNED_AL88] = 0, - [MESA_FORMAT_SIGNED_I8] = 0, - [MESA_FORMAT_SIGNED_A16] = 0, - [MESA_FORMAT_SIGNED_L16] = 0, - [MESA_FORMAT_SIGNED_AL1616] = 0, - [MESA_FORMAT_SIGNED_I16] = 0, - - [MESA_FORMAT_RGB9_E5_FLOAT] = BRW_SURFACEFORMAT_R9G9B9E5_SHAREDEXP, - [MESA_FORMAT_R11_G11_B10_FLOAT] = BRW_SURFACEFORMAT_R11G11B10_FLOAT, - - [MESA_FORMAT_Z32_FLOAT] = 0, - [MESA_FORMAT_Z32_FLOAT_X24S8] = 0, - - [MESA_FORMAT_ARGB2101010_UINT] = BRW_SURFACEFORMAT_B10G10R10A2_UINT, - [MESA_FORMAT_ABGR2101010_UINT] = BRW_SURFACEFORMAT_R10G10B10A2_UINT, - - [MESA_FORMAT_XRGB4444_UNORM] = 0, - [MESA_FORMAT_XRGB1555_UNORM] = BRW_SURFACEFORMAT_B5G5R5X1_UNORM, - [MESA_FORMAT_XBGR8888_SNORM] = 0, - [MESA_FORMAT_XBGR8888_SRGB] = 0, - [MESA_FORMAT_XBGR8888_UINT] = 0, - [MESA_FORMAT_XBGR8888_SINT] = 0, - [MESA_FORMAT_XRGB2101010_UNORM] = BRW_SURFACEFORMAT_B10G10R10X2_UNORM, - [MESA_FORMAT_XBGR16161616_UNORM] = BRW_SURFACEFORMAT_R16G16B16X16_UNORM, - [MESA_FORMAT_XBGR16161616_SNORM] = 0, - [MESA_FORMAT_XBGR16161616_FLOAT] = BRW_SURFACEFORMAT_R16G16B16X16_FLOAT, - [MESA_FORMAT_XBGR16161616_UINT] = 0, - [MESA_FORMAT_XBGR16161616_SINT] = 0, - [MESA_FORMAT_XBGR32323232_FLOAT] = BRW_SURFACEFORMAT_R32G32B32X32_FLOAT, - [MESA_FORMAT_XBGR32323232_UINT] = 0, - [MESA_FORMAT_XBGR32323232_SINT] = 0, - }; - assert(mesa_format < MESA_FORMAT_COUNT); - return table[mesa_format]; + [MESA_FORMAT_RGBA8888] = {BRW_SURFACEFORMAT_R8G8B8A8_UNORM, swizzle_all}, + [MESA_FORMAT_RGBA8888_REV] = {BRW_SURFACEFORMAT_R8G8B8A8_UNORM, 0}, + [MESA_FORMAT_ARGB8888] = {BRW_SURFACEFORMAT_B8G8R8A8_UNORM, 0}, + [MESA_FORMAT_ARGB8888_REV] = {BRW_SURFACEFORMAT_B8G8R8A8_UNORM, swizzle_all}, + [MESA_FORMAT_RGBX8888] = {BRW_SURFACEFORMAT_R8G8B8X8_UNORM, swizzle_all}, + [MESA_FORMAT_RGBX8888_REV] = {BRW_SURFACEFORMAT_R8G8B8X8_UNORM, 0}, + [MESA_FORMAT_XRGB8888] = {BRW_SURFACEFORMAT_B8G8R8X8_UNORM, 0}, + [MESA_FORMAT_XRGB8888_REV] = {BRW_SURFACEFORMAT_B8G8R8X8_UNORM, swizzle_all}, + [MESA_FORMAT_RGB888] = {BRW_SURFACEFORMAT_R8G8B8_UNORM, swizzle_xyz}, + [MESA_FORMAT_BGR888] = {BRW_SURFACEFORMAT_R8G8B8_UNORM, 0}, + [MESA_FORMAT_RGB565] = {BRW_SURFACEFORMAT_B5G6R5_UNORM, 0}, + [MESA_FORMAT_RGB565_REV] = {BRW_SURFACEFORMAT_B5G6R5_UNORM, swizzle_xyz}, + [MESA_FORMAT_ARGB4444] = {BRW_SURFACEFORMAT_B4G4R4A4_UNORM, 0}, + [MESA_FORMAT_ARGB4444_REV] = {BRW_SURFACEFORMAT_B4G4R4A4_UNORM, swizzle_all}, + [MESA_FORMAT_RGBA5551] = {BRW_SURFACEFORMAT_B5G5R5A1_UNORM, swizzle_all}, + [MESA_FORMAT_ARGB1555] = {BRW_SURFACEFORMAT_B5G5R5A1_UNORM, 0}, + [MESA_FORMAT_ARGB1555_REV] = {BRW_SURFACEFORMAT_B5G5R5A1_UNORM, swizzle_yzw}, + [MESA_FORMAT_AL44] = {BRW_SURFACEFORMAT_L8A8_UNORM, scale_x}, + [MESA_FORMAT_AL88] = {BRW_SURFACEFORMAT_L8A8_UNORM, 0}, + [MESA_FORMAT_AL88_REV] = {BRW_SURFACEFORMAT_L8A8_UNORM, swizzle_xy}, + [MESA_FORMAT_AL1616] = {BRW_SURFACEFORMAT_L16A16_UNORM, 0}, + [MESA_FORMAT_AL1616_REV] = {BRW_SURFACEFORMAT_L16A16_UNORM, swizzle_xy}, + [MESA_FORMAT_RGB332] = {BRW_SURFACEFORMAT_B5G6R5_UNORM, scale_x}, + [MESA_FORMAT_A8] = {BRW_SURFACEFORMAT_A8_UNORM, 0}, + [MESA_FORMAT_A16] = {BRW_SURFACEFORMAT_A16_UNORM, 0}, + [MESA_FORMAT_L8] = {BRW_SURFACEFORMAT_L8_UNORM, 0}, + [MESA_FORMAT_L16] = {BRW_SURFACEFORMAT_L16_UNORM, 0}, + [MESA_FORMAT_I8] = {BRW_SURFACEFORMAT_I8_UNORM, 0}, + [MESA_FORMAT_I16] = {BRW_SURFACEFORMAT_I16_UNORM, 0}, + [MESA_FORMAT_YCBCR_REV] = {BRW_SURFACEFORMAT_YCRCB_NORMAL, 0}, + [MESA_FORMAT_YCBCR] = {BRW_SURFACEFORMAT_YCRCB_SWAPUVY, 0}, + [MESA_FORMAT_R8] = {BRW_SURFACEFORMAT_R8_UNORM, 0}, + [MESA_FORMAT_GR88] = {BRW_SURFACEFORMAT_R8G8_UNORM, 0}, + [MESA_FORMAT_RG88] = {BRW_SURFACEFORMAT_R8G8_UNORM, swizzle_xy}, + [MESA_FORMAT_R16] = {BRW_SURFACEFORMAT_R16_UNORM, 0}, + [MESA_FORMAT_GR1616] = {BRW_SURFACEFORMAT_R16G16_UNORM, 0}, + [MESA_FORMAT_RG1616] = {BRW_SURFACEFORMAT_R16G16_UNORM, swizzle_xy}, + [MESA_FORMAT_ARGB2101010] = {BRW_SURFACEFORMAT_B10G10R10A2_UNORM, 0}, + [MESA_FORMAT_Z24_S8] = {0, swizzle_all}, + [MESA_FORMAT_S8_Z24] = {0, swizzle_all}, + [MESA_FORMAT_Z16] = {0, swizzle_all}, + [MESA_FORMAT_X8_Z24] = {0, swizzle_all}, + [MESA_FORMAT_Z24_X8] = {0, swizzle_all}, + [MESA_FORMAT_Z32] = {0, swizzle_all}, + [MESA_FORMAT_S8] = {0, swizzle_all}, + + [MESA_FORMAT_SRGB8] = {BRW_SURFACEFORMAT_B8G8R8X8_UNORM_SRGB, swizzle_xyz}, + [MESA_FORMAT_SRGBA8] = {BRW_SURFACEFORMAT_B8G8R8A8_UNORM_SRGB, swizzle_all}, + [MESA_FORMAT_SARGB8] = {BRW_SURFACEFORMAT_B8G8R8A8_UNORM_SRGB, 0}, + [MESA_FORMAT_SL8] = {BRW_SURFACEFORMAT_L8_UNORM_SRGB, 0}, + [MESA_FORMAT_SLA8] = {BRW_SURFACEFORMAT_L8A8_UNORM_SRGB, 0}, + [MESA_FORMAT_SRGB_DXT1] = {BRW_SURFACEFORMAT_DXT1_RGB_SRGB, 0}, + [MESA_FORMAT_SRGBA_DXT1] = {BRW_SURFACEFORMAT_BC1_UNORM_SRGB, 0}, + [MESA_FORMAT_SRGBA_DXT3] = {BRW_SURFACEFORMAT_BC2_UNORM_SRGB, 0}, + [MESA_FORMAT_SRGBA_DXT5] = {BRW_SURFACEFORMAT_BC3_UNORM_SRGB, 0}, + + [MESA_FORMAT_RGB_FXT1] = {BRW_SURFACEFORMAT_FXT1, 0}, + [MESA_FORMAT_RGBA_FXT1] = {BRW_SURFACEFORMAT_FXT1, 0}, + [MESA_FORMAT_RGB_DXT1] = {BRW_SURFACEFORMAT_DXT1_RGB, 0}, + [MESA_FORMAT_RGBA_DXT1] = {BRW_SURFACEFORMAT_BC1_UNORM, 0}, + [MESA_FORMAT_RGBA_DXT3] = {BRW_SURFACEFORMAT_BC2_UNORM, 0}, + [MESA_FORMAT_RGBA_DXT5] = {BRW_SURFACEFORMAT_BC3_UNORM, 0}, + + [MESA_FORMAT_RGBA_FLOAT32] = {BRW_SURFACEFORMAT_R32G32B32A32_FLOAT, 0}, + [MESA_FORMAT_RGBA_FLOAT16] = {BRW_SURFACEFORMAT_R16G16B16A16_FLOAT, 0}, + [MESA_FORMAT_RGB_FLOAT32] = {BRW_SURFACEFORMAT_R32G32B32_FLOAT, 0}, + [MESA_FORMAT_RGB_FLOAT16] = {BRW_SURFACEFORMAT_R16G16B16_FLOAT, 0}, + [MESA_FORMAT_ALPHA_FLOAT32] = {BRW_SURFACEFORMAT_A32_FLOAT, 0}, + [MESA_FORMAT_ALPHA_FLOAT16] = {BRW_SURFACEFORMAT_A16_FLOAT, 0}, + [MESA_FORMAT_LUMINANCE_FLOAT32] = {BRW_SURFACEFORMAT_L32_FLOAT, 0}, + [MESA_FORMAT_LUMINANCE_FLOAT16] = {BRW_SURFACEFORMAT_L16_FLOAT, 0}, + [MESA_FORMAT_LUMINANCE_ALPHA_FLOAT32] = {BRW_SURFACEFORMAT_L32A32_FLOAT, 0}, + [MESA_FORMAT_LUMINANCE_ALPHA_FLOAT16] = {BRW_SURFACEFORMAT_L16A16_FLOAT, 0}, + [MESA_FORMAT_INTENSITY_FLOAT32] = {BRW_SURFACEFORMAT_I32_FLOAT, 0}, + [MESA_FORMAT_INTENSITY_FLOAT16] = {BRW_SURFACEFORMAT_I16_FLOAT, 0}, + [MESA_FORMAT_R_FLOAT32] = {BRW_SURFACEFORMAT_R32_FLOAT, 0}, + [MESA_FORMAT_R_FLOAT16] = {BRW_SURFACEFORMAT_R16_FLOAT, 0}, + [MESA_FORMAT_RG_FLOAT32] = {BRW_SURFACEFORMAT_R32G32_FLOAT, 0}, + [MESA_FORMAT_RG_FLOAT16] = {BRW_SURFACEFORMAT_R16G16_FLOAT, 0}, + + [MESA_FORMAT_ALPHA_UINT8] = {BRW_SURFACEFORMAT_R8_UINT, type_convert | alpha_shadow}, + [MESA_FORMAT_ALPHA_UINT16] = {BRW_SURFACEFORMAT_R16_UINT, type_convert | alpha_shadow}, + [MESA_FORMAT_ALPHA_UINT32] = {BRW_SURFACEFORMAT_R32_UINT, type_convert | alpha_shadow}, + [MESA_FORMAT_ALPHA_INT8] = {BRW_SURFACEFORMAT_R8_SINT, type_convert | alpha_shadow}, + [MESA_FORMAT_ALPHA_INT16] = {BRW_SURFACEFORMAT_R16_SINT, type_convert | alpha_shadow}, + [MESA_FORMAT_ALPHA_INT32] = {BRW_SURFACEFORMAT_R32_SINT, type_convert | alpha_shadow}, + + [MESA_FORMAT_INTENSITY_UINT8] = {BRW_SURFACEFORMAT_R8_UINT, type_convert | intensity_shadow}, + [MESA_FORMAT_INTENSITY_UINT16] = {BRW_SURFACEFORMAT_R16_UINT, type_convert | intensity_shadow}, + [MESA_FORMAT_INTENSITY_UINT32] = {BRW_SURFACEFORMAT_R32_UINT, type_convert | intensity_shadow}, + [MESA_FORMAT_INTENSITY_INT8] = {BRW_SURFACEFORMAT_R8_SINT, type_convert | intensity_shadow}, + [MESA_FORMAT_INTENSITY_INT16] = {BRW_SURFACEFORMAT_R16_SINT, type_convert | intensity_shadow}, + [MESA_FORMAT_INTENSITY_INT32] = {BRW_SURFACEFORMAT_R32_SINT, type_convert | intensity_shadow}, + + [MESA_FORMAT_LUMINANCE_UINT8] = {BRW_SURFACEFORMAT_R8_UINT, type_convert | luminance_shadow}, + [MESA_FORMAT_LUMINANCE_UINT16] = {BRW_SURFACEFORMAT_R16_UINT, type_convert | luminance_shadow}, + [MESA_FORMAT_LUMINANCE_UINT32] = {BRW_SURFACEFORMAT_R32_UINT, type_convert | luminance_shadow}, + [MESA_FORMAT_LUMINANCE_INT8] = {BRW_SURFACEFORMAT_R8_SINT, type_convert | luminance_shadow}, + [MESA_FORMAT_LUMINANCE_INT16] = {BRW_SURFACEFORMAT_R16_SINT, type_convert | luminance_shadow}, + [MESA_FORMAT_LUMINANCE_INT32] = {BRW_SURFACEFORMAT_R32_SINT, type_convert | luminance_shadow}, + + [MESA_FORMAT_LUMINANCE_ALPHA_UINT8] = {BRW_SURFACEFORMAT_R8_UINT, type_convert | luminance_shadow | alpha_shadow}, + [MESA_FORMAT_LUMINANCE_ALPHA_UINT16] = {BRW_SURFACEFORMAT_R16_UINT, type_convert | luminance_shadow | alpha_shadow}, + [MESA_FORMAT_LUMINANCE_ALPHA_UINT32] = {BRW_SURFACEFORMAT_R32_UINT, type_convert | luminance_shadow | alpha_shadow}, + [MESA_FORMAT_LUMINANCE_ALPHA_INT8] = {BRW_SURFACEFORMAT_R8_SINT, type_convert | luminance_shadow | alpha_shadow}, + [MESA_FORMAT_LUMINANCE_ALPHA_INT16] = {BRW_SURFACEFORMAT_R16_SINT, type_convert | luminance_shadow | alpha_shadow}, + [MESA_FORMAT_LUMINANCE_ALPHA_INT32] = {BRW_SURFACEFORMAT_R32_SINT, type_convert | luminance_shadow | alpha_shadow}, + + [MESA_FORMAT_R_INT8] = {BRW_SURFACEFORMAT_R8_SINT, type_convert}, + [MESA_FORMAT_RG_INT8] = {BRW_SURFACEFORMAT_R8G8_SINT, type_convert}, + [MESA_FORMAT_RGB_INT8] = {BRW_SURFACEFORMAT_R8G8B8_SINT, type_convert}, + [MESA_FORMAT_RGBA_INT8] = {BRW_SURFACEFORMAT_R8G8B8A8_SINT, type_convert}, + [MESA_FORMAT_R_INT16] = {BRW_SURFACEFORMAT_R16_SINT, type_convert}, + [MESA_FORMAT_RG_INT16] = {BRW_SURFACEFORMAT_R16G16_SINT, type_convert}, + [MESA_FORMAT_RGB_INT16] = {BRW_SURFACEFORMAT_R16G16B16_SINT, type_convert}, + [MESA_FORMAT_RGBA_INT16] = {BRW_SURFACEFORMAT_R16G16B16A16_SINT, type_convert}, + [MESA_FORMAT_R_INT32] = {BRW_SURFACEFORMAT_R32_SINT, type_convert}, + [MESA_FORMAT_RG_INT32] = {BRW_SURFACEFORMAT_R32G32_SINT, type_convert}, + [MESA_FORMAT_RGB_INT32] = {BRW_SURFACEFORMAT_R32G32B32_SINT, type_convert}, + [MESA_FORMAT_RGBA_INT32] = {BRW_SURFACEFORMAT_R32G32B32A32_SINT, type_convert}, + + [MESA_FORMAT_R_UINT8] = {BRW_SURFACEFORMAT_R8_UINT, type_convert}, + [MESA_FORMAT_RG_UINT8] = {BRW_SURFACEFORMAT_R8G8_UINT, type_convert}, + [MESA_FORMAT_RGB_UINT8] = {BRW_SURFACEFORMAT_R8G8B8_UINT, type_convert}, + [MESA_FORMAT_RGBA_UINT8] = {BRW_SURFACEFORMAT_R8G8B8A8_UINT, type_convert}, + [MESA_FORMAT_R_UINT16] = {BRW_SURFACEFORMAT_R16_UINT, type_convert}, + [MESA_FORMAT_RG_UINT16] = {BRW_SURFACEFORMAT_R16G16_UINT, type_convert}, + [MESA_FORMAT_RGB_UINT16] = {BRW_SURFACEFORMAT_R16G16B16_UINT, type_convert}, + [MESA_FORMAT_RGBA_UINT16] = {BRW_SURFACEFORMAT_R16G16B16A16_UINT, type_convert}, + [MESA_FORMAT_R_UINT32] = {BRW_SURFACEFORMAT_R32_UINT, type_convert}, + [MESA_FORMAT_RG_UINT32] = {BRW_SURFACEFORMAT_R32G32_UINT, type_convert}, + [MESA_FORMAT_RGB_UINT32] = {BRW_SURFACEFORMAT_R32G32B32_UINT, type_convert}, + [MESA_FORMAT_RGBA_UINT32] = {BRW_SURFACEFORMAT_R32G32B32A32_UINT, type_convert}, + + [MESA_FORMAT_DUDV8] = {BRW_SURFACEFORMAT_R8G8_SNORM, 0}, + [MESA_FORMAT_SIGNED_R8] = {BRW_SURFACEFORMAT_R8_SNORM, 0}, + [MESA_FORMAT_SIGNED_RG88_REV] = {BRW_SURFACEFORMAT_R8G8_SNORM, 0}, + [MESA_FORMAT_SIGNED_RGBX8888] = {0, swizzle_all}, + [MESA_FORMAT_SIGNED_RGBA8888] = {0, swizzle_all}, + [MESA_FORMAT_SIGNED_RGBA8888_REV] = {BRW_SURFACEFORMAT_R8G8B8A8_SNORM, 0}, + [MESA_FORMAT_SIGNED_R16] = {BRW_SURFACEFORMAT_R16_SNORM, 0}, + [MESA_FORMAT_SIGNED_GR1616] = {BRW_SURFACEFORMAT_R16G16_SNORM, 0}, + [MESA_FORMAT_SIGNED_RGB_16] = {BRW_SURFACEFORMAT_R16G16B16_SNORM, 0}, + [MESA_FORMAT_SIGNED_RGBA_16] = {BRW_SURFACEFORMAT_R16G16B16A16_SNORM, 0}, + [MESA_FORMAT_RGBA_16] = {BRW_SURFACEFORMAT_R16G16B16A16_UNORM, 0}, + + [MESA_FORMAT_RED_RGTC1] = {BRW_SURFACEFORMAT_BC4_UNORM, 0}, + [MESA_FORMAT_SIGNED_RED_RGTC1] = {BRW_SURFACEFORMAT_BC4_SNORM, 0}, + [MESA_FORMAT_RG_RGTC2] = {BRW_SURFACEFORMAT_BC5_UNORM, 0}, + [MESA_FORMAT_SIGNED_RG_RGTC2] = {BRW_SURFACEFORMAT_BC5_SNORM, 0}, + + [MESA_FORMAT_L_LATC1] = {0, swizzle_all}, + [MESA_FORMAT_SIGNED_L_LATC1] = {0, swizzle_all}, + [MESA_FORMAT_LA_LATC2] = {0, swizzle_all}, + [MESA_FORMAT_SIGNED_LA_LATC2] = {0, swizzle_all}, + + [MESA_FORMAT_ETC1_RGB8] = {BRW_SURFACEFORMAT_ETC1_RGB8, 0}, + [MESA_FORMAT_ETC2_RGB8] = {BRW_SURFACEFORMAT_ETC2_RGB8, 0}, + [MESA_FORMAT_ETC2_SRGB8] = {BRW_SURFACEFORMAT_ETC2_SRGB8, 0}, + [MESA_FORMAT_ETC2_RGBA8_EAC] = {BRW_SURFACEFORMAT_ETC2_EAC_RGBA8, 0}, + [MESA_FORMAT_ETC2_SRGB8_ALPHA8_EAC] = {BRW_SURFACEFORMAT_ETC2_EAC_SRGB8_A8, 0}, + [MESA_FORMAT_ETC2_R11_EAC] = {BRW_SURFACEFORMAT_EAC_R11, 0}, + [MESA_FORMAT_ETC2_RG11_EAC] = {BRW_SURFACEFORMAT_EAC_RG11, 0}, + [MESA_FORMAT_ETC2_SIGNED_R11_EAC] = {BRW_SURFACEFORMAT_EAC_SIGNED_R11, 0}, + [MESA_FORMAT_ETC2_SIGNED_RG11_EAC] = {BRW_SURFACEFORMAT_EAC_SIGNED_RG11, 0}, + [MESA_FORMAT_ETC2_RGB8_PUNCHTHROUGH_ALPHA1] = {BRW_SURFACEFORMAT_ETC2_RGB8_PTA, 0}, + [MESA_FORMAT_ETC2_SRGB8_PUNCHTHROUGH_ALPHA1] = {BRW_SURFACEFORMAT_ETC2_SRGB8_PTA, 0}, + + [MESA_FORMAT_SIGNED_A8] = {0, swizzle_all}, + [MESA_FORMAT_SIGNED_L8] = {0, swizzle_all}, + [MESA_FORMAT_SIGNED_AL88] = {0, swizzle_all}, + [MESA_FORMAT_SIGNED_I8] = {0, swizzle_all}, + [MESA_FORMAT_SIGNED_A16] = {0, swizzle_all}, + [MESA_FORMAT_SIGNED_L16] = {0, swizzle_all}, + [MESA_FORMAT_SIGNED_AL1616] = {0, swizzle_all}, + [MESA_FORMAT_SIGNED_I16] = {0, swizzle_all}, + + [MESA_FORMAT_RGB9_E5_FLOAT] = {BRW_SURFACEFORMAT_R9G9B9E5_SHAREDEXP, 0}, + [MESA_FORMAT_R11_G11_B10_FLOAT] = {BRW_SURFACEFORMAT_R11G11B10_FLOAT, 0}, + + [MESA_FORMAT_Z32_FLOAT] = {0, swizzle_all}, + [MESA_FORMAT_Z32_FLOAT_X24S8] = {0, swizzle_all}, + + [MESA_FORMAT_ARGB2101010_UINT] = {BRW_SURFACEFORMAT_B10G10R10A2_UINT, type_convert}, + [MESA_FORMAT_ABGR2101010_UINT] = {BRW_SURFACEFORMAT_R10G10B10A2_UINT, type_convert}, + + [MESA_FORMAT_XRGB4444_UNORM] = {BRW_SURFACEFORMAT_R8G8_UNORM, swizzle_xy | scale_xy}, + [MESA_FORMAT_XRGB1555_UNORM] = {BRW_SURFACEFORMAT_B5G5R5X1_UNORM, 0}, + [MESA_FORMAT_XBGR8888_SNORM] = {BRW_SURFACEFORMAT_R8G8B8A8_SNORM, swizzle_all | x_shadow}, + [MESA_FORMAT_XBGR8888_SRGB] = {BRW_SURFACEFORMAT_R8G8B8X8_UNORM_SRGB, swizzle_all}, + [MESA_FORMAT_XBGR8888_UINT] = {BRW_SURFACEFORMAT_R8G8B8A8_UINT, swizzle_all | x_shadow}, + [MESA_FORMAT_XBGR8888_SINT] = {BRW_SURFACEFORMAT_R8G8B8A8_SINT, swizzle_all | x_shadow}, + [MESA_FORMAT_XRGB2101010_UNORM] = {BRW_SURFACEFORMAT_B10G10R10X2_UNORM, 0}, + [MESA_FORMAT_XBGR16161616_UNORM] = {BRW_SURFACEFORMAT_R16G16B16X16_UNORM, 0}, + [MESA_FORMAT_XBGR16161616_SNORM] = {BRW_SURFACEFORMAT_R16G16B16A16_SNORM, swizzle_all | x_shadow}, + [MESA_FORMAT_XBGR16161616_FLOAT] = {BRW_SURFACEFORMAT_R16G16B16X16_FLOAT, 0}, + [MESA_FORMAT_XBGR16161616_UINT] = {BRW_SURFACEFORMAT_R16G16B16A16_UINT, swizzle_all | x_shadow}, + [MESA_FORMAT_XBGR16161616_SINT] = {BRW_SURFACEFORMAT_R16G16B16A16_SINT, swizzle_all | x_shadow}, + [MESA_FORMAT_XBGR32323232_FLOAT] = {BRW_SURFACEFORMAT_R32G32B32X32_FLOAT, 0}, + [MESA_FORMAT_XBGR32323232_UINT] = {BRW_SURFACEFORMAT_R32G32B32A32_UINT, swizzle_all | x_shadow}, + [MESA_FORMAT_XBGR32323232_SINT] = {BRW_SURFACEFORMAT_R32G32B32A32_SINT, swizzle_all | x_shadow} + + }; + assert(mesa_format < MESA_PRIVATE_FORMAT_COUNT); + *process_flags = table[mesa_format].process_flags; + return table[mesa_format].brw_format; } void @@ -550,17 +563,19 @@ brw_init_surface_formats(struct brw_context *brw) const struct surface_format_info *rinfo, *tinfo; bool is_integer = _mesa_is_format_integer_color(format); - render = texture = brw_format_for_mesa_format(format); + blorp_process_format process_flags; + render = texture = brw_format_for_mesa_format(format, &process_flags); tinfo = &surface_formats[texture]; /* The value of BRW_SURFACEFORMAT_R32G32B32A32_FLOAT is 0, so don't skip * it. */ if (texture == 0 && format != MESA_FORMAT_RGBA_FLOAT32) - continue; + continue; - if (gen >= tinfo->sampling && (gen >= tinfo->filtering || is_integer)) - ctx->TextureFormatSupported[format] = true; + process_flags &= supported_mask; + if (gen >= tinfo->sampling && (gen >= tinfo->filtering || is_integer) && 0 == process_flags) + ctx->TextureFormatSupported[format] = true; /* Re-map some render target formats to make them supported when they * wouldn't be using their format for texturing. @@ -694,7 +709,8 @@ GLuint translate_tex_format(struct brw_context *brw, gl_format mesa_format, GLenum srgb_decode, - bool for_render) + bool for_render, + blorp_process_format *process_flags) { if (srgb_decode == GL_SKIP_DECODE_EXT) mesa_format = _mesa_get_srgb_format_linear(mesa_format); @@ -717,12 +733,6 @@ translate_tex_format(struct brw_context *brw, case MESA_FORMAT_Z32_FLOAT_X24S8: return BRW_SURFACEFORMAT_R32_FLOAT_X8X24_TYPELESS; - case MESA_FORMAT_RGBA_FLOAT32: - /* The value of this BRW_SURFACEFORMAT is 0, which tricks the - * assertion below. - */ - return for_render ? BRW_SURFACEFORMAT_B8G8R8A8_UNORM : BRW_SURFACEFORMAT_R32G32B32A32_FLOAT; - case MESA_FORMAT_SRGB_DXT1: if (brw->gen == 4 && !brw->is_g4x) { /* Work around missing SRGB DXT1 support on original gen4 by just @@ -735,7 +745,7 @@ translate_tex_format(struct brw_context *brw, } default: - return brw_format_for_mesa_format(mesa_format); + return brw_format_for_mesa_format(mesa_format, process_flags); } } diff --git a/src/mesa/drivers/dri/i965/brw_wm_surface_state.c b/src/mesa/drivers/dri/i965/brw_wm_surface_state.c index 35466647dd..0b5174f42b 100644 --- a/src/mesa/drivers/dri/i965/brw_wm_surface_state.c +++ b/src/mesa/drivers/dri/i965/brw_wm_surface_state.c @@ -238,7 +238,8 @@ brw_update_buffer_texture_surface(struct gl_context *ctx, uint32_t size = tObj->BufferSize; drm_intel_bo *bo = NULL; gl_format format = tObj->_BufferObjectFormat; - uint32_t brw_format = brw_format_for_mesa_format(format); + blorp_process_format process_flags; + uint32_t brw_format = brw_format_for_mesa_format(format, &process_flags); int texel_size = _mesa_get_format_bytes(format); if (intel_obj) { @@ -284,13 +285,14 @@ brw_update_texture_surface(struct gl_context *ctx, (void) for_gather; /* no w/a to apply for this gen */ + blorp_process_format process_flags; surf[0] = (translate_tex_target(tObj->Target) << BRW_SURFACE_TYPE_SHIFT | BRW_SURFACE_MIPMAPLAYOUT_BELOW << BRW_SURFACE_MIPLAYOUT_SHIFT | BRW_SURFACE_CUBEFACE_ENABLES | (translate_tex_format(brw, mt->format, sampler->sRGBDecode, - false) << + false, &process_flags) << BRW_SURFACE_FORMAT_SHIFT)); surf[1] = intelObj->mt->region->bo->offset + intelObj->mt->offset; /* reloc */ diff --git a/src/mesa/drivers/dri/i965/gen7_wm_surface_state.c b/src/mesa/drivers/dri/i965/gen7_wm_surface_state.c index 761bc3ba3e..ac57f7f066 100644 --- a/src/mesa/drivers/dri/i965/gen7_wm_surface_state.c +++ b/src/mesa/drivers/dri/i965/gen7_wm_surface_state.c @@ -289,6 +289,7 @@ gen7_update_texture_surface(struct gl_context *ctx, 8 * 4, 32, surf_offset); memset(surf, 0, 8 * 4); + blorp_process_format process_flags; uint32_t tex_format = translate_tex_format(brw, mt->format, sampler->sRGBDecode); diff --git a/src/mesa/drivers/dri/i965/intel_mipmap_tree.c b/src/mesa/drivers/dri/i965/intel_mipmap_tree.c index 0818226f3c..f97b504d44 100644 --- a/src/mesa/drivers/dri/i965/intel_mipmap_tree.c +++ b/src/mesa/drivers/dri/i965/intel_mipmap_tree.c @@ -42,6 +42,7 @@ #include "main/enums.h" #include "main/formats.h" #include "main/glformats.h" +#include "main/image.h" #include "main/texcompress_etc.h" #include "main/teximage.h" #include "main/streaming-load-memcpy.h" @@ -232,7 +233,8 @@ intel_miptree_create_layout(struct brw_context *brw, GLuint height0, GLuint depth0, bool for_bo, - GLuint num_samples) + GLuint num_samples, + enum intel_miptree_tiling_mode requested_tiling) { struct intel_mipmap_tree *mt = calloc(sizeof(*mt), 1); if (!mt) @@ -361,7 +363,7 @@ intel_miptree_create_layout(struct brw_context *brw, mt->logical_depth0, true, num_samples, - INTEL_MIPTREE_TILING_ANY); + requested_tiling); if (!mt->stencil_mt) { intel_miptree_release(&mt); return NULL; @@ -539,9 +541,9 @@ intel_miptree_create(struct brw_context *brw, etc_format = (format != tex_format) ? tex_format : MESA_FORMAT_NONE; mt = intel_miptree_create_layout(brw, target, format, - first_level, last_level, width0, - height0, depth0, - false, num_samples); + first_level, last_level, width0, + height0, depth0, + false, num_samples, INTEL_MIPTREE_TILING_ANY); /* * pitch == 0 || height == 0 indicates the null texture */ @@ -645,7 +647,8 @@ intel_miptree_create_for_bo(struct brw_context *brw, mt = intel_miptree_create_layout(brw, GL_TEXTURE_2D, format, 0, 0, width, height, 1, - true, 0 /* num_samples */); + true, 0 /* num_samples */, + INTEL_MIPTREE_TILING_ANY); if (!mt) { free(region); return mt; @@ -738,7 +741,220 @@ intel_miptree_create_for_dri2_buffer(struct brw_context *brw, return multisample_mt; } -/** +static int +CopyClientBuffer(struct brw_context *brw, drm_intel_bo *intelBO, + unsigned offset, size_t len, const void *from) +{ + static unsigned totalCount = 0; + static unsigned bailCount = 0; + static unsigned memcpyCount = 0; + + totalCount++; + static double dmaBytes = 0.0; + static double dmaTime = 0.0; + static double mapTime = 0.0; + static double mapBytes = 0.0; + static double memcpyBytes = 0.0; + static double memcpyTime = 0.0; + static double se4cpyBytes = 0.0; + static double se4cpyTime = 0.0; + + enum { + testmemcpy = 0, + testSSE4Memcpy = 1, + testBOSubdata = 0 + }; + +// if (0 == totalCount % 16) { +// _mesa_debug(&brw->ctx, "TotalCount: %d. DMA sec/byte: %g. Memcpy sec/byte: %g. SE4cpy sec/byte: %g.\n", +// totalCount, dmaTime / dmaBytes, memcpyTime / memcpyBytes, se4cpyTime / se4cpyBytes); +// } + + + struct timespec timestruct; + clock_gettime(CLOCK_MONOTONIC, ×truct); + const double time0 = timestruct.tv_sec + timestruct.tv_nsec / 1000000000.0; + + drm_intel_bo_map(intelBO, true); + clock_gettime(CLOCK_MONOTONIC, ×truct); + double time1 = timestruct.tv_sec + timestruct.tv_nsec / 1000000000.0; + + mapTime += time1 - time0; + mapBytes += len; +// _mesa_debug(&brw->ctx, "texture size: %d. Maptime bytes/sec: %g\n", +// len, len / (time1 - time0)); + + if (!intelBO->virtual) { + _mesa_debug(&brw->ctx, "%s: Mapping Failed\n", __FUNCTION__); + return 0; + } + + void *targetHead = (void *)((char *)intelBO->virtual + offset); + +#ifdef __SSE4_1__ + _mesa_streaming_load_memcpy(targetHead, from, len); + clock_gettime(CLOCK_MONOTONIC, ×truct); + time1 = timestruct.tv_sec + timestruct.tv_nsec / 1000000000.0; + + memcpyTime += time1 - time0; + memcpyBytes += len; + _mesa_debug(&brw->ctx, "texture size: %d. Memcpy byte/sec: %g.\n", + len, len / (time1 - time0)); + + return len; +#else + + const unsigned alignOffset = (size_t)targetHead & 0xf; + + if (64 >= len || (alignOffset != ((size_t)from & 0xf)) || testmemcpy) { + bailCount++; + memcpy(targetHead, from, len); + drm_intel_bo_unmap(intelBO); + clock_gettime(CLOCK_MONOTONIC, ×truct); + time1 = timestruct.tv_sec + timestruct.tv_nsec / 1000000000.0; + + memcpyTime += time1 - time0; + memcpyBytes += len; +// _mesa_debug(&brw->ctx, "texture size: %d. Memcpy byte/sec: %g.\n", +// (unsigned)len, len / (time1 - time0)); + + return len; + } + + if (testSSE4Memcpy) { + void *sourceHead; + + if (alignOffset) { + const unsigned byteAlign = 16 - alignOffset; + + memcpy(targetHead, from, byteAlign); + + targetHead = (void *)((char *)targetHead + byteAlign); + sourceHead = (void *)((char *)from + byteAlign); + len -= byteAlign; + _mesa_debug(&brw->ctx, "aligning offset: %d.\n", byteAlign); + + } else { + sourceHead = (void *)from; + } + + memcpyCount++; + + for(unsigned i = 0; i < len / 64; i++) { + __asm__ __volatile__ ( + " movntdqa (%0), %%xmm0\n" + " movntdqa 16(%0), %%xmm2\n" + " movntdqa 32(%0), %%xmm4\n" + " movntdqa 48(%0), %%xmm6\n" + " movdqa %%xmm0, (%1)\n" + " movdqa %%xmm2, 16(%1)\n" + " movdqa %%xmm4, 32(%1)\n" + " movdqa %%xmm6, 48(%1)\n" + : : "r" (sourceHead), "r" (targetHead) : "memory"); + sourceHead += 64; + targetHead += 64; + } + /* + *Now do the tail of the block + */ + const unsigned remainingBytes = len & 63; + if (0 != remainingBytes) { + memcpy(targetHead, sourceHead, remainingBytes); + } + + drm_intel_bo_unmap(intelBO); + +// clock_gettime(CLOCK_MONOTONIC, ×truct); +// time1 = timestruct.tv_sec + timestruct.tv_nsec / 1000000000.0; + +// se4cpyTime += time1 - time0; +// se4cpyBytes += len; +// _mesa_debug(&brw->ctx, "texture size: %d. SEE4 Memcpy byte/sec: %g.\n", +// (int)len, len / (time1 - time0)); + } + + if (testBOSubdata) { + struct timespec timestruct; + clock_gettime(CLOCK_MONOTONIC, ×truct); + double time0 = timestruct.tv_sec + timestruct.tv_nsec / 1000000000.0; + + drm_intel_bo_subdata(intelBO, offset, len, from); + + clock_gettime(CLOCK_MONOTONIC, ×truct); + double time1 = timestruct.tv_sec + timestruct.tv_nsec / 1000000000.0; + + dmaTime += time1 - time0; + dmaBytes += len; + _mesa_debug(&brw->ctx, "texture size: %d. DMA sec/byte: %g.\n", + (int)len, (time1 - time0) / len); + } + return len; +#endif +} + +struct intel_mipmap_tree* +intel_miptree_create_for_client_texture_DMA(struct brw_context *brw, + GLenum target, + GLenum src_format, + gl_format compat_format, + GLenum type, + GLuint level, + const void *src_pixels, + uint32_t width, + uint32_t height, + const struct gl_pixelstore_attrib *unpack) +{ + const GLint bytesPerRow = _mesa_image_row_stride(unpack, width, src_format, type); + + if (0 >= bytesPerRow) { + _mesa_debug(&brw->ctx, "%s Error, unrecognized format: 0x%x or type: 0x%x Failed\n", __FUNCTION__, src_format, type); + return false; + } + + const unsigned clientBufferByteCount = bytesPerRow * height; + + struct intel_mipmap_tree *mt = intel_miptree_create_layout(brw, target, compat_format, + level, level, + width, height, 1, + true, 0,/* num_samples */ + INTEL_MIPTREE_TILING_NONE); + if (!mt) { + DBG("%s intel_miptree_create_layout Failed\n", __FUNCTION__); + return NULL; + } + + // MKM Oct 2013: TODO - verify HiZ allocation isn't required for the bo cache? + + drm_intel_bo *intel_bufferobj = drm_intel_bo_alloc(brw->bufmgr, "texture temp", clientBufferByteCount, 64); + if (!intel_bufferobj) { + intel_miptree_release(&mt); + DBG("%s drm_intel_bo_alloc Failed\n", __FUNCTION__); + return NULL; + } + + CopyClientBuffer(brw, intel_bufferobj, 0, clientBufferByteCount, src_pixels); + + struct intel_region *region = calloc(1, sizeof(*region)); + if (!region) { + intel_miptree_release(&mt); + drm_intel_bo_unreference(intel_bufferobj); + DBG("%s Out of memory\n", __FUNCTION__); + return NULL; + } + + region->cpp = mt->cpp; + region->width = width; + region->height = height; + region->pitch = bytesPerRow; + region->refcount = 1; +// drm_intel_bo_reference(intel_bufferobj); + region->bo = intel_bufferobj; + region->tiling = I915_TILING_NONE; + + mt->region = region; + + return mt; +}/** * For a singlesample image buffer, this simply wraps the given region with a miptree. * * For a multisample image buffer, this wraps the given region with diff --git a/src/mesa/drivers/dri/i965/intel_mipmap_tree.h b/src/mesa/drivers/dri/i965/intel_mipmap_tree.h index 329eeb0fbd..6bac288d04 100644 --- a/src/mesa/drivers/dri/i965/intel_mipmap_tree.h +++ b/src/mesa/drivers/dri/i965/intel_mipmap_tree.h @@ -514,7 +514,8 @@ intel_miptree_create_layout(struct brw_context *brw, GLuint height0, GLuint depth0, bool for_bo, - GLuint num_samples); + GLuint num_samples, + enum intel_miptree_tiling_mode requested_tiling); struct intel_mipmap_tree * intel_miptree_create_for_bo(struct brw_context *brw, @@ -533,6 +534,21 @@ intel_miptree_create_for_dri2_buffer(struct brw_context *brw, uint32_t num_samples, struct intel_region *region); +/** + * Create a miptree appropriate to DMA copy the appication texture with minimal modification. + * The miptree has the following properties: + * - There are no levels other than the base level 0. + * - Depth is 1. + */ +struct intel_mipmap_tree* +intel_miptree_create_for_client_texture_DMA(struct brw_context *brw, + GLenum target, GLenum src_format, + gl_format format, + GLenum type, GLuint level, + const void *src_pixels, + uint32_t width, + uint32_t height, + const struct gl_pixelstore_attrib *unpack); struct intel_mipmap_tree* intel_miptree_create_for_image_buffer(struct brw_context *intel, enum __DRIimageBufferMask buffer_type, diff --git a/src/mesa/drivers/dri/i965/intel_tex_image.c b/src/mesa/drivers/dri/i965/intel_tex_image.c index cc50f84ea3..f9db45116f 100644 --- a/src/mesa/drivers/dri/i965/intel_tex_image.c +++ b/src/mesa/drivers/dri/i965/intel_tex_image.c @@ -168,21 +168,52 @@ intelTexImage(struct gl_context * ctx, GLenum format, GLenum type, const void *pixels, const struct gl_pixelstore_attrib *unpack) { - bool ok; + static unsigned gpuCount = 0; + static unsigned totalCount = 0; + static double time0 = 0.0; + + if (0 == totalCount) { + struct timespec timestruct; + clock_gettime(CLOCK_MONOTONIC, ×truct); + time0 = timestruct.tv_sec + timestruct.tv_nsec / 1000000000.0; + } + + totalCount++; + + if (300 == totalCount) { + struct timespec timestruct; + clock_gettime(CLOCK_MONOTONIC, ×truct); + double time1 = timestruct.tv_sec + timestruct.tv_nsec / 1000000000.0; +// _mesa_debug(ctx, "%s Load time for 300 textures: %g \n", __FUNCTION__, time1 - time0); + } DBG("%s target %s level %d %dx%dx%d\n", __FUNCTION__, _mesa_lookup_enum_by_nr(texImage->TexObject->Target), texImage->Level, texImage->Width, texImage->Height, texImage->Depth); - ok = intel_texsubimage_tiled_memcpy(ctx, dims, texImage, - 0, 0, 0, /*x,y,z offsets*/ - texImage->Width, - texImage->Height, - texImage->Depth, - format, type, pixels, unpack, - true /*for_glTexImage*/); - if (ok) + /* Try BLORP first. It can handle almost everything. */ + if (brw_blorp_GPUcopytexsubimage(brw_context(ctx), dims, texImage, format, type, + pixels, unpack, 0, 0, 0, + 0, 0, texImage->Width, texImage->Height)) { + + gpuCount++; + if (!(totalCount % 512)) { +// _mesa_debug(ctx, "%s used blorp load. ratio = %g \n", __FUNCTION__, (double)gpuCount / (double)totalCount); + } + + return; + } + + bool ok = intel_texsubimage_tiled_memcpy(ctx, dims, texImage, + 0, 0, 0, /*x,y,z offsets*/ + texImage->Width, + texImage->Height, + texImage->Depth, + format, type, pixels, unpack, + true /*for_glTexImage*/); + if (ok) { return; + } /* Attempt to use the blitter for PBO image uploads. */ @@ -233,7 +264,8 @@ intel_set_texture_image_region(struct gl_context *ctx, intel_image->mt = intel_miptree_create_layout(brw, target, image->TexFormat, 0, 0, width, height, 1, - true, 0 /* num_samples */); + true, 0 /* num_samples */, + INTEL_MIPTREE_TILING_ANY); if (intel_image->mt == NULL) return; intel_region_reference(&intel_image->mt->region, region); diff --git a/src/mesa/main/enums.h b/src/mesa/main/enums.h index 36c053d4bc..a5ce88f3fa 100644 --- a/src/mesa/main/enums.h +++ b/src/mesa/main/enums.h @@ -37,6 +37,10 @@ #define _ENUMS_H_ +#ifdef __cplusplus +extern "C" { +#endif + extern const char *_mesa_lookup_enum_by_nr( int nr ); /* Get the name of an enum given that it is a primitive type. Avoids @@ -44,4 +48,8 @@ extern const char *_mesa_lookup_enum_by_nr( int nr ); */ const char *_mesa_lookup_prim_by_nr( unsigned nr ); +#ifdef __cplusplus +} +#endif + #endif diff --git a/src/mesa/main/formats.c b/src/mesa/main/formats.c index 5390ed2b09..3d177b39d1 100644 --- a/src/mesa/main/formats.c +++ b/src/mesa/main/formats.c @@ -1772,110 +1772,6 @@ static struct gl_format_info format_info[MESA_PRIVATE_FORMAT_COUNT] = * do not apply and these are not intended to be used as render targets. * Listing is based on the order presented in the glTexImage2D spec. */ - /* Red Solo - !cup */ - { - MESA_FORMAT_R32, - "MESA_FORMAT_R32", - GL_RED, - GL_UNSIGNED_NORMALIZED, - 32, 0, 0, 0, - 0, 0, 0, 0, 0, - 1, 1, 4 - }, - { - MESA_FORMAT_SIGNED_R32, - "MESA_FORMAT_SIGNED_R32", - GL_RED, - GL_SIGNED_NORMALIZED, - 32, 0, 0, 0, - 0, 0, 0, 0, 0, - 1, 1, 4 - }, - - /* Red Green - !show */ - { - MESA_FORMAT_SIGNED_RG88, - "MESA_FORMAT_SIGNED_RG88", - GL_RG, - GL_SIGNED_NORMALIZED, - 8, 8, 0, 0, - 0, 0, 0, 0, 0, - 1, 1, 2 - }, - { - MESA_FORMAT_SIGNED_RG1616, - "MESA_FORMAT_SIGNED_RG1616", - GL_RG, - GL_SIGNED_NORMALIZED, - 16, 16, 0, 0, - 0, 0, 0, 0, 0, - 1, 1, 4 - }, - { - MESA_FORMAT_RG3232, - "MESA_FORMAT_RG3232", - GL_RG, - GL_UNSIGNED_NORMALIZED, - 32, 32, 0, 0, - 0, 0, 0, 0, 0, - 1, 1, 8 - }, - { - MESA_FORMAT_SIGNED_RG3232, - "MESA_FORMAT_SIGNED_RG3232", - GL_RG, - GL_SIGNED_NORMALIZED, - 32, 32, 0, 0, - 0, 0, 0, 0, 0, - 1, 1, 8 - }, - - /* Red Green Blue */ - { - MESA_FORMAT_SIGNED_RGB888, - "MESA_FORMAT_SIGNED_RGB888", - GL_RGB, - GL_SIGNED_NORMALIZED, - 8, 8, 8, 0, - 0, 0, 0, 0, 0, - 1, 1, 3 - }, - { - MESA_FORMAT_RGB161616, - "MESA_FORMAT_RG161616", - GL_RGB, - GL_UNSIGNED_NORMALIZED, - 16, 16, 16, 0, - 0, 0, 0, 0, 0, - 1, 1, 6 - }, - { - MESA_FORMAT_SIGNED_RGB161616, - "MESA_FORMAT_SIGNED_RGB161616", - GL_RGB, - GL_SIGNED_NORMALIZED, - 16, 16, 16, 0, - 0, 0, 0, 0, 0, - 1, 1, 6 - }, - { - MESA_FORMAT_RGB323232, - "MESA_FORMAT_RGB323232", - GL_RGB, - GL_UNSIGNED_NORMALIZED, - 32, 32, 32, 0, - 0, 0, 0, 0, 0, - 1, 1, 12 - }, - { - MESA_FORMAT_SIGNED_RGB323232, - "MESA_FORMAT_SIGNED_RGB323232", - GL_RGB, - GL_SIGNED_NORMALIZED, - 32, 32, 32, 0, - 0, 0, 0, 0, 0, - 1, 1, 12 - }, { MESA_FORMAT_RGB233_REV, "MESA_FORMAT_RGB233_REV", @@ -1896,29 +1792,39 @@ static struct gl_format_info format_info[MESA_PRIVATE_FORMAT_COUNT] = }, /* Blue Green Red */ + /* Blue Green Red */ + { + MESA_FORMAT_BGR_INT8, + "MESA_FORMAT_BGR_INT8", + GL_RGB, + GL_SIGNED_NORMALIZED, + 8, 8, 8, 0, + 0, 0, 0, 0, 0, + 1, 1, 3 + }, { - MESA_FORMAT_SIGNED_BGR888, - "MESA_FORMAT_SIGNED_BGR888", + MESA_FORMAT_BGR_UINT8, + "MESA_FORMAT_BGR_INT8", GL_RGB, - GL_SIGNED_NORMALIZED, + GL_UNSIGNED_NORMALIZED, 8, 8, 8, 0, 0, 0, 0, 0, 0, 1, 1, 3 }, { - MESA_FORMAT_BGR161616, - "MESA_FORMAT_BGR161616", + MESA_FORMAT_BGR_INT16, + "MESA_FORMAT_BGR_INT16", GL_RGB, - GL_UNSIGNED_NORMALIZED, + GL_SIGNED_NORMALIZED, 16, 16, 16, 0, 0, 0, 0, 0, 0, 1, 1, 6 }, { - MESA_FORMAT_SIGNED_BGR161616, - "MESA_FORMAT_SIGNED_BGR161616", + MESA_FORMAT_BGR_UINT16, + "MESA_FORMAT_BGR_UINT16", GL_RGB, - GL_SIGNED_NORMALIZED, + GL_UNSIGNED_NORMALIZED, 16, 16, 16, 0, 0, 0, 0, 0, 0, 1, 1, 6 @@ -1933,19 +1839,19 @@ static struct gl_format_info format_info[MESA_PRIVATE_FORMAT_COUNT] = 1, 1, 6 }, { - MESA_FORMAT_BGR323232, - "MESA_FORMAT_BGR323232", + MESA_FORMAT_BGR_INT32, + "MESA_FORMAT_BGR_INT32", GL_RGB, - GL_UNSIGNED_NORMALIZED, + GL_SIGNED_NORMALIZED, 32, 32, 32, 0, 0, 0, 0, 0, 0, 1, 1, 12 }, { - MESA_FORMAT_SIGNED_BGR323232, - "MESA_FORMAT_SIGNED_BGR323232", + MESA_FORMAT_BGR_UINT32, + "MESA_FORMAT_BGR_UINT32", GL_RGB, - GL_SIGNED_NORMALIZED, + GL_UNSIGNED_NORMALIZED, 32, 32, 32, 0, 0, 0, 0, 0, 0, 1, 1, 12 @@ -1962,42 +1868,6 @@ static struct gl_format_info format_info[MESA_PRIVATE_FORMAT_COUNT] = /* Red Green Blue Alpha */ { - MESA_FORMAT_RGBA16161616, - "MESA_FORMAT_RGBA161616", - GL_RGBA, - GL_UNSIGNED_NORMALIZED, - 16, 16, 16, 16, - 0, 0, 0, 0, 0, - 1, 1, 8 - }, - { - MESA_FORMAT_SIGNED_RGBA16161616, - "MESA_FORMAT_SIGNED_RGBA161616", - GL_RGBA, - GL_SIGNED_NORMALIZED, - 16, 16, 16, 16, - 0, 0, 0, 0, 0, - 1, 1, 8 - }, - { - MESA_FORMAT_RGBA32323232, - "MESA_FORMAT_RGBA323232", - GL_RGBA, - GL_UNSIGNED_NORMALIZED, - 32, 32, 32, 32, - 0, 0, 0, 0, 0, - 1, 1, 16 - }, - { - MESA_FORMAT_SIGNED_RGBA32323232, - "MESA_FORMAT_SIGNED_RGBA323232", - GL_RGBA, - GL_SIGNED_NORMALIZED, - 32, 32, 32, 32, - 0, 0, 0, 0, 0, - 1, 1, 16 - }, - { MESA_FORMAT_RGBA1010102, "MESA_FORMAT_RGBA1010102", GL_RGBA, @@ -2051,20 +1921,28 @@ static struct gl_format_info format_info[MESA_PRIVATE_FORMAT_COUNT] = 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ 1, 1, 2 /* BlockWidth/Height,Bytes */ }, - /* Blue Green Red Alpha */ { - MESA_FORMAT_BGRA8888, /* Name */ - "MESA_FORMAT_BGRA8888", /* StrName */ + MESA_FORMAT_BGRA_INT8, + "MESA_FORMAT_BGRA_INT8", + GL_RGBA, + GL_SIGNED_NORMALIZED, + 8, 8, 8, 8, + 0, 0, 0, 0, 0, + 1, 1, 4 + }, + { + MESA_FORMAT_BGRA_INT8_REV, /* Name */ + "MESA_FORMAT_BGRA_INT8_REV",/* StrName */ GL_RGBA, /* BaseFormat */ GL_UNSIGNED_NORMALIZED, /* DataType */ 8, 8, 8, 8, /* Red/Green/Blue/AlphaBits */ 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */ 1, 1, 4 /* BlockWidth/Height,Bytes */ - }, + }, { - MESA_FORMAT_BGRA8888_REV, /* Name */ - "MESA_FORMAT_BGRA8888", /* StrName */ + MESA_FORMAT_BGRA_UINT8, /* Name */ + "MESA_FORMAT_BGRA_UINT8", /* StrName */ GL_RGBA, /* BaseFormat */ GL_UNSIGNED_NORMALIZED, /* DataType */ 8, 8, 8, 8, /* Red/Green/Blue/AlphaBits */ @@ -2072,28 +1950,19 @@ static struct gl_format_info format_info[MESA_PRIVATE_FORMAT_COUNT] = 1, 1, 4 /* BlockWidth/Height,Bytes */ }, { - MESA_FORMAT_SIGNED_BGRA8888, - "MESA_FORMAT_SIGNED_BGRA8888", + MESA_FORMAT_BGRA_INT16, + "MESA_FORMAT_BGRA_INT16", GL_RGBA, GL_SIGNED_NORMALIZED, - 8, 8, 8, 8, - 0, 0, 0, 0, 0, - 1, 1, 4 - }, - { - MESA_FORMAT_BGRA16161616, - "MESA_FORMAT_BGRA16161616", - GL_RGBA, - GL_UNSIGNED_NORMALIZED, 16, 16, 16, 16, 0, 0, 0, 0, 0, 1, 1, 8 }, { - MESA_FORMAT_SIGNED_BGRA16161616, - "MESA_FORMAT_SIGNED_BGRA16161616", + MESA_FORMAT_BGRA_UINT16, + "MESA_FORMAT_BGRA_UINT16", GL_RGBA, - GL_SIGNED_NORMALIZED, + GL_UNSIGNED_NORMALIZED, 16, 16, 16, 16, 0, 0, 0, 0, 0, 1, 1, 8 @@ -2108,19 +1977,19 @@ static struct gl_format_info format_info[MESA_PRIVATE_FORMAT_COUNT] = 1, 1, 8 }, { - MESA_FORMAT_BGRA32323232, - "MESA_FORMAT_BGRA32323232", + MESA_FORMAT_BGRA_INT32, + "MESA_FORMAT_BGRA_INT32", GL_RGBA, - GL_UNSIGNED_NORMALIZED, + GL_SIGNED_NORMALIZED, 32, 32, 32, 32, 0, 0, 0, 0, 0, 1, 1, 16 }, { - MESA_FORMAT_SIGNED_BGRA32323232, - "MESA_FORMAT_SIGNED_BGRA32323232", + MESA_FORMAT_BGRA_UINT32, + "MESA_FORMAT_BGRA_UINT32", GL_RGBA, - GL_SIGNED_NORMALIZED, + GL_UNSIGNED_NORMALIZED, 32, 32, 32, 32, 0, 0, 0, 0, 0, 1, 1, 16 diff --git a/src/mesa/main/formats.h b/src/mesa/main/formats.h index 5b89e822b4..5b7d0ebe02 100644 --- a/src/mesa/main/formats.h +++ b/src/mesa/main/formats.h @@ -314,39 +314,21 @@ typedef enum * do not apply and these are not intended to be used as render targets. * Listing is based on the order presented in the glTexImage2D spec. */ - /* Red Solo - !cup */ - MESA_FORMAT_R32 = MESA_FORMAT_COUNT, - MESA_FORMAT_SIGNED_R32, - - /* Red Green - !show */ - MESA_FORMAT_SIGNED_RG88, - MESA_FORMAT_SIGNED_RG1616, - MESA_FORMAT_RG3232, - MESA_FORMAT_SIGNED_RG3232, - /* Red Green Blue */ - MESA_FORMAT_SIGNED_RGB888, - MESA_FORMAT_RGB161616, - MESA_FORMAT_SIGNED_RGB161616, - MESA_FORMAT_RGB323232, - MESA_FORMAT_SIGNED_RGB323232, - MESA_FORMAT_RGB233_REV, + MESA_FORMAT_RGB233_REV = MESA_FORMAT_COUNT, MESA_FORMAT_RGB101111_REV, /* Blue Green Red */ - MESA_FORMAT_SIGNED_BGR888, - MESA_FORMAT_BGR161616, - MESA_FORMAT_SIGNED_BGR161616, + MESA_FORMAT_BGR_INT8, + MESA_FORMAT_BGR_UINT8, + MESA_FORMAT_BGR_INT16, + MESA_FORMAT_BGR_UINT16, MESA_FORMAT_BGR_FLOAT16, - MESA_FORMAT_BGR323232, - MESA_FORMAT_SIGNED_BGR323232, + MESA_FORMAT_BGR_INT32, + MESA_FORMAT_BGR_UINT32, MESA_FORMAT_BGR_FLOAT32, /* Red Green Blue Alpha */ - MESA_FORMAT_RGBA16161616, - MESA_FORMAT_SIGNED_RGBA16161616, - MESA_FORMAT_RGBA32323232, - MESA_FORMAT_SIGNED_RGBA32323232, MESA_FORMAT_RGBA1010102, MESA_FORMAT_RGBA2101010_REV, MESA_FORMAT_RGBA5999_REV, @@ -355,14 +337,14 @@ typedef enum MESA_FORMAT_RGBA1555_REV, /* Blue Green Red Alpha */ - MESA_FORMAT_BGRA8888, - MESA_FORMAT_BGRA8888_REV, - MESA_FORMAT_SIGNED_BGRA8888, - MESA_FORMAT_BGRA16161616, - MESA_FORMAT_SIGNED_BGRA16161616, + MESA_FORMAT_BGRA_INT8, + MESA_FORMAT_BGRA_INT8_REV, + MESA_FORMAT_BGRA_UINT8, + MESA_FORMAT_BGRA_INT16, + MESA_FORMAT_BGRA_UINT16, MESA_FORMAT_BGRA_FLOAT16, - MESA_FORMAT_BGRA32323232, - MESA_FORMAT_SIGNED_BGRA32323232, + MESA_FORMAT_BGRA_INT32, + MESA_FORMAT_BGRA_UINT32, MESA_FORMAT_BGRA_FLOAT32, MESA_FORMAT_BGRA4444, MESA_FORMAT_BGRA4444_REV, diff --git a/src/mesa/main/pbo.h b/src/mesa/main/pbo.h index 9851ef1a17..93f7638164 100644 --- a/src/mesa/main/pbo.h +++ b/src/mesa/main/pbo.h @@ -31,6 +31,10 @@ #include "mtypes.h" +#ifdef __cplusplus +extern "C" { +#endif + extern GLboolean _mesa_validate_pbo_access(GLuint dimensions, const struct gl_pixelstore_attrib *pack, @@ -91,5 +95,9 @@ extern void _mesa_unmap_teximage_pbo(struct gl_context *ctx, const struct gl_pixelstore_attrib *unpack); +#ifdef __cplusplus +} +#endif + #endif diff --git a/src/mesa/main/texformat.c b/src/mesa/main/texformat.c index 91be9d3111..474a310d61 100644 --- a/src/mesa/main/texformat.c +++ b/src/mesa/main/texformat.c @@ -850,17 +850,17 @@ _mesa_choose_cached_tex_format(struct gl_context *ctx, GLenum format, GLenum typ case GL_RED: switch (type) { case GL_BYTE: - return MESA_FORMAT_SIGNED_R8; + return MESA_FORMAT_R_INT8; case GL_UNSIGNED_BYTE: - return MESA_FORMAT_R8; + return MESA_FORMAT_R_UINT8; case GL_SHORT: - return MESA_FORMAT_SIGNED_R16; + return MESA_FORMAT_R_INT16; case GL_UNSIGNED_SHORT: - return MESA_FORMAT_R16; + return MESA_FORMAT_R_UINT16; case GL_INT: - return MESA_FORMAT_SIGNED_R32; + return MESA_FORMAT_R_INT32; case GL_UNSIGNED_INT: - return MESA_FORMAT_R32; + return MESA_FORMAT_R_UINT32; case GL_FLOAT: return MESA_FORMAT_R_FLOAT32; case GL_HALF_FLOAT: @@ -871,17 +871,17 @@ _mesa_choose_cached_tex_format(struct gl_context *ctx, GLenum format, GLenum typ case GL_RG: switch (type) { case GL_BYTE: - return MESA_FORMAT_SIGNED_RG88; + return MESA_FORMAT_RG_INT8; case GL_UNSIGNED_BYTE: - return MESA_FORMAT_RG88; + return MESA_FORMAT_RG_UINT8; case GL_SHORT: - return MESA_FORMAT_SIGNED_RG1616; + return MESA_FORMAT_RG_INT16; case GL_UNSIGNED_SHORT: - return MESA_FORMAT_RG1616; + return MESA_FORMAT_RG_UINT16; case GL_INT: - return MESA_FORMAT_SIGNED_RG3232; + return MESA_FORMAT_RG_INT32; case GL_UNSIGNED_INT: - return MESA_FORMAT_RG3232; + return MESA_FORMAT_RG_UINT32; case GL_FLOAT: return MESA_FORMAT_RG_FLOAT32; case GL_HALF_FLOAT: @@ -892,17 +892,17 @@ _mesa_choose_cached_tex_format(struct gl_context *ctx, GLenum format, GLenum typ case GL_RGB: switch (type) { case GL_BYTE: - return MESA_FORMAT_SIGNED_RGB888; + return MESA_FORMAT_RGB_INT8; case GL_UNSIGNED_BYTE: - return MESA_FORMAT_RGB888; + return MESA_FORMAT_RGB_UINT8; case GL_SHORT: - return MESA_FORMAT_SIGNED_RGB161616; + return MESA_FORMAT_RGB_INT16; case GL_UNSIGNED_SHORT: - return MESA_FORMAT_RGB161616; + return MESA_FORMAT_RGB_UINT16; case GL_INT: - return MESA_FORMAT_SIGNED_RGB323232; + return MESA_FORMAT_RGB_INT32; case GL_UNSIGNED_INT: - return MESA_FORMAT_RGB323232; + return MESA_FORMAT_RGB_UINT32; case GL_FLOAT: return MESA_FORMAT_RGB_FLOAT32; case GL_HALF_FLOAT: @@ -923,17 +923,17 @@ _mesa_choose_cached_tex_format(struct gl_context *ctx, GLenum format, GLenum typ case GL_BGR: switch (type) { case GL_BYTE: - return MESA_FORMAT_SIGNED_BGR888; + return MESA_FORMAT_BGR_INT8; case GL_UNSIGNED_BYTE: - return MESA_FORMAT_BGR888; + return MESA_FORMAT_BGR_UINT8; case GL_SHORT: - return MESA_FORMAT_SIGNED_BGR161616; + return MESA_FORMAT_BGR_INT16; case GL_UNSIGNED_SHORT: - return MESA_FORMAT_BGR161616; + return MESA_FORMAT_BGR_UINT16; case GL_INT: - return MESA_FORMAT_SIGNED_BGR323232; + return MESA_FORMAT_BGR_INT32; case GL_UNSIGNED_INT: - return MESA_FORMAT_BGR323232; + return MESA_FORMAT_BGR_UINT32; case GL_FLOAT: return MESA_FORMAT_BGR_FLOAT32; case GL_HALF_FLOAT: @@ -944,17 +944,17 @@ _mesa_choose_cached_tex_format(struct gl_context *ctx, GLenum format, GLenum typ case GL_RGBA: switch (type) { case GL_BYTE: - return MESA_FORMAT_SIGNED_RGBA8888; + return MESA_FORMAT_RGBA_INT8; case GL_UNSIGNED_BYTE: - return MESA_FORMAT_RGBA8888; + return MESA_FORMAT_RGBA_UINT8; case GL_SHORT: - return MESA_FORMAT_SIGNED_RGBA16161616; + return MESA_FORMAT_RGBA_INT16; case GL_UNSIGNED_SHORT: - return MESA_FORMAT_RGBA16161616; + return MESA_FORMAT_RGBA_UINT16; case GL_INT: - return MESA_FORMAT_SIGNED_RGBA32323232; + return MESA_FORMAT_RGBA_INT32; case GL_UNSIGNED_INT: - return MESA_FORMAT_RGBA32323232; + return MESA_FORMAT_RGBA_UINT32; case GL_FLOAT: return MESA_FORMAT_RGBA_FLOAT32; case GL_HALF_FLOAT: @@ -968,7 +968,7 @@ _mesa_choose_cached_tex_format(struct gl_context *ctx, GLenum format, GLenum typ case GL_UNSIGNED_SHORT_1_5_5_5_REV: return MESA_FORMAT_RGBA1555_REV; case GL_UNSIGNED_INT_8_8_8_8: - return MESA_FORMAT_RGBA32323232; + return MESA_FORMAT_RGBA8888; case GL_UNSIGNED_INT_8_8_8_8_REV: return MESA_FORMAT_RGBA8888_REV; case GL_UNSIGNED_INT_10_10_10_2: @@ -983,17 +983,17 @@ _mesa_choose_cached_tex_format(struct gl_context *ctx, GLenum format, GLenum typ case GL_BGRA: switch (type) { case GL_BYTE: - return MESA_FORMAT_SIGNED_BGRA8888; + return MESA_FORMAT_BGRA_INT8; case GL_UNSIGNED_BYTE: - return MESA_FORMAT_BGRA8888; + return MESA_FORMAT_BGRA_UINT8; case GL_SHORT: - return MESA_FORMAT_SIGNED_BGRA16161616; + return MESA_FORMAT_BGRA_INT16; case GL_UNSIGNED_SHORT: - return MESA_FORMAT_BGRA16161616; + return MESA_FORMAT_BGRA_UINT16; case GL_INT: - return MESA_FORMAT_BGRA32323232; + return MESA_FORMAT_BGRA_INT32; case GL_UNSIGNED_INT: - return MESA_FORMAT_SIGNED_BGRA32323232; + return MESA_FORMAT_BGRA_UINT32; case GL_FLOAT: return MESA_FORMAT_BGRA_FLOAT32; case GL_HALF_FLOAT: @@ -1007,9 +1007,9 @@ _mesa_choose_cached_tex_format(struct gl_context *ctx, GLenum format, GLenum typ case GL_UNSIGNED_SHORT_1_5_5_5_REV: return MESA_FORMAT_BGRA1555_REV; case GL_UNSIGNED_INT_8_8_8_8: - return MESA_FORMAT_BGRA8888; + return MESA_FORMAT_BGRA_INT8; case GL_UNSIGNED_INT_8_8_8_8_REV: - return MESA_FORMAT_BGRA8888_REV; + return MESA_FORMAT_BGRA_INT8_REV; case GL_UNSIGNED_INT_10_10_10_2: return MESA_FORMAT_BGRA1010102; case GL_UNSIGNED_INT_2_10_10_10_REV: |