[Mesa-dev] [PATCH] i965: correct alignment units for 2D compressed textures on Skylake
From: Nanley Chery On Gen9+, vertical and horizontal alignment values for compressed textures are equal to the pre-Gen9 value squared. Each miplevel must be aligned to this value. Signed-off-by: Nanley Chery --- This fixes an FXT1 Piglit test regression and shows no failures on Jenkins. src/mesa/drivers/dri/i965/brw_tex_layout.c | 20 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/src/mesa/drivers/dri/i965/brw_tex_layout.c b/src/mesa/drivers/dri/i965/brw_tex_layout.c index 312a887..dffc699 100644 --- a/src/mesa/drivers/dri/i965/brw_tex_layout.c +++ b/src/mesa/drivers/dri/i965/brw_tex_layout.c @@ -149,15 +149,8 @@ intel_horizontal_texture_alignment_unit(struct brw_context *brw, unsigned int i, j; _mesa_get_format_block_size(mt->format, &i, &j); - /* On Gen9+ we can pick our own alignment for compressed textures but it - * has to be a multiple of the block size. The minimum alignment we can - * pick is 4 so we effectively have to align to 4 times the block - * size - */ - if (brw->gen >= 9) - return i * 4; - else - return i; + /* On Gen9+ the alignment value is squared. */ + return brw->gen >= 9 ? i * i : i; } if (mt->format == MESA_FORMAT_S_UINT8) @@ -269,9 +262,12 @@ intel_vertical_texture_alignment_unit(struct brw_context *brw, * Where "*" means either VALIGN_2 or VALIGN_4 depending on the setting of * the SURFACE_STATE "Surface Vertical Alignment" field. */ - if (_mesa_is_format_compressed(mt->format)) + if (_mesa_is_format_compressed(mt->format)) { + unsigned int i, j; + _mesa_get_format_block_size(mt->format, &i, &j); /* See comment above for the horizontal alignment */ - return brw->gen >= 9 ? 16 : 4; + return brw->gen >= 9 ? j * j : j; + } if (mt->format == MESA_FORMAT_S_UINT8) return brw->gen >= 7 ? 8 : 4; @@ -379,7 +375,7 @@ brw_miptree_layout_2d(struct intel_mipmap_tree *mt) if (mt->compressed) { mip1_width = ALIGN(minify(mt->physical_width0, 1), mt->align_w) + - ALIGN(minify(mt->physical_width0, 2), bw); + ALIGN(minify(mt->physical_width0, 2), mt->align_w); } else { mip1_width = ALIGN(minify(mt->physical_width0, 1), mt->align_w) + minify(mt->physical_width0, 2); -- 2.4.2 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH] i965: Fix aligning to the block size in intel_miptree_copy_slice
Hey Neil, While this patch does fix FXT1, it also regresses 21 other Piglit tests on SKL. - Nanley On Thu, Jun 11, 2015 at 8:59 AM, Neil Roberts wrote: > This function was trying to align the width and height to a multiple > of the block size for compressed textures. It was using align_w/h as a > shortcut to get the block size as up until Gen9 this always happens to > match. However in Gen9+ the alignment values are expressed as > multiples of the block size so in effect the alignment values are > always 4 for compressed textures as that is the minimum value we can > pick. This happened to work for most compressed formats because the > block size is also 4, but for FXT1 this was breaking because it has a > block width of 8. > > This fixes some Piglit tests testing FXT1 such as > > spec@3dfx_texture_compression_fxt1@fbo-generatemipmap-formats > --- > src/mesa/drivers/dri/i965/intel_mipmap_tree.c | 6 -- > 1 file changed, 4 insertions(+), 2 deletions(-) > > diff --git a/src/mesa/drivers/dri/i965/intel_mipmap_tree.c > b/src/mesa/drivers/dri/i965/intel_mipmap_tree.c > index 615cbfb..6c00581 100644 > --- a/src/mesa/drivers/dri/i965/intel_mipmap_tree.c > +++ b/src/mesa/drivers/dri/i965/intel_mipmap_tree.c > @@ -1168,8 +1168,10 @@ intel_miptree_copy_slice(struct brw_context *brw, > assert(src_mt->format == dst_mt->format); > > if (dst_mt->compressed) { > - height = ALIGN(height, dst_mt->align_h) / dst_mt->align_h; > - width = ALIGN(width, dst_mt->align_w); > + unsigned int i, j; > + _mesa_get_format_block_size(dst_mt->format, &i, &j); > + height = ALIGN(height, j) / j; > + width = ALIGN(width, i); > } > > /* If it's a packed depth/stencil buffer with separate stencil, the blit > -- > 1.9.3 > > ___ > mesa-dev mailing list > mesa-dev@lists.freedesktop.org > http://lists.freedesktop.org/mailman/listinfo/mesa-dev ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH] i965: Fix aligning to the block size in intel_miptree_copy_slice
Hey Neil, My testing method was to run the following command against master and master + your patch: ./piglit run gpu -x glx -x glean -x fbo-depth-array # exclusions necessary to prevent SKL hang. I then ran a piglit summary comparison (console output) against the result and grepped for "pass fail". The regressions I saw were: spec/arb_texture_multisample/texelfetch/2-fs-sampler2dmsarray: pass fail spec/arb_texture_float/fbo-clear-formats/GL_RGBA16F_ARB: pass fail spec/glsl-1.30/execution/vs-float-uint-conversion: pass fail spec/glsl-1.50/execution/built-in-functions/gs-op-mult-mat4x3-float: pass fail spec/ext_framebuffer_multisample_blit_scaled/blit-scaled samples=2: pass fail spec/arb_texture_compression_bptc/fbo-generatemipmap-formats float/GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT: pass fail spec/arb_texture_gather/texturegatheroffset/vs-rgb-one-int-2d: pass fail spec/glsl-1.20/execution/uniform-initializer/vs-float-array: pass fail spec/glsl-1.10/execution/variable-indexing/vs-varying-array-mat3-col-rd: pass fail spec/glsl-1.30/execution/interpolation/interpolation-smooth-gl_backsecondarycolor-smooth-fixed: pass fail spec/!opengl 1.1/texwrap 2d/GL_RGBA8: pass fail spec/arb_texture_compression_bptc/fbo-generatemipmap-formats float/GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT NPOT: pass fail spec/glsl-1.30/execution/built-in-functions/fs-op-bitand-neg-abs-ivec3-ivec3: pass fail spec/glsl-1.50/execution/built-in-functions/gs-op-uplus-mat3: pass fail spec/!opengl 2.0/vertex-program-two-side enabled front back front2 back2: pass fail spec/arb_texture_multisample/texelfetch/4-fs-isampler2dms: pass fail spec/glsl-1.20/execution/built-in-functions/fs-op-mult-mat4x2-mat3x4: pass fail spec/ext_framebuffer_multisample/accuracy 6 depth_draw small: pass fail spec/!opengl 3.0/clearbuffer-mixed-format: pass fail spec/arb_texture_compression_bptc/fbo-generatemipmap-formats float/GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT: pass fail spec/arb_texture_float/fbo-clear-formats/GL_RGB16F_ARB: pass fail However, I'm going through and testing some of them by hand as you suggested and they've all been passing thus far. I'm not sure why I'm getting different results now. Thanks, Nanley On Fri, Jun 12, 2015 at 9:07 AM, Neil Roberts wrote: > Hi, > > Could you perhaps send me a list of the regressions? I ran it through on > my Skylake and the only changes I see are the two FXT1 tests. However, I > have to admit that my device is being a bit flakey so I cheated a little > bit to make this work. Originally when I compared the differences with > and without the patch I had about 150 differences (some fixes, some > regressions) that were pretty random. I got the list of these with > "piglit summary console -d" and then reran just those tests (with the > --test-list option) after a reboot with and without the patch. I then > have a noddy Python script to merge a Piglit results file so that it > replaces test results from the first file with any that appear in the > second file. Once I do that then there are no regressions and only the > two FXT1 tests appear in the fixes. > > It might be interesting to see if you can run some of the regressing > tests by hand after a reboot to see if they fail consistently. > > Regards, > - Neil > > Nanley Chery writes: > >> Hey Neil, >> >> While this patch does fix FXT1, it also regresses 21 other Piglit tests on >> SKL. >> >> - Nanley >> >> On Thu, Jun 11, 2015 at 8:59 AM, Neil Roberts wrote: >>> This function was trying to align the width and height to a multiple >>> of the block size for compressed textures. It was using align_w/h as a >>> shortcut to get the block size as up until Gen9 this always happens to >>> match. However in Gen9+ the alignment values are expressed as >>> multiples of the block size so in effect the alignment values are >>> always 4 for compressed textures as that is the minimum value we can >>> pick. This happened to work for most compressed formats because the >>> block size is also 4, but for FXT1 this was breaking because it has a >>> block width of 8. >>> >>> This fixes some Piglit tests testing FXT1 such as >>> >>> spec@3dfx_texture_compression_fxt1@fbo-generatemipmap-formats >>> --- >>> src/mesa/drivers/dri/i965/intel_mipmap_tree.c | 6 -- >>> 1 file changed, 4 insertions(+), 2 deletions(-) >>> >>> diff --git a/src/mesa/drivers/dri/i965/intel_mipmap_tree.c >>> b/src/mesa/drivers/dri/i965/intel_mipmap_tree.c >>> index 615cbfb..6c00581 100644 >>> --- a/src/mesa/drivers/dri/i965/intel_mipmap_tree.c >>> +++ b/src/mesa/drivers/dri/i965/intel_mipmap_tree.c >>> @@ -1168,8 +1168,10 @@ intel_miptree_copy_slice(str
Re: [Mesa-dev] [PATCH] i965: correct alignment units for 2D compressed textures on Skylake
On Thu, Jun 11, 2015 at 8:56 AM, Neil Roberts wrote: > Hi Nanley, > > Could you explain the reasoning behind this patch? I can't find any > mention of needing to align to the square of the block size in the docs. > Sure. I came to the conclusion that alignment must be squared due to 3 parts of the Bspec. The "Alignment Unit Size" table lists the i and j values for each texture. The compressed textures have their alignment values listed here as constants and "all others" are set by Surface Horizontal Alignment in the RENDER_SURFACE_STATE object. In the section concerning Calculating Texel Location for 2D Surfaces SKL+, the formula to cache align the width of an LOD is "ALIGN_NPOT(w, i*p) / i*p" where i is the alignment width from the table (either a constant or a variable set by RENDER_SURFACE_STATE) and p is the width of the block (1 for non compressed textures). The formula is the same for cache aligning the height. Since i and p, j and q are equal this means that alignment units for compressed textures are effectively squared. Because the compressed texture alignments are constants in the table, I thought that the HALIGN and VALIGN values in the RENDER_SURFACE_STATE object were ignored. This was explicitly stated to be true for IVB, but for SKL, there is no mention of this. > I think how it works is that on Skylake you can pick any alignment value > you want out of 4, 8 or 16 but for compressed textures that is counted > in units of blocks rather than pixels. Currently we effectively always > pick 4 for compressed textures because I don't think there's any reason > to align to a higher value. The mt->align_w/h values are used for two > things; in intel_miptree_set_total_width_height they are used to choose > the positions for the mipmap images and after that they are only used to > upload the alignment values as part of the surface state. On Skylake > mt->align_w/h is temporarily set to be in units of pixels during > brw_miptree_layout but at the end of the function it divides the values > by the block size so that they will be in units of blocks ready for > uploading as part of the surface state. > I agree with your explanation on what the mt->align_w/h values are used for. I thought that the RENDER_SURFACE_STATE values 4, 8, and 16 would only used if the alignment value is not a constant defined in the "Alignment Unit Size" table. This is mentioned in the section concerning Calculating Texel Location for 2D Surfaces SKL+. My comment below points towards this not being the case. > Your patch modifies how it picks the alignment value but it doesn't > modify the bit at the end which divides the chosen alignment by the > block size. For FXT1 I think that would end up making it pick a > horizontal alignment value of ALIGN_8 (ie, the pixel alignment value is > now 8*8=64 which when divided by the block width ends up as > 64/8=ALIGN_8). > > Before my patches for Skylake bits of the code were lazily assuming that > mt->align_w/h is always the same as the block size because that > previously happened to be always correct. I fixed some of the cases > within the layouting code to instead directly query the block size. > However it looks like I missed one in intel_miptree_copy_slice. I think > your patch would make this particular case work because now the > alignment value is ALIGN_8 which happens to match the block width for > FXT1. > You're right, it does work because the align_w is set to ALIGN_8. Hardcoding the alignment to ALIGN_4 causes the test to fail. Perhaps the i and j must match the RENDER_SURFACE_STATE values. I can't find this explicitly stated in the documentation unfortunately. > I'm about to post an alternative patch which fixes this case to use the > block size instead and it does seem to fix the broken FXT1 test cases as > well. > Thanks, Nanley ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH] i965: correct alignment units for 2D compressed textures on Skylake
On Thu, Jun 11, 2015 at 9:04 AM, Ben Widawsky wrote: > On Wed, Jun 10, 2015 at 05:01:44PM -0700, Nanley Chery wrote: >> From: Nanley Chery >> >> On Gen9+, vertical and horizontal alignment values for compressed textures >> are >> equal to the pre-Gen9 value squared. Each miplevel must be aligned to this >> value. >> >> Signed-off-by: Nanley Chery > > While not a requirement, for future reference you should add Cc on patches > which > are touching something someone recently changed/and or was working on. In this > case Ccing Neil would have been great. > I thought about this after sending out the patch unfortunately, thanks for the reminder. >> --- >> >> This fixes an FXT1 Piglit test regression and shows no failures on Jenkins. > > You ran full piglit on SKL? Jenkins won't and it's pretty important for this > patch. > I recently ran piglit with: ./piglit run gpu -x glx -gx glean -x fbo-depth-array. There are no regressions and 9 additional fixes. Unfortunately, my Piglit tests haven't been consistent, so please take the results with a grain of salt. >> >> src/mesa/drivers/dri/i965/brw_tex_layout.c | 20 >> 1 file changed, 8 insertions(+), 12 deletions(-) >> >> diff --git a/src/mesa/drivers/dri/i965/brw_tex_layout.c >> b/src/mesa/drivers/dri/i965/brw_tex_layout.c >> index 312a887..dffc699 100644 >> --- a/src/mesa/drivers/dri/i965/brw_tex_layout.c >> +++ b/src/mesa/drivers/dri/i965/brw_tex_layout.c >> @@ -149,15 +149,8 @@ intel_horizontal_texture_alignment_unit(struct >> brw_context *brw, >>unsigned int i, j; >>_mesa_get_format_block_size(mt->format, &i, &j); >> >> - /* On Gen9+ we can pick our own alignment for compressed textures but >> it >> - * has to be a multiple of the block size. The minimum alignment we >> can >> - * pick is 4 so we effectively have to align to 4 times the block >> - * size >> - */ >> - if (brw->gen >= 9) >> - return i * 4; >> - else >> - return i; >> + /* On Gen9+ the alignment value is squared. */ >> + return brw->gen >= 9 ? i * i : i; > > I don't think this is right. Isn't this going to push non compressed textures > to > an invalid HALIGN when we divide later ie. don't you get 1? > The divide only occurs for compressed textures. >> } >> >> if (mt->format == MESA_FORMAT_S_UINT8) >> @@ -269,9 +262,12 @@ intel_vertical_texture_alignment_unit(struct >> brw_context *brw, >> * Where "*" means either VALIGN_2 or VALIGN_4 depending on the setting >> of >> * the SURFACE_STATE "Surface Vertical Alignment" field. >> */ >> - if (_mesa_is_format_compressed(mt->format)) >> + if (_mesa_is_format_compressed(mt->format)) { >> + unsigned int i, j; >> + _mesa_get_format_block_size(mt->format, &i, &j); >>/* See comment above for the horizontal alignment */ > > I think you need to kill this comment now. Doesn't it refer to what you killed > above? > I replaced the comment with another, so it's still valid. I can just replace it with the same one-liner though. >> - return brw->gen >= 9 ? 16 : 4; >> + return brw->gen >= 9 ? j * j : j; >> + } > > It kind of looks like this is just working around the way Neil implemented the > divide later on. There's probably a nicer way to do the right thing, but I > haven't tried it myself. Also, I believe this doesn't actually fix anything, > it > just uses slightly more optimal aligns - ie. maybe do a separate patch. No big > deal though. > The logic is derived from the Bspec. After doing more testing and getting Neil's feedback, I'm not completely sure the alignment is correct. I'm looking into it more. >> >> if (mt->format == MESA_FORMAT_S_UINT8) >>return brw->gen >= 7 ? 8 : 4; >> @@ -379,7 +375,7 @@ brw_miptree_layout_2d(struct intel_mipmap_tree *mt) >> >> if (mt->compressed) { >>mip1_width = ALIGN(minify(mt->physical_width0, 1), mt->align_w) + >> - ALIGN(minify(mt->physical_width0, 2), bw); >> + ALIGN(minify(mt->physical_width0, 2), mt->align_w); >> } else { >>mip1_width = ALIGN(minify(mt->physical_width0, 1), mt->align_w) + >> minify(mt->physical_width0, 2); > ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH] i965: Fix aligning to the block size in intel_miptree_copy_slice
My test results haven't been consistent and some of the failures don't seem to match what's going on in this patch. I'll have to look into improving my testing methods on SKL, but that's a separate issue. This patch makes sense. Reviewed-by: Nanley Chery ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH] i965: correct alignment units for 2D compressed textures on Skylake
>>> >>> src/mesa/drivers/dri/i965/brw_tex_layout.c | 20 >>> 1 file changed, 8 insertions(+), 12 deletions(-) >>> >>> diff --git a/src/mesa/drivers/dri/i965/brw_tex_layout.c >>> b/src/mesa/drivers/dri/i965/brw_tex_layout.c >>> index 312a887..dffc699 100644 >>> --- a/src/mesa/drivers/dri/i965/brw_tex_layout.c >>> +++ b/src/mesa/drivers/dri/i965/brw_tex_layout.c >>> @@ -149,15 +149,8 @@ intel_horizontal_texture_alignment_unit(struct >>> brw_context *brw, >>>unsigned int i, j; >>>_mesa_get_format_block_size(mt->format, &i, &j); >>> >>> - /* On Gen9+ we can pick our own alignment for compressed textures >>> but it >>> - * has to be a multiple of the block size. The minimum alignment we >>> can >>> - * pick is 4 so we effectively have to align to 4 times the block >>> - * size >>> - */ >>> - if (brw->gen >= 9) >>> - return i * 4; >>> - else >>> - return i; >>> + /* On Gen9+ the alignment value is squared. */ >>> + return brw->gen >= 9 ? i * i : i; >> >> I don't think this is right. Isn't this going to push non compressed >> textures to >> an invalid HALIGN when we divide later ie. don't you get 1? >> > The divide only occurs for compressed textures. > Sorry, this isn't quite right. The divide occurs for all textures, but the divisor is the block size. For non compressed textures, it will be 1. -Nanley ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH] i965: correct alignment units for 2D compressed textures on Skylake
Although most of the patch is incorrect, the following change is still necessary isn't it? if (mt->compressed) { mip1_width = ALIGN(minify(mt->physical_width0, 1), mt->align_w) + - ALIGN(minify(mt->physical_width0, 2), bw); + ALIGN(minify(mt->physical_width0, 2), mt->align_w); Each LOD is aligned by the alignment term. I don't see why we're switching to block width here. - Nanley ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH] i965: correct alignment units for 2D compressed textures on Skylake
Thanks for the diagram and explanation. The Bspec's Calculating Texel Location for 2D Surfaces section says that each LOD's width and height is determined by a formula using an alignment term. One reason is to calculate the LOD positions. I'm assuming another is to prevent the sampler engine from fetching texels outside of pages defined by the GTT by padding images for cache alignment. Is this true? If we don't align LOD-{0,2} by the alignment term and use a block dimension instead, don't we risk getting this error? Even if this is not the case, the spec doesn't exempt LOD-0 from being aligned by the alignment term, right? Thanks, Nanley On Mon, Jun 15, 2015 at 10:45 AM, Neil Roberts wrote: > Nanley Chery writes: > >> Although most of the patch is incorrect, the following change is still >> necessary isn't it? >> if (mt->compressed) { >> mip1_width = ALIGN(minify(mt->physical_width0, 1), mt->align_w) + >> - ALIGN(minify(mt->physical_width0, 2), bw); >> + ALIGN(minify(mt->physical_width0, 2), mt->align_w); >> >> Each LOD is aligned by the alignment term. I don't see why we're >> switching to block width here. > > I'm pretty sure the original version is correct and we do want to align > to the block width here. This bit of code is not being used to work out > the position of an image so it doesn't need to take into account the > image alignment. It is only being used to calculate the mt->total_width > value. That value is not aligned to the image alignment. You can see > this because it will usually just be directly taken from > mt->physical_width0 and that is not aligned. In the non-compressed case > just below you can see that the second half of the addition is not > aligned to anything at all. The total_width does however need to be at > least a multiple of the block size because it isn't possible to allocate > space for half of a block. > > If I understand correctly this code is just trying to cope with cases > where the third image in the mipmap is positioned so that it extends > past the width of the first image. If that happens then the width of the > image containing all of the mipmap images needs to be extended slightly > or it would crop the third mipmap image. > > Please see the attached SVG. > > Looking at it a bit more I think this bit above is wrong: > > if (mt->compressed) { > mt->total_width = ALIGN(mt->physical_width0, mt->align_w); > } > > That should also be using bw instead of mt->align_w for the same reason. > I think it could only end up making the total_width a bit larger than > necessary so it probably isn't causing any actual problems. > > I'll make a patch and test it. > > Regards, > - Neil > ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [RFC v2 10/15] i965: enable ASTC support for Skylake
I agree. This will be fixed in the next revision. On Tue, Jun 9, 2015 at 12:03 PM, Ian Romanick wrote: > Should this patch be last? It looks like later patches fix bugs. > > On 06/01/2015 10:13 AM, Nanley Chery wrote: >> From: Nanley Chery >> >> v2: remove OES ASTC extension reference. >> >> Signed-off-by: Nanley Chery >> --- >> src/mesa/drivers/dri/i965/intel_extensions.c | 5 + >> 1 file changed, 5 insertions(+) >> >> diff --git a/src/mesa/drivers/dri/i965/intel_extensions.c >> b/src/mesa/drivers/dri/i965/intel_extensions.c >> index 18b69a0..3c07c8e 100644 >> --- a/src/mesa/drivers/dri/i965/intel_extensions.c >> +++ b/src/mesa/drivers/dri/i965/intel_extensions.c >> @@ -354,6 +354,11 @@ intelInitExtensions(struct gl_context *ctx) >>ctx->Extensions.ARB_stencil_texturing = true; >> } >> >> + if (brw->gen >= 9) { >> + ctx->Extensions.KHR_texture_compression_astc_ldr = true; >> + ctx->Extensions.KHR_texture_compression_astc_hdr = true; >> + } >> + >> if (ctx->API == API_OPENGL_CORE) >>ctx->Extensions.ARB_base_instance = true; >> if (ctx->API != API_OPENGL_CORE) >> > ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [RFC v2 14/15] i965: refactor miptree alignment calculation code
The next revision will be all code refactoring. I moved the spec references into the new top-level function intel_get_texture_alignment_unit because some of the alignment calculations occurring in the top-level function reference the spec. Since the intel_vertical_texture_alignment_unit and intel_horizontal_texture_alignment_unit are called from within the top-level (and only within it), it would be assumed that the references also apply to these functions. On Tue, Jun 9, 2015 at 12:13 PM, Ian Romanick wrote: > On 06/01/2015 10:13 AM, Nanley Chery wrote: >> From: Nanley Chery >> >> - Remove redundant checks and comments by grouping our calculations for >> align_w and align_h wherever possible. >> - Don't pass more parameters than necessary. >> - Minor code simplifications. >> >> Signed-off-by: Nanley Chery >> --- >> src/mesa/drivers/dri/i965/brw_tex_layout.c | 181 >> + >> 1 file changed, 83 insertions(+), 98 deletions(-) >> >> diff --git a/src/mesa/drivers/dri/i965/brw_tex_layout.c >> b/src/mesa/drivers/dri/i965/brw_tex_layout.c >> index 5aadd00..a54b77d 100644 >> --- a/src/mesa/drivers/dri/i965/brw_tex_layout.c >> +++ b/src/mesa/drivers/dri/i965/brw_tex_layout.c >> @@ -40,16 +40,9 @@ >> #define FILE_DEBUG_FLAG DEBUG_MIPTREE >> >> static unsigned int >> -intel_horizontal_texture_alignment_unit(struct brw_context *brw, >> -struct intel_mipmap_tree *mt) >> +intel_horizontal_texture_alignment_unit(int gen, const struct >> intel_mipmap_tree *mt) >> { >> /** >> -* From the "Alignment Unit Size" section of various specs, namely: >> -* - Gen3 Spec: "Memory Data Formats" Volume, Section 1.20.1.4 >> -* - i965 and G45 PRMs: Volume 1, Section 6.17.3.4. >> -* - Ironlake and Sandybridge PRMs: Volume 1, Part 1, Section 7.18.3.4 >> -* - BSpec (for Ivybridge and slight variations in separate stencil) >> -* > > Since the rest of the spec quotation remains, why remove this part? > > I also agree with Anuj's comments about splitting this into multiple > patches. > >> * >> +--+ >> * || alignment unit width >> ("i") | >> * | Surface Property >> |-| >> @@ -67,47 +60,19 @@ intel_horizontal_texture_alignment_unit(struct >> brw_context *brw, >> * On IVB+, non-special cases can be overridden by setting the >> SURFACE_STATE >> * "Surface Horizontal Alignment" field to HALIGN_4 or HALIGN_8. >> */ >> -if (_mesa_is_format_compressed(mt->format)) { >> - /* The hardware alignment requirements for compressed textures >> -* happen to match the block boundaries. >> -*/ >> - unsigned int i, j; >> - _mesa_get_format_block_size(mt->format, &i, &j); >> - >> - /* On Gen9+ we can pick our own alignment for compressed textures but >> it >> - * has to be a multiple of the block size. The minimum alignment we >> can >> - * pick is 4 so we effectively have to align to 4 times the block >> - * size >> - */ >> - if (brw->gen >= 9) >> - return i * 4; >> - else >> - return i; >> -} >> - >> - if (mt->format == MESA_FORMAT_S_UINT8) >> - return 8; >> - >> - if (brw->gen >= 7 && mt->format == MESA_FORMAT_Z_UNORM16) >> + if (gen >= 7 && mt->format == MESA_FORMAT_Z_UNORM16) >>return 8; >> >> - if (brw->gen == 8 && mt->mcs_mt && mt->num_samples <= 1) >> + if (gen == 8 && mt->mcs_mt && mt->num_samples <= 1) >>return 16; >> >> return 4; >> } >> >> static unsigned int >> -intel_vertical_texture_alignment_unit(struct brw_context *brw, >> - mesa_format format, bool multisampled) >> +intel_vertical_texture_alignment_unit(int gen, const struct >> intel_mipmap_tree *mt) >> { >> /** >> -* From the "Alignment Unit Size" section of various specs, namely: >> -* - Gen3 Spec: "Memory Data Formats" Volume, Section 1.20.1.4 >> -* - i965 and G45 PRMs: Volume 1, Section 6.17.3.4. >> -*
[Mesa-dev] [PATCH v3 06/18] mesa/glformats: recognize ASTC formats as compressed
From: Nanley Chery Reviewed-by: Anuj Phogat Signed-off-by: Nanley Chery --- src/mesa/main/glformats.c | 29 + 1 file changed, 29 insertions(+) diff --git a/src/mesa/main/glformats.c b/src/mesa/main/glformats.c index ac69fab..e7363b5 100644 --- a/src/mesa/main/glformats.c +++ b/src/mesa/main/glformats.c @@ -1262,6 +1262,35 @@ _mesa_is_compressed_format(const struct gl_context *ctx, GLenum format) case GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT: return _mesa_is_desktop_gl(ctx) && ctx->Extensions.ARB_texture_compression_bptc; + case GL_COMPRESSED_RGBA_ASTC_4x4_KHR: + case GL_COMPRESSED_RGBA_ASTC_5x4_KHR: + case GL_COMPRESSED_RGBA_ASTC_5x5_KHR: + case GL_COMPRESSED_RGBA_ASTC_6x5_KHR: + case GL_COMPRESSED_RGBA_ASTC_6x6_KHR: + case GL_COMPRESSED_RGBA_ASTC_8x5_KHR: + case GL_COMPRESSED_RGBA_ASTC_8x6_KHR: + case GL_COMPRESSED_RGBA_ASTC_8x8_KHR: + case GL_COMPRESSED_RGBA_ASTC_10x5_KHR: + case GL_COMPRESSED_RGBA_ASTC_10x6_KHR: + case GL_COMPRESSED_RGBA_ASTC_10x8_KHR: + case GL_COMPRESSED_RGBA_ASTC_10x10_KHR: + case GL_COMPRESSED_RGBA_ASTC_12x10_KHR: + case GL_COMPRESSED_RGBA_ASTC_12x12_KHR: + case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR: + case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR: + case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR: + case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR: + case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR: + case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR: + case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR: + case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR: + case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR: + case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR: + case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR: + case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR: + case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR: + case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR: + return ctx->Extensions.KHR_texture_compression_astc_ldr; case GL_PALETTE4_RGB8_OES: case GL_PALETTE4_RGBA8_OES: case GL_PALETTE4_R5_G6_B5_OES: -- 2.4.2 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH v3 03/18] mesa: disable online compression for ASTC formats
From: Nanley Chery Reviewed-by: Anuj Phogat Signed-off-by: Nanley Chery --- src/mesa/main/texcompress.c | 22 ++ src/mesa/main/teximage.c| 28 2 files changed, 50 insertions(+) diff --git a/src/mesa/main/texcompress.c b/src/mesa/main/texcompress.c index 0fd1a36..1654fc6 100644 --- a/src/mesa/main/texcompress.c +++ b/src/mesa/main/texcompress.c @@ -229,6 +229,28 @@ _mesa_gl_compressed_format_base_format(GLenum format) *what GL_NUM_COMPRESSED_TEXTURE_FORMATS and *GL_COMPRESSED_TEXTURE_FORMATS return." * + * The KHR_texture_compression_astc_hdr spec says: + * + *"Interactions with OpenGL 4.2 + * + *OpenGL 4.2 supports the feature that compressed textures can be + *compressed online, by passing the compressed texture format enum as + *the internal format when uploading a texture using TexImage1D, + *TexImage2D or TexImage3D (see Section 3.9.3, Texture Image + *Specification, subsection Encoding of Special Internal Formats). + * + *Due to the complexity of the ASTC compression algorithm, it is not + *usually suitable for online use, and therefore ASTC support will be + *limited to pre-compressed textures only. Where on-device compression + *is required, a domain-specific limited compressor will typically + *be used, and this is therefore not suitable for implementation in + *the driver. + * + *In particular, the ASTC format specifiers will not be added to + *Table 3.14, and thus will not be accepted by the TexImage*D + *functions, and will not be returned by the (already deprecated) + *COMPRESSED_TEXTURE_FORMATS query." + * * There is no formal spec for GL_ATI_texture_compression_3dc. Since the * formats added by this extension are luminance-alpha formats, it is * reasonable to expect them to follow the same rules as diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c index 3d85615..86ef407 100644 --- a/src/mesa/main/teximage.c +++ b/src/mesa/main/teximage.c @@ -1778,6 +1778,34 @@ compressedteximage_only_format(const struct gl_context *ctx, GLenum format) case GL_PALETTE8_R5_G6_B5_OES: case GL_PALETTE8_RGBA4_OES: case GL_PALETTE8_RGB5_A1_OES: + case GL_COMPRESSED_RGBA_ASTC_4x4_KHR: + case GL_COMPRESSED_RGBA_ASTC_5x4_KHR: + case GL_COMPRESSED_RGBA_ASTC_5x5_KHR: + case GL_COMPRESSED_RGBA_ASTC_6x5_KHR: + case GL_COMPRESSED_RGBA_ASTC_6x6_KHR: + case GL_COMPRESSED_RGBA_ASTC_8x5_KHR: + case GL_COMPRESSED_RGBA_ASTC_8x6_KHR: + case GL_COMPRESSED_RGBA_ASTC_8x8_KHR: + case GL_COMPRESSED_RGBA_ASTC_10x5_KHR: + case GL_COMPRESSED_RGBA_ASTC_10x6_KHR: + case GL_COMPRESSED_RGBA_ASTC_10x8_KHR: + case GL_COMPRESSED_RGBA_ASTC_10x10_KHR: + case GL_COMPRESSED_RGBA_ASTC_12x10_KHR: + case GL_COMPRESSED_RGBA_ASTC_12x12_KHR: + case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR: + case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR: + case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR: + case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR: + case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR: + case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR: + case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR: + case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR: + case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR: + case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR: + case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR: + case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR: + case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR: + case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR: return GL_TRUE; default: return GL_FALSE; -- 2.4.2 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH v3 02/18] glapi: add support for KHR_texture_compression_astc_ldr
From: Nanley Chery v2: correct the spelling of the sRGB variants. remove spaces around "=" when setting the enum value. Reviewed-by: Anuj Phogat Signed-off-by: Nanley Chery --- .../glapi/gen/KHR_texture_compression_astc.xml | 40 ++ src/mapi/glapi/gen/Makefile.am | 1 + src/mapi/glapi/gen/gl_API.xml | 2 +- 3 files changed, 42 insertions(+), 1 deletion(-) create mode 100644 src/mapi/glapi/gen/KHR_texture_compression_astc.xml diff --git a/src/mapi/glapi/gen/KHR_texture_compression_astc.xml b/src/mapi/glapi/gen/KHR_texture_compression_astc.xml new file mode 100644 index 000..7b5864d --- /dev/null +++ b/src/mapi/glapi/gen/KHR_texture_compression_astc.xml @@ -0,0 +1,40 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/mapi/glapi/gen/Makefile.am b/src/mapi/glapi/gen/Makefile.am index 5b163b0..53edab5 100644 --- a/src/mapi/glapi/gen/Makefile.am +++ b/src/mapi/glapi/gen/Makefile.am @@ -187,6 +187,7 @@ API_XML = \ INTEL_performance_query.xml \ KHR_debug.xml \ KHR_context_flush_control.xml \ + KHR_texture_compression_astc.xml \ NV_conditional_render.xml \ NV_primitive_restart.xml \ NV_texture_barrier.xml \ diff --git a/src/mapi/glapi/gen/gl_API.xml b/src/mapi/glapi/gen/gl_API.xml index 2f33075..8df58a3 100644 --- a/src/mapi/glapi/gen/gl_API.xml +++ b/src/mapi/glapi/gen/gl_API.xml @@ -8162,7 +8162,7 @@ http://www.w3.org/2001/XInclude"/> - +http://www.w3.org/2001/XInclude"/> http://www.w3.org/2001/XInclude"/> -- 2.4.2 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH v3 04/18] mesa: return bool instead of GLboolean in compressedteximage_only_format()
From: Nanley Chery In agreement with the coding style, functions that aren't directly visible to the GL API should prefer the use of bool over GLboolean. Suggested-by: Ian Romanick Signed-off-by: Nanley Chery --- src/mesa/main/teximage.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c index 86ef407..0e0488a 100644 --- a/src/mesa/main/teximage.c +++ b/src/mesa/main/teximage.c @@ -1763,7 +1763,7 @@ _mesa_test_proxy_teximage(struct gl_context *ctx, GLenum target, GLint level, /** * Return true if the format is only valid for glCompressedTexImage. */ -static GLboolean +static bool compressedteximage_only_format(const struct gl_context *ctx, GLenum format) { switch (format) { @@ -1806,9 +1806,9 @@ compressedteximage_only_format(const struct gl_context *ctx, GLenum format) case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR: case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR: case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR: - return GL_TRUE; + return true; default: - return GL_FALSE; + return false; } } -- 2.4.2 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH v3 07/18] mesa/texcompress: enable translation between MESA and GL ASTC formats
From: Nanley Chery Reviewed-by: Anuj Phogat Signed-off-by: Nanley Chery --- src/mesa/main/texcompress.c | 114 1 file changed, 114 insertions(+) diff --git a/src/mesa/main/texcompress.c b/src/mesa/main/texcompress.c index 1654fc6..203a065 100644 --- a/src/mesa/main/texcompress.c +++ b/src/mesa/main/texcompress.c @@ -471,6 +471,63 @@ _mesa_glenum_to_compressed_format(GLenum format) case GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT: return MESA_FORMAT_BPTC_RGB_UNSIGNED_FLOAT; + case GL_COMPRESSED_RGBA_ASTC_4x4_KHR: + return MESA_FORMAT_ASTC_4x4_RGBA; + case GL_COMPRESSED_RGBA_ASTC_5x4_KHR: + return MESA_FORMAT_ASTC_5x4_RGBA; + case GL_COMPRESSED_RGBA_ASTC_5x5_KHR: + return MESA_FORMAT_ASTC_5x5_RGBA; + case GL_COMPRESSED_RGBA_ASTC_6x5_KHR: + return MESA_FORMAT_ASTC_6x5_RGBA; + case GL_COMPRESSED_RGBA_ASTC_6x6_KHR: + return MESA_FORMAT_ASTC_6x6_RGBA; + case GL_COMPRESSED_RGBA_ASTC_8x5_KHR: + return MESA_FORMAT_ASTC_8x5_RGBA; + case GL_COMPRESSED_RGBA_ASTC_8x6_KHR: + return MESA_FORMAT_ASTC_8x6_RGBA; + case GL_COMPRESSED_RGBA_ASTC_8x8_KHR: + return MESA_FORMAT_ASTC_8x8_RGBA; + case GL_COMPRESSED_RGBA_ASTC_10x5_KHR: + return MESA_FORMAT_ASTC_10x5_RGBA; + case GL_COMPRESSED_RGBA_ASTC_10x6_KHR: + return MESA_FORMAT_ASTC_10x6_RGBA; + case GL_COMPRESSED_RGBA_ASTC_10x8_KHR: + return MESA_FORMAT_ASTC_10x8_RGBA; + case GL_COMPRESSED_RGBA_ASTC_10x10_KHR: + return MESA_FORMAT_ASTC_10x10_RGBA; + case GL_COMPRESSED_RGBA_ASTC_12x10_KHR: + return MESA_FORMAT_ASTC_12x10_RGBA; + case GL_COMPRESSED_RGBA_ASTC_12x12_KHR: + return MESA_FORMAT_ASTC_12x12_RGBA; + case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR: + return MESA_FORMAT_ASTC_4x4_SRGB8_ALPHA8; + case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR: + return MESA_FORMAT_ASTC_5x4_SRGB8_ALPHA8; + case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR: + return MESA_FORMAT_ASTC_5x5_SRGB8_ALPHA8; + case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR: + return MESA_FORMAT_ASTC_6x5_SRGB8_ALPHA8; + case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR: + return MESA_FORMAT_ASTC_6x6_SRGB8_ALPHA8; + case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR: + return MESA_FORMAT_ASTC_8x5_SRGB8_ALPHA8; + case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR: + return MESA_FORMAT_ASTC_8x6_SRGB8_ALPHA8; + case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR: + return MESA_FORMAT_ASTC_8x8_SRGB8_ALPHA8; + case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR: + return MESA_FORMAT_ASTC_10x5_SRGB8_ALPHA8; + case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR: + return MESA_FORMAT_ASTC_10x6_SRGB8_ALPHA8; + case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR: + return MESA_FORMAT_ASTC_10x8_SRGB8_ALPHA8; + case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR: + return MESA_FORMAT_ASTC_10x10_SRGB8_ALPHA8; + case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR: + return MESA_FORMAT_ASTC_12x10_SRGB8_ALPHA8; + case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR: + return MESA_FORMAT_ASTC_12x12_SRGB8_ALPHA8; + default: return MESA_FORMAT_NONE; } @@ -561,6 +618,63 @@ _mesa_compressed_format_to_glenum(struct gl_context *ctx, mesa_format mesaFormat case MESA_FORMAT_BPTC_RGB_UNSIGNED_FLOAT: return GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT; + case MESA_FORMAT_ASTC_4x4_RGBA: + return GL_COMPRESSED_RGBA_ASTC_4x4_KHR; + case MESA_FORMAT_ASTC_5x4_RGBA: + return GL_COMPRESSED_RGBA_ASTC_5x4_KHR; + case MESA_FORMAT_ASTC_5x5_RGBA: + return GL_COMPRESSED_RGBA_ASTC_5x5_KHR; + case MESA_FORMAT_ASTC_6x5_RGBA: + return GL_COMPRESSED_RGBA_ASTC_6x5_KHR; + case MESA_FORMAT_ASTC_6x6_RGBA: + return GL_COMPRESSED_RGBA_ASTC_6x6_KHR; + case MESA_FORMAT_ASTC_8x5_RGBA: + return GL_COMPRESSED_RGBA_ASTC_8x5_KHR; + case MESA_FORMAT_ASTC_8x6_RGBA: + return GL_COMPRESSED_RGBA_ASTC_8x6_KHR; + case MESA_FORMAT_ASTC_8x8_RGBA: + return GL_COMPRESSED_RGBA_ASTC_8x8_KHR; + case MESA_FORMAT_ASTC_10x5_RGBA: + return GL_COMPRESSED_RGBA_ASTC_10x5_KHR; + case MESA_FORMAT_ASTC_10x6_RGBA: + return GL_COMPRESSED_RGBA_ASTC_10x6_KHR; + case MESA_FORMAT_ASTC_10x8_RGBA: + return GL_COMPRESSED_RGBA_ASTC_10x8_KHR; + case MESA_FORMAT_ASTC_10x10_RGBA: + return GL_COMPRESSED_RGBA_ASTC_10x10_KHR; + case MESA_FORMAT_ASTC_12x10_RGBA: + return GL_COMPRESSED_RGBA_ASTC_12x10_KHR; + case MESA_FORMAT_ASTC_12x12_RGBA: + return GL_COMPRESSED_RGBA_ASTC_12x12_KHR; + case MESA_FORMAT_ASTC_4x4_SRGB8_ALPHA8: + return GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR; + case MESA_FORMAT_ASTC_5x4_SRGB8_ALPHA8: + return GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR; + case MESA_FORMAT_ASTC_5x5_SRGB8_ALPHA8: + return GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR; + case MESA_FORMAT_ASTC_6x5_SRGB8_ALPHA8: + return GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR; + case MESA_FORMAT_ASTC_6x6_SRGB8_ALPHA8
[Mesa-dev] [PATCH v3 05/18] mesa: add ASTC extensions to the extensions table
From: Nanley Chery v2: alphabetize the extensions. remove OES ASTC extension. Reviewed-by: Anuj Phogat Signed-off-by: Nanley Chery --- src/mesa/main/extensions.c | 2 ++ src/mesa/main/mtypes.h | 2 ++ 2 files changed, 4 insertions(+) diff --git a/src/mesa/main/extensions.c b/src/mesa/main/extensions.c index 4176a69..adbeecc 100644 --- a/src/mesa/main/extensions.c +++ b/src/mesa/main/extensions.c @@ -337,6 +337,8 @@ static const struct extension extension_table[] = { /* KHR extensions */ { "GL_KHR_debug", o(dummy_true), GL, 2012 }, { "GL_KHR_context_flush_control", o(dummy_true), GL | ES2, 2014 }, + { "GL_KHR_texture_compression_astc_hdr", o(KHR_texture_compression_astc_hdr),GL | ES2, 2012 }, + { "GL_KHR_texture_compression_astc_ldr", o(KHR_texture_compression_astc_ldr),GL | ES2, 2012 }, /* Vendor extensions */ { "GL_3DFX_texture_compression_FXT1", o(TDFX_texture_compression_FXT1), GL, 1999 }, diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index 983b9dc..6a5d15f 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -3772,6 +3772,8 @@ struct gl_extensions GLboolean ATI_fragment_shader; GLboolean ATI_separate_stencil; GLboolean INTEL_performance_query; + GLboolean KHR_texture_compression_astc_hdr; + GLboolean KHR_texture_compression_astc_ldr; GLboolean MESA_pack_invert; GLboolean MESA_ycbcr_texture; GLboolean NV_conditional_render; -- 2.4.2 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH v3 09/18] mesa/formats: store whether or not a format is sRGB in gl_format_info
From: Nanley Chery v2: remove extra newline. v3: use bool instead of GLboolean. Reviewed-by: Anuj Phogat Signed-off-by: Nanley Chery --- src/mesa/main/format_info.py | 2 ++ src/mesa/main/formats.c | 28 2 files changed, 6 insertions(+), 24 deletions(-) diff --git a/src/mesa/main/format_info.py b/src/mesa/main/format_info.py index 40104a2..8134e8e 100644 --- a/src/mesa/main/format_info.py +++ b/src/mesa/main/format_info.py @@ -191,6 +191,8 @@ for fmat in formats: bits = [ get_channel_bits(fmat, name) for name in ['l', 'i', 'z', 's']] print ' {0},'.format(', '.join(map(str, bits))) + print ' {0:d},'.format(fmat.colorspace == 'srgb') + print ' {0}, {1}, {2},'.format(fmat.block_width, fmat.block_height, int(fmat.block_size() / 8)) diff --git a/src/mesa/main/formats.c b/src/mesa/main/formats.c index 745fd8c..1f5a2b9 100644 --- a/src/mesa/main/formats.c +++ b/src/mesa/main/formats.c @@ -65,6 +65,8 @@ struct gl_format_info GLubyte DepthBits; GLubyte StencilBits; + bool IsSRGBFormat; + /** * To describe compressed formats. If not compressed, Width=Height=1. */ @@ -553,30 +555,8 @@ _mesa_is_format_color_format(mesa_format format) GLenum _mesa_get_format_color_encoding(mesa_format format) { - /* XXX this info should be encoded in gl_format_info */ - switch (format) { - case MESA_FORMAT_BGR_SRGB8: - case MESA_FORMAT_A8B8G8R8_SRGB: - case MESA_FORMAT_B8G8R8A8_SRGB: - case MESA_FORMAT_A8R8G8B8_SRGB: - case MESA_FORMAT_R8G8B8A8_SRGB: - case MESA_FORMAT_L_SRGB8: - case MESA_FORMAT_L8A8_SRGB: - case MESA_FORMAT_A8L8_SRGB: - case MESA_FORMAT_SRGB_DXT1: - case MESA_FORMAT_SRGBA_DXT1: - case MESA_FORMAT_SRGBA_DXT3: - case MESA_FORMAT_SRGBA_DXT5: - case MESA_FORMAT_R8G8B8X8_SRGB: - case MESA_FORMAT_ETC2_SRGB8: - case MESA_FORMAT_ETC2_SRGB8_ALPHA8_EAC: - case MESA_FORMAT_ETC2_SRGB8_PUNCHTHROUGH_ALPHA1: - case MESA_FORMAT_B8G8R8X8_SRGB: - case MESA_FORMAT_BPTC_SRGB_ALPHA_UNORM: - return GL_SRGB; - default: - return GL_LINEAR; - } + const struct gl_format_info *info = _mesa_get_format_info(format); + return info->IsSRGBFormat ? GL_SRGB : GL_LINEAR; } -- 2.4.2 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH v3 00/18] Enable support for 2D ASTC (LDR and HDR modes) in SKL
From: Nanley Chery This patch series enables support for the KHR_texture_compression_astc_{ldr,hdr} extensions on Skylake machines. This revision includes developer suggestions and fixes rendering issues on previously untested systems. The sRGB issues were fixed and determined to be unrelated to this patchset. The Piglit tests for this extension can be found here: cgit.freedesktop.org/~nchery/piglit Nanley Chery (18): mesa/formats: define the 2D ASTC formats glapi: add support for KHR_texture_compression_astc_ldr mesa: disable online compression for ASTC formats mesa: return bool instead of GLboolean in compressedteximage_only_format() mesa: add ASTC extensions to the extensions table mesa/glformats: recognize ASTC formats as compressed mesa/texcompress: enable translation between MESA and GL ASTC formats mesa/teximage: return the base internal format of the ASTC formats mesa/formats: store whether or not a format is sRGB in gl_format_info i965/surface_formats: add support for 2D ASTC surface formats mesa/macros: add power-of-two assertions for alignment macros mesa/macros: move ALIGN_NPOT to macros.h i965: use ALIGN_NPOT for setting ASTC mipmap layouts i965: correct mt->align_h for 2D textures on Skylake i965: change the meaning of cpp for compressed textures i965: enable ASTC support for Skylake i965: refactor miptree alignment calculation code swrast: add a new macro, FETCH_COMPRESSED .../glapi/gen/KHR_texture_compression_astc.xml | 40 +++ src/mapi/glapi/gen/Makefile.am | 1 + src/mapi/glapi/gen/gl_API.xml | 2 +- src/mesa/drivers/dri/i965/brw_defines.h| 32 +++ src/mesa/drivers/dri/i965/brw_fs_nir.cpp | 2 +- src/mesa/drivers/dri/i965/brw_surface_formats.c| 80 ++ src/mesa/drivers/dri/i965/brw_tex_layout.c | 105 src/mesa/drivers/dri/i965/intel_copy_image.c | 19 +- src/mesa/drivers/dri/i965/intel_extensions.c | 5 + src/mesa/drivers/dri/i965/intel_mipmap_tree.c | 15 +- src/mesa/drivers/dri/i965/intel_mipmap_tree.h | 2 +- src/mesa/drivers/dri/i965/intel_upload.c | 6 - src/mesa/main/extensions.c | 2 + src/mesa/main/format_info.py | 5 + src/mesa/main/formats.c| 158 ++-- src/mesa/main/formats.csv | 31 +++ src/mesa/main/formats.h| 30 +++ src/mesa/main/glformats.c | 29 +++ src/mesa/main/macros.h | 22 +- src/mesa/main/mtypes.h | 2 + src/mesa/main/texcompress.c| 136 +++ src/mesa/main/teximage.c | 70 +- src/mesa/swrast/s_texfetch.c | 269 ++--- 23 files changed, 736 insertions(+), 327 deletions(-) create mode 100644 src/mapi/glapi/gen/KHR_texture_compression_astc.xml -- 2.4.2 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH v3 01/18] mesa/formats: define the 2D ASTC formats
From: Nanley Chery Includes definition of the formats, updates to functions likely to be used, as well as changes necessary for compilation. Reviewed-by: Anuj Phogat Signed-off-by: Nanley Chery --- src/mesa/main/format_info.py | 3 + src/mesa/main/formats.c | 130 +++ src/mesa/main/formats.csv| 31 +++ src/mesa/main/formats.h | 30 ++ src/mesa/swrast/s_texfetch.c | 32 ++- 5 files changed, 225 insertions(+), 1 deletion(-) diff --git a/src/mesa/main/format_info.py b/src/mesa/main/format_info.py index 3bae57e..40104a2 100644 --- a/src/mesa/main/format_info.py +++ b/src/mesa/main/format_info.py @@ -130,6 +130,9 @@ def get_channel_bits(fmat, chan_name): elif fmat.layout == 'bptc': bits = 16 if fmat.name.endswith('_FLOAT') else 8 return bits if fmat.has_channel(chan_name) else 0 + elif fmat.layout == 'astc': + bits = 16 if fmat.name.endswith('_RGBA') else 8 + return bits if fmat.has_channel(chan_name) else 0 else: assert False else: diff --git a/src/mesa/main/formats.c b/src/mesa/main/formats.c index baeb1bf..745fd8c 100644 --- a/src/mesa/main/formats.c +++ b/src/mesa/main/formats.c @@ -667,6 +667,48 @@ _mesa_get_srgb_format_linear(mesa_format format) case MESA_FORMAT_BPTC_SRGB_ALPHA_UNORM: format = MESA_FORMAT_BPTC_RGBA_UNORM; break; + case MESA_FORMAT_ASTC_4x4_SRGB8_ALPHA8: + format = MESA_FORMAT_ASTC_4x4_RGBA; + break; + case MESA_FORMAT_ASTC_5x4_SRGB8_ALPHA8: + format = MESA_FORMAT_ASTC_5x4_RGBA; + break; + case MESA_FORMAT_ASTC_5x5_SRGB8_ALPHA8: + format = MESA_FORMAT_ASTC_5x5_RGBA; + break; + case MESA_FORMAT_ASTC_6x5_SRGB8_ALPHA8: + format = MESA_FORMAT_ASTC_6x5_RGBA; + break; + case MESA_FORMAT_ASTC_6x6_SRGB8_ALPHA8: + format = MESA_FORMAT_ASTC_6x6_RGBA; + break; + case MESA_FORMAT_ASTC_8x5_SRGB8_ALPHA8: + format = MESA_FORMAT_ASTC_8x5_RGBA; + break; + case MESA_FORMAT_ASTC_8x6_SRGB8_ALPHA8: + format = MESA_FORMAT_ASTC_8x6_RGBA; + break; + case MESA_FORMAT_ASTC_8x8_SRGB8_ALPHA8: + format = MESA_FORMAT_ASTC_8x8_RGBA; + break; + case MESA_FORMAT_ASTC_10x5_SRGB8_ALPHA8: + format = MESA_FORMAT_ASTC_10x5_RGBA; + break; + case MESA_FORMAT_ASTC_10x6_SRGB8_ALPHA8: + format = MESA_FORMAT_ASTC_10x6_RGBA; + break; + case MESA_FORMAT_ASTC_10x8_SRGB8_ALPHA8: + format = MESA_FORMAT_ASTC_10x8_RGBA; + break; + case MESA_FORMAT_ASTC_10x10_SRGB8_ALPHA8: + format = MESA_FORMAT_ASTC_10x10_RGBA; + break; + case MESA_FORMAT_ASTC_12x10_SRGB8_ALPHA8: + format = MESA_FORMAT_ASTC_12x10_RGBA; + break; + case MESA_FORMAT_ASTC_12x12_SRGB8_ALPHA8: + format = MESA_FORMAT_ASTC_12x12_RGBA; + break; case MESA_FORMAT_B8G8R8X8_SRGB: format = MESA_FORMAT_B8G8R8X8_UNORM; break; @@ -741,6 +783,36 @@ _mesa_get_uncompressed_format(mesa_format format) case MESA_FORMAT_BPTC_RGB_UNSIGNED_FLOAT: case MESA_FORMAT_BPTC_RGB_SIGNED_FLOAT: return MESA_FORMAT_RGB_FLOAT32; + case MESA_FORMAT_ASTC_4x4_RGBA: + case MESA_FORMAT_ASTC_5x4_RGBA: + case MESA_FORMAT_ASTC_5x5_RGBA: + case MESA_FORMAT_ASTC_6x5_RGBA: + case MESA_FORMAT_ASTC_6x6_RGBA: + case MESA_FORMAT_ASTC_8x5_RGBA: + case MESA_FORMAT_ASTC_8x6_RGBA: + case MESA_FORMAT_ASTC_8x8_RGBA: + case MESA_FORMAT_ASTC_10x5_RGBA: + case MESA_FORMAT_ASTC_10x6_RGBA: + case MESA_FORMAT_ASTC_10x8_RGBA: + case MESA_FORMAT_ASTC_10x10_RGBA: + case MESA_FORMAT_ASTC_12x10_RGBA: + case MESA_FORMAT_ASTC_12x12_RGBA: + return MESA_FORMAT_RGBA_FLOAT16; + case MESA_FORMAT_ASTC_4x4_SRGB8_ALPHA8: + case MESA_FORMAT_ASTC_5x4_SRGB8_ALPHA8: + case MESA_FORMAT_ASTC_5x5_SRGB8_ALPHA8: + case MESA_FORMAT_ASTC_6x5_SRGB8_ALPHA8: + case MESA_FORMAT_ASTC_6x6_SRGB8_ALPHA8: + case MESA_FORMAT_ASTC_8x5_SRGB8_ALPHA8: + case MESA_FORMAT_ASTC_8x6_SRGB8_ALPHA8: + case MESA_FORMAT_ASTC_8x8_SRGB8_ALPHA8: + case MESA_FORMAT_ASTC_10x5_SRGB8_ALPHA8: + case MESA_FORMAT_ASTC_10x6_SRGB8_ALPHA8: + case MESA_FORMAT_ASTC_10x8_SRGB8_ALPHA8: + case MESA_FORMAT_ASTC_10x10_SRGB8_ALPHA8: + case MESA_FORMAT_ASTC_12x10_SRGB8_ALPHA8: + case MESA_FORMAT_ASTC_12x12_SRGB8_ALPHA8: + return MESA_FORMAT_A8B8G8R8_SRGB; default: #ifdef DEBUG assert(!_mesa_is_format_compressed(format)); @@ -1253,6 +1325,34 @@ _mesa_format_to_type_and_comps(mesa_format format, case MESA_FORMAT_BPTC_SRGB_ALPHA_UNORM: case MESA_FORMAT_BPTC_RGB_SIGNED_FLOAT: case MESA_FORMAT_BPTC_RGB_UNSIGNED_FLOAT: + case MESA_FORMAT_ASTC_4x4_RGBA: + case MESA_FORMAT_ASTC_5x4_RGBA: + case MESA_FORMAT_ASTC_5x5_RGBA: + case MESA_FORMAT_ASTC_6x5_RGBA: + case MESA_FORMAT_ASTC_6x6_RGBA: + case MESA_FORMAT_ASTC_8x5_RGBA: + case MESA_FORMAT_ASTC_8x6_RGBA: + case MESA_FORMAT_ASTC_8x8_RGBA: + c
[Mesa-dev] [PATCH v3 14/18] i965: correct mt->align_h for 2D textures on Skylake
From: Nanley Chery In agreement with commit 4ab8d59a23, vertical alignment values are equal to four times the block height on Gen9+. v2: add newlines to separate declarations, statments, and comments. Reviewed-by: Anuj Phogat Reviewed-by: Neil Roberts Signed-off-by: Nanley Chery --- src/mesa/drivers/dri/i965/brw_tex_layout.c | 11 --- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/mesa/drivers/dri/i965/brw_tex_layout.c b/src/mesa/drivers/dri/i965/brw_tex_layout.c index 4007697..ade2940 100644 --- a/src/mesa/drivers/dri/i965/brw_tex_layout.c +++ b/src/mesa/drivers/dri/i965/brw_tex_layout.c @@ -270,9 +270,14 @@ intel_vertical_texture_alignment_unit(struct brw_context *brw, * Where "*" means either VALIGN_2 or VALIGN_4 depending on the setting of * the SURFACE_STATE "Surface Vertical Alignment" field. */ - if (_mesa_is_format_compressed(mt->format)) - /* See comment above for the horizontal alignment */ - return brw->gen >= 9 ? 16 : 4; +if (_mesa_is_format_compressed(mt->format)) { + unsigned int i, j; + + _mesa_get_format_block_size(mt->format, &i, &j); + + /* See comment above for the horizontal alignment */ + return brw->gen >= 9 ? j * 4 : 4; +} if (mt->format == MESA_FORMAT_S_UINT8) return brw->gen >= 7 ? 8 : 4; -- 2.4.2 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH v3 17/18] i965: refactor miptree alignment calculation code
From: Nanley Chery Remove redundant checks and comments by grouping our calculations for align_w and align_h wherever possible. v2: reintroduce brw. don't include functional changes. don't adjust function parameters or create a new function. Signed-off-by: Nanley Chery --- src/mesa/drivers/dri/i965/brw_tex_layout.c | 85 +++--- 1 file changed, 30 insertions(+), 55 deletions(-) diff --git a/src/mesa/drivers/dri/i965/brw_tex_layout.c b/src/mesa/drivers/dri/i965/brw_tex_layout.c index 840a069..493ed4f 100644 --- a/src/mesa/drivers/dri/i965/brw_tex_layout.c +++ b/src/mesa/drivers/dri/i965/brw_tex_layout.c @@ -123,12 +123,6 @@ intel_horizontal_texture_alignment_unit(struct brw_context *brw, return 16; /** -* From the "Alignment Unit Size" section of various specs, namely: -* - Gen3 Spec: "Memory Data Formats" Volume, Section 1.20.1.4 -* - i965 and G45 PRMs: Volume 1, Section 6.17.3.4. -* - Ironlake and Sandybridge PRMs: Volume 1, Part 1, Section 7.18.3.4 -* - BSpec (for Ivybridge and slight variations in separate stencil) -* * +--+ * || alignment unit width ("i") | * | Surface Property |-| @@ -146,32 +140,6 @@ intel_horizontal_texture_alignment_unit(struct brw_context *brw, * On IVB+, non-special cases can be overridden by setting the SURFACE_STATE * "Surface Horizontal Alignment" field to HALIGN_4 or HALIGN_8. */ -if (_mesa_is_format_compressed(mt->format)) { - /* The hardware alignment requirements for compressed textures -* happen to match the block boundaries. -*/ - unsigned int i, j; - _mesa_get_format_block_size(mt->format, &i, &j); - - /* On Gen9+ we can pick our own alignment for compressed textures but it - * has to be a multiple of the block size. The minimum alignment we can - * pick is 4 so we effectively have to align to 4 times the block - * size - */ - if (brw->gen >= 9) - return i * 4; - else - return i; -} - - if (mt->format == MESA_FORMAT_S_UINT8) - return 8; - - if (brw->gen >= 9 && mt->tr_mode != INTEL_MIPTREE_TRMODE_NONE) { - uint32_t align = tr_mode_horizontal_texture_alignment(brw, mt); - /* XY_FAST_COPY_BLT doesn't support horizontal alignment < 32. */ - return align < 32 ? 32 : align; - } if (brw->gen >= 7 && mt->format == MESA_FORMAT_Z_UNORM16) return 8; @@ -248,12 +216,6 @@ intel_vertical_texture_alignment_unit(struct brw_context *brw, const struct intel_mipmap_tree *mt) { /** -* From the "Alignment Unit Size" section of various specs, namely: -* - Gen3 Spec: "Memory Data Formats" Volume, Section 1.20.1.4 -* - i965 and G45 PRMs: Volume 1, Section 6.17.3.4. -* - Ironlake and Sandybridge PRMs: Volume 1, Part 1, Section 7.18.3.4 -* - BSpec (for Ivybridge and slight variations in separate stencil) -* * +--+ * || alignment unit height ("j") | * | Surface Property |-| @@ -270,23 +232,6 @@ intel_vertical_texture_alignment_unit(struct brw_context *brw, * Where "*" means either VALIGN_2 or VALIGN_4 depending on the setting of * the SURFACE_STATE "Surface Vertical Alignment" field. */ -if (_mesa_is_format_compressed(mt->format)) { - unsigned int i, j; - - _mesa_get_format_block_size(mt->format, &i, &j); - - /* See comment above for the horizontal alignment */ - return brw->gen >= 9 ? j * 4 : 4; -} - - if (mt->format == MESA_FORMAT_S_UINT8) - return brw->gen >= 7 ? 8 : 4; - - if (mt->tr_mode != INTEL_MIPTREE_TRMODE_NONE) { - uint32_t align = tr_mode_vertical_texture_alignment(brw, mt); - /* XY_FAST_COPY_BLT doesn't support vertical alignment < 64 */ - return align < 64 ? 64 : align; - } /* Broadwell only supports VALIGN of 4, 8, and 16. The BSpec says 4 * should always be used, except for stencil buffers, which should be 8. @@ -780,6 +725,13 @@ brw_miptree_layout(struct brw_context *brw, mt->tr_mode = INTEL_MIPTREE_TRMODE_NONE; + /** +* From the "Alignment Unit Size" section of various specs, namely: +* - Gen3 Spec: "Memory Data Formats" Volume, Section 1.20.1.4 +* - i965 and G45 PRMs: Volume 1, Section 6.17.3.4. +* - Ironlake and Sa
[Mesa-dev] [PATCH v3 11/18] mesa/macros: add power-of-two assertions for alignment macros
From: Nanley Chery ALIGN and ROUND_DOWN_TO both require that the alignment value passed into the macro be a power of two in the comments. Using software assertions verifies this to be the case. v2: use static inline functions instead of gcc-specific statement expressions. Signed-off-by: Nanley Chery --- src/mesa/drivers/dri/i965/brw_fs_nir.cpp | 2 +- src/mesa/main/macros.h | 16 +--- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/mesa/drivers/dri/i965/brw_fs_nir.cpp b/src/mesa/drivers/dri/i965/brw_fs_nir.cpp index 59081ea..1a57784 100644 --- a/src/mesa/drivers/dri/i965/brw_fs_nir.cpp +++ b/src/mesa/drivers/dri/i965/brw_fs_nir.cpp @@ -134,7 +134,7 @@ fs_visitor::nir_setup_outputs(nir_shader *shader) : var->type->vector_elements; if (stage == MESA_SHADER_VERTEX) { - for (int i = 0; i < ALIGN(type_size(var->type), 4) / 4; i++) { + for (unsigned int i = 0; i < ALIGN(type_size(var->type), 4) / 4; i++) { int output = var->data.location + i; this->outputs[output] = offset(reg, 4 * i); this->output_components[output] = vector_elements; diff --git a/src/mesa/main/macros.h b/src/mesa/main/macros.h index 0608650..4a640ad 100644 --- a/src/mesa/main/macros.h +++ b/src/mesa/main/macros.h @@ -684,7 +684,7 @@ minify(unsigned value, unsigned levels) * Note that this considers 0 a power of two. */ static inline bool -is_power_of_two(unsigned value) +is_power_of_two(uintptr_t value) { return (value & (value - 1)) == 0; } @@ -700,7 +700,12 @@ is_power_of_two(unsigned value) * * \sa ROUND_DOWN_TO() */ -#define ALIGN(value, alignment) (((value) + (alignment) - 1) & ~((alignment) - 1)) +static inline uintptr_t +ALIGN(uintptr_t value, uintptr_t alignment) +{ + assert(is_power_of_two(alignment)); + return (((value) + (alignment) - 1) & ~((alignment) - 1)); +} /** * Align a value down to an alignment value @@ -713,7 +718,12 @@ is_power_of_two(unsigned value) * * \sa ALIGN() */ -#define ROUND_DOWN_TO(value, alignment) ((value) & ~(alignment - 1)) +static inline uintptr_t +ROUND_DOWN_TO(uintptr_t value, uintptr_t alignment) +{ + assert(is_power_of_two(alignment)); + return ((value) & ~(alignment - 1)); +} /** Cross product of two 3-element vectors */ -- 2.4.2 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH v3 08/18] mesa/teximage: return the base internal format of the ASTC formats
From: Nanley Chery This is necesary to initialize the gl_texture_image struct. From the KHR_texture_compression_astc_ldr spec: "Added to Section 3.8.6, Compressed Texture Images Add the tokens specified above to Table 3.16, Compressed Internal Formats. In all cases, the base internal format will be RGBA. The encoding allows images to be encoded with fewer channels, but this is always presented as RGBA to the sampler." Reviewed-by: Anuj Phogat Signed-off-by: Nanley Chery --- src/mesa/main/teximage.c | 36 1 file changed, 36 insertions(+) diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c index 0e0488a..8de0c11 100644 --- a/src/mesa/main/teximage.c +++ b/src/mesa/main/teximage.c @@ -565,6 +565,42 @@ _mesa_base_tex_format( struct gl_context *ctx, GLint internalFormat ) } } + if (ctx->Extensions.KHR_texture_compression_astc_ldr) { + switch (internalFormat) { + case GL_COMPRESSED_RGBA_ASTC_4x4_KHR: + case GL_COMPRESSED_RGBA_ASTC_5x4_KHR: + case GL_COMPRESSED_RGBA_ASTC_5x5_KHR: + case GL_COMPRESSED_RGBA_ASTC_6x5_KHR: + case GL_COMPRESSED_RGBA_ASTC_6x6_KHR: + case GL_COMPRESSED_RGBA_ASTC_8x5_KHR: + case GL_COMPRESSED_RGBA_ASTC_8x6_KHR: + case GL_COMPRESSED_RGBA_ASTC_8x8_KHR: + case GL_COMPRESSED_RGBA_ASTC_10x5_KHR: + case GL_COMPRESSED_RGBA_ASTC_10x6_KHR: + case GL_COMPRESSED_RGBA_ASTC_10x8_KHR: + case GL_COMPRESSED_RGBA_ASTC_10x10_KHR: + case GL_COMPRESSED_RGBA_ASTC_12x10_KHR: + case GL_COMPRESSED_RGBA_ASTC_12x12_KHR: + case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR: + case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR: + case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR: + case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR: + case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR: + case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR: + case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR: + case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR: + case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR: + case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR: + case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR: + case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR: + case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR: + case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR: + return GL_RGBA; + default: + ; /* fallthrough */ + } + } + if (_mesa_is_gles3(ctx) || ctx->Extensions.ARB_ES3_compatibility) { switch (internalFormat) { case GL_COMPRESSED_RGB8_ETC2: -- 2.4.2 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH v3 16/18] i965: enable ASTC support for Skylake
From: Nanley Chery v2: remove OES ASTC extension reference. Signed-off-by: Nanley Chery --- src/mesa/drivers/dri/i965/intel_extensions.c | 5 + 1 file changed, 5 insertions(+) diff --git a/src/mesa/drivers/dri/i965/intel_extensions.c b/src/mesa/drivers/dri/i965/intel_extensions.c index 365b4b8..cc793e5 100644 --- a/src/mesa/drivers/dri/i965/intel_extensions.c +++ b/src/mesa/drivers/dri/i965/intel_extensions.c @@ -354,6 +354,11 @@ intelInitExtensions(struct gl_context *ctx) ctx->Extensions.ARB_stencil_texturing = true; } + if (brw->gen >= 9) { + ctx->Extensions.KHR_texture_compression_astc_ldr = true; + ctx->Extensions.KHR_texture_compression_astc_hdr = true; + } + if (ctx->API == API_OPENGL_CORE) ctx->Extensions.ARB_base_instance = true; if (ctx->API != API_OPENGL_CORE) -- 2.4.2 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH v3 12/18] mesa/macros: move ALIGN_NPOT to macros.h
From: Nanley Chery Aligning with a non-power-of-two number is a general task that can be used in various places. This commit is required for the next one. Signed-off-by: Nanley Chery --- src/mesa/drivers/dri/i965/intel_upload.c | 6 -- src/mesa/main/macros.h | 6 ++ 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/mesa/drivers/dri/i965/intel_upload.c b/src/mesa/drivers/dri/i965/intel_upload.c index 870aabc..deaae6c 100644 --- a/src/mesa/drivers/dri/i965/intel_upload.c +++ b/src/mesa/drivers/dri/i965/intel_upload.c @@ -44,12 +44,6 @@ #define INTEL_UPLOAD_SIZE (64*1024) -/** - * Like ALIGN(), but works with a non-power-of-two alignment. - */ -#define ALIGN_NPOT(value, alignment) \ - (((value) + (alignment) - 1) / (alignment) * (alignment)) - void intel_upload_finish(struct brw_context *brw) { diff --git a/src/mesa/main/macros.h b/src/mesa/main/macros.h index 4a640ad..4a08130 100644 --- a/src/mesa/main/macros.h +++ b/src/mesa/main/macros.h @@ -708,6 +708,12 @@ ALIGN(uintptr_t value, uintptr_t alignment) } /** + * Like ALIGN(), but works with a non-power-of-two alignment. + */ +#define ALIGN_NPOT(value, alignment) \ + (((value) + (alignment) - 1) / (alignment) * (alignment)) + +/** * Align a value down to an alignment value * * If \c value is not already aligned to the requested alignment value, it -- 2.4.2 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH v3 18/18] swrast: add a new macro, FETCH_COMPRESSED
From: Nanley Chery This patch creates a new macro, FETCH_COMPRESSED - similar in nature to the other FETCH_* macros. This reduces repetition in the code that deals with compressed textures. Reviewed-by: Anuj Phogat Signed-off-by: Nanley Chery --- src/mesa/swrast/s_texfetch.c | 239 --- 1 file changed, 41 insertions(+), 198 deletions(-) diff --git a/src/mesa/swrast/s_texfetch.c b/src/mesa/swrast/s_texfetch.c index 14e5293..92a4a37 100644 --- a/src/mesa/swrast/s_texfetch.c +++ b/src/mesa/swrast/s_texfetch.c @@ -116,6 +116,14 @@ static void fetch_null_texelf( const struct swrast_texture_image *texImage, NULL \ } +#define FETCH_COMPRESSED(NAME) \ + {\ + MESA_FORMAT_ ## NAME, \ + fetch_compressed, \ + fetch_compressed, \ + fetch_compressed \ + } + /** * Table to map MESA_FORMAT_ to texel fetch/store funcs. */ @@ -344,214 +352,49 @@ texfetch_funcs[] = FETCH_NULL(RGBX_SINT32), /* DXT compressed formats */ - { - MESA_FORMAT_RGB_DXT1, - fetch_compressed, - fetch_compressed, - fetch_compressed - }, - { - MESA_FORMAT_RGBA_DXT1, - fetch_compressed, - fetch_compressed, - fetch_compressed - }, - { - MESA_FORMAT_RGBA_DXT3, - fetch_compressed, - fetch_compressed, - fetch_compressed - }, - { - MESA_FORMAT_RGBA_DXT5, - fetch_compressed, - fetch_compressed, - fetch_compressed - }, + FETCH_COMPRESSED(RGB_DXT1), + FETCH_COMPRESSED(RGBA_DXT1), + FETCH_COMPRESSED(RGBA_DXT3), + FETCH_COMPRESSED(RGBA_DXT5), /* DXT sRGB compressed formats */ - { - MESA_FORMAT_SRGB_DXT1, - fetch_compressed, - fetch_compressed, - fetch_compressed - }, - { - MESA_FORMAT_SRGBA_DXT1, - fetch_compressed, - fetch_compressed, - fetch_compressed - }, - { - MESA_FORMAT_SRGBA_DXT3, - fetch_compressed, - fetch_compressed, - fetch_compressed - }, - { - MESA_FORMAT_SRGBA_DXT5, - fetch_compressed, - fetch_compressed, - fetch_compressed - }, + FETCH_COMPRESSED(SRGB_DXT1), + FETCH_COMPRESSED(SRGBA_DXT1), + FETCH_COMPRESSED(SRGBA_DXT3), + FETCH_COMPRESSED(SRGBA_DXT5), /* FXT1 compressed formats */ - { - MESA_FORMAT_RGB_FXT1, - fetch_compressed, - fetch_compressed, - fetch_compressed - }, - { - MESA_FORMAT_RGBA_FXT1, - fetch_compressed, - fetch_compressed, - fetch_compressed - }, + FETCH_COMPRESSED(RGB_FXT1), + FETCH_COMPRESSED(RGBA_FXT1), /* RGTC compressed formats */ - { - MESA_FORMAT_R_RGTC1_UNORM, - fetch_compressed, - fetch_compressed, - fetch_compressed - }, - { - MESA_FORMAT_R_RGTC1_SNORM, - fetch_compressed, - fetch_compressed, - fetch_compressed - }, - { - MESA_FORMAT_RG_RGTC2_UNORM, - fetch_compressed, - fetch_compressed, - fetch_compressed - }, - { - MESA_FORMAT_RG_RGTC2_SNORM, - fetch_compressed, - fetch_compressed, - fetch_compressed - }, + FETCH_COMPRESSED(R_RGTC1_UNORM), + FETCH_COMPRESSED(R_RGTC1_SNORM), + FETCH_COMPRESSED(RG_RGTC2_UNORM), + FETCH_COMPRESSED(RG_RGTC2_SNORM), /* LATC1/2 compressed formats */ - { - MESA_FORMAT_L_LATC1_UNORM, - fetch_compressed, - fetch_compressed, - fetch_compressed - }, - { - MESA_FORMAT_L_LATC1_SNORM, - fetch_compressed, - fetch_compressed, - fetch_compressed - }, - { - MESA_FORMAT_LA_LATC2_UNORM, - fetch_compressed, - fetch_compressed, - fetch_compressed - }, - { - MESA_FORMAT_LA_LATC2_SNORM, - fetch_compressed, - fetch_compressed, - fetch_compressed - }, + FETCH_COMPRESSED(L_LATC1_UNORM), + FETCH_COMPRESSED(L_LATC1_SNORM), + FETCH_COMPRESSED(LA_LATC2_UNORM), + FETCH_COMPRESSED(LA_LATC2_SNORM), /* ETC1/2 compressed formats */ - { - MESA_FORMAT_ETC1_RGB8, - fetch_compressed, - fetch_compressed, - fetch_compressed - }, - { - MESA_FORMAT_ETC2_RGB8, - fetch_compressed, - fetch_compressed, - fetch_compressed - }, - { - MESA_FORMAT_ETC2_SRGB8, - fetch_compressed, - fetch_compressed, - fetch_compressed - }, - { - MESA_FORMAT_ETC2_RGBA8_EAC, - fetch_compressed, - fetch_compressed, - fetch_compressed - }, - { - MESA_FORMAT_ETC2_SRGB8_ALPHA8_EAC, - fetch_compressed, - fetch_compressed, - fetch_compressed - }, - { - MESA_FORMAT_ETC2_R11_EAC, - fetch_compressed, - fetch_compressed, - fetch_compressed - }, - { - MESA_FORMAT_ETC2_RG11_EAC, - fetch_compressed, - fetch_compressed, - fetch_compressed - }, - { - MESA_FORMAT_ETC2_SIGNED_R11_EAC, - fetch_compressed, - fetch_compressed
[Mesa-dev] [PATCH v3 13/18] i965: use ALIGN_NPOT for setting ASTC mipmap layouts
From: Nanley Chery ALIGN is changed to ALIGN_NPOT because alignment values are sometimes not powers of two when working with ASTC. Signed-off-by: Nanley Chery --- src/mesa/drivers/dri/i965/brw_tex_layout.c| 12 ++-- src/mesa/drivers/dri/i965/intel_mipmap_tree.c | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/mesa/drivers/dri/i965/brw_tex_layout.c b/src/mesa/drivers/dri/i965/brw_tex_layout.c index 998d8c4..4007697 100644 --- a/src/mesa/drivers/dri/i965/brw_tex_layout.c +++ b/src/mesa/drivers/dri/i965/brw_tex_layout.c @@ -367,7 +367,7 @@ brw_miptree_layout_2d(struct intel_mipmap_tree *mt) mt->total_width = mt->physical_width0; if (mt->compressed) { - mt->total_width = ALIGN(mt->physical_width0, mt->align_w); + mt->total_width = ALIGN_NPOT(mt->physical_width0, mt->align_w); } /* May need to adjust width to accommodate the placement of @@ -379,10 +379,10 @@ brw_miptree_layout_2d(struct intel_mipmap_tree *mt) unsigned mip1_width; if (mt->compressed) { - mip1_width = ALIGN(minify(mt->physical_width0, 1), mt->align_w) + - ALIGN(minify(mt->physical_width0, 2), bw); + mip1_width = ALIGN_NPOT(minify(mt->physical_width0, 1), mt->align_w) + + ALIGN_NPOT(minify(mt->physical_width0, 2), bw); } else { - mip1_width = ALIGN(minify(mt->physical_width0, 1), mt->align_w) + + mip1_width = ALIGN_NPOT(minify(mt->physical_width0, 1), mt->align_w) + minify(mt->physical_width0, 2); } @@ -398,7 +398,7 @@ brw_miptree_layout_2d(struct intel_mipmap_tree *mt) intel_miptree_set_level_info(mt, level, x, y, depth); - img_height = ALIGN(height, mt->align_h); + img_height = ALIGN_NPOT(height, mt->align_h); if (mt->compressed) img_height /= bh; @@ -415,7 +415,7 @@ brw_miptree_layout_2d(struct intel_mipmap_tree *mt) /* Layout_below: step right after second mipmap. */ if (level == mt->first_level + 1) { -x += ALIGN(width, mt->align_w); +x += ALIGN_NPOT(width, mt->align_w); } else { y += img_height; } diff --git a/src/mesa/drivers/dri/i965/intel_mipmap_tree.c b/src/mesa/drivers/dri/i965/intel_mipmap_tree.c index 6aa969a..b47f49d0 100644 --- a/src/mesa/drivers/dri/i965/intel_mipmap_tree.c +++ b/src/mesa/drivers/dri/i965/intel_mipmap_tree.c @@ -1213,8 +1213,8 @@ intel_miptree_copy_slice(struct brw_context *brw, if (dst_mt->compressed) { unsigned int i, j; _mesa_get_format_block_size(dst_mt->format, &i, &j); - height = ALIGN(height, j) / j; - width = ALIGN(width, i); + height = ALIGN_NPOT(height, j) / j; + width = ALIGN_NPOT(width, i); } /* If it's a packed depth/stencil buffer with separate stencil, the blit -- 2.4.2 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH v3 10/18] i965/surface_formats: add support for 2D ASTC surface formats
From: Nanley Chery Intel surface formats default to LDR unless there is hardware support for HDR and the texture is able to be processed in HDR mode. v2: remove extra newlines. v3: follow existing coding style in translate_tex_format(). Signed-off-by: Nanley Chery --- src/mesa/drivers/dri/i965/brw_defines.h | 32 ++ src/mesa/drivers/dri/i965/brw_surface_formats.c | 80 + 2 files changed, 112 insertions(+) diff --git a/src/mesa/drivers/dri/i965/brw_defines.h b/src/mesa/drivers/dri/i965/brw_defines.h index bfcc442..da5d434 100644 --- a/src/mesa/drivers/dri/i965/brw_defines.h +++ b/src/mesa/drivers/dri/i965/brw_defines.h @@ -504,6 +504,38 @@ #define BRW_SURFACEFORMAT_R8G8B8_UINT0x1C8 #define BRW_SURFACEFORMAT_R8G8B8_SINT0x1C9 #define BRW_SURFACEFORMAT_RAW0x1FF + +#define GEN9_SURFACE_ASTC_HDR_FORMAT_BIT 0x100 + +#define BRW_SURFACEFORMAT_ASTC_LDR_2D_4x4_U8sRGB 0x200 +#define BRW_SURFACEFORMAT_ASTC_LDR_2D_5x4_U8sRGB 0x208 +#define BRW_SURFACEFORMAT_ASTC_LDR_2D_5x5_U8sRGB 0x209 +#define BRW_SURFACEFORMAT_ASTC_LDR_2D_6x5_U8sRGB 0x211 +#define BRW_SURFACEFORMAT_ASTC_LDR_2D_6x6_U8sRGB 0x212 +#define BRW_SURFACEFORMAT_ASTC_LDR_2D_8x5_U8sRGB 0x221 +#define BRW_SURFACEFORMAT_ASTC_LDR_2D_8x6_U8sRGB 0x222 +#define BRW_SURFACEFORMAT_ASTC_LDR_2D_8x8_U8sRGB 0x224 +#define BRW_SURFACEFORMAT_ASTC_LDR_2D_10x5_U8sRGB0x231 +#define BRW_SURFACEFORMAT_ASTC_LDR_2D_10x6_U8sRGB0x232 +#define BRW_SURFACEFORMAT_ASTC_LDR_2D_10x8_U8sRGB0x234 +#define BRW_SURFACEFORMAT_ASTC_LDR_2D_10x10_U8sRGB 0x236 +#define BRW_SURFACEFORMAT_ASTC_LDR_2D_12x10_U8sRGB 0x23E +#define BRW_SURFACEFORMAT_ASTC_LDR_2D_12x12_U8sRGB 0x23F +#define BRW_SURFACEFORMAT_ASTC_LDR_2D_4x4_FLT16 0x240 +#define BRW_SURFACEFORMAT_ASTC_LDR_2D_5x4_FLT16 0x248 +#define BRW_SURFACEFORMAT_ASTC_LDR_2D_5x5_FLT16 0x249 +#define BRW_SURFACEFORMAT_ASTC_LDR_2D_6x5_FLT16 0x251 +#define BRW_SURFACEFORMAT_ASTC_LDR_2D_6x6_FLT16 0x252 +#define BRW_SURFACEFORMAT_ASTC_LDR_2D_8x5_FLT16 0x261 +#define BRW_SURFACEFORMAT_ASTC_LDR_2D_8x6_FLT16 0x262 +#define BRW_SURFACEFORMAT_ASTC_LDR_2D_8x8_FLT16 0x264 +#define BRW_SURFACEFORMAT_ASTC_LDR_2D_10x5_FLT16 0x271 +#define BRW_SURFACEFORMAT_ASTC_LDR_2D_10x6_FLT16 0x272 +#define BRW_SURFACEFORMAT_ASTC_LDR_2D_10x8_FLT16 0x274 +#define BRW_SURFACEFORMAT_ASTC_LDR_2D_10x10_FLT160x276 +#define BRW_SURFACEFORMAT_ASTC_LDR_2D_12x10_FLT160x27E +#define BRW_SURFACEFORMAT_ASTC_LDR_2D_12x12_FLT160x27F + #define BRW_SURFACE_FORMAT_SHIFT 18 #define BRW_SURFACE_FORMAT_MASKINTEL_MASK(26, 18) diff --git a/src/mesa/drivers/dri/i965/brw_surface_formats.c b/src/mesa/drivers/dri/i965/brw_surface_formats.c index 0501606..a896b79 100644 --- a/src/mesa/drivers/dri/i965/brw_surface_formats.c +++ b/src/mesa/drivers/dri/i965/brw_surface_formats.c @@ -307,6 +307,34 @@ const struct surface_format_info surface_formats[] = { SF( x, x, x, x, x, x, x, x, x, ETC2_EAC_SRGB8_A8) SF( x, x, x, x, x, x, x, x, x, R8G8B8_UINT) SF( x, x, x, x, x, x, x, x, x, R8G8B8_SINT) + SF(90, 90, x, x, x, x, x, x, x, ASTC_LDR_2D_4x4_FLT16) + SF(90, 90, x, x, x, x, x, x, x, ASTC_LDR_2D_5x4_FLT16) + SF(90, 90, x, x, x, x, x, x, x, ASTC_LDR_2D_5x5_FLT16) + SF(90, 90, x, x, x, x, x, x, x, ASTC_LDR_2D_6x5_FLT16) + SF(90, 90, x, x, x, x, x, x, x, ASTC_LDR_2D_6x6_FLT16) + SF(90, 90, x, x, x, x, x, x, x, ASTC_LDR_2D_8x5_FLT16) + SF(90, 90, x, x, x, x, x, x, x, ASTC_LDR_2D_8x6_FLT16) + SF(90, 90, x, x, x, x, x, x, x, ASTC_LDR_2D_8x8_FLT16) + SF(90, 90, x, x, x, x, x, x, x, ASTC_LDR_2D_10x5_FLT16) + SF(90, 90, x, x, x, x, x, x, x, ASTC_LDR_2D_10x6_FLT16) + SF(90, 90, x, x, x, x, x, x, x, ASTC_LDR_2D_10x8_FLT16) + SF(90, 90, x, x, x, x, x, x, x, ASTC_LDR_2D_10x10_FLT16) + SF(90, 90, x, x, x, x, x, x, x, ASTC_LDR_2D_12x10_FLT16) + SF(90, 90, x, x, x, x, x, x, x, ASTC_LDR_2D_12x12_FLT16) + SF(90, 90, x, x, x, x, x, x, x, ASTC_LDR_2D_4x4_U8sRGB) + SF(90, 90, x, x, x, x, x, x, x, ASTC_LDR_2D_5x4_U8sRGB) + SF(90, 90, x, x, x, x, x, x, x, ASTC_LDR_2D_5x5_U8sRGB) + SF(90, 90, x, x, x, x, x, x, x, ASTC_LDR_2D_6x5_U8sRGB) + SF(90, 90, x, x, x, x, x, x, x, ASTC_LDR_2D_6x6_U8sRGB) + SF(90, 90, x, x, x, x, x, x, x, ASTC_LDR_2D_8x5_U8sRGB) + SF(90, 90, x, x, x, x, x, x, x, ASTC_LDR_2D_8x6_U8sRGB) + SF(90, 90, x, x, x, x, x, x, x, ASTC_LDR_2D_8x8_U8sRGB) + SF(90, 90, x, x, x, x, x, x, x, ASTC_LDR_2D_10x5_U8sRGB) + SF(90, 90, x, x, x, x, x, x, x, ASTC_LDR_2D_10x6_U8sRGB) + SF(90, 90, x, x, x, x
[Mesa-dev] [PATCH v3 15/18] i965: change the meaning of cpp for compressed textures
From: Nanley Chery An ASTC block takes up 16 bytes for all block width and height configurations. This size is not integrally divisible by all ASTC block widths. Therefore cpp is changed to mean bytes per block if the texture is compressed. Because the original definition was bytes per block divided by block width, all references to the mipmap width must be divided the block width. This keeps the address calculation formulas consistent. For example, the units for miptree_level x_offset and miptree total_width has changed from pixels to blocks. v2: reuse preexisting ALIGN_NPOT macro located in an i965 driver file. v3: move ALIGN_NPOT into seperate commit. simplify cpp assignment in copy_image_with_blitter(). update miptree width and offset variables in: intel_miptree_copy_slice(), intel_miptree_map_gtt(), and brw_miptree_layout_texture_3d(). Signed-off-by: Nanley Chery --- src/mesa/drivers/dri/i965/brw_tex_layout.c| 15 +-- src/mesa/drivers/dri/i965/intel_copy_image.c | 19 +-- src/mesa/drivers/dri/i965/intel_mipmap_tree.c | 13 +++-- src/mesa/drivers/dri/i965/intel_mipmap_tree.h | 2 +- 4 files changed, 14 insertions(+), 35 deletions(-) diff --git a/src/mesa/drivers/dri/i965/brw_tex_layout.c b/src/mesa/drivers/dri/i965/brw_tex_layout.c index ade2940..840a069 100644 --- a/src/mesa/drivers/dri/i965/brw_tex_layout.c +++ b/src/mesa/drivers/dri/i965/brw_tex_layout.c @@ -396,6 +396,7 @@ brw_miptree_layout_2d(struct intel_mipmap_tree *mt) } } + mt->total_width /= bw; mt->total_height = 0; for (unsigned level = mt->first_level; level <= mt->last_level; level++) { @@ -420,7 +421,7 @@ brw_miptree_layout_2d(struct intel_mipmap_tree *mt) /* Layout_below: step right after second mipmap. */ if (level == mt->first_level + 1) { -x += ALIGN_NPOT(width, mt->align_w); +x += ALIGN_NPOT(width, mt->align_w) / bw; } else { y += img_height; } @@ -582,12 +583,14 @@ static void brw_miptree_layout_texture_3d(struct brw_context *brw, struct intel_mipmap_tree *mt) { - unsigned yscale = mt->compressed ? 4 : 1; - mt->total_width = 0; mt->total_height = 0; unsigned ysum = 0; + unsigned bh, bw; + + _mesa_get_format_block_size(mt->format, &bw, &bh); + for (unsigned level = mt->first_level; level <= mt->last_level; level++) { unsigned WL = MAX2(mt->physical_width0 >> level, 1); unsigned HL = MAX2(mt->physical_height0 >> level, 1); @@ -604,9 +607,9 @@ brw_miptree_layout_texture_3d(struct brw_context *brw, unsigned x = (q % (1 << level)) * wL; unsigned y = ysum + (q >> level) * hL; - intel_miptree_set_image_offset(mt, level, q, x, y / yscale); - mt->total_width = MAX2(mt->total_width, x + wL); - mt->total_height = MAX2(mt->total_height, (y + hL) / yscale); + intel_miptree_set_image_offset(mt, level, q, x / bw, y / bh); + mt->total_width = MAX2(mt->total_width, (x + wL) / bw); + mt->total_height = MAX2(mt->total_height, (y + hL) / bh); } ysum += ALIGN(DL, 1 << level) / (1 << level) * hL; diff --git a/src/mesa/drivers/dri/i965/intel_copy_image.c b/src/mesa/drivers/dri/i965/intel_copy_image.c index f4c7eff..93a64b5 100644 --- a/src/mesa/drivers/dri/i965/intel_copy_image.c +++ b/src/mesa/drivers/dri/i965/intel_copy_image.c @@ -41,7 +41,6 @@ copy_image_with_blitter(struct brw_context *brw, { GLuint bw, bh; uint32_t src_image_x, src_image_y, dst_image_x, dst_image_y; - int cpp; /* The blitter doesn't understand multisampling at all. */ if (src_mt->num_samples > 0 || dst_mt->num_samples > 0) @@ -86,16 +85,6 @@ copy_image_with_blitter(struct brw_context *brw, src_y /= (int)bh; src_width /= (int)bw; src_height /= (int)bh; - - /* Inside of the miptree, the x offsets are stored in pixels while - * the y offsets are stored in blocks. We need to scale just the x - * offset. - */ - src_image_x /= bw; - - cpp = _mesa_get_format_bytes(src_mt->format); - } else { - cpp = src_mt->cpp; } src_x += src_image_x; src_y += src_image_y; @@ -111,18 +100,12 @@ copy_image_with_blitter(struct brw_context *brw, dst_x /= (int)bw; dst_y /= (int)bh; - - /* Inside of the miptree, the x offsets are stored in pixels while - * the y offsets are stored in blocks. We need to scale just the x - * offset. - */ - dst_image_x /= bw; } dst_x += dst_image_x; dst_y += dst_image_y; return intelEmitCopyBlit(brw, -cpp, +src_mt->cpp, src_mt->pitch, src_mt->b
[Mesa-dev] [PATCH] i965/gen9: use an unreserved surface alignment value
From: Nanley Chery Although the horizontal and vertical alignment fields are ignored here, 0 is a reserved value for them and may cause undefined behavior. Change the default value to an abitrary valid one. Signed-off-by: Nanley Chery --- src/mesa/drivers/dri/i965/gen8_surface_state.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/mesa/drivers/dri/i965/gen8_surface_state.c b/src/mesa/drivers/dri/i965/gen8_surface_state.c index b2d1a57..22ae960 100644 --- a/src/mesa/drivers/dri/i965/gen8_surface_state.c +++ b/src/mesa/drivers/dri/i965/gen8_surface_state.c @@ -93,7 +93,7 @@ vertical_alignment(const struct brw_context *brw, if (brw->gen > 8 && (mt->tr_mode != INTEL_MIPTREE_TRMODE_NONE || surf_type == BRW_SURFACE_1D)) - return 0; + return GEN8_SURFACE_VALIGN_4; switch (mt->align_h) { case 4: @@ -118,7 +118,7 @@ horizontal_alignment(const struct brw_context *brw, if (brw->gen > 8 && (mt->tr_mode != INTEL_MIPTREE_TRMODE_NONE || gen9_use_linear_1d_layout(brw, mt))) - return 0; + return GEN8_SURFACE_HALIGN_4; switch (mt->align_w) { case 4: -- 2.4.4 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH] i965/gen9: use an unreserved surface alignment value
On Thu, Jun 25, 2015 at 12:37 AM, Pohjolainen, Topi wrote: > On Wed, Jun 24, 2015 at 05:57:13PM -0700, Anuj Phogat wrote: >> On Wed, Jun 24, 2015 at 3:51 PM, Nanley Chery wrote: >> > From: Nanley Chery >> > >> > Although the horizontal and vertical alignment fields are ignored here, >> > 0 is a reserved value for them and may cause undefined behavior. Change >> > the default value to an abitrary valid one. >> > >> > Signed-off-by: Nanley Chery >> > --- >> > src/mesa/drivers/dri/i965/gen8_surface_state.c | 4 ++-- >> > 1 file changed, 2 insertions(+), 2 deletions(-) >> > >> > diff --git a/src/mesa/drivers/dri/i965/gen8_surface_state.c >> > b/src/mesa/drivers/dri/i965/gen8_surface_state.c >> > index b2d1a57..22ae960 100644 >> > --- a/src/mesa/drivers/dri/i965/gen8_surface_state.c >> > +++ b/src/mesa/drivers/dri/i965/gen8_surface_state.c >> > @@ -93,7 +93,7 @@ vertical_alignment(const struct brw_context *brw, >> > if (brw->gen > 8 && >> > (mt->tr_mode != INTEL_MIPTREE_TRMODE_NONE || >> > surf_type == BRW_SURFACE_1D)) >> > - return 0; >> > + return GEN8_SURFACE_VALIGN_4; >> > >> > switch (mt->align_h) { >> > case 4: >> > @@ -118,7 +118,7 @@ horizontal_alignment(const struct brw_context *brw, >> > if (brw->gen > 8 && >> > (mt->tr_mode != INTEL_MIPTREE_TRMODE_NONE || >> > gen9_use_linear_1d_layout(brw, mt))) >> > - return 0; >> > + return GEN8_SURFACE_HALIGN_4; >> > >> > switch (mt->align_w) { >> > case 4: >> > -- >> > 2.4.4 >> > >> > ___ >> > mesa-dev mailing list >> > mesa-dev@lists.freedesktop.org >> > http://lists.freedesktop.org/mailman/listinfo/mesa-dev >> >> Good find Nanley. We had no known issues with value 0 but it's >> always nice to avoid undefined behavior :). > > Right, I thought about this when I reviewed the original. The spec says > it is ignored in these cases and hence the reserved value seemed fine. Now > that we put something meaningful there, somebody is going to compare the > spec and wonder why we set it to 4. If we added also a comment here that > says this is just an arbitrary (non-reserved) value and really ignored > by the hardware, it would prevent misunderstandings. What do you guys think? > There's enough space to insert "Set to an arbitrary non-reserved value." in both of the comments preceding the conditional without adding an extra line. I wouldn't mind including it. Thanks, Nanley ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH v3 11/18] mesa/macros: add power-of-two assertions for alignment macros
How about if I create a patch which puts the greater than 0 check into is_power_of_two()? (value > 0) && (value & (value - 1)) == 0); Thanks, Nanley On Wed, Jun 24, 2015 at 3:22 PM, Anuj Phogat wrote: > On Mon, Jun 22, 2015 at 4:02 PM, Nanley Chery wrote: >> From: Nanley Chery >> >> ALIGN and ROUND_DOWN_TO both require that the alignment value passed >> into the macro be a power of two in the comments. Using software assertions >> verifies this to be the case. >> >> v2: use static inline functions instead of gcc-specific statement >> expressions. >> >> Signed-off-by: Nanley Chery >> --- >> src/mesa/drivers/dri/i965/brw_fs_nir.cpp | 2 +- >> src/mesa/main/macros.h | 16 +--- >> 2 files changed, 14 insertions(+), 4 deletions(-) >> >> diff --git a/src/mesa/drivers/dri/i965/brw_fs_nir.cpp >> b/src/mesa/drivers/dri/i965/brw_fs_nir.cpp >> index 59081ea..1a57784 100644 >> --- a/src/mesa/drivers/dri/i965/brw_fs_nir.cpp >> +++ b/src/mesa/drivers/dri/i965/brw_fs_nir.cpp >> @@ -134,7 +134,7 @@ fs_visitor::nir_setup_outputs(nir_shader *shader) >> : var->type->vector_elements; >> >>if (stage == MESA_SHADER_VERTEX) { >> - for (int i = 0; i < ALIGN(type_size(var->type), 4) / 4; i++) { >> + for (unsigned int i = 0; i < ALIGN(type_size(var->type), 4) / 4; >> i++) { >> int output = var->data.location + i; >> this->outputs[output] = offset(reg, 4 * i); >> this->output_components[output] = vector_elements; >> diff --git a/src/mesa/main/macros.h b/src/mesa/main/macros.h >> index 0608650..4a640ad 100644 >> --- a/src/mesa/main/macros.h >> +++ b/src/mesa/main/macros.h >> @@ -684,7 +684,7 @@ minify(unsigned value, unsigned levels) >> * Note that this considers 0 a power of two. >> */ >> static inline bool >> -is_power_of_two(unsigned value) >> +is_power_of_two(uintptr_t value) >> { >> return (value & (value - 1)) == 0; >> } >> @@ -700,7 +700,12 @@ is_power_of_two(unsigned value) >> * >> * \sa ROUND_DOWN_TO() >> */ >> -#define ALIGN(value, alignment) (((value) + (alignment) - 1) & >> ~((alignment) - 1)) >> +static inline uintptr_t >> +ALIGN(uintptr_t value, uintptr_t alignment) >> +{ >> + assert(is_power_of_two(alignment)); > Also handle the 0 alignment. is_power_of_two() returns true for 0. > Use assert(alignment > 0 && is_power_of_two(alignment))? >> + return (((value) + (alignment) - 1) & ~((alignment) - 1)); >> +} >> >> /** >> * Align a value down to an alignment value >> @@ -713,7 +718,12 @@ is_power_of_two(unsigned value) >> * >> * \sa ALIGN() >> */ >> -#define ROUND_DOWN_TO(value, alignment) ((value) & ~(alignment - 1)) >> +static inline uintptr_t >> +ROUND_DOWN_TO(uintptr_t value, uintptr_t alignment) >> +{ >> + assert(is_power_of_two(alignment)); > Here as well. >> + return ((value) & ~(alignment - 1)); >> +} >> >> >> /** Cross product of two 3-element vectors */ >> -- >> 2.4.2 >> >> ___ >> mesa-dev mailing list >> mesa-dev@lists.freedesktop.org >> http://lists.freedesktop.org/mailman/listinfo/mesa-dev > > With above changes and indentation fixes: > Reviewed-by: Anuj Phogat ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH v3 12/18] mesa/macros: move ALIGN_NPOT to macros.h
On Wed, Jun 24, 2015 at 3:43 PM, Anuj Phogat wrote: > On Mon, Jun 22, 2015 at 4:02 PM, Nanley Chery wrote: >> From: Nanley Chery >> >> Aligning with a non-power-of-two number is a general task that can be used in >> various places. This commit is required for the next one. >> >> Signed-off-by: Nanley Chery >> --- >> src/mesa/drivers/dri/i965/intel_upload.c | 6 -- >> src/mesa/main/macros.h | 6 ++ >> 2 files changed, 6 insertions(+), 6 deletions(-) >> >> diff --git a/src/mesa/drivers/dri/i965/intel_upload.c >> b/src/mesa/drivers/dri/i965/intel_upload.c >> index 870aabc..deaae6c 100644 >> --- a/src/mesa/drivers/dri/i965/intel_upload.c >> +++ b/src/mesa/drivers/dri/i965/intel_upload.c >> @@ -44,12 +44,6 @@ >> >> #define INTEL_UPLOAD_SIZE (64*1024) >> >> -/** >> - * Like ALIGN(), but works with a non-power-of-two alignment. >> - */ >> -#define ALIGN_NPOT(value, alignment) \ >> - (((value) + (alignment) - 1) / (alignment) * (alignment)) >> - >> void >> intel_upload_finish(struct brw_context *brw) >> { >> diff --git a/src/mesa/main/macros.h b/src/mesa/main/macros.h >> index 4a640ad..4a08130 100644 >> --- a/src/mesa/main/macros.h >> +++ b/src/mesa/main/macros.h >> @@ -708,6 +708,12 @@ ALIGN(uintptr_t value, uintptr_t alignment) >> } >> >> /** >> + * Like ALIGN(), but works with a non-power-of-two alignment. >> + */ >> +#define ALIGN_NPOT(value, alignment) \ >> + (((value) + (alignment) - 1) / (alignment) * (alignment)) >> + >> +/** > Add an assert for the 0 alignment? > Good catch Anuj. I will convert the macro to a static inline function in order to include this assertion. Thanks, Nanley >> * Align a value down to an alignment value >> * >> * If \c value is not already aligned to the requested alignment value, it >> -- >> 2.4.2 >> >> ___ >> mesa-dev mailing list >> mesa-dev@lists.freedesktop.org >> http://lists.freedesktop.org/mailman/listinfo/mesa-dev > > R ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH v3 11/18] mesa/macros: add power-of-two assertions for alignment macros
On Thu, Jun 25, 2015 at 4:16 PM, Anuj Phogat wrote: > On Thu, Jun 25, 2015 at 3:22 PM, Nanley Chery wrote: >> How about if I create a patch which puts the greater than 0 check into >> is_power_of_two()? >> >> (value > 0) && (value & (value - 1)) == 0); >> > Not a bad idea except that you'll need to fix conditions at all other places > which expect the current behavior. I'll leave it up to you. FYI gallium also > have a helper function util_is_power_of_two() which returns true for 0. > I'll avoid putting the condition into the function for now and follow your suggestion. >> Thanks, >> Nanley >> >> On Wed, Jun 24, 2015 at 3:22 PM, Anuj Phogat wrote: >>> On Mon, Jun 22, 2015 at 4:02 PM, Nanley Chery wrote: >>>> From: Nanley Chery >>>> >>>> ALIGN and ROUND_DOWN_TO both require that the alignment value passed >>>> into the macro be a power of two in the comments. Using software assertions >>>> verifies this to be the case. >>>> >>>> v2: use static inline functions instead of gcc-specific statement >>>> expressions. >>>> >>>> Signed-off-by: Nanley Chery >>>> --- >>>> src/mesa/drivers/dri/i965/brw_fs_nir.cpp | 2 +- >>>> src/mesa/main/macros.h | 16 +--- >>>> 2 files changed, 14 insertions(+), 4 deletions(-) >>>> >>>> diff --git a/src/mesa/drivers/dri/i965/brw_fs_nir.cpp >>>> b/src/mesa/drivers/dri/i965/brw_fs_nir.cpp >>>> index 59081ea..1a57784 100644 >>>> --- a/src/mesa/drivers/dri/i965/brw_fs_nir.cpp >>>> +++ b/src/mesa/drivers/dri/i965/brw_fs_nir.cpp >>>> @@ -134,7 +134,7 @@ fs_visitor::nir_setup_outputs(nir_shader *shader) >>>> : var->type->vector_elements; >>>> >>>>if (stage == MESA_SHADER_VERTEX) { >>>> - for (int i = 0; i < ALIGN(type_size(var->type), 4) / 4; i++) { >>>> + for (unsigned int i = 0; i < ALIGN(type_size(var->type), 4) / 4; >>>> i++) { >>>> int output = var->data.location + i; >>>> this->outputs[output] = offset(reg, 4 * i); >>>> this->output_components[output] = vector_elements; >>>> diff --git a/src/mesa/main/macros.h b/src/mesa/main/macros.h >>>> index 0608650..4a640ad 100644 >>>> --- a/src/mesa/main/macros.h >>>> +++ b/src/mesa/main/macros.h >>>> @@ -684,7 +684,7 @@ minify(unsigned value, unsigned levels) >>>> * Note that this considers 0 a power of two. >>>> */ >>>> static inline bool >>>> -is_power_of_two(unsigned value) >>>> +is_power_of_two(uintptr_t value) >>>> { >>>> return (value & (value - 1)) == 0; >>>> } >>>> @@ -700,7 +700,12 @@ is_power_of_two(unsigned value) >>>> * >>>> * \sa ROUND_DOWN_TO() >>>> */ >>>> -#define ALIGN(value, alignment) (((value) + (alignment) - 1) & >>>> ~((alignment) - 1)) >>>> +static inline uintptr_t >>>> +ALIGN(uintptr_t value, uintptr_t alignment) >>>> +{ >>>> + assert(is_power_of_two(alignment)); >>> Also handle the 0 alignment. is_power_of_two() returns true for 0. >>> Use assert(alignment > 0 && is_power_of_two(alignment))? >>>> + return (((value) + (alignment) - 1) & ~((alignment) - 1)); >>>> +} >>>> >>>> /** >>>> * Align a value down to an alignment value >>>> @@ -713,7 +718,12 @@ is_power_of_two(unsigned value) >>>> * >>>> * \sa ALIGN() >>>> */ >>>> -#define ROUND_DOWN_TO(value, alignment) ((value) & ~(alignment - 1)) >>>> +static inline uintptr_t >>>> +ROUND_DOWN_TO(uintptr_t value, uintptr_t alignment) >>>> +{ >>>> + assert(is_power_of_two(alignment)); >>> Here as well. >>>> + return ((value) & ~(alignment - 1)); >>>> +} >>>> >>>> >>>> /** Cross product of two 3-element vectors */ >>>> -- >>>> 2.4.2 >>>> >>>> ___ >>>> mesa-dev mailing list >>>> mesa-dev@lists.freedesktop.org >>>> http://lists.freedesktop.org/mailman/listinfo/mesa-dev >>> >>> With above changes and indentation fixes: >>> Reviewed-by: Anuj Phogat ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH] mesa/macros: move ALIGN_NPOT to macros.h
From: Nanley Chery Aligning with a non-power-of-two number is a general task that can be used in various places. This commit is required for the next one. v2: add greater than 0 assertion (Anuj). convert the macro to a static inline function. Signed-off-by: Nanley Chery --- src/mesa/drivers/dri/i965/intel_upload.c | 6 -- src/mesa/main/macros.h | 10 ++ 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/mesa/drivers/dri/i965/intel_upload.c b/src/mesa/drivers/dri/i965/intel_upload.c index 870aabc..deaae6c 100644 --- a/src/mesa/drivers/dri/i965/intel_upload.c +++ b/src/mesa/drivers/dri/i965/intel_upload.c @@ -44,12 +44,6 @@ #define INTEL_UPLOAD_SIZE (64*1024) -/** - * Like ALIGN(), but works with a non-power-of-two alignment. - */ -#define ALIGN_NPOT(value, alignment) \ - (((value) + (alignment) - 1) / (alignment) * (alignment)) - void intel_upload_finish(struct brw_context *brw) { diff --git a/src/mesa/main/macros.h b/src/mesa/main/macros.h index 7f89447..1a587fb 100644 --- a/src/mesa/main/macros.h +++ b/src/mesa/main/macros.h @@ -708,6 +708,16 @@ ALIGN(uintptr_t value, int32_t alignment) } /** + * Like ALIGN(), but works with a non-power-of-two alignment. + */ +static inline uintptr_t +ALIGN_NPOT(uintptr_t value, int32_t alignment) +{ + assert(alignment > 0); + return (value + alignment - 1) / alignment * alignment; +} + +/** * Align a value down to an alignment value * * If \c value is not already aligned to the requested alignment value, it -- 2.4.4 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH] i965/surface_formats: add support for 2D ASTC surface formats
From: Nanley Chery Define two-thirds of the 2D Intel ASTC surface formats (LDR-only). This allows a 1-to-1 mapping from the mesa format to the Intel format. ASTC textures will default to being processed in LDR mode. If there is hardware support for HDR/Full mode and the texture is not sRGB, add the format bit necessary to process it in HDR/Full mode. v2: remove extra newlines. v3: follow existing coding style in translate_tex_format(). v4: expound on the GEN9_SURFACE_ASTC_HDR_FORMAT_BIT comment. update SF table - ASTC is actually supported in Gen8. Reviewed-by: Anuj Phogat Signed-off-by: Nanley Chery --- src/mesa/drivers/dri/i965/brw_defines.h | 32 + src/mesa/drivers/dri/i965/brw_surface_formats.c | 87 + 2 files changed, 119 insertions(+) diff --git a/src/mesa/drivers/dri/i965/brw_defines.h b/src/mesa/drivers/dri/i965/brw_defines.h index 66b9abc..61e9b71 100644 --- a/src/mesa/drivers/dri/i965/brw_defines.h +++ b/src/mesa/drivers/dri/i965/brw_defines.h @@ -504,6 +504,38 @@ #define BRW_SURFACEFORMAT_R8G8B8_UINT0x1C8 #define BRW_SURFACEFORMAT_R8G8B8_SINT0x1C9 #define BRW_SURFACEFORMAT_RAW0x1FF + +#define GEN9_SURFACE_ASTC_HDR_FORMAT_BIT 0x100 + +#define BRW_SURFACEFORMAT_ASTC_LDR_2D_4x4_U8sRGB 0x200 +#define BRW_SURFACEFORMAT_ASTC_LDR_2D_5x4_U8sRGB 0x208 +#define BRW_SURFACEFORMAT_ASTC_LDR_2D_5x5_U8sRGB 0x209 +#define BRW_SURFACEFORMAT_ASTC_LDR_2D_6x5_U8sRGB 0x211 +#define BRW_SURFACEFORMAT_ASTC_LDR_2D_6x6_U8sRGB 0x212 +#define BRW_SURFACEFORMAT_ASTC_LDR_2D_8x5_U8sRGB 0x221 +#define BRW_SURFACEFORMAT_ASTC_LDR_2D_8x6_U8sRGB 0x222 +#define BRW_SURFACEFORMAT_ASTC_LDR_2D_8x8_U8sRGB 0x224 +#define BRW_SURFACEFORMAT_ASTC_LDR_2D_10x5_U8sRGB0x231 +#define BRW_SURFACEFORMAT_ASTC_LDR_2D_10x6_U8sRGB0x232 +#define BRW_SURFACEFORMAT_ASTC_LDR_2D_10x8_U8sRGB0x234 +#define BRW_SURFACEFORMAT_ASTC_LDR_2D_10x10_U8sRGB 0x236 +#define BRW_SURFACEFORMAT_ASTC_LDR_2D_12x10_U8sRGB 0x23E +#define BRW_SURFACEFORMAT_ASTC_LDR_2D_12x12_U8sRGB 0x23F +#define BRW_SURFACEFORMAT_ASTC_LDR_2D_4x4_FLT16 0x240 +#define BRW_SURFACEFORMAT_ASTC_LDR_2D_5x4_FLT16 0x248 +#define BRW_SURFACEFORMAT_ASTC_LDR_2D_5x5_FLT16 0x249 +#define BRW_SURFACEFORMAT_ASTC_LDR_2D_6x5_FLT16 0x251 +#define BRW_SURFACEFORMAT_ASTC_LDR_2D_6x6_FLT16 0x252 +#define BRW_SURFACEFORMAT_ASTC_LDR_2D_8x5_FLT16 0x261 +#define BRW_SURFACEFORMAT_ASTC_LDR_2D_8x6_FLT16 0x262 +#define BRW_SURFACEFORMAT_ASTC_LDR_2D_8x8_FLT16 0x264 +#define BRW_SURFACEFORMAT_ASTC_LDR_2D_10x5_FLT16 0x271 +#define BRW_SURFACEFORMAT_ASTC_LDR_2D_10x6_FLT16 0x272 +#define BRW_SURFACEFORMAT_ASTC_LDR_2D_10x8_FLT16 0x274 +#define BRW_SURFACEFORMAT_ASTC_LDR_2D_10x10_FLT160x276 +#define BRW_SURFACEFORMAT_ASTC_LDR_2D_12x10_FLT160x27E +#define BRW_SURFACEFORMAT_ASTC_LDR_2D_12x12_FLT160x27F + #define BRW_SURFACE_FORMAT_SHIFT 18 #define BRW_SURFACE_FORMAT_MASKINTEL_MASK(26, 18) diff --git a/src/mesa/drivers/dri/i965/brw_surface_formats.c b/src/mesa/drivers/dri/i965/brw_surface_formats.c index 0501606..2546ff8 100644 --- a/src/mesa/drivers/dri/i965/brw_surface_formats.c +++ b/src/mesa/drivers/dri/i965/brw_surface_formats.c @@ -307,6 +307,34 @@ const struct surface_format_info surface_formats[] = { SF( x, x, x, x, x, x, x, x, x, ETC2_EAC_SRGB8_A8) SF( x, x, x, x, x, x, x, x, x, R8G8B8_UINT) SF( x, x, x, x, x, x, x, x, x, R8G8B8_SINT) + SF(80, 80, x, x, x, x, x, x, x, ASTC_LDR_2D_4x4_FLT16) + SF(80, 80, x, x, x, x, x, x, x, ASTC_LDR_2D_5x4_FLT16) + SF(80, 80, x, x, x, x, x, x, x, ASTC_LDR_2D_5x5_FLT16) + SF(80, 80, x, x, x, x, x, x, x, ASTC_LDR_2D_6x5_FLT16) + SF(80, 80, x, x, x, x, x, x, x, ASTC_LDR_2D_6x6_FLT16) + SF(80, 80, x, x, x, x, x, x, x, ASTC_LDR_2D_8x5_FLT16) + SF(80, 80, x, x, x, x, x, x, x, ASTC_LDR_2D_8x6_FLT16) + SF(80, 80, x, x, x, x, x, x, x, ASTC_LDR_2D_8x8_FLT16) + SF(80, 80, x, x, x, x, x, x, x, ASTC_LDR_2D_10x5_FLT16) + SF(80, 80, x, x, x, x, x, x, x, ASTC_LDR_2D_10x6_FLT16) + SF(80, 80, x, x, x, x, x, x, x, ASTC_LDR_2D_10x8_FLT16) + SF(80, 80, x, x, x, x, x, x, x, ASTC_LDR_2D_10x10_FLT16) + SF(80, 80, x, x, x, x, x, x, x, ASTC_LDR_2D_12x10_FLT16) + SF(80, 80, x, x, x, x, x, x, x, ASTC_LDR_2D_12x12_FLT16) + SF(80, 80, x, x, x, x, x, x, x, ASTC_LDR_2D_4x4_U8sRGB) + SF(80, 80, x, x, x, x, x, x, x, ASTC_LDR_2D_5x4_U8sRGB) + SF(80, 80, x, x, x, x, x, x, x, ASTC_LDR_2D_5x5_U8sRGB) + SF(80, 80, x, x, x, x, x, x, x, ASTC_LDR_2D_6x5_U8sRGB) + SF(80, 80, x, x, x, x, x, x, x, ASTC_LDR_2D_6x6_U8sRGB) + SF(80, 80, x, x
Re: [Mesa-dev] [PATCH] i965/chv|skl: Apply sampler bypass w/a
Nice find. What do you think about putting this in a function to reduce the code duplication? - Nanley On Wed, Jul 1, 2015 at 6:14 PM, Ben Widawsky wrote: > On Wed, Jul 01, 2015 at 04:03:53PM -0700, Ben Widawsky wrote: >> Certain compressed formats require this setting. The docs don't go into much >> detail as to why it's needed exactly. >> >> This fixes 0 piglit failures with a GBM gpu piglit run. > > I just ran this again in piglit since Chris asked me to clarify. There are > also > no regressions (http://otc-mesa-ci.jf.intel.com/job/Leeroy/124112/) - ie. no > changes. > > (It looks like BSW was removed from jenkins). > > [snip] > > > ___ > mesa-dev mailing list > mesa-dev@lists.freedesktop.org > http://lists.freedesktop.org/mailman/listinfo/mesa-dev ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [RFC 02/21] mesa/extensions: Remove array sentinel
From: Nanley Chery Simplify future updates to the extension struct array by removing the sentinel. Signed-off-by: Nanley Chery --- src/mesa/main/extensions.c | 43 +-- 1 file changed, 25 insertions(+), 18 deletions(-) diff --git a/src/mesa/main/extensions.c b/src/mesa/main/extensions.c index b2c88c3..389bbb0 100644 --- a/src/mesa/main/extensions.c +++ b/src/mesa/main/extensions.c @@ -405,8 +405,6 @@ static const struct extension extension_table[] = { { "GL_SGIS_texture_edge_clamp", o(dummy_true), GLL,1997 }, { "GL_SGIS_texture_lod",o(dummy_true), GLL,1997 }, { "GL_SUN_multi_draw_arrays", o(dummy_true), GLL,1999 }, - - { 0, 0, 0, 0 }, }; @@ -421,14 +419,14 @@ static const struct extension extension_table[] = { static size_t name_to_offset(const char* name) { - const struct extension *i; + unsigned i; if (name == 0) return 0; - for (i = extension_table; i->name != 0; ++i) { - if (strcmp(name, i->name) == 0) -return i->offset; + for (i = 0; i < ARRAY_SIZE(extension_table); ++i) { + if (strcmp(name, extension_table[i].name) == 0) +return extension_table[i].offset; } return 0; @@ -441,15 +439,16 @@ name_to_offset(const char* name) static void override_extensions_in_context(struct gl_context *ctx) { - const struct extension *i; + unsigned i; const GLboolean *enables = (GLboolean*) &_mesa_extension_override_enables; const GLboolean *disables = (GLboolean*) &_mesa_extension_override_disables; GLboolean *ctx_ext = (GLboolean*)&ctx->Extensions; - for (i = extension_table; i->name != 0; ++i) { - size_t offset = i->offset; + for (i = 0; i < ARRAY_SIZE(extension_table); ++i) { + size_t offset = extension_table[i].offset; + assert(!enables[offset] || !disables[offset]); if (enables[offset]) { ctx_ext[offset] = 1; @@ -773,7 +772,7 @@ _mesa_make_extension_string(struct gl_context *ctx) /* String of extra extensions. */ char *extra_extensions = get_extension_override(ctx); GLboolean *base = (GLboolean *) &ctx->Extensions; - const struct extension *i; + unsigned k; unsigned j; unsigned maxYear = ~0; unsigned api_set = (1 << ctx->API); @@ -794,7 +793,9 @@ _mesa_make_extension_string(struct gl_context *ctx) /* Compute length of the extension string. */ count = 0; - for (i = extension_table; i->name != 0; ++i) { + for (k = 0; k < ARRAY_SIZE(extension_table); ++k) { + const struct extension *i = extension_table + k; + if (base[i->offset] && i->year <= maxYear && (i->api_set & api_set)) { @@ -824,11 +825,13 @@ _mesa_make_extension_string(struct gl_context *ctx) * expect will fit into that buffer. */ j = 0; - for (i = extension_table; i->name != 0; ++i) { + for (k = 0; k < ARRAY_SIZE(extension_table); ++k) { + const struct extension *i = extension_table + k; + if (base[i->offset] && i->year <= maxYear && (i->api_set & api_set)) { - extension_indices[j++] = i - extension_table; + extension_indices[j++] = k; } } assert(j == count); @@ -837,7 +840,7 @@ _mesa_make_extension_string(struct gl_context *ctx) /* Build the extension string.*/ for (j = 0; j < count; ++j) { - i = &extension_table[extension_indices[j]]; + const struct extension *i = &extension_table[extension_indices[j]]; assert(base[i->offset] && (i->api_set & api_set)); strcat(exts, i->name); strcat(exts, " "); @@ -858,7 +861,7 @@ GLuint _mesa_get_extension_count(struct gl_context *ctx) { GLboolean *base; - const struct extension *i; + unsigned k; unsigned api_set = (1 << ctx->API); if (_mesa_is_gles3(ctx)) api_set |= ES3; @@ -870,7 +873,9 @@ _mesa_get_extension_count(struct gl_context *ctx) return ctx->Extensions.Count; base = (GLboolean *) &ctx->Extensions; - for (i = extension_table; i->name != 0; ++i) { + for (k = 0; k < ARRAY_SIZE(extension_table); ++k) { + const struct extension *i = extension_table + k; + if (base[i->offset] && (i->api_set & api_set)) { ctx->Extensions.Count++; } @@ -886,7 +891,7 @@ _mesa_get_enabled_extension(struct gl_context *ctx, GLuint index) { const GLboolean *base; size_t n; - const struct extension *i; + unsigned k; unsigned api_set = (1 << ctx->API); if (_mesa_is_gles3(ctx)) api_set |= ES3; @@ -895,7 +900,9 @@ _mesa_
[Mesa-dev] [RFC 04/21] mesa/extensions: Move entries entries to seperate file
From: Nanley Chery With this infrastructure set in place, we can now reuse the entries to generate useful code. Signed-off-by: Nanley Chery --- src/mesa/main/extensions.c | 321 +-- src/mesa/main/extensions_table.h | 320 ++ 2 files changed, 321 insertions(+), 320 deletions(-) create mode 100644 src/mesa/main/extensions_table.h diff --git a/src/mesa/main/extensions.c b/src/mesa/main/extensions.c index fb4d791..30f5b98 100644 --- a/src/mesa/main/extensions.c +++ b/src/mesa/main/extensions.c @@ -85,326 +85,7 @@ struct extension { static const struct extension extension_table[] = { #define EXT(name_str, driver_cap, api_flags, ) \ { .name = "GL_" #name_str, .offset = o(driver_cap), .api_set = api_flags, .year = }, -EXT(ARB_ES2_compatibility , ARB_ES2_compatibility , GL , 2009) -EXT(ARB_ES3_compatibility , ARB_ES3_compatibility , GL , 2012) -EXT(ARB_arrays_of_arrays, ARB_arrays_of_arrays , GL , 2012) -EXT(ARB_base_instance , ARB_base_instance , GL , 2011) -EXT(ARB_blend_func_extended , ARB_blend_func_extended , GL , 2009) -EXT(ARB_buffer_storage , ARB_buffer_storage , GL , 2013) -EXT(ARB_clear_buffer_object , dummy_true , GL , 2012) -EXT(ARB_clear_texture , ARB_clear_texture , GL , 2013) -EXT(ARB_clip_control, ARB_clip_control , GL , 2014) -EXT(ARB_color_buffer_float , ARB_color_buffer_float , GL , 2004) -EXT(ARB_compressed_texture_pixel_storage, dummy_true , GL , 2011) -EXT(ARB_compute_shader , ARB_compute_shader , GL , 2012) -EXT(ARB_conditional_render_inverted , ARB_conditional_render_inverted , GL , 2014) -EXT(ARB_copy_buffer , dummy_true , GL , 2008) -EXT(ARB_copy_image , ARB_copy_image , GL , 2012) -EXT(ARB_conservative_depth , ARB_conservative_depth , GL , 2011) -EXT(ARB_debug_output, dummy_true , GL , 2009) -EXT(ARB_depth_buffer_float , ARB_depth_buffer_float , GL , 2008) -EXT(ARB_depth_clamp , ARB_depth_clamp , GL , 2003) -EXT(ARB_depth_texture , ARB_depth_texture , GLL , 2001) -EXT(ARB_derivative_control , ARB_derivative_control , GL , 2014) -EXT(ARB_direct_state_access , dummy_true , GLC , 2014) -EXT(ARB_draw_buffers, dummy_true , GL , 2002) -EXT(ARB_draw_buffers_blend , ARB_draw_buffers_blend , GL , 2009) -EXT(ARB_draw_elements_base_vertex , ARB_draw_elements_base_vertex , GL , 2009) -EXT(ARB_draw_indirect , ARB_draw_indirect , GLC , 2010) -EXT(ARB_draw_instanced , ARB_draw_instanced , GL , 2008) -EXT(ARB_explicit_attrib_location, ARB_explicit_attrib_location , GL , 2009) -EXT(ARB_explicit_uniform_location , ARB_explicit_uniform_location , GL , 2012) -EXT(ARB_fragment_coord_conventions , ARB_fragment_coord_conventions , GL , 2009) -EXT(ARB_fragment_layer_viewport , ARB_fragment_layer_viewport , GLC , 2012) -EXT(ARB_fragment_program, ARB_fragment_program , GLL , 2002) -EXT(ARB_fragment_program_shadow , ARB_fragment_program_shadow , GLL , 2003) -EXT(ARB_fragment_shader , ARB_fragment_shader , GL , 2002) -EXT(ARB_framebuffer_no_attachments , ARB_framebuffer_no_attachments , GL , 2012) -EXT(ARB_framebuf
[Mesa-dev] [RFC 03/21] mesa/extensions: Wrap array entries in macros
From: Nanley Chery Now that we're using macros, remove the redundant text from each entry. Remove comments between the entries to make editing easier and separate the sections with blank lines. Structure the EXT macros in a way that helps reviewers verify that no meaning has been altered. Signed-off-by: Nanley Chery --- src/mesa/main/extensions.c | 645 +++-- 1 file changed, 323 insertions(+), 322 deletions(-) diff --git a/src/mesa/main/extensions.c b/src/mesa/main/extensions.c index 389bbb0..fb4d791 100644 --- a/src/mesa/main/extensions.c +++ b/src/mesa/main/extensions.c @@ -83,328 +83,329 @@ struct extension { * \brief Table of supported OpenGL extensions for all API's. */ static const struct extension extension_table[] = { - /* ARB Extensions */ - { "GL_ARB_ES2_compatibility", o(ARB_ES2_compatibility), GL, 2009 }, - { "GL_ARB_ES3_compatibility", o(ARB_ES3_compatibility), GL, 2012 }, - { "GL_ARB_arrays_of_arrays",o(ARB_arrays_of_arrays), GL, 2012 }, - { "GL_ARB_base_instance", o(ARB_base_instance), GL, 2011 }, - { "GL_ARB_blend_func_extended", o(ARB_blend_func_extended), GL, 2009 }, - { "GL_ARB_buffer_storage", o(ARB_buffer_storage), GL, 2013 }, - { "GL_ARB_clear_buffer_object", o(dummy_true), GL, 2012 }, - { "GL_ARB_clear_texture", o(ARB_clear_texture), GL, 2013 }, - { "GL_ARB_clip_control",o(ARB_clip_control), GL, 2014 }, - { "GL_ARB_color_buffer_float", o(ARB_color_buffer_float), GL, 2004 }, - { "GL_ARB_compressed_texture_pixel_storage",o(dummy_true), GL, 2011 }, - { "GL_ARB_compute_shader", o(ARB_compute_shader), GL, 2012 }, - { "GL_ARB_conditional_render_inverted", o(ARB_conditional_render_inverted), GL, 2014 }, - { "GL_ARB_copy_buffer", o(dummy_true), GL, 2008 }, - { "GL_ARB_copy_image", o(ARB_copy_image), GL, 2012 }, - { "GL_ARB_conservative_depth", o(ARB_conservative_depth), GL, 2011 }, - { "GL_ARB_debug_output",o(dummy_true), GL, 2009 }, - { "GL_ARB_depth_buffer_float", o(ARB_depth_buffer_float), GL, 2008 }, - { "GL_ARB_depth_clamp", o(ARB_depth_clamp), GL, 2003 }, - { "GL_ARB_depth_texture", o(ARB_depth_texture), GLL,2001 }, - { "GL_ARB_derivative_control", o(ARB_derivative_control), GL, 2014 }, - { "GL_ARB_direct_state_access", o(dummy_true), GLC,2014 }, - { "GL_ARB_draw_buffers",o(dummy_true), GL, 2002 }, - { "GL_ARB_draw_buffers_blend", o(ARB_draw_buffers_blend), GL, 2009 }, - { "GL_ARB_draw_elements_base_vertex", o(ARB_draw_elements_base_vertex), GL, 2009 }, - { "GL_ARB_draw_indirect", o(ARB_draw_indirect), GLC,2010 }, - { "GL_ARB_draw_instanced", o(ARB_draw_instanced), GL, 2008 }, - { "GL_ARB_explicit_attrib_location", o(ARB_explicit_attrib_location),GL, 2009 }, - { "GL_ARB_explicit_uniform_location", o(ARB_explicit_uniform_location), GL, 2012 }, - { "GL_ARB_fragment_coord_conventions", o(ARB_fragment_coord_conventions), GL, 2009 }, - { "GL_ARB_fragment_layer_viewport", o(ARB_fragment_layer_viewport), GLC,2012 }, - { "GL_ARB_fragment_program",o(ARB_fragment_program),
[Mesa-dev] [RFC 01/21] mesa/texcompress: Restrict FXT1 format to desktop GL subset
From: Nanley Chery In agreement with the extension spec and commit dd0eb004874645135b9aaac3ebbd0aaf274079ea, filter FXT1 formats to the desktop GL profiles. Now we no longer advertise such formats as supported in an ES context and then throw an INVALID_ENUM error when the client tries to use such formats with CompressedTexImage2D. Fixes the following 26 dEQP tests: * dEQP-GLES2.functional.negative_api.texture.compressedteximage2d_invalid_border * dEQP-GLES2.functional.negative_api.texture.compressedteximage2d_invalid_border_cube_neg_x * dEQP-GLES2.functional.negative_api.texture.compressedteximage2d_invalid_border_cube_neg_y * dEQP-GLES2.functional.negative_api.texture.compressedteximage2d_invalid_border_cube_neg_z * dEQP-GLES2.functional.negative_api.texture.compressedteximage2d_invalid_border_cube_pos_x * dEQP-GLES2.functional.negative_api.texture.compressedteximage2d_invalid_border_cube_pos_y * dEQP-GLES2.functional.negative_api.texture.compressedteximage2d_invalid_border_cube_pos_z * dEQP-GLES2.functional.negative_api.texture.compressedteximage2d_invalid_size * dEQP-GLES2.functional.negative_api.texture.compressedteximage2d_level_max_cube_pos * dEQP-GLES2.functional.negative_api.texture.compressedteximage2d_level_max_tex2d * dEQP-GLES2.functional.negative_api.texture.compressedteximage2d_neg_level_cube * dEQP-GLES2.functional.negative_api.texture.compressedteximage2d_neg_level_tex2d * dEQP-GLES2.functional.negative_api.texture.compressedteximage2d_neg_width_height_cube_neg_x * dEQP-GLES2.functional.negative_api.texture.compressedteximage2d_neg_width_height_cube_neg_y * dEQP-GLES2.functional.negative_api.texture.compressedteximage2d_neg_width_height_cube_neg_z * dEQP-GLES2.functional.negative_api.texture.compressedteximage2d_neg_width_height_cube_pos_x * dEQP-GLES2.functional.negative_api.texture.compressedteximage2d_neg_width_height_cube_pos_y * dEQP-GLES2.functional.negative_api.texture.compressedteximage2d_neg_width_height_cube_pos_z * dEQP-GLES2.functional.negative_api.texture.compressedteximage2d_neg_width_height_tex2d * dEQP-GLES2.functional.negative_api.texture.compressedteximage2d_width_height_max_cube_neg_x * dEQP-GLES2.functional.negative_api.texture.compressedteximage2d_width_height_max_cube_neg_y * dEQP-GLES2.functional.negative_api.texture.compressedteximage2d_width_height_max_cube_neg_z * dEQP-GLES2.functional.negative_api.texture.compressedteximage2d_width_height_max_cube_pos_x * dEQP-GLES2.functional.negative_api.texture.compressedteximage2d_width_height_max_cube_pos_y * dEQP-GLES2.functional.negative_api.texture.compressedteximage2d_width_height_max_cube_pos_z * dEQP-GLES2.functional.negative_api.texture.compressedteximage2d_width_height_max_tex2d Cc: Ian Romanick Cc: Mark Janes Cc: "11.0" Signed-off-by: Nanley Chery --- src/mesa/main/texcompress.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/mesa/main/texcompress.c b/src/mesa/main/texcompress.c index feaf061..1615f4f 100644 --- a/src/mesa/main/texcompress.c +++ b/src/mesa/main/texcompress.c @@ -286,7 +286,9 @@ GLuint _mesa_get_compressed_formats(struct gl_context *ctx, GLint *formats) { GLuint n = 0; - if (ctx->Extensions.TDFX_texture_compression_FXT1) { + if (ctx->Extensions.TDFX_texture_compression_FXT1 && + (ctx->API == API_OPENGL_CORE || + (ctx->API == API_OPENGL_COMPAT && ctx->Version > 10))) { if (formats) { formats[n++] = GL_COMPRESSED_RGB_FXT1_3DFX; formats[n++] = GL_COMPRESSED_RGBA_FXT1_3DFX; -- 2.6.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [RFC 07/21] mesa/extensions: Use _mesa_extension_supported()
From: Nanley Chery Replace open-coded checks for extension support with _mesa_extension_supported(). Signed-off-by: Nanley Chery --- src/mesa/main/extensions.c | 54 src/mesa/main/extensions_table.h | 6 ++--- 2 files changed, 14 insertions(+), 46 deletions(-) diff --git a/src/mesa/main/extensions.c b/src/mesa/main/extensions.c index 7137bc9..5d2eb1d 100644 --- a/src/mesa/main/extensions.c +++ b/src/mesa/main/extensions.c @@ -49,8 +49,6 @@ enum { GL = (1 << API_OPENGL_COMPAT) | (1 << API_OPENGL_CORE), ES1 = 1 << API_OPENGLES, ES2 = 1 << API_OPENGLES2, - ES3 = 1 << (API_OPENGL_LAST + 1), - ES31 = 1 << (API_OPENGL_LAST + 2), }; /** @@ -481,15 +479,9 @@ _mesa_make_extension_string(struct gl_context *ctx) extension_index *extension_indices; /* String of extra extensions. */ char *extra_extensions = get_extension_override(ctx); - GLboolean *base = (GLboolean *) &ctx->Extensions; unsigned k; unsigned j; unsigned maxYear = ~0; - unsigned api_set = (1 << ctx->API); - if (_mesa_is_gles3(ctx)) - api_set |= ES3; - if (_mesa_is_gles31(ctx)) - api_set |= ES31; /* Check if the MESA_EXTENSION_MAX_YEAR env var is set */ { @@ -506,9 +498,8 @@ _mesa_make_extension_string(struct gl_context *ctx) for (k = 0; k < ARRAY_SIZE(extension_table); ++k) { const struct extension *i = extension_table + k; - if (base[i->offset] && - i->year <= maxYear && - (i->api_set & api_set)) { + if (i->year <= maxYear && + _mesa_extension_supported(ctx, k)) { length += strlen(i->name) + 1; /* +1 for space */ ++count; } @@ -536,11 +527,8 @@ _mesa_make_extension_string(struct gl_context *ctx) */ j = 0; for (k = 0; k < ARRAY_SIZE(extension_table); ++k) { - const struct extension *i = extension_table + k; - - if (base[i->offset] && - i->year <= maxYear && - (i->api_set & api_set)) { + if (extension_table[k].year <= maxYear && + _mesa_extension_supported(ctx, k)) { extension_indices[j++] = k; } } @@ -551,7 +539,7 @@ _mesa_make_extension_string(struct gl_context *ctx) /* Build the extension string.*/ for (j = 0; j < count; ++j) { const struct extension *i = &extension_table[extension_indices[j]]; - assert(base[i->offset] && (i->api_set & api_set)); + assert(_mesa_extension_supported(ctx, extension_indices[j])); strcat(exts, i->name); strcat(exts, " "); } @@ -570,25 +558,15 @@ _mesa_make_extension_string(struct gl_context *ctx) GLuint _mesa_get_extension_count(struct gl_context *ctx) { - GLboolean *base; unsigned k; - unsigned api_set = (1 << ctx->API); - if (_mesa_is_gles3(ctx)) - api_set |= ES3; - if (_mesa_is_gles31(ctx)) - api_set |= ES31; /* only count once */ if (ctx->Extensions.Count != 0) return ctx->Extensions.Count; - base = (GLboolean *) &ctx->Extensions; for (k = 0; k < ARRAY_SIZE(extension_table); ++k) { - const struct extension *i = extension_table + k; - - if (base[i->offset] && (i->api_set & api_set)) { + if (_mesa_extension_supported(ctx, k)) ctx->Extensions.Count++; - } } return ctx->Extensions.Count; } @@ -599,23 +577,13 @@ _mesa_get_extension_count(struct gl_context *ctx) const GLubyte * _mesa_get_enabled_extension(struct gl_context *ctx, GLuint index) { - const GLboolean *base; - size_t n; - unsigned k; - unsigned api_set = (1 << ctx->API); - if (_mesa_is_gles3(ctx)) - api_set |= ES3; - if (_mesa_is_gles31(ctx)) - api_set |= ES31; - - base = (GLboolean*) &ctx->Extensions; - n = 0; - for (k = 0; k < ARRAY_SIZE(extension_table); ++k) { - const struct extension *i = extension_table + k; + size_t n = 0; + unsigned i; - if (base[i->offset] && (i->api_set & api_set)) { + for (i = 0; i < ARRAY_SIZE(extension_table); ++i) { + if (_mesa_extension_supported(ctx, i)) { if (n == index) -return (const GLubyte*) i->name; +return (const GLubyte*) extension_table[i].name; else ++n; } diff --git a/src/mesa/main/extensions_table.h b/src/mesa/main/extensions_table.h index 24a0908..fecb402 100644 --- a/src/mesa/main/extensions_table.h +++ b/src/mesa/main/extensions_table.h @@ -167,7 +167,7 @@ EXT(EXT_rescale_normal , dummy_true EXT(EXT_secondary_color , dummy_true , GLL, 0, 0, 0, 0, 1999) EXT(EXT_separate_shader_objects , dummy_true ,
[Mesa-dev] [RFC 00/21] Extensions Rework
From: Nanley Chery Summary: This series fixes 26 dEQP tests with prefix: dEQP-GLES2.functional.negative_api.texture.compressedteximage2d* and prevents similar bugs from occuring in the future. The bug fix that originated from using the helper functions (mentioned below) is split out for easy backporting to stable. Intro: Mesa tries to advertise an extension to a client application if the environment satifies the following 3 requirements: the driver capability flag is enabled in struct gl_extensions, the provided context's API matches the extension's spec requirement, and the provided context's version is within the range specified by the extension's spec. If an extension is advertised externally, Mesa's internal behavior is changed as a result. Problem: Although most extension advertisement requirements are statically defined in extensions.c (struct extension extension_table[]), checks for each of these requirements are open-coded throughout Mesa. Sometimes, only 1-2 of the requirements are checked. This can introduce bugs by leaking extension functionality into improper contexts. The version requirement for extensions exists in the extension table, but only with a coarse granularity (Compat, Core, ES{1,2,3,31}). If an extension requires Compat 3.3, but a Compat 3.0 context is provided, Mesa advertises the extension anyways. One extension this exact problem occurs with is ARB_ES3_compatibility. Solution: This series uses the extension table to generate query functions which check all 3 requirements to determine if an extension should be advertised. Using these helper functions eliminates the extension functionality leaks that arise from coding error and makes fixing leaks that arise from a misunderstanding of the extension spec as simple as changing entries in the extension table (see patches for examples). This series also modifies the extension table so that extensions can be advertised or hidden with the same granularity used to advertise our GL[ES] version (e.g., 21, 33, etc.). This series can be divided into four logical parts: 1 : Fix dEQP bugs. 2-8 : Enable specifying the required GL version needed to advertise an extension. 9-17: Create auto-generated query functions and use them to fix bugs. 18-21: Minor cleanups. This series is an RFC because this new way of advertising extensions is based on a more restrictive interpretation of extension specs than Mesa currently has (see paragraph two in the problem section). Since this would set a precedence for future patches to come, I'd like to make sure others believe this is the right way to go about this. Note: This series is rebased onto the following bug-fix patch: http://lists.freedesktop.org/archives/mesa-stable/2015-October/003248.html Nanley Chery (21): mesa/texcompress: Restrict FXT1 format to desktop GL subset mesa/extensions: Remove array sentinel mesa/extensions: Wrap array entries in macros mesa/extensions: Move entries entries to seperate file mesa/extensions: Add extension::version mesa/extensions: Create _mesa_extension_supported() mesa/extensions: Use _mesa_extension_supported() mesa/extensions: Replace extension::api_set with ::version mesa: Generate a helper function for each extension mesa: Remove equality check in helper functions mesa: In helpers, only check driver capability for meta mesa: Fix 3DFX_texture_compression_FXT1 funtionality leaks mesa: Fix EXT_texture_compression_s3tc functionality leaks mesa: Fix ASTC extension functionality leak into GLES 1 mesa: Fix EXT_texture_sRGB functionality leaks mesa: Fix ARB_texture_compression_bptc functionality leaks mesa: Fix ARB_ES3_compatibility functionality leaks mesa/extensions: Remove extra memsets on gl_extensions mesa: Replace gl_extensions::EXT_texture3D with ::dummy_true mesa: Remove gl_extensions::dummy mesa/extensions: Declare _mesa_init_extensions() static inline src/glsl/glsl_parser_extras.cpp | 2 +- src/glsl/standalone_scaffolding.cpp | 1 - src/mesa/drivers/common/meta.c | 11 + src/mesa/drivers/common/meta.h | 1 + src/mesa/main/context.h | 1 + src/mesa/main/enable.c | 4 +- src/mesa/main/extensions.c | 493 +--- src/mesa/main/extensions.h | 55 +++- src/mesa/main/extensions_table.h| 330 src/mesa/main/glformats.c | 30 ++- src/mesa/main/mtypes.h | 10 +- src/mesa/main/queryobj.c| 2 +- src/mesa/main/texcompress.c | 4 +- src/mesa/main/teximage.c| 8 +- src/mesa/main/textureview.c | 4 +- src/mesa/main/version.c | 1 + 16 files changed, 493 insertions(+), 464 deletions(-) create mode 100644 src/mesa/main/extensions_table.h -- 2.6.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.fr
[Mesa-dev] [RFC 05/21] mesa/extensions: Add extension::version
From: Nanley Chery Enable limiting advertised extension support by context version with finer granularity. GLuint is chosen over smaller datatypes because, when this field is eventually used, usage of this datatype provides the smallest .text size of the compiled library. Signed-off-by: Nanley Chery --- src/mesa/main/extensions.c | 15 +- src/mesa/main/extensions_table.h | 626 +++ 2 files changed, 326 insertions(+), 315 deletions(-) diff --git a/src/mesa/main/extensions.c b/src/mesa/main/extensions.c index 30f5b98..390e026 100644 --- a/src/mesa/main/extensions.c +++ b/src/mesa/main/extensions.c @@ -66,6 +66,11 @@ struct extension { /** Set of API's in which the extension exists, as a bitset. */ uint8_t api_set; + /** Minimum version the extension requires for the given API +* (see gl_api defined in mtypes.h) +*/ + GLuint version[API_OPENGL_LAST + 1]; + /** Year the extension was proposed or approved. Used to sort the * extension string chronologically. */ uint16_t year; @@ -83,8 +88,14 @@ struct extension { * \brief Table of supported OpenGL extensions for all API's. */ static const struct extension extension_table[] = { -#define EXT(name_str, driver_cap, api_flags, ) \ -{ .name = "GL_" #name_str, .offset = o(driver_cap), .api_set = api_flags, .year = }, +#define EXT(name_str, driver_cap, api_flags, gll_ver, glc_ver, gles_ver, gles2_ver, ) \ +{ .name = "GL_" #name_str, .offset = o(driver_cap), .api_set = api_flags, \ + .version = { \ +[API_OPENGL_COMPAT] = gll_ver, \ +[API_OPENGL_CORE] = glc_ver, \ +[API_OPENGLES] = gles_ver, \ +[API_OPENGLES2] = gles2_ver, \ + }, .year = }, #include "extensions_table.h" #undef EXT }; diff --git a/src/mesa/main/extensions_table.h b/src/mesa/main/extensions_table.h index 59f2224..24a0908 100644 --- a/src/mesa/main/extensions_table.h +++ b/src/mesa/main/extensions_table.h @@ -1,320 +1,320 @@ -EXT(ARB_ES2_compatibility , ARB_ES2_compatibility , GL , 2009) -EXT(ARB_ES3_compatibility , ARB_ES3_compatibility , GL , 2012) -EXT(ARB_arrays_of_arrays, ARB_arrays_of_arrays , GL , 2012) -EXT(ARB_base_instance , ARB_base_instance , GL , 2011) -EXT(ARB_blend_func_extended , ARB_blend_func_extended , GL , 2009) -EXT(ARB_buffer_storage , ARB_buffer_storage , GL , 2013) -EXT(ARB_clear_buffer_object , dummy_true , GL , 2012) -EXT(ARB_clear_texture , ARB_clear_texture , GL , 2013) -EXT(ARB_clip_control, ARB_clip_control , GL , 2014) -EXT(ARB_color_buffer_float , ARB_color_buffer_float , GL , 2004) -EXT(ARB_compressed_texture_pixel_storage, dummy_true , GL , 2011) -EXT(ARB_compute_shader , ARB_compute_shader , GL , 2012) -EXT(ARB_conditional_render_inverted , ARB_conditional_render_inverted , GL , 2014) -EXT(ARB_copy_buffer , dummy_true , GL , 2008) -EXT(ARB_copy_image , ARB_copy_image , GL , 2012) -EXT(ARB_conservative_depth , ARB_conservative_depth , GL , 2011) -EXT(ARB_debug_output, dummy_true , GL , 2009) -EXT(ARB_depth_buffer_float , ARB_depth_buffer_float , GL , 2008) -EXT(ARB_depth_clamp , ARB_depth_clamp , GL , 2003) -EXT(ARB_depth_texture , ARB_depth_texture , GLL , 2001) -EXT(ARB_derivative_control , ARB_derivative_control , GL , 2014) -EXT(ARB_direct_state_access , dummy_true , GLC , 2014) -EXT(ARB_draw_buffers, dummy_true , GL , 2002) -EXT(ARB_draw_buffers_blend , ARB_draw_buffers_blend , GL , 2009) -EXT(ARB_draw_elements_base_vertex , ARB_
[Mesa-dev] [RFC 06/21] mesa/extensions: Create _mesa_extension_supported()
From: Nanley Chery Create a function which determines if an extension is supported in the current context. Signed-off-by: Nanley Chery --- src/mesa/main/extensions.c | 17 + 1 file changed, 17 insertions(+) diff --git a/src/mesa/main/extensions.c b/src/mesa/main/extensions.c index 390e026..7137bc9 100644 --- a/src/mesa/main/extensions.c +++ b/src/mesa/main/extensions.c @@ -423,6 +423,23 @@ typedef unsigned short extension_index; /** + * Given an extension enum, return whether or not the extension is supported + * dependent on the following factors: + * There's driver support and the OpenGL/ES version is at least that + * specified in the extension_table. + */ +static inline bool +_mesa_extension_supported(const struct gl_context *ctx, extension_index ei) +{ + const bool *base = (bool *) &ctx->Extensions; + const struct extension *i = extension_table + ei; + const uint8_t api_set = 1 << ctx->API; + return (i->api_set & api_set) && + (ctx->Version >= i->version[ctx->API]) && + base[i->offset]; +} + +/** * Compare two entries of the extensions table. Sorts first by year, * then by name. * -- 2.6.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [RFC 17/21] mesa: Fix ARB_ES3_compatibility functionality leaks
From: Nanley Chery Stop leaks into GLES1/2 and pre-3.3 GL contexts in all uses. The extension spec lists OpenGL 3.3 as one of the requirements, so update the extension table accordingly. v2. Require 3.3 for GL legacy contexts as well (Chad). Signed-off-by: Nanley Chery --- src/mesa/main/enable.c | 4 ++-- src/mesa/main/extensions_table.h | 2 +- src/mesa/main/glformats.c| 2 +- src/mesa/main/queryobj.c | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/mesa/main/enable.c b/src/mesa/main/enable.c index 42f6799..ee95334 100644 --- a/src/mesa/main/enable.c +++ b/src/mesa/main/enable.c @@ -972,7 +972,7 @@ _mesa_set_enable(struct gl_context *ctx, GLenum cap, GLboolean state) break; case GL_PRIMITIVE_RESTART_FIXED_INDEX: -if (!_mesa_is_gles3(ctx) && !ctx->Extensions.ARB_ES3_compatibility) +if (!_mesa_is_gles3(ctx) && !_mesa_has_ARB_ES3_compatibility(ctx)) goto invalid_enum_error; if (ctx->Array.PrimitiveRestartFixedIndex != state) { FLUSH_VERTICES(ctx, _NEW_TRANSFORM); @@ -1582,7 +1582,7 @@ _mesa_IsEnabled( GLenum cap ) return ctx->Array.PrimitiveRestart; case GL_PRIMITIVE_RESTART_FIXED_INDEX: -if (!_mesa_is_gles3(ctx) && !ctx->Extensions.ARB_ES3_compatibility) { +if (!_mesa_is_gles3(ctx) && !_mesa_has_ARB_ES3_compatibility(ctx)) { goto invalid_enum_error; } return ctx->Array.PrimitiveRestartFixedIndex; diff --git a/src/mesa/main/extensions_table.h b/src/mesa/main/extensions_table.h index 62e0804..760fbe9 100644 --- a/src/mesa/main/extensions_table.h +++ b/src/mesa/main/extensions_table.h @@ -4,7 +4,7 @@ #define ES2 1u #define x ~0u EXT(ARB_ES2_compatibility , ARB_ES2_compatibility , GLL, GLC, x , x , 2009) -EXT(ARB_ES3_compatibility , ARB_ES3_compatibility , GLL, GLC, x , x , 2012) +EXT(ARB_ES3_compatibility , ARB_ES3_compatibility , 33, 33, x , x , 2012) EXT(ARB_arrays_of_arrays, ARB_arrays_of_arrays , GLL, GLC, x , x , 2012) EXT(ARB_base_instance , ARB_base_instance , GLL, GLC, x , x , 2011) EXT(ARB_blend_func_extended , ARB_blend_func_extended , GLL, GLC, x , x , 2009) diff --git a/src/mesa/main/glformats.c b/src/mesa/main/glformats.c index 542dcfc..6b602d8 100644 --- a/src/mesa/main/glformats.c +++ b/src/mesa/main/glformats.c @@ -1325,7 +1325,7 @@ _mesa_is_compressed_format(const struct gl_context *ctx, GLenum format) return _mesa_is_gles(ctx) && ctx->Extensions.OES_compressed_ETC1_RGB8_texture; case MESA_FORMAT_LAYOUT_ETC2: - return _mesa_is_gles3(ctx) || ctx->Extensions.ARB_ES3_compatibility; + return _mesa_is_gles3(ctx) || _mesa_has_ARB_ES3_compatibility(ctx); case MESA_FORMAT_LAYOUT_BPTC: return _mesa_has_ARB_texture_compression_bptc(ctx); case MESA_FORMAT_LAYOUT_ASTC: diff --git a/src/mesa/main/queryobj.c b/src/mesa/main/queryobj.c index 9836685..48fd571 100644 --- a/src/mesa/main/queryobj.c +++ b/src/mesa/main/queryobj.c @@ -176,7 +176,7 @@ get_query_binding_point(struct gl_context *ctx, GLenum target, GLuint index) else return NULL; case GL_ANY_SAMPLES_PASSED_CONSERVATIVE: - if (ctx->Extensions.ARB_ES3_compatibility + if (_mesa_has_ARB_ES3_compatibility(ctx) || (ctx->API == API_OPENGLES2 && ctx->Version >= 30)) return &ctx->Query.CurrentOcclusionObject; else -- 2.6.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [RFC 12/21] mesa: Fix 3DFX_texture_compression_FXT1 funtionality leaks
From: Nanley Chery Stop leaks into the following contexts: * GLES in _mesa_get_compressed_formats(). * GL legacy 1.0 in all uses. The extension spec lists OpenGL 1.1 as required, so update the extension table accordingly. Signed-off-by: Nanley Chery --- src/mesa/main/extensions_table.h | 2 +- src/mesa/main/glformats.c| 3 +-- src/mesa/main/texcompress.c | 4 +--- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/src/mesa/main/extensions_table.h b/src/mesa/main/extensions_table.h index b18f4e6..7fe4546 100644 --- a/src/mesa/main/extensions_table.h +++ b/src/mesa/main/extensions_table.h @@ -266,7 +266,7 @@ EXT(KHR_texture_compression_astc_hdr, KHR_texture_compression_astc_hdr EXT(KHR_texture_compression_astc_ldr, KHR_texture_compression_astc_ldr , GLL, GLC, x , ES2, 2012) -EXT(3DFX_texture_compression_FXT1 , TDFX_texture_compression_FXT1 , GLL, GLC, x , x , 1999) +EXT(3DFX_texture_compression_FXT1 , TDFX_texture_compression_FXT1 , 11, GLC, x , x , 1999) EXT(AMD_conservative_depth , ARB_conservative_depth , GLL, GLC, x , x , 2009) EXT(AMD_draw_buffers_blend , ARB_draw_buffers_blend , GLL, GLC, x , x , 2009) EXT(AMD_performance_monitor , AMD_performance_monitor , GLL, GLC, x , x , 2007) diff --git a/src/mesa/main/glformats.c b/src/mesa/main/glformats.c index 2ed42ea..3ad9e3c 100644 --- a/src/mesa/main/glformats.c +++ b/src/mesa/main/glformats.c @@ -1315,8 +1315,7 @@ _mesa_is_compressed_format(const struct gl_context *ctx, GLenum format) && ctx->Extensions.EXT_texture_compression_s3tc; } case MESA_FORMAT_LAYOUT_FXT1: - return _mesa_is_desktop_gl(ctx) - && ctx->Extensions.TDFX_texture_compression_FXT1; + return _mesa_has_3DFX_texture_compression_FXT1(ctx); case MESA_FORMAT_LAYOUT_RGTC: return _mesa_is_desktop_gl(ctx) && ctx->Extensions.ARB_texture_compression_rgtc; diff --git a/src/mesa/main/texcompress.c b/src/mesa/main/texcompress.c index 1615f4f..8ea7fe9 100644 --- a/src/mesa/main/texcompress.c +++ b/src/mesa/main/texcompress.c @@ -286,9 +286,7 @@ GLuint _mesa_get_compressed_formats(struct gl_context *ctx, GLint *formats) { GLuint n = 0; - if (ctx->Extensions.TDFX_texture_compression_FXT1 && - (ctx->API == API_OPENGL_CORE || - (ctx->API == API_OPENGL_COMPAT && ctx->Version > 10))) { + if (_mesa_has_3DFX_texture_compression_FXT1(ctx)) { if (formats) { formats[n++] = GL_COMPRESSED_RGB_FXT1_3DFX; formats[n++] = GL_COMPRESSED_RGBA_FXT1_3DFX; -- 2.6.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [RFC 13/21] mesa: Fix EXT_texture_compression_s3tc functionality leaks
From: Nanley Chery Stop leaks into the following contexts: * GLES 1 in _mesa_get_compressed_formats() and lookup_view_class(). * GL legacy 1.0 in all uses. The extension spec lists 1.1 as required for OpenGL and Rev 1.6 of the extension adds GLES 2.0.25 and 3.0.2 dependencies, so update the extension table accordingly. Signed-off-by: Nanley Chery --- src/mesa/main/extensions_table.h | 2 +- src/mesa/main/glformats.c| 2 +- src/mesa/main/texcompress.c | 2 +- src/mesa/main/textureview.c | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/mesa/main/extensions_table.h b/src/mesa/main/extensions_table.h index 7fe4546..3729d22 100644 --- a/src/mesa/main/extensions_table.h +++ b/src/mesa/main/extensions_table.h @@ -184,7 +184,7 @@ EXT(ANGLE_texture_compression_dxt3 , ANGLE_texture_compression_dxt EXT(ANGLE_texture_compression_dxt5 , ANGLE_texture_compression_dxt , GLL, GLC, ES1, ES2, 2011) EXT(EXT_texture_compression_latc, EXT_texture_compression_latc , GLL, x , x , x , 2006) EXT(EXT_texture_compression_rgtc, ARB_texture_compression_rgtc , GLL, GLC, x , x , 2004) -EXT(EXT_texture_compression_s3tc, EXT_texture_compression_s3tc , GLL, GLC, x , x , 2000) +EXT(EXT_texture_compression_s3tc, EXT_texture_compression_s3tc , 11, GLC, x , ES2, 2000) EXT(EXT_texture_cube_map, ARB_texture_cube_map , GLL, x , x , x , 2001) EXT(EXT_texture_edge_clamp , dummy_true , GLL, x , x , x , 1997) EXT(EXT_texture_env_add , dummy_true , GLL, x , x , x , 1999) diff --git a/src/mesa/main/glformats.c b/src/mesa/main/glformats.c index 3ad9e3c..5610de2 100644 --- a/src/mesa/main/glformats.c +++ b/src/mesa/main/glformats.c @@ -1312,7 +1312,7 @@ _mesa_is_compressed_format(const struct gl_context *ctx, GLenum format) } else { return _mesa_is_desktop_gl(ctx) && ctx->Extensions.EXT_texture_sRGB -&& ctx->Extensions.EXT_texture_compression_s3tc; +&& _mesa_has_EXT_texture_compression_s3tc(ctx); } case MESA_FORMAT_LAYOUT_FXT1: return _mesa_has_3DFX_texture_compression_FXT1(ctx); diff --git a/src/mesa/main/texcompress.c b/src/mesa/main/texcompress.c index 8ea7fe9..7a6b538 100644 --- a/src/mesa/main/texcompress.c +++ b/src/mesa/main/texcompress.c @@ -296,7 +296,7 @@ _mesa_get_compressed_formats(struct gl_context *ctx, GLint *formats) } } - if (ctx->Extensions.EXT_texture_compression_s3tc) { + if (_mesa_has_EXT_texture_compression_s3tc(ctx)) { if (formats) { formats[n++] = GL_COMPRESSED_RGB_S3TC_DXT1_EXT; formats[n++] = GL_COMPRESSED_RGBA_S3TC_DXT3_EXT; diff --git a/src/mesa/main/textureview.c b/src/mesa/main/textureview.c index 04b7d73..1ac46d6 100644 --- a/src/mesa/main/textureview.c +++ b/src/mesa/main/textureview.c @@ -176,7 +176,7 @@ lookup_view_class(const struct gl_context *ctx, GLenum internalformat) return compatible_internal_formats[i].view_class; } - if (ctx->Extensions.EXT_texture_compression_s3tc && + if (_mesa_has_EXT_texture_compression_s3tc(ctx) && ctx->Extensions.EXT_texture_sRGB) { for (i = 0; i < ARRAY_SIZE(s3tc_compatible_internal_formats); i++) { if (s3tc_compatible_internal_formats[i].internal_format -- 2.6.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [RFC 14/21] mesa: Fix ASTC extension functionality leak into GLES 1
From: Nanley Chery Stop a leak of ASTC functionality into GLES 1 contexts. Signed-off-by: Nanley Chery --- src/mesa/main/glformats.c | 4 ++-- src/mesa/main/teximage.c | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/mesa/main/glformats.c b/src/mesa/main/glformats.c index 5610de2..f37b5da 100644 --- a/src/mesa/main/glformats.c +++ b/src/mesa/main/glformats.c @@ -1331,7 +1331,7 @@ _mesa_is_compressed_format(const struct gl_context *ctx, GLenum format) return _mesa_is_desktop_gl(ctx) && ctx->Extensions.ARB_texture_compression_bptc; case MESA_FORMAT_LAYOUT_ASTC: - return ctx->Extensions.KHR_texture_compression_astc_ldr; + return _mesa_has_KHR_texture_compression_astc_ldr(ctx); default: return GL_FALSE; } @@ -2281,7 +2281,7 @@ _mesa_base_tex_format(const struct gl_context *ctx, GLint internalFormat) return base_compressed; } - if (ctx->Extensions.KHR_texture_compression_astc_ldr && + if (_mesa_has_KHR_texture_compression_astc_ldr(ctx) && _mesa_is_astc_format(internalFormat)) return GL_RGBA; diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c index d9453e3..c14f941 100644 --- a/src/mesa/main/teximage.c +++ b/src/mesa/main/teximage.c @@ -1374,7 +1374,7 @@ _mesa_target_can_be_compressed(const struct gl_context *ctx, GLenum target, * TEXTURE_CUBE_MAP_ARRAY and the format is not ASTC. */ if (target_can_be_compresed && - ctx->Extensions.KHR_texture_compression_astc_ldr && + _mesa_has_KHR_texture_compression_astc_ldr(ctx) && layout != MESA_FORMAT_LAYOUT_ASTC) return write_error(error, GL_INVALID_OPERATION); @@ -1391,7 +1391,7 @@ _mesa_target_can_be_compressed(const struct gl_context *ctx, GLenum target, break; case MESA_FORMAT_LAYOUT_ASTC: target_can_be_compresed = - ctx->Extensions.KHR_texture_compression_astc_hdr; + _mesa_has_KHR_texture_compression_astc_hdr(ctx); /* Throw an INVALID_OPERATION error if the target is TEXTURE_3D and * and the hdr extension is not supported. @@ -1405,7 +1405,7 @@ _mesa_target_can_be_compressed(const struct gl_context *ctx, GLenum target, * the format is not ASTC. * See comment in switch case GL_TEXTURE_CUBE_MAP_ARRAY for more info. */ - if (ctx->Extensions.KHR_texture_compression_astc_ldr) + if (_mesa_has_KHR_texture_compression_astc_ldr(ctx)) return write_error(error, GL_INVALID_OPERATION); break; } -- 2.6.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [RFC 10/21] mesa: Remove equality check in helper functions
From: Nanley Chery Since the version numbers being compared are integral and we don't ever expect gl_context::Version to be equal to 0, subtract 1 from the rhs of the equation and perform the optimization of removing the equality check. Signed-off-by: Nanley Chery --- src/mesa/main/extensions.c | 10 +- src/mesa/main/extensions.h | 2 +- src/mesa/main/extensions_table.h | 10 +- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/mesa/main/extensions.c b/src/mesa/main/extensions.c index 136313f..365e7ed 100644 --- a/src/mesa/main/extensions.c +++ b/src/mesa/main/extensions.c @@ -57,10 +57,10 @@ const struct extension extension_table[] = { #define EXT(name_str, driver_cap, gll_ver, glc_ver, gles_ver, gles2_ver, ) \ { .name = "GL_" #name_str, .offset = o(driver_cap), \ .version = { \ -[API_OPENGL_COMPAT] = gll_ver, \ -[API_OPENGL_CORE] = glc_ver, \ -[API_OPENGLES] = gles_ver, \ -[API_OPENGLES2] = gles2_ver, \ +[API_OPENGL_COMPAT] = gll_ver - 1, \ +[API_OPENGL_CORE] = glc_ver - 1, \ +[API_OPENGLES] = gles_ver - 1, \ +[API_OPENGLES2] = gles2_ver - 1, \ }, .year = }, #include "extensions_table.h" #undef EXT @@ -399,7 +399,7 @@ _mesa_extension_supported(const struct gl_context *ctx, extension_index ei) { const bool *base = (bool *) &ctx->Extensions; const struct extension *i = extension_table + ei; - return (ctx->Version >= i->version[ctx->API]) && base[i->offset]; + return (ctx->Version > i->version[ctx->API]) && base[i->offset]; } /** diff --git a/src/mesa/main/extensions.h b/src/mesa/main/extensions.h index 24cc04d..50456e98 100644 --- a/src/mesa/main/extensions.h +++ b/src/mesa/main/extensions.h @@ -88,7 +88,7 @@ enum { /** Checks if the context suports a user-facing extension */ #define EXT(name_str, driver_cap, ...) \ static inline bool _mesa_has_##name_str(const struct gl_context *ctx) { \ - return ctx->Extensions.driver_cap && (ctx->Version >= \ + return ctx->Extensions.driver_cap && (ctx->Version > \ extension_table[MESA_EXTENSION_##name_str].version[ctx->API]); \ } #include "extensions_table.h" diff --git a/src/mesa/main/extensions_table.h b/src/mesa/main/extensions_table.h index ce48b51..b18f4e6 100644 --- a/src/mesa/main/extensions_table.h +++ b/src/mesa/main/extensions_table.h @@ -1,8 +1,8 @@ -#define GLL 0 -#define GLC 0 -#define ES1 0 -#define ES2 0 -#define x ~0 +#define GLL 1u +#define GLC 1u +#define ES1 1u +#define ES2 1u +#define x ~0u EXT(ARB_ES2_compatibility , ARB_ES2_compatibility , GLL, GLC, x , x , 2009) EXT(ARB_ES3_compatibility , ARB_ES3_compatibility , GLL, GLC, x , x , 2012) EXT(ARB_arrays_of_arrays, ARB_arrays_of_arrays , GLL, GLC, x , x , 2012) -- 2.6.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [RFC 08/21] mesa/extensions: Replace extension::api_set with ::version
From: Nanley Chery The api_set field has no users outside of _mesa_extension_supported(). Remove it and allow the version field to take its place. The brunt of the transformation was performed with the following vim commands: s/\(GL [^,]\+\),\s*\d*,\s*\d*\(,\s*\d*\)\(,\s*\d*\)/\1, GLL, GLC\2\3/g s/\(GLL [^,]\+\)\,\s*\d*/\1, GLL/g s/\(GLC [^,]\+\)\(,\s*\d*\),\s*\d*\(,\s*\d*\)\(,\s*\d*\)/\1\2, GLC\3\4/g s/\( ES1[^,]*\)\(,\s*\(\w\|\d\)\+\)\(,\s*\(\w\|\d\)\+\),\s*\d*/\1\2\4, ES1/g s/\( ES2[^,]*\)\(,\s*\(\w\|\d\)\+\)\(,\s*\(\w\|\d\)\+\)\(,\s*\(\w\|\d\)\+\),\s*\d*/\1\2\4\6, ES2/g Signed-off-by: Nanley Chery --- src/mesa/main/extensions.c | 21 +- src/mesa/main/extensions_table.h | 636 --- 2 files changed, 326 insertions(+), 331 deletions(-) diff --git a/src/mesa/main/extensions.c b/src/mesa/main/extensions.c index 5d2eb1d..9451085 100644 --- a/src/mesa/main/extensions.c +++ b/src/mesa/main/extensions.c @@ -42,15 +42,6 @@ struct gl_extensions _mesa_extension_override_disables; static char *extra_extensions = NULL; static char *cant_disable_extensions = NULL; -enum { - DISABLE = 0, - GLL = 1 << API_OPENGL_COMPAT, /* GL Legacy / Compatibility */ - GLC = 1 << API_OPENGL_CORE, /* GL Core */ - GL = (1 << API_OPENGL_COMPAT) | (1 << API_OPENGL_CORE), - ES1 = 1 << API_OPENGLES, - ES2 = 1 << API_OPENGLES2, -}; - /** * \brief An element of the \c extension_table. */ @@ -61,9 +52,6 @@ struct extension { /** Offset (in bytes) of the corresponding member in struct gl_extensions. */ size_t offset; - /** Set of API's in which the extension exists, as a bitset. */ - uint8_t api_set; - /** Minimum version the extension requires for the given API * (see gl_api defined in mtypes.h) */ @@ -86,8 +74,8 @@ struct extension { * \brief Table of supported OpenGL extensions for all API's. */ static const struct extension extension_table[] = { -#define EXT(name_str, driver_cap, api_flags, gll_ver, glc_ver, gles_ver, gles2_ver, ) \ -{ .name = "GL_" #name_str, .offset = o(driver_cap), .api_set = api_flags, \ +#define EXT(name_str, driver_cap, gll_ver, glc_ver, gles_ver, gles2_ver, ) \ +{ .name = "GL_" #name_str, .offset = o(driver_cap), \ .version = { \ [API_OPENGL_COMPAT] = gll_ver, \ [API_OPENGL_CORE] = glc_ver, \ @@ -431,10 +419,7 @@ _mesa_extension_supported(const struct gl_context *ctx, extension_index ei) { const bool *base = (bool *) &ctx->Extensions; const struct extension *i = extension_table + ei; - const uint8_t api_set = 1 << ctx->API; - return (i->api_set & api_set) && - (ctx->Version >= i->version[ctx->API]) && - base[i->offset]; + return (ctx->Version >= i->version[ctx->API]) && base[i->offset]; } /** diff --git a/src/mesa/main/extensions_table.h b/src/mesa/main/extensions_table.h index fecb402..ce48b51 100644 --- a/src/mesa/main/extensions_table.h +++ b/src/mesa/main/extensions_table.h @@ -1,320 +1,330 @@ -EXT(ARB_ES2_compatibility , ARB_ES2_compatibility , GL , 0, 0, 0, 0, 2009) -EXT(ARB_ES3_compatibility , ARB_ES3_compatibility , GL , 0, 0, 0, 0, 2012) -EXT(ARB_arrays_of_arrays, ARB_arrays_of_arrays , GL , 0, 0, 0, 0, 2012) -EXT(ARB_base_instance , ARB_base_instance , GL , 0, 0, 0, 0, 2011) -EXT(ARB_blend_func_extended , ARB_blend_func_extended , GL , 0, 0, 0, 0, 2009) -EXT(ARB_buffer_storage , ARB_buffer_storage , GL , 0, 0, 0, 0, 2013) -EXT(ARB_clear_buffer_object , dummy_true , GL , 0, 0, 0, 0, 2012) -EXT(ARB_clear_texture , ARB_clear_texture , GL , 0, 0, 0, 0, 2013) -EXT(ARB_clip_control, ARB_clip_control , GL , 0, 0, 0, 0, 2014) -EXT(ARB_color_buffer_float , ARB_color_buffer_float , GL , 0, 0, 0, 0, 2004) -EXT(ARB_compressed_texture_pixel_storage, dummy_true , GL , 0, 0, 0, 0, 2011) -EXT(ARB_compute_shader , ARB_compute_shader , GL , 0, 0, 0, 0, 2012) -EXT(ARB_conditional_render_inverted , ARB_conditional_render_inverted , GL , 0, 0, 0, 0, 2014) -EXT(ARB_copy_buffer , dummy_true , GL , 0, 0, 0,
[Mesa-dev] [RFC 11/21] mesa: In helpers, only check driver capability for meta
From: Nanley Chery Make constext API and version checks done by the helper functions pass unconditionally while meta is in progress. This transparently makes extension checks solely dependent on struct gl_extensions while in meta. Signed-off-by: Nanley Chery --- src/mesa/drivers/common/meta.c | 11 +++ src/mesa/drivers/common/meta.h | 1 + src/mesa/main/extensions.h | 2 +- src/mesa/main/mtypes.h | 6 ++ src/mesa/main/version.c| 1 + 5 files changed, 20 insertions(+), 1 deletion(-) diff --git a/src/mesa/drivers/common/meta.c b/src/mesa/drivers/common/meta.c index e27489d..0ffcd9c 100644 --- a/src/mesa/drivers/common/meta.c +++ b/src/mesa/drivers/common/meta.c @@ -449,6 +449,16 @@ _mesa_meta_begin(struct gl_context *ctx, GLbitfield state) save->API = ctx->API; ctx->API = API_OPENGL_COMPAT; + /* Mesa's extension helper functions use the current context's API to look up +* the version required by an extension as a step in determining whether or +* not it has been advertised. Since meta aims to only be restricted by the +* driver capability (and not by whether or not an extension has been +* advertised), set the helper functions' Version variable to a value that +* will make the checks on the context API and version unconditionally pass. +*/ + save->ExtensionsVersion = ctx->Extensions.Version; + ctx->Extensions.Version = ~0; + /* Pausing transform feedback needs to be done early, or else we won't be * able to change other state. */ @@ -1222,6 +1232,7 @@ _mesa_meta_end(struct gl_context *ctx) ctx->Meta->SaveStackDepth--; ctx->API = save->API; + ctx->Extensions.Version = save->ExtensionsVersion; } diff --git a/src/mesa/drivers/common/meta.h b/src/mesa/drivers/common/meta.h index 23fa209..4351242 100644 --- a/src/mesa/drivers/common/meta.h +++ b/src/mesa/drivers/common/meta.h @@ -72,6 +72,7 @@ struct save_state /* Always saved/restored with meta. */ gl_api API; + GLuint ExtensionsVersion; /** MESA_META_CLEAR (and others?) */ struct gl_query_object *CurrentOcclusionObject; diff --git a/src/mesa/main/extensions.h b/src/mesa/main/extensions.h index 50456e98..8f106aa 100644 --- a/src/mesa/main/extensions.h +++ b/src/mesa/main/extensions.h @@ -88,7 +88,7 @@ enum { /** Checks if the context suports a user-facing extension */ #define EXT(name_str, driver_cap, ...) \ static inline bool _mesa_has_##name_str(const struct gl_context *ctx) { \ - return ctx->Extensions.driver_cap && (ctx->Version > \ + return ctx->Extensions.driver_cap && (ctx->Extensions.Version > \ extension_table[MESA_EXTENSION_##name_str].version[ctx->API]); \ } #include "extensions_table.h" diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index f7118c1..a67c5c0 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -3824,6 +3824,12 @@ struct gl_extensions const GLubyte *String; /** Number of supported extensions */ GLuint Count; + /** +* The context version which extension helper functions compare against. +* By default, the value is equal to ctx->Version. This changes to ~0, +* while meta is in progress. +*/ + GLuint Version; }; diff --git a/src/mesa/main/version.c b/src/mesa/main/version.c index 5635a64..314b26d 100644 --- a/src/mesa/main/version.c +++ b/src/mesa/main/version.c @@ -524,6 +524,7 @@ _mesa_compute_version(struct gl_context *ctx) return; ctx->Version = _mesa_get_version(&ctx->Extensions, &ctx->Const, ctx->API); + ctx->Extensions.Version = ctx->Version; /* Make sure that the GLSL version lines up with the GL version. In some * cases it can be too high, e.g. if an extension is missing. -- 2.6.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [RFC 18/21] mesa/extensions: Remove extra memsets on gl_extensions
From: Nanley Chery Aside from those modified in this commit, all gl_extensions structs are zero-initialized by default. There is therefore no need to memset the structs to 0. Also, remove the open-coded memset in _mesa_init_extensions(). Signed-off-by: Nanley Chery --- src/mesa/main/extensions.c | 18 -- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/src/mesa/main/extensions.c b/src/mesa/main/extensions.c index 365e7ed..6cd2b27 100644 --- a/src/mesa/main/extensions.c +++ b/src/mesa/main/extensions.c @@ -37,8 +37,8 @@ #include "macros.h" #include "mtypes.h" -struct gl_extensions _mesa_extension_override_enables; -struct gl_extensions _mesa_extension_override_disables; +struct gl_extensions _mesa_extension_override_enables = {0}; +struct gl_extensions _mesa_extension_override_disables = {0}; static char *extra_extensions = NULL; static char *cant_disable_extensions = NULL; @@ -284,9 +284,6 @@ _mesa_one_time_init_extension_overrides(void) atexit(free_unknown_extensions_strings); - memset(&_mesa_extension_override_enables, 0, sizeof(struct gl_extensions)); - memset(&_mesa_extension_override_disables, 0, sizeof(struct gl_extensions)); - if (env_const == NULL) { return; } @@ -366,20 +363,13 @@ _mesa_one_time_init_extension_overrides(void) * \brief Initialize extension tables and enable default extensions. * * This should be called during context initialization. + * This function expects a zeroed gl_extensions struct. * Note: Sets gl_extensions.dummy_true to true. */ void _mesa_init_extensions(struct gl_extensions *extensions) { - GLboolean *base = (GLboolean *) extensions; - GLboolean *sentinel = base + o(extension_sentinel); - GLboolean *i; - - /* First, turn all extensions off. */ - for (i = base; i != sentinel; ++i) - *i = GL_FALSE; - - /* Then, selectively turn default extensions on. */ + /* Selectively turn default extensions on. */ extensions->dummy_true = GL_TRUE; extensions->EXT_texture3D = GL_TRUE; } -- 2.6.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [RFC 15/21] mesa: Fix EXT_texture_sRGB functionality leaks
From: Nanley Chery Stop leaks into the following contexts: * GLES in _mesa_base_tex_format() and lookup_view_class(). * Pre-1.1 GL legacy contexts in all uses. Stop allowing compressed sRGB formats as valid formats in GLES3 contexts. I realized this was happening when CTS failures occured after fixing the extension functionality leak with the helper function. The extension spec lists 1.1 as required for OpenGL, so update the extension table accordingly. Signed-off-by: Nanley Chery --- src/mesa/main/extensions_table.h | 2 +- src/mesa/main/glformats.c| 16 src/mesa/main/textureview.c | 2 +- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/src/mesa/main/extensions_table.h b/src/mesa/main/extensions_table.h index 3729d22..cf6eed7 100644 --- a/src/mesa/main/extensions_table.h +++ b/src/mesa/main/extensions_table.h @@ -202,7 +202,7 @@ EXT(EXT_texture , dummy_true EXT(EXT_texture_rectangle , NV_texture_rectangle , GLL, x , x , x , 2004) EXT(EXT_texture_shared_exponent , EXT_texture_shared_exponent , GLL, GLC, x , x , 2004) EXT(EXT_texture_snorm , EXT_texture_snorm , GLL, GLC, x , x , 2009) -EXT(EXT_texture_sRGB, EXT_texture_sRGB , GLL, GLC, x , x , 2004) +EXT(EXT_texture_sRGB, EXT_texture_sRGB , 11, GLC, x , x , 2004) EXT(EXT_texture_sRGB_decode , EXT_texture_sRGB_decode , GLL, GLC, x , x , 2006) EXT(EXT_texture_swizzle , EXT_texture_swizzle , GLL, GLC, x , x , 2008) EXT(EXT_texture_type_2_10_10_10_REV , dummy_true , x , x , x , ES2, 2008) diff --git a/src/mesa/main/glformats.c b/src/mesa/main/glformats.c index f37b5da..9134d7d 100644 --- a/src/mesa/main/glformats.c +++ b/src/mesa/main/glformats.c @@ -1310,8 +1310,7 @@ _mesa_is_compressed_format(const struct gl_context *ctx, GLenum format) */ return ctx->Extensions.ANGLE_texture_compression_dxt; } else { - return _mesa_is_desktop_gl(ctx) -&& ctx->Extensions.EXT_texture_sRGB + return _mesa_has_EXT_texture_sRGB(ctx) && _mesa_has_EXT_texture_compression_s3tc(ctx); } case MESA_FORMAT_LAYOUT_FXT1: @@ -2354,14 +2353,23 @@ _mesa_base_tex_format(const struct gl_context *ctx, GLint internalFormat) } } - if (ctx->Extensions.EXT_texture_sRGB) { + if (_mesa_has_EXT_texture_sRGB(ctx) || + _mesa_is_gles3(ctx)) { switch (internalFormat) { case GL_SRGB_EXT: case GL_SRGB8_EXT: - case GL_COMPRESSED_SRGB_EXT: return GL_RGB; case GL_SRGB_ALPHA_EXT: case GL_SRGB8_ALPHA8_EXT: + return GL_RGBA; + default: + ; /* fallthrough */ + } + } + if (_mesa_has_EXT_texture_sRGB(ctx)) { + switch (internalFormat) { + case GL_COMPRESSED_SRGB_EXT: + return GL_RGB; case GL_COMPRESSED_SRGB_ALPHA_EXT: return GL_RGBA; case GL_SLUMINANCE_ALPHA_EXT: diff --git a/src/mesa/main/textureview.c b/src/mesa/main/textureview.c index 1ac46d6..c5b0175 100644 --- a/src/mesa/main/textureview.c +++ b/src/mesa/main/textureview.c @@ -177,7 +177,7 @@ lookup_view_class(const struct gl_context *ctx, GLenum internalformat) } if (_mesa_has_EXT_texture_compression_s3tc(ctx) && - ctx->Extensions.EXT_texture_sRGB) { + _mesa_has_EXT_texture_sRGB(ctx)) { for (i = 0; i < ARRAY_SIZE(s3tc_compatible_internal_formats); i++) { if (s3tc_compatible_internal_formats[i].internal_format == internalformat) -- 2.6.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [RFC 19/21] mesa: Replace gl_extensions::EXT_texture3D with ::dummy_true
From: Nanley Chery Mesa unconditionally sets this driver flag to true in _mesa_init_extensions(). There is therefore no need for the driver to communicate support for this extension. Replace the driver capability flag with ::dummy_true. Signed-off-by: Nanley Chery --- src/glsl/glsl_parser_extras.cpp | 2 +- src/glsl/standalone_scaffolding.cpp | 1 - src/mesa/main/extensions.c | 2 -- src/mesa/main/extensions_table.h| 4 ++-- src/mesa/main/mtypes.h | 1 - 5 files changed, 3 insertions(+), 7 deletions(-) diff --git a/src/glsl/glsl_parser_extras.cpp b/src/glsl/glsl_parser_extras.cpp index b521c5f..d3d6417 100644 --- a/src/glsl/glsl_parser_extras.cpp +++ b/src/glsl/glsl_parser_extras.cpp @@ -632,7 +632,7 @@ static const _mesa_glsl_extension _mesa_glsl_supported_extensions[] = { */ EXT(OES_EGL_image_external, false, true, OES_EGL_image_external), EXT(OES_standard_derivatives, false, true, OES_standard_derivatives), - EXT(OES_texture_3D, false, true, EXT_texture3D), + EXT(OES_texture_3D, false, true, dummy_true), EXT(OES_texture_storage_multisample_2d_array, false, true, ARB_texture_multisample), /* All other extensions go here, sorted alphabetically. diff --git a/src/glsl/standalone_scaffolding.cpp b/src/glsl/standalone_scaffolding.cpp index eccf094..03cd90e 100644 --- a/src/glsl/standalone_scaffolding.cpp +++ b/src/glsl/standalone_scaffolding.cpp @@ -167,7 +167,6 @@ void initialize_context_to_defaults(struct gl_context *ctx, gl_api api) ctx->Extensions.OES_standard_derivatives = true; ctx->Extensions.EXT_shader_integer_mix = true; - ctx->Extensions.EXT_texture3D = true; ctx->Extensions.EXT_texture_array = true; ctx->Extensions.NV_texture_rectangle = true; diff --git a/src/mesa/main/extensions.c b/src/mesa/main/extensions.c index 6cd2b27..7373928 100644 --- a/src/mesa/main/extensions.c +++ b/src/mesa/main/extensions.c @@ -369,9 +369,7 @@ _mesa_one_time_init_extension_overrides(void) void _mesa_init_extensions(struct gl_extensions *extensions) { - /* Selectively turn default extensions on. */ extensions->dummy_true = GL_TRUE; - extensions->EXT_texture3D = GL_TRUE; } diff --git a/src/mesa/main/extensions_table.h b/src/mesa/main/extensions_table.h index 760fbe9..51eb129 100644 --- a/src/mesa/main/extensions_table.h +++ b/src/mesa/main/extensions_table.h @@ -177,7 +177,7 @@ EXT(EXT_shadow_funcs, ARB_shadow EXT(EXT_stencil_two_side, EXT_stencil_two_side , GLL, x , x , x , 2001) EXT(EXT_stencil_wrap, dummy_true , GLL, x , x , x , 2002) EXT(EXT_subtexture , dummy_true , GLL, x , x , x , 1995) -EXT(EXT_texture3D , EXT_texture3D , GLL, x , x , x , 1996) +EXT(EXT_texture3D , dummy_true , GLL, x , x , x , 1996) EXT(EXT_texture_array , EXT_texture_array , GLL, GLC, x , x , 2006) EXT(EXT_texture_compression_dxt1, ANGLE_texture_compression_dxt , GLL, GLC, ES1, ES2, 2004) EXT(ANGLE_texture_compression_dxt3 , ANGLE_texture_compression_dxt , GLL, GLC, ES1, ES2, 2011) @@ -247,7 +247,7 @@ EXT(OES_stencil4, dummy_false EXT(OES_stencil8, dummy_true , x , x , ES1, ES2, 2005) EXT(OES_stencil_wrap, dummy_true , x , x , ES1, x , 2002) EXT(OES_surfaceless_context , dummy_true , x , x , ES1, ES2, 2012) -EXT(OES_texture_3D , EXT_texture3D , x , x , x , ES2, 2005) +EXT(OES_texture_3D , dummy_true , x , x , x , ES2, 2005) EXT(OES_texture_cube_map, ARB_texture_cube_map , x , x , ES1, x , 2007) EXT(OES_texture_env_crossbar, ARB_texture_env_crossbar , x , x , ES1, x , 2005) EXT(OES_texture_float , OES_texture_float , x , x , x , ES2, 2005) diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index a67c5c0..a89d6d1 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -3766,7 +3766,6 @@ struct gl_extensions GLboolean EXT_provoking_vertex; GLboolean EXT_shader_integer_mix; GLboolean EXT_stencil_two_side; - GLboolean EXT_texture3D; GLboolean EXT_texture_array; GLboolean EXT_texture_compression_latc; GLboolean EXT_texture_compression_s3tc; -- 2.6.1 ___ mesa-dev
[Mesa-dev] [RFC 09/21] mesa: Generate a helper function for each extension
From: Nanley Chery Generate functions which determine if an extension is supported in the current context. Initially, enums were going to be explicitly used with _mesa_extension_supported(). The idea to embed the function and enums into generated helper functions was suggested by Kristian Høgsberg. For performance, the function body no longer uses _mesa_extension_supported() and, as suggested by Chad Versace, the functions are also declared static inline. Signed-off-by: Nanley Chery --- src/mesa/main/context.h| 1 + src/mesa/main/extensions.c | 22 +- src/mesa/main/extensions.h | 39 +++ 3 files changed, 41 insertions(+), 21 deletions(-) diff --git a/src/mesa/main/context.h b/src/mesa/main/context.h index 1e7a12c..4798b1f 100644 --- a/src/mesa/main/context.h +++ b/src/mesa/main/context.h @@ -50,6 +50,7 @@ #include "imports.h" +#include "extensions.h" #include "mtypes.h" #include "vbo/vbo.h" diff --git a/src/mesa/main/extensions.c b/src/mesa/main/extensions.c index 9451085..136313f 100644 --- a/src/mesa/main/extensions.c +++ b/src/mesa/main/extensions.c @@ -42,26 +42,6 @@ struct gl_extensions _mesa_extension_override_disables; static char *extra_extensions = NULL; static char *cant_disable_extensions = NULL; -/** - * \brief An element of the \c extension_table. - */ -struct extension { - /** Name of extension, such as "GL_ARB_depth_clamp". */ - const char *name; - - /** Offset (in bytes) of the corresponding member in struct gl_extensions. */ - size_t offset; - - /** Minimum version the extension requires for the given API -* (see gl_api defined in mtypes.h) -*/ - GLuint version[API_OPENGL_LAST + 1]; - - /** Year the extension was proposed or approved. Used to sort the -* extension string chronologically. */ - uint16_t year; -}; - /** * Given a member \c x of struct gl_extensions, return offset of @@ -73,7 +53,7 @@ struct extension { /** * \brief Table of supported OpenGL extensions for all API's. */ -static const struct extension extension_table[] = { +const struct extension extension_table[] = { #define EXT(name_str, driver_cap, gll_ver, glc_ver, gles_ver, gles2_ver, ) \ { .name = "GL_" #name_str, .offset = o(driver_cap), \ .version = { \ diff --git a/src/mesa/main/extensions.h b/src/mesa/main/extensions.h index 595512a..24cc04d 100644 --- a/src/mesa/main/extensions.h +++ b/src/mesa/main/extensions.h @@ -55,6 +55,45 @@ _mesa_get_extension_count(struct gl_context *ctx); extern const GLubyte * _mesa_get_enabled_extension(struct gl_context *ctx, GLuint index); + +/** + * \brief An element of the \c extension_table. + */ +struct extension { + /** Name of extension, such as "GL_ARB_depth_clamp". */ + const char *name; + + /** Offset (in bytes) of the corresponding member in struct gl_extensions. */ + size_t offset; + + /** Minimum version the extension requires for the given API +* (see gl_api defined in mtypes.h) +*/ + GLuint version[API_OPENGL_LAST + 1]; + + /** Year the extension was proposed or approved. Used to sort the +* extension string chronologically. */ + uint16_t year; +} extern const extension_table[]; + + +/* Generate enums for the functions below */ +enum { +#define EXT(name_str, ...) MESA_EXTENSION_##name_str, +#include "extensions_table.h" +#undef EXT +}; + + +/** Checks if the context suports a user-facing extension */ +#define EXT(name_str, driver_cap, ...) \ +static inline bool _mesa_has_##name_str(const struct gl_context *ctx) { \ + return ctx->Extensions.driver_cap && (ctx->Version >= \ + extension_table[MESA_EXTENSION_##name_str].version[ctx->API]); \ +} +#include "extensions_table.h" +#undef EXT + extern struct gl_extensions _mesa_extension_override_enables; extern struct gl_extensions _mesa_extension_override_disables; -- 2.6.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [RFC 20/21] mesa: Remove gl_extensions::dummy
From: Nanley Chery This variable existed to provide an unsigned error value for name_to_offset(). Since o(extension_sentinel) is also a valid unsigned error value, save space and replace this mysterious variable with a less mysterious one (extension_sentinel). Signed-off-by: Nanley Chery --- src/mesa/main/extensions.c | 9 + src/mesa/main/mtypes.h | 3 +-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/mesa/main/extensions.c b/src/mesa/main/extensions.c index 7373928..d050b0f 100644 --- a/src/mesa/main/extensions.c +++ b/src/mesa/main/extensions.c @@ -79,16 +79,17 @@ static size_t name_to_offset(const char* name) { unsigned i; + const size_t error_value = o(extension_sentinel); if (name == 0) - return 0; + return error_value; for (i = 0; i < ARRAY_SIZE(extension_table); ++i) { if (strcmp(name, extension_table[i].name) == 0) return extension_table[i].offset; } - return 0; + return error_value; } /** @@ -209,7 +210,7 @@ set_extension(struct gl_extensions *ext, const char *name, GLboolean state) size_t offset; offset = name_to_offset(name); - if (offset != 0 && (offset != o(dummy_true) || state != GL_FALSE)) { + if (offset != o(extension_sentinel) && (offset != o(dummy_true) || state != GL_FALSE)) { ((GLboolean *) ext)[offset] = state; } @@ -321,7 +322,7 @@ _mesa_one_time_init_extension_overrides(void) } offset = set_extension(&_mesa_extension_override_enables, ext, enable); - if (offset != 0 && (offset != o(dummy_true) || enable != GL_FALSE)) { + if (offset != o(extension_sentinel) && (offset != o(dummy_true) || enable != GL_FALSE)) { ((GLboolean *) &_mesa_extension_override_disables)[offset] = !enable; recognized = true; } else { diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index a89d6d1..ef90453 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -3652,9 +3652,8 @@ struct gl_constants */ struct gl_extensions { - GLboolean dummy; /* don't remove this! */ GLboolean dummy_true; /* Set true by _mesa_init_extensions(). */ - GLboolean dummy_false; /* Set false by _mesa_init_extensions(). */ + GLboolean dummy_false; /* Set false by zeroed initialization. */ GLboolean ANGLE_texture_compression_dxt; GLboolean ARB_ES2_compatibility; GLboolean ARB_ES3_compatibility; -- 2.6.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [RFC 16/21] mesa: Fix ARB_texture_compression_bptc functionality leaks
From: Nanley Chery Stop leaks into the following contexts: * GLES in _mesa_target_can_be_compressed(). * Pre-3.1 GL legacy versions in all uses. The extension spec lists OpenGL 3.1 as required, so update the extension table accordingly. Signed-off-by: Nanley Chery --- src/mesa/main/extensions_table.h | 2 +- src/mesa/main/glformats.c| 3 +-- src/mesa/main/teximage.c | 2 +- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/mesa/main/extensions_table.h b/src/mesa/main/extensions_table.h index cf6eed7..62e0804 100644 --- a/src/mesa/main/extensions_table.h +++ b/src/mesa/main/extensions_table.h @@ -93,7 +93,7 @@ EXT(ARB_texture_buffer_object , ARB_texture_buffer_object EXT(ARB_texture_buffer_object_rgb32 , ARB_texture_buffer_object_rgb32 , x , GLC, x , x , 2009) EXT(ARB_texture_buffer_range, ARB_texture_buffer_range , x , GLC, x , x , 2012) EXT(ARB_texture_compression , dummy_true , GLL, x , x , x , 2000) -EXT(ARB_texture_compression_bptc, ARB_texture_compression_bptc , GLL, GLC, x , x , 2010) +EXT(ARB_texture_compression_bptc, ARB_texture_compression_bptc , 31, GLC, x , x , 2010) EXT(ARB_texture_compression_rgtc, ARB_texture_compression_rgtc , GLL, GLC, x , x , 2004) EXT(ARB_texture_cube_map, ARB_texture_cube_map , GLL, x , x , x , 1999) EXT(ARB_texture_cube_map_array , ARB_texture_cube_map_array , GLL, GLC, x , x , 2009) diff --git a/src/mesa/main/glformats.c b/src/mesa/main/glformats.c index 9134d7d..542dcfc 100644 --- a/src/mesa/main/glformats.c +++ b/src/mesa/main/glformats.c @@ -1327,8 +1327,7 @@ _mesa_is_compressed_format(const struct gl_context *ctx, GLenum format) case MESA_FORMAT_LAYOUT_ETC2: return _mesa_is_gles3(ctx) || ctx->Extensions.ARB_ES3_compatibility; case MESA_FORMAT_LAYOUT_BPTC: - return _mesa_is_desktop_gl(ctx) && - ctx->Extensions.ARB_texture_compression_bptc; + return _mesa_has_ARB_texture_compression_bptc(ctx); case MESA_FORMAT_LAYOUT_ASTC: return _mesa_has_KHR_texture_compression_astc_ldr(ctx); default: diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c index c14f941..7910fe7 100644 --- a/src/mesa/main/teximage.c +++ b/src/mesa/main/teximage.c @@ -1387,7 +1387,7 @@ _mesa_target_can_be_compressed(const struct gl_context *ctx, GLenum target, return write_error(error, GL_INVALID_OPERATION); break; case MESA_FORMAT_LAYOUT_BPTC: - target_can_be_compresed = ctx->Extensions.ARB_texture_compression_bptc; + target_can_be_compresed = _mesa_has_ARB_texture_compression_bptc(ctx); break; case MESA_FORMAT_LAYOUT_ASTC: target_can_be_compresed = -- 2.6.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [RFC 21/21] mesa/extensions: Declare _mesa_init_extensions() static inline
From: Nanley Chery Avoid the function call overhead for this one-liner. Signed-off-by: Nanley Chery --- src/mesa/main/extensions.c | 14 -- src/mesa/main/extensions.h | 16 ++-- 2 files changed, 14 insertions(+), 16 deletions(-) diff --git a/src/mesa/main/extensions.c b/src/mesa/main/extensions.c index d050b0f..1f6caac 100644 --- a/src/mesa/main/extensions.c +++ b/src/mesa/main/extensions.c @@ -360,20 +360,6 @@ _mesa_one_time_init_extension_overrides(void) } -/** - * \brief Initialize extension tables and enable default extensions. - * - * This should be called during context initialization. - * This function expects a zeroed gl_extensions struct. - * Note: Sets gl_extensions.dummy_true to true. - */ -void -_mesa_init_extensions(struct gl_extensions *extensions) -{ - extensions->dummy_true = GL_TRUE; -} - - typedef unsigned short extension_index; diff --git a/src/mesa/main/extensions.h b/src/mesa/main/extensions.h index 8f106aa..3953894 100644 --- a/src/mesa/main/extensions.h +++ b/src/mesa/main/extensions.h @@ -45,8 +45,6 @@ extern void _mesa_enable_sw_extensions(struct gl_context *ctx); extern void _mesa_one_time_init_extension_overrides(void); -extern void _mesa_init_extensions(struct gl_extensions *extentions); - extern GLubyte *_mesa_make_extension_string(struct gl_context *ctx); extern GLuint @@ -57,6 +55,20 @@ _mesa_get_enabled_extension(struct gl_context *ctx, GLuint index); /** + * \brief Initialize extension tables and enable default extensions. + * + * This should be called during context initialization. + * This function expects a zeroed gl_extensions struct. + * Note: Sets gl_extensions.dummy_true to true. + */ +static inline void +_mesa_init_extensions(struct gl_extensions *extensions) +{ + extensions->dummy_true = GL_TRUE; +} + + +/** * \brief An element of the \c extension_table. */ struct extension { -- 2.6.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [RFC 01/21] mesa/texcompress: Restrict FXT1 format to desktop GL subset
On Mon, Oct 19, 2015 at 3:47 PM, Ilia Mirkin wrote: > On Mon, Oct 19, 2015 at 6:36 PM, Nanley Chery > wrote: > > From: Nanley Chery > > > > In agreement with the extension spec and commit > > dd0eb004874645135b9aaac3ebbd0aaf274079ea, filter FXT1 formats to the > > desktop GL profiles. Now we no longer advertise such formats as supported > > in an ES context and then throw an INVALID_ENUM error when the client > > tries to use such formats with CompressedTexImage2D. > > > > Fixes the following 26 dEQP tests: > > * > dEQP-GLES2.functional.negative_api.texture.compressedteximage2d_invalid_border > > * > dEQP-GLES2.functional.negative_api.texture.compressedteximage2d_invalid_border_cube_neg_x > > * > dEQP-GLES2.functional.negative_api.texture.compressedteximage2d_invalid_border_cube_neg_y > > * > dEQP-GLES2.functional.negative_api.texture.compressedteximage2d_invalid_border_cube_neg_z > > * > dEQP-GLES2.functional.negative_api.texture.compressedteximage2d_invalid_border_cube_pos_x > > * > dEQP-GLES2.functional.negative_api.texture.compressedteximage2d_invalid_border_cube_pos_y > > * > dEQP-GLES2.functional.negative_api.texture.compressedteximage2d_invalid_border_cube_pos_z > > * > dEQP-GLES2.functional.negative_api.texture.compressedteximage2d_invalid_size > > * > dEQP-GLES2.functional.negative_api.texture.compressedteximage2d_level_max_cube_pos > > * > dEQP-GLES2.functional.negative_api.texture.compressedteximage2d_level_max_tex2d > > * > dEQP-GLES2.functional.negative_api.texture.compressedteximage2d_neg_level_cube > > * > dEQP-GLES2.functional.negative_api.texture.compressedteximage2d_neg_level_tex2d > > * > dEQP-GLES2.functional.negative_api.texture.compressedteximage2d_neg_width_height_cube_neg_x > > * > dEQP-GLES2.functional.negative_api.texture.compressedteximage2d_neg_width_height_cube_neg_y > > * > dEQP-GLES2.functional.negative_api.texture.compressedteximage2d_neg_width_height_cube_neg_z > > * > dEQP-GLES2.functional.negative_api.texture.compressedteximage2d_neg_width_height_cube_pos_x > > * > dEQP-GLES2.functional.negative_api.texture.compressedteximage2d_neg_width_height_cube_pos_y > > * > dEQP-GLES2.functional.negative_api.texture.compressedteximage2d_neg_width_height_cube_pos_z > > * > dEQP-GLES2.functional.negative_api.texture.compressedteximage2d_neg_width_height_tex2d > > * > dEQP-GLES2.functional.negative_api.texture.compressedteximage2d_width_height_max_cube_neg_x > > * > dEQP-GLES2.functional.negative_api.texture.compressedteximage2d_width_height_max_cube_neg_y > > * > dEQP-GLES2.functional.negative_api.texture.compressedteximage2d_width_height_max_cube_neg_z > > * > dEQP-GLES2.functional.negative_api.texture.compressedteximage2d_width_height_max_cube_pos_x > > * > dEQP-GLES2.functional.negative_api.texture.compressedteximage2d_width_height_max_cube_pos_y > > * > dEQP-GLES2.functional.negative_api.texture.compressedteximage2d_width_height_max_cube_pos_z > > * > dEQP-GLES2.functional.negative_api.texture.compressedteximage2d_width_height_max_tex2d > > > > Cc: Ian Romanick > > Cc: Mark Janes > > Cc: "11.0" > > Signed-off-by: Nanley Chery > > --- > > src/mesa/main/texcompress.c | 4 +++- > > 1 file changed, 3 insertions(+), 1 deletion(-) > > > > diff --git a/src/mesa/main/texcompress.c b/src/mesa/main/texcompress.c > > index feaf061..1615f4f 100644 > > --- a/src/mesa/main/texcompress.c > > +++ b/src/mesa/main/texcompress.c > > @@ -286,7 +286,9 @@ GLuint > > _mesa_get_compressed_formats(struct gl_context *ctx, GLint *formats) > > { > > GLuint n = 0; > > - if (ctx->Extensions.TDFX_texture_compression_FXT1) { > > + if (ctx->Extensions.TDFX_texture_compression_FXT1 && > > + (ctx->API == API_OPENGL_CORE || > > + (ctx->API == API_OPENGL_COMPAT && ctx->Version > 10))) { > > Not sure if you get rid of such helpers down the line in your series, > but this is the same thing as _mesa_is_desktop_gl(ctx). > > Later on, I replace these checks with a new helper function. The main difference between what I've done and _mesa_is_desktop_gl(ctx) is that I'm checking that the minimum version of the context is 11 (as required by the spec). I suppose I could've done (_mesa_is_desktop_gl(ctx) && ctx->Version > 10) for simplicity. The current expression was optimized for me to test how the .text size changes when moving from open-coded checks to helper functions. >if (formats) { > > formats[n++] = GL_COMPRESSED_RGB_FXT1_3DFX; > > formats[n++] = GL_COMPRESSED_RGBA_FXT1_3DFX; > > -- > > 2.6.1 > > > > ___ > > mesa-dev mailing list > > mesa-dev@lists.freedesktop.org > > http://lists.freedesktop.org/mailman/listinfo/mesa-dev > ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [RFC 01/21] mesa/texcompress: Restrict FXT1 format to desktop GL subset
On Mon, Oct 19, 2015 at 4:02 PM, Ilia Mirkin wrote: > On Mon, Oct 19, 2015 at 6:58 PM, Nanley Chery > wrote: > > > > > > On Mon, Oct 19, 2015 at 3:47 PM, Ilia Mirkin > wrote: > >> > >> On Mon, Oct 19, 2015 at 6:36 PM, Nanley Chery > >> wrote: > >> > From: Nanley Chery > >> > > >> > In agreement with the extension spec and commit > >> > dd0eb004874645135b9aaac3ebbd0aaf274079ea, filter FXT1 formats to the > >> > desktop GL profiles. Now we no longer advertise such formats as > >> > supported > >> > in an ES context and then throw an INVALID_ENUM error when the client > >> > tries to use such formats with CompressedTexImage2D. > >> > > >> > Fixes the following 26 dEQP tests: > >> > * > >> > > dEQP-GLES2.functional.negative_api.texture.compressedteximage2d_invalid_border > >> > * > >> > > dEQP-GLES2.functional.negative_api.texture.compressedteximage2d_invalid_border_cube_neg_x > >> > * > >> > > dEQP-GLES2.functional.negative_api.texture.compressedteximage2d_invalid_border_cube_neg_y > >> > * > >> > > dEQP-GLES2.functional.negative_api.texture.compressedteximage2d_invalid_border_cube_neg_z > >> > * > >> > > dEQP-GLES2.functional.negative_api.texture.compressedteximage2d_invalid_border_cube_pos_x > >> > * > >> > > dEQP-GLES2.functional.negative_api.texture.compressedteximage2d_invalid_border_cube_pos_y > >> > * > >> > > dEQP-GLES2.functional.negative_api.texture.compressedteximage2d_invalid_border_cube_pos_z > >> > * > >> > > dEQP-GLES2.functional.negative_api.texture.compressedteximage2d_invalid_size > >> > * > >> > > dEQP-GLES2.functional.negative_api.texture.compressedteximage2d_level_max_cube_pos > >> > * > >> > > dEQP-GLES2.functional.negative_api.texture.compressedteximage2d_level_max_tex2d > >> > * > >> > > dEQP-GLES2.functional.negative_api.texture.compressedteximage2d_neg_level_cube > >> > * > >> > > dEQP-GLES2.functional.negative_api.texture.compressedteximage2d_neg_level_tex2d > >> > * > >> > > dEQP-GLES2.functional.negative_api.texture.compressedteximage2d_neg_width_height_cube_neg_x > >> > * > >> > > dEQP-GLES2.functional.negative_api.texture.compressedteximage2d_neg_width_height_cube_neg_y > >> > * > >> > > dEQP-GLES2.functional.negative_api.texture.compressedteximage2d_neg_width_height_cube_neg_z > >> > * > >> > > dEQP-GLES2.functional.negative_api.texture.compressedteximage2d_neg_width_height_cube_pos_x > >> > * > >> > > dEQP-GLES2.functional.negative_api.texture.compressedteximage2d_neg_width_height_cube_pos_y > >> > * > >> > > dEQP-GLES2.functional.negative_api.texture.compressedteximage2d_neg_width_height_cube_pos_z > >> > * > >> > > dEQP-GLES2.functional.negative_api.texture.compressedteximage2d_neg_width_height_tex2d > >> > * > >> > > dEQP-GLES2.functional.negative_api.texture.compressedteximage2d_width_height_max_cube_neg_x > >> > * > >> > > dEQP-GLES2.functional.negative_api.texture.compressedteximage2d_width_height_max_cube_neg_y > >> > * > >> > > dEQP-GLES2.functional.negative_api.texture.compressedteximage2d_width_height_max_cube_neg_z > >> > * > >> > > dEQP-GLES2.functional.negative_api.texture.compressedteximage2d_width_height_max_cube_pos_x > >> > * > >> > > dEQP-GLES2.functional.negative_api.texture.compressedteximage2d_width_height_max_cube_pos_y > >> > * > >> > > dEQP-GLES2.functional.negative_api.texture.compressedteximage2d_width_height_max_cube_pos_z > >> > * > >> > > dEQP-GLES2.functional.negative_api.texture.compressedteximage2d_width_height_max_tex2d > >> > > >> > Cc: Ian Romanick > >> > Cc: Mark Janes > >> > Cc: "11.0" > >> > Signed-off-by: Nanley Chery > >> > --- > >> > src/mesa/main/texcompress.c | 4 +++- > >> > 1 file changed, 3 insertions(+), 1 deletion(-) > >> > > >> > diff --git a/src/mesa/main/texcompress.c b/src/mesa/main/texcompress.c > >> > index feaf061..1615f4f 100644 > >> > --- a/src/mesa/main/texcompress.c > >> > +++ b/src/mesa/main/texcompress.c > >> > @@ -286,7 +286,9 @@ GLuint > >> > _mesa_get
Re: [Mesa-dev] [RFC 01/21] mesa/texcompress: Restrict FXT1 format to desktop GL subset
On Tue, Oct 20, 2015 at 6:26 AM, Ian Romanick wrote: > On 10/19/2015 05:58 PM, Nanley Chery wrote: > > > > > > On Mon, Oct 19, 2015 at 3:47 PM, Ilia Mirkin > <mailto:imir...@alum.mit.edu>> wrote: > > > > On Mon, Oct 19, 2015 at 6:36 PM, Nanley Chery > <mailto:nanleych...@gmail.com>> wrote: > > > From: Nanley Chery > <mailto:nanley.g.ch...@intel.com>> > > > > > > In agreement with the extension spec and commit > > > dd0eb004874645135b9aaac3ebbd0aaf274079ea, filter FXT1 formats to > the > > > desktop GL profiles. Now we no longer advertise such formats as > > supported > > > in an ES context and then throw an INVALID_ENUM error when the > client > > > tries to use such formats with CompressedTexImage2D. > > > > > > Fixes the following 26 dEQP tests: > > > * > > > > dEQP-GLES2.functional.negative_api.texture.compressedteximage2d_invalid_border > > > * > > > > dEQP-GLES2.functional.negative_api.texture.compressedteximage2d_invalid_border_cube_neg_x > > > * > > > > dEQP-GLES2.functional.negative_api.texture.compressedteximage2d_invalid_border_cube_neg_y > > > * > > > > dEQP-GLES2.functional.negative_api.texture.compressedteximage2d_invalid_border_cube_neg_z > > > * > > > > dEQP-GLES2.functional.negative_api.texture.compressedteximage2d_invalid_border_cube_pos_x > > > * > > > > dEQP-GLES2.functional.negative_api.texture.compressedteximage2d_invalid_border_cube_pos_y > > > * > > > > dEQP-GLES2.functional.negative_api.texture.compressedteximage2d_invalid_border_cube_pos_z > > > * > > > dEQP-GLES2.functional.negative_api.texture.compressedteximage2d_invalid_size > > > * > > > > dEQP-GLES2.functional.negative_api.texture.compressedteximage2d_level_max_cube_pos > > > * > > > > dEQP-GLES2.functional.negative_api.texture.compressedteximage2d_level_max_tex2d > > > * > > > > dEQP-GLES2.functional.negative_api.texture.compressedteximage2d_neg_level_cube > > > * > > > > dEQP-GLES2.functional.negative_api.texture.compressedteximage2d_neg_level_tex2d > > > * > > > > dEQP-GLES2.functional.negative_api.texture.compressedteximage2d_neg_width_height_cube_neg_x > > > * > > > > dEQP-GLES2.functional.negative_api.texture.compressedteximage2d_neg_width_height_cube_neg_y > > > * > > > > dEQP-GLES2.functional.negative_api.texture.compressedteximage2d_neg_width_height_cube_neg_z > > > * > > > > dEQP-GLES2.functional.negative_api.texture.compressedteximage2d_neg_width_height_cube_pos_x > > > * > > > > dEQP-GLES2.functional.negative_api.texture.compressedteximage2d_neg_width_height_cube_pos_y > > > * > > > > dEQP-GLES2.functional.negative_api.texture.compressedteximage2d_neg_width_height_cube_pos_z > > > * > > > > dEQP-GLES2.functional.negative_api.texture.compressedteximage2d_neg_width_height_tex2d > > > * > > > > dEQP-GLES2.functional.negative_api.texture.compressedteximage2d_width_height_max_cube_neg_x > > > * > > > > dEQP-GLES2.functional.negative_api.texture.compressedteximage2d_width_height_max_cube_neg_y > > > * > > > > dEQP-GLES2.functional.negative_api.texture.compressedteximage2d_width_height_max_cube_neg_z > > > * > > > > dEQP-GLES2.functional.negative_api.texture.compressedteximage2d_width_height_max_cube_pos_x > > > * > > > > dEQP-GLES2.functional.negative_api.texture.compressedteximage2d_width_height_max_cube_pos_y > > > * > > > > dEQP-GLES2.functional.negative_api.texture.compressedteximage2d_width_height_max_cube_pos_z > > > * > > > > dEQP-GLES2.functional.negative_api.texture.compressedteximage2d_width_height_max_tex2d > > > > > > Cc: Ian Romanick > <mailto:ian.d.roman...@intel.com>> > > > Cc: Mark Janes > <mailto:mark.a.ja...@intel.com>> > > > Cc: "11.0" > <mailto:mesa-sta...@lists.freedesktop.org>> > > > Signed-off-by: Nanley Chery > <mailto:nanley.g.ch...@intel.com>> > > > --- > > > src/mesa/main/texcompress.c | 4 +++- > > > 1 file changed, 3 insertions(+), 1 deletion(-) > > > > > > diff --git a/src/mesa/main/te
Re: [Mesa-dev] [RFC 03/21] mesa/extensions: Wrap array entries in macros
On Tue, Oct 20, 2015 at 8:14 AM, Marek Olšák wrote: > On Tue, Oct 20, 2015 at 4:31 PM, Erik Faye-Lund > wrote: > > On Tue, Oct 20, 2015 at 12:36 AM, Nanley Chery > wrote: > >> From: Nanley Chery > >> > >> - { "GL_SUN_multi_draw_arrays", o(dummy_true), > GLL,1999 }, > >> +#define EXT(name_str, driver_cap, api_flags, ) \ > >> +{ .name = "GL_" #name_str, .offset = o(driver_cap), .api_set = > api_flags, .year = }, > > > > I suspect that using designated initializers will make the MSVC build > unhappy. > > Yes, this syntax isn't allowed in core Mesa. Only drivers can use it. > I meant to look into this, but forgot. Thanks for catching this. ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [RFC 03/21] mesa/extensions: Wrap array entries in macros
On Tue, Oct 20, 2015 at 8:16 AM, Marek Olšák wrote: > Also, the FIXME comment should be on its own line. > > I moved it aside to make editing the table easier. However, since the formatting of the table is unlikely to change much after this series, I agree that I should move it back to its original position. Thanks, Nanley Marek > > On Tue, Oct 20, 2015 at 5:14 PM, Marek Olšák wrote: > > On Tue, Oct 20, 2015 at 4:31 PM, Erik Faye-Lund > wrote: > >> On Tue, Oct 20, 2015 at 12:36 AM, Nanley Chery > wrote: > >>> From: Nanley Chery > >>> > >>> - { "GL_SUN_multi_draw_arrays", o(dummy_true), > GLL,1999 }, > >>> +#define EXT(name_str, driver_cap, api_flags, ) \ > >>> +{ .name = "GL_" #name_str, .offset = o(driver_cap), .api_set > = api_flags, .year = }, > >> > >> I suspect that using designated initializers will make the MSVC build > unhappy. > > > > Yes, this syntax isn't allowed in core Mesa. Only drivers can use it. > ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [RFC 09/21] mesa: Generate a helper function for each extension
On Tue, Oct 20, 2015 at 8:26 AM, Marek Olšák wrote: > On Tue, Oct 20, 2015 at 12:44 AM, Nanley Chery > wrote: > > From: Nanley Chery > > > > Generate functions which determine if an extension is supported in the > > current context. Initially, enums were going to be explicitly used with > > _mesa_extension_supported(). The idea to embed the function and enums > > into generated helper functions was suggested by Kristian Høgsberg. > > > > For performance, the function body no longer uses > > _mesa_extension_supported() and, as suggested by Chad Versace, the > > functions are also declared static inline. > > > > Signed-off-by: Nanley Chery > > --- > > src/mesa/main/context.h| 1 + > > src/mesa/main/extensions.c | 22 +- > > src/mesa/main/extensions.h | 39 +++ > > 3 files changed, 41 insertions(+), 21 deletions(-) > > > > diff --git a/src/mesa/main/context.h b/src/mesa/main/context.h > > index 1e7a12c..4798b1f 100644 > > --- a/src/mesa/main/context.h > > +++ b/src/mesa/main/context.h > > @@ -50,6 +50,7 @@ > > > > > > #include "imports.h" > > +#include "extensions.h" > > #include "mtypes.h" > > #include "vbo/vbo.h" > > > > diff --git a/src/mesa/main/extensions.c b/src/mesa/main/extensions.c > > index 9451085..136313f 100644 > > --- a/src/mesa/main/extensions.c > > +++ b/src/mesa/main/extensions.c > > @@ -42,26 +42,6 @@ struct gl_extensions > _mesa_extension_override_disables; > > static char *extra_extensions = NULL; > > static char *cant_disable_extensions = NULL; > > > > -/** > > - * \brief An element of the \c extension_table. > > - */ > > -struct extension { > > - /** Name of extension, such as "GL_ARB_depth_clamp". */ > > - const char *name; > > - > > - /** Offset (in bytes) of the corresponding member in struct > gl_extensions. */ > > - size_t offset; > > - > > - /** Minimum version the extension requires for the given API > > -* (see gl_api defined in mtypes.h) > > -*/ > > - GLuint version[API_OPENGL_LAST + 1]; > > - > > - /** Year the extension was proposed or approved. Used to sort the > > -* extension string chronologically. */ > > - uint16_t year; > > -}; > > - > > > > /** > > * Given a member \c x of struct gl_extensions, return offset of > > @@ -73,7 +53,7 @@ struct extension { > > /** > > * \brief Table of supported OpenGL extensions for all API's. > > */ > > -static const struct extension extension_table[] = { > > +const struct extension extension_table[] = { > > #define EXT(name_str, driver_cap, gll_ver, glc_ver, gles_ver, > gles2_ver, ) \ > > { .name = "GL_" #name_str, .offset = o(driver_cap), \ > >.version = { \ > > diff --git a/src/mesa/main/extensions.h b/src/mesa/main/extensions.h > > index 595512a..24cc04d 100644 > > --- a/src/mesa/main/extensions.h > > +++ b/src/mesa/main/extensions.h > > @@ -55,6 +55,45 @@ _mesa_get_extension_count(struct gl_context *ctx); > > extern const GLubyte * > > _mesa_get_enabled_extension(struct gl_context *ctx, GLuint index); > > > > + > > +/** > > + * \brief An element of the \c extension_table. > > + */ > > +struct extension { > > + /** Name of extension, such as "GL_ARB_depth_clamp". */ > > + const char *name; > > + > > + /** Offset (in bytes) of the corresponding member in struct > gl_extensions. */ > > + size_t offset; > > + > > + /** Minimum version the extension requires for the given API > > +* (see gl_api defined in mtypes.h) > > +*/ > > + GLuint version[API_OPENGL_LAST + 1]; > > + > > + /** Year the extension was proposed or approved. Used to sort the > > +* extension string chronologically. */ > > + uint16_t year; > > +} extern const extension_table[]; > > Global variables should have a proper prefix. > > I'll send out an update for this. Thanks, Nanley > Marek > ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [RFC 15/21] mesa: Fix EXT_texture_sRGB functionality leaks
On Tue, Oct 20, 2015 at 8:32 AM, Marek Olšák wrote: > On Tue, Oct 20, 2015 at 12:44 AM, Nanley Chery > wrote: > > From: Nanley Chery > > > > Stop leaks into the following contexts: > >* GLES in _mesa_base_tex_format() and lookup_view_class(). > >* Pre-1.1 GL legacy contexts in all uses. > > Fixing OpenGL 1.0? Seriously? Come on. :) > > :) I was just notified (in the first patch's thread) that 1.2 is the minimum version advertised in Mesa. I'll have to update the comments in other such patches which mention pre 1.2 versions of GL. > Marek > ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [RFC 21/21] mesa/extensions: Declare _mesa_init_extensions() static inline
On Tue, Oct 20, 2015 at 8:57 AM, Marek Olšák wrote: > On Tue, Oct 20, 2015 at 12:44 AM, Nanley Chery > wrote: > > From: Nanley Chery > > > > Avoid the function call overhead for this one-liner. > > Can you measure the overhead? If not, there is no reason for this change. > > The .text size does decrease by 48 bytes: text data bss dec hex filename 5190616 209856 27712 5428184 52d3d8 lib/i965_dri.so (before) 5190568 209856 27712 5428136 52d3a8 lib/i965_dri.so (after) Is this sufficient? If so, I can add the snippet above to the git comment. Regards, Nanley Marek > ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [RFC 21/21] mesa/extensions: Declare _mesa_init_extensions() static inline
On Tue, Oct 20, 2015 at 9:31 AM, Marek Olšák wrote: > On Tue, Oct 20, 2015 at 6:25 PM, Nanley Chery > wrote: > > > > > > On Tue, Oct 20, 2015 at 8:57 AM, Marek Olšák wrote: > >> > >> On Tue, Oct 20, 2015 at 12:44 AM, Nanley Chery > >> wrote: > >> > From: Nanley Chery > >> > > >> > Avoid the function call overhead for this one-liner. > >> > >> Can you measure the overhead? If not, there is no reason for this > change. > >> > > > > The .text size does decrease by 48 bytes: > > text data bss dec hex filename > > 5190616 209856 27712 5428184 52d3d8 lib/i965_dri.so (before) > > 5190568 209856 27712 5428136 52d3a8 lib/i965_dri.so (after) > > > > Is this sufficient? If so, I can add the snippet above to the git > comment. > > I don't think so. :) > > :) Okay. I suppose that the function isn't called often enough to warrant the loss of encapsulation. Thanks, Nanley > Marek > ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [RFC 18/21] mesa/extensions: Remove extra memsets on gl_extensions
On Tue, Oct 20, 2015 at 8:49 AM, Marek Olšák wrote: > On Tue, Oct 20, 2015 at 12:44 AM, Nanley Chery > wrote: > > From: Nanley Chery > > > > Aside from those modified in this commit, all gl_extensions structs are > > zero-initialized by default. There is therefore no need to memset the > > structs to 0. Also, remove the open-coded memset in > > _mesa_init_extensions(). > > > > Signed-off-by: Nanley Chery > > --- > > src/mesa/main/extensions.c | 18 -- > > 1 file changed, 4 insertions(+), 14 deletions(-) > > > > diff --git a/src/mesa/main/extensions.c b/src/mesa/main/extensions.c > > index 365e7ed..6cd2b27 100644 > > --- a/src/mesa/main/extensions.c > > +++ b/src/mesa/main/extensions.c > > @@ -37,8 +37,8 @@ > > #include "macros.h" > > #include "mtypes.h" > > > > -struct gl_extensions _mesa_extension_override_enables; > > -struct gl_extensions _mesa_extension_override_disables; > > +struct gl_extensions _mesa_extension_override_enables = {0}; > > +struct gl_extensions _mesa_extension_override_disables = {0}; > > This looks good. Note that global variables are always > zero-initialized, thus the initializer is useless there. This hunk > could be dropped, but it's not a big deal. > > Thanks for the feedback. My git comment incorrectly says that those two variables are not zero-initialized. So I'll have to drop this hunk and update the comment. Nanley > Marek > ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [RFC 16/21] mesa: Fix ARB_texture_compression_bptc functionality leaks
On Tue, Oct 20, 2015 at 8:37 AM, Marek Olšák wrote: > NAK. I'd like this extension in compatibility contexts. The fact the > spec requires OpenGL 3.1 was just authors' laziness. > > I had thought it might be the case that some specs may unecessarily require a certain version, when in fact a longer list of dependencies would suffice instead. I'll look into this issue. If it's the right way to go, I can allow all versions of GL compatibility by simply replacing the '31' with 'GLL' in a v2. > Marek > > On Tue, Oct 20, 2015 at 12:44 AM, Nanley Chery > wrote: > > From: Nanley Chery > > > > Stop leaks into the following contexts: > >* GLES in _mesa_target_can_be_compressed(). > >* Pre-3.1 GL legacy versions in all uses. > > > > The extension spec lists OpenGL 3.1 as required, so update the extension > > table accordingly. > > > > Signed-off-by: Nanley Chery > > --- > > src/mesa/main/extensions_table.h | 2 +- > > src/mesa/main/glformats.c| 3 +-- > > src/mesa/main/teximage.c | 2 +- > > 3 files changed, 3 insertions(+), 4 deletions(-) > > > > diff --git a/src/mesa/main/extensions_table.h > b/src/mesa/main/extensions_table.h > > index cf6eed7..62e0804 100644 > > --- a/src/mesa/main/extensions_table.h > > +++ b/src/mesa/main/extensions_table.h > > @@ -93,7 +93,7 @@ EXT(ARB_texture_buffer_object , > ARB_texture_buffer_object > > EXT(ARB_texture_buffer_object_rgb32 , > ARB_texture_buffer_object_rgb32, x , GLC, x , x , 2009) > > EXT(ARB_texture_buffer_range, ARB_texture_buffer_range > , x , GLC, x , x , 2012) > > EXT(ARB_texture_compression , dummy_true > , GLL, x , x , x , 2000) > > -EXT(ARB_texture_compression_bptc, > ARB_texture_compression_bptc , GLL, GLC, x , x , 2010) > > +EXT(ARB_texture_compression_bptc, > ARB_texture_compression_bptc , 31, GLC, x , x , 2010) > > EXT(ARB_texture_compression_rgtc, > ARB_texture_compression_rgtc , GLL, GLC, x , x , 2004) > > EXT(ARB_texture_cube_map, ARB_texture_cube_map > , GLL, x , x , x , 1999) > > EXT(ARB_texture_cube_map_array , > ARB_texture_cube_map_array , GLL, GLC, x , x , 2009) > > diff --git a/src/mesa/main/glformats.c b/src/mesa/main/glformats.c > > index 9134d7d..542dcfc 100644 > > --- a/src/mesa/main/glformats.c > > +++ b/src/mesa/main/glformats.c > > @@ -1327,8 +1327,7 @@ _mesa_is_compressed_format(const struct gl_context > *ctx, GLenum format) > > case MESA_FORMAT_LAYOUT_ETC2: > >return _mesa_is_gles3(ctx) || > ctx->Extensions.ARB_ES3_compatibility; > > case MESA_FORMAT_LAYOUT_BPTC: > > - return _mesa_is_desktop_gl(ctx) && > > - ctx->Extensions.ARB_texture_compression_bptc; > > + return _mesa_has_ARB_texture_compression_bptc(ctx); > > case MESA_FORMAT_LAYOUT_ASTC: > >return _mesa_has_KHR_texture_compression_astc_ldr(ctx); > > default: > > diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c > > index c14f941..7910fe7 100644 > > --- a/src/mesa/main/teximage.c > > +++ b/src/mesa/main/teximage.c > > @@ -1387,7 +1387,7 @@ _mesa_target_can_be_compressed(const struct > gl_context *ctx, GLenum target, > > return write_error(error, GL_INVALID_OPERATION); > > break; > >case MESA_FORMAT_LAYOUT_BPTC: > > - target_can_be_compresed = > ctx->Extensions.ARB_texture_compression_bptc; > > + target_can_be_compresed = > _mesa_has_ARB_texture_compression_bptc(ctx); > > break; > >case MESA_FORMAT_LAYOUT_ASTC: > > target_can_be_compresed = > > -- > > 2.6.1 > > > > ___ > > mesa-dev mailing list > > mesa-dev@lists.freedesktop.org > > http://lists.freedesktop.org/mailman/listinfo/mesa-dev > ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [RFC 17/21] mesa: Fix ARB_ES3_compatibility functionality leaks
On Tue, Oct 20, 2015 at 8:45 AM, Marek Olšák wrote: > NAK. I'd like this extension in compatibility contexts. The fact the > spec requires OpenGL 3.3 was just authors' laziness. > > If it's the right thing to do, I can allow all versions of GL compatibility by simply replacing '33' with 'GLL' in a v2. I'll try to nail down what the actual minimum version required is. > Generally, when a spec requires 3.3, we should allow 3.0 at least, > because Mesa doesn't support 3.3 compatibility contexts. > > I will keep this in mind. > Unless you have a very good _technical_ reason not to support this > extension, it should be supported by all versions. This applies to > other such patches as well. > > GL 3.3 may have introduced a new feature on which this extension is dependent. If this feature is not contained within any other extension and our context version is less than 3.3, we may not be able to actually implement the extension spec as described. I will try to see if this is the case. I agree that technical roadblocks should be the only things which prevent us from advertising certain extensions. Thanks, Nanley Marek > > On Tue, Oct 20, 2015 at 12:44 AM, Nanley Chery > wrote: > > From: Nanley Chery > > > > Stop leaks into GLES1/2 and pre-3.3 GL contexts in all uses. > > > > The extension spec lists OpenGL 3.3 as one of the requirements, so > > update the extension table accordingly. > > > > v2. Require 3.3 for GL legacy contexts as well (Chad). > > > > Signed-off-by: Nanley Chery > > --- > > src/mesa/main/enable.c | 4 ++-- > > src/mesa/main/extensions_table.h | 2 +- > > src/mesa/main/glformats.c| 2 +- > > src/mesa/main/queryobj.c | 2 +- > > 4 files changed, 5 insertions(+), 5 deletions(-) > > > > diff --git a/src/mesa/main/enable.c b/src/mesa/main/enable.c > > index 42f6799..ee95334 100644 > > --- a/src/mesa/main/enable.c > > +++ b/src/mesa/main/enable.c > > @@ -972,7 +972,7 @@ _mesa_set_enable(struct gl_context *ctx, GLenum cap, > GLboolean state) > > break; > > > >case GL_PRIMITIVE_RESTART_FIXED_INDEX: > > -if (!_mesa_is_gles3(ctx) && > !ctx->Extensions.ARB_ES3_compatibility) > > +if (!_mesa_is_gles3(ctx) && > !_mesa_has_ARB_ES3_compatibility(ctx)) > > goto invalid_enum_error; > > if (ctx->Array.PrimitiveRestartFixedIndex != state) { > > FLUSH_VERTICES(ctx, _NEW_TRANSFORM); > > @@ -1582,7 +1582,7 @@ _mesa_IsEnabled( GLenum cap ) > > return ctx->Array.PrimitiveRestart; > > > >case GL_PRIMITIVE_RESTART_FIXED_INDEX: > > -if (!_mesa_is_gles3(ctx) && > !ctx->Extensions.ARB_ES3_compatibility) { > > +if (!_mesa_is_gles3(ctx) && > !_mesa_has_ARB_ES3_compatibility(ctx)) { > > goto invalid_enum_error; > > } > > return ctx->Array.PrimitiveRestartFixedIndex; > > diff --git a/src/mesa/main/extensions_table.h > b/src/mesa/main/extensions_table.h > > index 62e0804..760fbe9 100644 > > --- a/src/mesa/main/extensions_table.h > > +++ b/src/mesa/main/extensions_table.h > > @@ -4,7 +4,7 @@ > > #define ES2 1u > > #define x ~0u > > EXT(ARB_ES2_compatibility , ARB_ES2_compatibility > , GLL, GLC, x , x , 2009) > > -EXT(ARB_ES3_compatibility , ARB_ES3_compatibility > , GLL, GLC, x , x , 2012) > > +EXT(ARB_ES3_compatibility , ARB_ES3_compatibility > , 33, 33, x , x , 2012) > > EXT(ARB_arrays_of_arrays, ARB_arrays_of_arrays > , GLL, GLC, x , x , 2012) > > EXT(ARB_base_instance , ARB_base_instance > , GLL, GLC, x , x , 2011) > > EXT(ARB_blend_func_extended , ARB_blend_func_extended > , GLL, GLC, x , x , 2009) > > diff --git a/src/mesa/main/glformats.c b/src/mesa/main/glformats.c > > index 542dcfc..6b602d8 100644 > > --- a/src/mesa/main/glformats.c > > +++ b/src/mesa/main/glformats.c > > @@ -1325,7 +1325,7 @@ _mesa_is_compressed_format(const struct gl_context > *ctx, GLenum format) > >return _mesa_is_gles(ctx) > > && ctx->Extensions.OES_compressed_ETC1_RGB8_texture; > > case MESA_FORMAT_LAYOUT_ETC2: > > - return _mesa_is_gles3(ctx) || > ctx->Extensions.ARB_ES3_compatibility; > > + return _mesa_is_gles3(ctx) || > _mesa_has_ARB_ES3_compatibility(ctx); &g
Re: [Mesa-dev] [PATCH] mesa/glformats: Undo code changes from _mesa_base_tex_format() move
On Wed, Oct 21, 2015 at 7:23 AM, Emil Velikov wrote: > On 9 October 2015 at 23:35, Nanley Chery wrote: > > From: Nanley Chery > > > > The refactoring commit, c6bf1cd, accidentally reverted cd49b97 > > and 99b1f47. These changes caused more code to be added to the > > function and removed the existing support for ASTC. This patch > > reverts those modifications. > > > > v2. Actually include ASTC support again. > > > Thanks Nanley. > > I take it that with this in place the KHR_texture_compression_astc_ldr > piglits/tests are back online (pass) ? > With this in place a dEQP failure is fixed. If I remember correctly, this did also enable a piglit test to pass. > I have double-checked and this patch does fix the erroneous reverts by > c6bf1cd. > > Reviewed-by: Emil Velikov > > Thanks! Nanley > -Emil > ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH] mesa: Enable ASTC in GLES' [NUM_]COMPRESSED_TEXTURE_FORMATS queries
From: Nanley Chery In OpenGL ES, the COMPRESSED_TEXTURE_FORMATS query returns the set of supported specific compressed formats. Since ASTC formats fit within that category, include them in the set and update the NUM_COMPRESSED_TEXTURE_FORMATS query as well. This enables GLES2-based ASTC dEQP tests to run. See the Bugzilla for more info. Cc: "11.0" Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=92193 Reported-by: Tapani Pälli Suggested-by: Ian Romanick Signed-off-by: Nanley Chery --- src/mesa/main/texcompress.c | 85 + 1 file changed, 63 insertions(+), 22 deletions(-) diff --git a/src/mesa/main/texcompress.c b/src/mesa/main/texcompress.c index 84973d3..9d22586 100644 --- a/src/mesa/main/texcompress.c +++ b/src/mesa/main/texcompress.c @@ -243,28 +243,6 @@ _mesa_gl_compressed_format_base_format(GLenum format) *what GL_NUM_COMPRESSED_TEXTURE_FORMATS and *GL_COMPRESSED_TEXTURE_FORMATS return." * - * The KHR_texture_compression_astc_hdr spec says: - * - *"Interactions with OpenGL 4.2 - * - *OpenGL 4.2 supports the feature that compressed textures can be - *compressed online, by passing the compressed texture format enum as - *the internal format when uploading a texture using TexImage1D, - *TexImage2D or TexImage3D (see Section 3.9.3, Texture Image - *Specification, subsection Encoding of Special Internal Formats). - * - *Due to the complexity of the ASTC compression algorithm, it is not - *usually suitable for online use, and therefore ASTC support will be - *limited to pre-compressed textures only. Where on-device compression - *is required, a domain-specific limited compressor will typically - *be used, and this is therefore not suitable for implementation in - *the driver. - * - *In particular, the ASTC format specifiers will not be added to - *Table 3.14, and thus will not be accepted by the TexImage*D - *functions, and will not be returned by the (already deprecated) - *COMPRESSED_TEXTURE_FORMATS query." - * * There is no formal spec for GL_ATI_texture_compression_3dc. Since the * formats added by this extension are luminance-alpha formats, it is * reasonable to expect them to follow the same rules as @@ -396,6 +374,69 @@ _mesa_get_compressed_formats(struct gl_context *ctx, GLint *formats) n += 10; } } + + /* The KHR_texture_compression_astc_hdr spec says: +* +*"Interactions with OpenGL 4.2 +* +*OpenGL 4.2 supports the feature that compressed textures can be +*compressed online, by passing the compressed texture format enum as +*the internal format when uploading a texture using TexImage1D, +*TexImage2D or TexImage3D (see Section 3.9.3, Texture Image +*Specification, subsection Encoding of Special Internal Formats). +* +*Due to the complexity of the ASTC compression algorithm, it is not +*usually suitable for online use, and therefore ASTC support will be +*limited to pre-compressed textures only. Where on-device compression +*is required, a domain-specific limited compressor will typically +*be used, and this is therefore not suitable for implementation in +*the driver. +* +*In particular, the ASTC format specifiers will not be added to +*Table 3.14, and thus will not be accepted by the TexImage*D +*functions, and will not be returned by the (already deprecated) +*COMPRESSED_TEXTURE_FORMATS query." +* +* The ES and the desktop specs diverge here. In OpenGL ES, the COMPRESSED_TEXTURE_FORMATS +* query returns the set of supported specific compressed formats. +*/ + if (ctx->API == API_OPENGLES2 && + ctx->Extensions.KHR_texture_compression_astc_ldr) { + if (formats) { + formats[n++] = GL_COMPRESSED_RGBA_ASTC_4x4_KHR; + formats[n++] = GL_COMPRESSED_RGBA_ASTC_5x4_KHR; + formats[n++] = GL_COMPRESSED_RGBA_ASTC_5x5_KHR; + formats[n++] = GL_COMPRESSED_RGBA_ASTC_6x5_KHR; + formats[n++] = GL_COMPRESSED_RGBA_ASTC_6x6_KHR; + formats[n++] = GL_COMPRESSED_RGBA_ASTC_8x5_KHR; + formats[n++] = GL_COMPRESSED_RGBA_ASTC_8x6_KHR; + formats[n++] = GL_COMPRESSED_RGBA_ASTC_8x8_KHR; + formats[n++] = GL_COMPRESSED_RGBA_ASTC_10x5_KHR; + formats[n++] = GL_COMPRESSED_RGBA_ASTC_10x6_KHR; + formats[n++] = GL_COMPRESSED_RGBA_ASTC_10x8_KHR; + formats[n++] = GL_COMPRESSED_RGBA_ASTC_10x10_KHR; + formats[n++] = GL_COMPRESSED_RGBA_ASTC_12x10_KHR; + formats[n++] = GL_COMPRESSED_RGBA_ASTC_12x12_KHR; + formats[n++] = GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR; + formats[n++] = GL_COMPRESS
Re: [Mesa-dev] [RFC 03/21] mesa/extensions: Wrap array entries in macros
On Thu, Oct 22, 2015 at 3:06 AM, Emil Velikov wrote: > On 20 October 2015 at 16:43, Nanley Chery wrote: > > On Tue, Oct 20, 2015 at 8:16 AM, Marek Olšák wrote: > >> > >> Also, the FIXME comment should be on its own line. > >> > > > > I moved it aside to make editing the table easier. However, since the > > formatting of the > > table is unlikely to change much after this series, I agree that I should > > move it back to > > its original position. > > > Actually the designated initalisers should be fine in core mesa. If in > doubt wrt MSVC compat, just grep MSVC.*COMPAT through whole of mesa. > The 2013 version adds support for this feature. > Alternatively feel free to ask Brian/Jose, as they have a fair bit of > experience in the area. > > That's good news. Thanks for the information. > That aside, I'm in favour of keeping the comments as is. The editing > comment does not apply imho. > > Since, there isn't a unanimous opinion on this, I'll leave the FIXME to save some rebasing time. Are you referring to my git comment? Or to my previous reply about why I moved the FIXME? -Emil > ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [RFC 06/21] mesa/extensions: Create _mesa_extension_supported()
On Thu, Oct 22, 2015 at 3:19 AM, Emil Velikov wrote: > On 19 October 2015 at 23:36, Nanley Chery wrote: > > From: Nanley Chery > > > > Create a function which determines if an extension is supported in the > > current context. > > > > Signed-off-by: Nanley Chery > > --- > > src/mesa/main/extensions.c | 17 + > > 1 file changed, 17 insertions(+) > > > > diff --git a/src/mesa/main/extensions.c b/src/mesa/main/extensions.c > > index 390e026..7137bc9 100644 > > --- a/src/mesa/main/extensions.c > > +++ b/src/mesa/main/extensions.c > > @@ -423,6 +423,23 @@ typedef unsigned short extension_index; > > > > > > /** > > + * Given an extension enum, return whether or not the extension is > supported > > + * dependent on the following factors: > > + * There's driver support and the OpenGL/ES version is at least that > > + * specified in the extension_table. > > + */ > > +static inline bool > > +_mesa_extension_supported(const struct gl_context *ctx, extension_index > ei) > > +{ > > + const bool *base = (bool *) &ctx->Extensions; > > + const struct extension *i = extension_table + ei; > > + const uint8_t api_set = 1 << ctx->API; > > + return (i->api_set & api_set) && > > + (ctx->Version >= i->version[ctx->API]) && > > + base[i->offset]; > Bikeshed: I realise that you're copying most of these, but wouldn't it > be better if we use more common/intuitive variable names ? > > ei -> i or idx > i -> ext > > Yes, I was mostly copying what was around. Thanks for the variable name suggestions. I'll update this function. > -Emil > ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [RFC 06/21] mesa/extensions: Create _mesa_extension_supported()
On Thu, Oct 22, 2015 at 11:08 AM, Chad Versace wrote: > On Thu 22 Oct 2015, Emil Velikov wrote: > > On 19 October 2015 at 23:36, Nanley Chery wrote: > > > From: Nanley Chery > > > > > > Create a function which determines if an extension is supported in the > > > current context. > > > > > > Signed-off-by: Nanley Chery > > > --- > > > src/mesa/main/extensions.c | 17 + > > > 1 file changed, 17 insertions(+) > > > > > > diff --git a/src/mesa/main/extensions.c b/src/mesa/main/extensions.c > > > index 390e026..7137bc9 100644 > > > --- a/src/mesa/main/extensions.c > > > +++ b/src/mesa/main/extensions.c > > > @@ -423,6 +423,23 @@ typedef unsigned short extension_index; > > > > > > > > > /** > > > + * Given an extension enum, return whether or not the extension is > supported > > > + * dependent on the following factors: > > > + * There's driver support and the OpenGL/ES version is at least that > > > + * specified in the extension_table. > > > + */ > > > +static inline bool > > > +_mesa_extension_supported(const struct gl_context *ctx, > extension_index ei) > > > +{ > > > + const bool *base = (bool *) &ctx->Extensions; > > > + const struct extension *i = extension_table + ei; > > > + const uint8_t api_set = 1 << ctx->API; > > > + return (i->api_set & api_set) && > > > + (ctx->Version >= i->version[ctx->API]) && > > > + base[i->offset]; > > Bikeshed: I realise that you're copying most of these, but wouldn't it > > be better if we use more common/intuitive variable names ? > > > > ei -> i or idx > > i -> ext > > I second Emil's suggestion. > > Please insert an empty line between the block of variable declarations > and the return statement. > > Also, it improves the readability if you rename the local variable > 'api_set' to 'api_bit', because it's not really a set. It's just one > bit. > I'll incorporate both changes. ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [RFC 04/21] mesa/extensions: Move entries entries to seperate file
On Thu, Oct 22, 2015 at 3:13 AM, Emil Velikov wrote: > On 19 October 2015 at 23:36, Nanley Chery wrote: > > From: Nanley Chery > > > > With this infrastructure set in place, we can now reuse the entries to > > generate useful code. > > > > Signed-off-by: Nanley Chery > > --- > > src/mesa/main/extensions.c | 321 > +-- > > src/mesa/main/extensions_table.h | 320 > ++ > > 2 files changed, 321 insertions(+), 320 deletions(-) > > create mode 100644 src/mesa/main/extensions_table.h > > > As a general rule of thumb if you add any file new in mesa, it should > be referenced in a Makefile.* somewhere. Please squash the following > > diff --git a/src/mesa/Makefile.sources b/src/mesa/Makefile.sources > index ed9848c..f86590b 100644 > --- a/src/mesa/Makefile.sources > +++ b/src/mesa/Makefile.sources > @@ -77,6 +77,7 @@ MAIN_FILES = \ >main/execmem.c \ >main/extensions.c \ >main/extensions.h \ > + main/extensions_table.h \ >main/fbobject.c \ >main/fbobject.h \ >main/feedback.c \ > > Will do. Thanks for the tip. > > -Emil > ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [RFC 20/21] mesa: Remove gl_extensions::dummy
On Thu, Oct 22, 2015 at 3:40 AM, Emil Velikov wrote: > On 19 October 2015 at 23:44, Nanley Chery wrote: > > From: Nanley Chery > > > > This variable existed to provide an unsigned error value for > > name_to_offset(). Since o(extension_sentinel) is also a valid unsigned > > error value, save space and replace this mysterious variable with > > a less mysterious one (extension_sentinel). > > > That's the first time I see someone calling 0, a "unsigned error > value". Perhaps reword the commit message a bit ? The comment/function > description should be updated as well. > > How's the following? This variable existed to enable 0 as a valid error value for name_to_offset(). Since o(extension_sentinel) is also a valid error value, save space and replace this mysterious variable with a less mysterious one (extension_sentinel). > -Emil > ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [RFC 10/21] mesa: Remove equality check in helper functions
On Wed, Oct 21, 2015 at 11:43 PM, Erik Faye-Lund wrote: > On Tue, Oct 20, 2015 at 12:44 AM, Nanley Chery > wrote: > > From: Nanley Chery > > > > Since the version numbers being compared are integral and we don't ever > > expect gl_context::Version to be equal to 0, subtract 1 from the rhs of > > the equation and perform the optimization of removing the equality check. > > Is this really an improvement? Changing '>=' to '>' and then making > all versions off-by-one seems like trading less readable and debugable > code for no real upside... > After looking at the assembly generated, I've determined that this is actually not an improvement. I'll drop this patch. I was using .text size as my metric earlier. I now realize that it isn't completely reliable. ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [RFC 05/21] mesa/extensions: Add extension::version
On Thu, Oct 22, 2015 at 3:17 AM, Emil Velikov wrote: > On 19 October 2015 at 23:36, Nanley Chery wrote: > > From: Nanley Chery > > > > Enable limiting advertised extension support by context version with > > finer granularity. GLuint is chosen over smaller datatypes because, > > when this field is eventually used, usage of this datatype provides > > the smallest .text size of the compiled library. > > > > Signed-off-by: Nanley Chery > > --- > > src/mesa/main/extensions.c | 15 +- > > src/mesa/main/extensions_table.h | 626 > +++ > > 2 files changed, 326 insertions(+), 315 deletions(-) > > > > diff --git a/src/mesa/main/extensions.c b/src/mesa/main/extensions.c > > index 30f5b98..390e026 100644 > > --- a/src/mesa/main/extensions.c > > +++ b/src/mesa/main/extensions.c > > @@ -66,6 +66,11 @@ struct extension { > > /** Set of API's in which the extension exists, as a bitset. */ > > uint8_t api_set; > > > > + /** Minimum version the extension requires for the given API > > +* (see gl_api defined in mtypes.h) > > +*/ > > + GLuint version[API_OPENGL_LAST + 1]; > > + > Please use uint*t type, like the surrounding code and add a note that > the version is 10*major+minor. > > Will do. > -Emil > ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [RFC 05/21] mesa/extensions: Add extension::version
On Thu, Oct 22, 2015 at 11:02 AM, Chad Versace wrote: > On Mon 19 Oct 2015, Nanley Chery wrote: > > From: Nanley Chery > > > > Enable limiting advertised extension support by context version with > > finer granularity. GLuint is chosen over smaller datatypes because, > > when this field is eventually used, usage of this datatype provides > > the smallest .text size of the compiled library. > > > > Signed-off-by: Nanley Chery > > --- > > src/mesa/main/extensions.c | 15 +- > > src/mesa/main/extensions_table.h | 626 > +++ > > 2 files changed, 326 insertions(+), 315 deletions(-) > > > > @@ -83,8 +88,14 @@ struct extension { > > * \brief Table of supported OpenGL extensions for all API's. > > */ > > static const struct extension extension_table[] = { > > -#define EXT(name_str, driver_cap, api_flags, ) \ > > -{ .name = "GL_" #name_str, .offset = o(driver_cap), .api_set = > api_flags, .year = }, > > +#define EXT(name_str, driver_cap, api_flags, gll_ver, glc_ver, > gles_ver, gles2_ver, ) \ > > +{ .name = "GL_" #name_str, .offset = o(driver_cap), .api_set = > api_flags, \ > > + .version = { \ > > +[API_OPENGL_COMPAT] = gll_ver, \ > > +[API_OPENGL_CORE] = glc_ver, \ > > +[API_OPENGLES] = gles_ver, \ > > +[API_OPENGLES2] = gles2_ver, \ > > + }, .year = }, > > Please place '.year' and the final '}' each on its own line. That makes > the macro easier to read. > > Will do. > > #include "extensions_table.h" > > #undef EXT > > }; > ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [RFC 18/21] mesa/extensions: Remove extra memsets on gl_extensions
On Thu, Oct 22, 2015 at 3:32 AM, Emil Velikov wrote: > On 19 October 2015 at 23:44, Nanley Chery wrote: > > From: Nanley Chery > > > > Aside from those modified in this commit, all gl_extensions structs are > > zero-initialized by default. There is therefore no need to memset the > > structs to 0. Also, remove the open-coded memset in > > _mesa_init_extensions(). > > > > Signed-off-by: Nanley Chery > > --- > > src/mesa/main/extensions.c | 18 -- > > 1 file changed, 4 insertions(+), 14 deletions(-) > > > > diff --git a/src/mesa/main/extensions.c b/src/mesa/main/extensions.c > > index 365e7ed..6cd2b27 100644 > > --- a/src/mesa/main/extensions.c > > +++ b/src/mesa/main/extensions.c > > @@ -37,8 +37,8 @@ > > #include "macros.h" > > #include "mtypes.h" > > > > -struct gl_extensions _mesa_extension_override_enables; > > -struct gl_extensions _mesa_extension_override_disables; > > +struct gl_extensions _mesa_extension_override_enables = {0}; > > +struct gl_extensions _mesa_extension_override_disables = {0}; > Side note: once ARB_compute_shader lands in for i965 we can even make > these local/static. > > That's interesting. How so? -Emil > ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [RFC 17/21] mesa: Fix ARB_ES3_compatibility functionality leaks
On Tue, Oct 20, 2015 at 4:32 PM, Nanley Chery wrote: > > > On Tue, Oct 20, 2015 at 8:45 AM, Marek Olšák wrote: > >> NAK. I'd like this extension in compatibility contexts. The fact the >> spec requires OpenGL 3.3 was just authors' laziness. >> >> > If it's the right thing to do, I can allow all versions of GL > compatibility by > simply replacing '33' with 'GLL' in a v2. I'll try to nail down what the > actual minimum version required is. > > It seems that GLSL 3.3 and ARB_occlusion_query2 are required instead of OpenGL 3.3. I'd like to spend more time confirming this and seeing if the spec authors would agree. Until then, I'll drop this patch from this series. Generally, when a spec requires 3.3, we should allow 3.0 at least, >> because Mesa doesn't support 3.3 compatibility contexts. >> >> > > I will keep this in mind. > > >> Unless you have a very good _technical_ reason not to support this >> extension, it should be supported by all versions. This applies to >> other such patches as well. >> >> > GL 3.3 may have introduced a new feature on which this extension is > dependent. > If this feature is not contained within any other extension and our > context version > is less than 3.3, we may not be able to actually implement the extension > spec as > described. I will try to see if this is the case. I agree that technical > roadblocks should be the > only things which prevent us from advertising certain extensions. > > Thanks, > Nanley > > Marek >> >> On Tue, Oct 20, 2015 at 12:44 AM, Nanley Chery >> wrote: >> > From: Nanley Chery >> > >> > Stop leaks into GLES1/2 and pre-3.3 GL contexts in all uses. >> > >> > The extension spec lists OpenGL 3.3 as one of the requirements, so >> > update the extension table accordingly. >> > >> > v2. Require 3.3 for GL legacy contexts as well (Chad). >> > >> > Signed-off-by: Nanley Chery >> > --- >> > src/mesa/main/enable.c | 4 ++-- >> > src/mesa/main/extensions_table.h | 2 +- >> > src/mesa/main/glformats.c| 2 +- >> > src/mesa/main/queryobj.c | 2 +- >> > 4 files changed, 5 insertions(+), 5 deletions(-) >> > >> > diff --git a/src/mesa/main/enable.c b/src/mesa/main/enable.c >> > index 42f6799..ee95334 100644 >> > --- a/src/mesa/main/enable.c >> > +++ b/src/mesa/main/enable.c >> > @@ -972,7 +972,7 @@ _mesa_set_enable(struct gl_context *ctx, GLenum >> cap, GLboolean state) >> > break; >> > >> >case GL_PRIMITIVE_RESTART_FIXED_INDEX: >> > -if (!_mesa_is_gles3(ctx) && >> !ctx->Extensions.ARB_ES3_compatibility) >> > +if (!_mesa_is_gles3(ctx) && >> !_mesa_has_ARB_ES3_compatibility(ctx)) >> > goto invalid_enum_error; >> > if (ctx->Array.PrimitiveRestartFixedIndex != state) { >> > FLUSH_VERTICES(ctx, _NEW_TRANSFORM); >> > @@ -1582,7 +1582,7 @@ _mesa_IsEnabled( GLenum cap ) >> > return ctx->Array.PrimitiveRestart; >> > >> >case GL_PRIMITIVE_RESTART_FIXED_INDEX: >> > -if (!_mesa_is_gles3(ctx) && >> !ctx->Extensions.ARB_ES3_compatibility) { >> > +if (!_mesa_is_gles3(ctx) && >> !_mesa_has_ARB_ES3_compatibility(ctx)) { >> > goto invalid_enum_error; >> > } >> > return ctx->Array.PrimitiveRestartFixedIndex; >> > diff --git a/src/mesa/main/extensions_table.h >> b/src/mesa/main/extensions_table.h >> > index 62e0804..760fbe9 100644 >> > --- a/src/mesa/main/extensions_table.h >> > +++ b/src/mesa/main/extensions_table.h >> > @@ -4,7 +4,7 @@ >> > #define ES2 1u >> > #define x ~0u >> > EXT(ARB_ES2_compatibility , ARB_ES2_compatibility >> , GLL, GLC, x , x , 2009) >> > -EXT(ARB_ES3_compatibility , ARB_ES3_compatibility >> , GLL, GLC, x , x , 2012) >> > +EXT(ARB_ES3_compatibility , ARB_ES3_compatibility >> , 33, 33, x , x , 2012) >> > EXT(ARB_arrays_of_arrays, ARB_arrays_of_arrays >>, GLL, GLC, x , x , 2012) >> > EXT(ARB_base_instance , ARB_base_instance >> , GLL, GLC, x , x , 2011) >> > EXT(ARB_blend_func_extended , ARB_blend_fun
Re: [Mesa-dev] [RFC 15/21] mesa: Fix EXT_texture_sRGB functionality leaks
On Thu, Oct 22, 2015 at 12:15 PM, Chad Versace wrote: > On Mon 19 Oct 2015, Nanley Chery wrote: > > From: Nanley Chery > > > > Stop leaks into the following contexts: > >* GLES in _mesa_base_tex_format() and lookup_view_class(). > >* Pre-1.1 GL legacy contexts in all uses. > > > > Stop allowing compressed sRGB formats as valid formats in GLES3 > > contexts. I realized this was happening when CTS failures occured after > > fixing the extension functionality leak with the helper function. > > Do you mean that this patch *fixes* CTS failures? If so, which CTS for > which GLES version? There are so many CTS's in the world :( > I meant that when I first modified _mesa_base_tex_format() to use the helper function, I had failures in piglit, dEQP, and the Khronos CTS. "failures in every test-suite" probably would've been better than "CTS failures" here. It was because of those failures, that I realized that we were incorrectly allowing formats like GL_COMPRESSED_SRGB_EXT in GLES contexts. This motivated the split of the switch statement you see in the diff of _mesa_base_tex_format(). ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [RFC 09/21] mesa: Generate a helper function for each extension
On Thu, Oct 22, 2015 at 11:30 AM, Chad Versace wrote: > On Mon 19 Oct 2015, Nanley Chery wrote: > > From: Nanley Chery > > > > Generate functions which determine if an extension is supported in the > > current context. Initially, enums were going to be explicitly used with > > _mesa_extension_supported(). The idea to embed the function and enums > > into generated helper functions was suggested by Kristian Høgsberg. > > > > For performance, the function body no longer uses > > _mesa_extension_supported() and, as suggested by Chad Versace, the > > functions are also declared static inline. > > > > Signed-off-by: Nanley Chery > > --- > > src/mesa/main/context.h| 1 + > > src/mesa/main/extensions.c | 22 +- > > src/mesa/main/extensions.h | 39 +++ > > 3 files changed, 41 insertions(+), 21 deletions(-) > > [...] > > > diff --git a/src/mesa/main/extensions.h b/src/mesa/main/extensions.h > > index 595512a..24cc04d 100644 > > --- a/src/mesa/main/extensions.h > > +++ b/src/mesa/main/extensions.h > > @@ -55,6 +55,45 @@ _mesa_get_extension_count(struct gl_context *ctx); > > extern const GLubyte * > > _mesa_get_enabled_extension(struct gl_context *ctx, GLuint index); > > > > + > > +/** > > + * \brief An element of the \c extension_table. > > + */ > > +struct extension { > > In addition to Marek's comment, the struct should be prefixed too. > > After rereading the coding style guidelines, I've found that it only says that functions need to be prefixed. Should these two suggestions be added? > > + /** Name of extension, such as "GL_ARB_depth_clamp". */ > > + const char *name; > > + > > + /** Offset (in bytes) of the corresponding member in struct > gl_extensions. */ > > + size_t offset; > > + > > + /** Minimum version the extension requires for the given API > > +* (see gl_api defined in mtypes.h) > > +*/ > > + GLuint version[API_OPENGL_LAST + 1]; > > + > > + /** Year the extension was proposed or approved. Used to sort the > > +* extension string chronologically. */ > > + uint16_t year; > > +} extern const extension_table[]; > > [...] > > > +/** Checks if the context suports a user-facing extension */ > > +#define EXT(name_str, driver_cap, ...) \ > > +static inline bool _mesa_has_##name_str(const struct gl_context *ctx) { > \ > > + return ctx->Extensions.driver_cap && (ctx->Version >= \ > > + > extension_table[MESA_EXTENSION_##name_str].version[ctx->API]); \ > > +} > > +#include "extensions_table.h" > > +#undef EXT > > The function should be formatted like this, to follow Mesa style: > > |static inline bool > |_mesa_has_foo(...) > |{ > | ... > |} > Will do. ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH v6 2/2] mesa/teximage: accept ASTC formats for 3D texture specification
On Mon, Oct 26, 2015 at 11:15 AM, Neil Roberts wrote: > Nanley Chery writes: > > > + /* Throw an INVALID_OPERATION error if the target is > > + * TEXTURE_CUBE_MAP_ARRAY and the format is not ASTC. > > + */ > > + if (target_can_be_compresed && > > + ctx->Extensions.KHR_texture_compression_astc_ldr && > > + layout != MESA_FORMAT_LAYOUT_ASTC) > > return write_error(error, GL_INVALID_OPERATION); > > This seems to cause regressions in the following Piglit tests for Gen9: > > piglit.spec.ext_texture_compression_s3tc.getteximage-targets cube_array > s3tc > piglit.spec.arb_texture_cube_map_array.fbo-generatemipmap-cubemap array > s3tc_dxt1 > > I think the spec for the extension is based on the GLES spec. Perhaps > the intention was to add ASTC support for cube-map array textures > whereas previously in GLES no compressed formats were supported for this > target. However in regular GL presumably S3TC is supposed to be > supported. As it stands this patch disables cube-map array textures for > any formats other than ASTC whenever the ASTC extension is available, so > it disables S3TC on Gen9. > > Maybe this section should be limited to GLES? > > Limiting this to GLES sounds like a good solution. Note that there is similar logic for the TEXTURE_3D target further down. Nanley > Regards, > - Neil > ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH v6 2/2] mesa/teximage: accept ASTC formats for 3D texture specification
On Mon, Oct 26, 2015 at 11:53 AM, Roland Scheidegger wrote: > Am 26.10.2015 um 19:31 schrieb Ilia Mirkin: > > On Mon, Oct 26, 2015 at 2:15 PM, Neil Roberts > wrote: > >> Nanley Chery writes: > >> > >>> + /* Throw an INVALID_OPERATION error if the target is > >>> + * TEXTURE_CUBE_MAP_ARRAY and the format is not ASTC. > >>> + */ > >>> + if (target_can_be_compresed && > >>> + ctx->Extensions.KHR_texture_compression_astc_ldr && > >>> + layout != MESA_FORMAT_LAYOUT_ASTC) > >>> return write_error(error, GL_INVALID_OPERATION); > >> > >> This seems to cause regressions in the following Piglit tests for Gen9: > >> > >> piglit.spec.ext_texture_compression_s3tc.getteximage-targets cube_array > s3tc > >> piglit.spec.arb_texture_cube_map_array.fbo-generatemipmap-cubemap array > s3tc_dxt1 > >> > >> I think the spec for the extension is based on the GLES spec. Perhaps > >> the intention was to add ASTC support for cube-map array textures > >> whereas previously in GLES no compressed formats were supported for this > >> target. However in regular GL presumably S3TC is supposed to be > >> supported. As it stands this patch disables cube-map array textures for > >> any formats other than ASTC whenever the ASTC extension is available, so > >> it disables S3TC on Gen9. > >> > >> Maybe this section should be limited to GLES? > > > > I'm having trouble parsing what you're saying, but just want to > > confirm that s3tc is definitely supposed to work on cubemaps, at least > > in desktop GL. > > > > FWIW compressed textures (all formats) not working with cube map > _arrays_ is imho a spec bug in both GL and GLES (in GLES it's just more > explicit with newest spec as it has a table listing all the compressed > formats NOT working for cube map arrays). Seems to be a result of the > compressed formats being developed when cube map arrays weren't arround > thus most of the wording in the spec now only allows them for 2d, 2d > array, cube maps, but not cube map arrays, which totally doesn't make > sense. s3tc itself (in contrast to rgtc etc.) doesn't say anything wrt > to cubemap arrays (spec was updated for 2d arrays, but not cubemap > arrays, thus you could theoretically conclude one way or another, albeit > as I said not allowing them makes no sense imho just like it doesn't for > the other formats). > I've filed bugs for this at khronos bugtracker and it looks like at > least for gles it's going to get fixed (no word on GL, unfortunately). > Of course, binary blobs ignored this bit since forever already, and mesa > was changed to do the same too. Thus imho every test expecting cube map > targets to fail for compressed formats should be ignored. > > Thank you for filing the spec bugs. Nanley ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [RFC 15/21] mesa: Fix EXT_texture_sRGB functionality leaks
On Fri, Oct 23, 2015 at 3:01 PM, Nanley Chery wrote: > > > On Thu, Oct 22, 2015 at 12:15 PM, Chad Versace > wrote: > >> On Mon 19 Oct 2015, Nanley Chery wrote: >> > From: Nanley Chery >> > >> > Stop leaks into the following contexts: >> >* GLES in _mesa_base_tex_format() and lookup_view_class(). >> >* Pre-1.1 GL legacy contexts in all uses. >> > >> > Stop allowing compressed sRGB formats as valid formats in GLES3 >> > contexts. I realized this was happening when CTS failures occured after >> > fixing the extension functionality leak with the helper function. >> >> Do you mean that this patch *fixes* CTS failures? If so, which CTS for >> which GLES version? There are so many CTS's in the world :( >> > > I meant that when I first modified _mesa_base_tex_format() to use the > helper > function, I had failures in piglit, dEQP, and the Khronos CTS. "failures > in every > test-suite" probably would've been better than "CTS failures" here. It was > because of those failures, that I realized that we were incorrectly > allowing > formats like GL_COMPRESSED_SRGB_EXT in GLES contexts. This motivated > the split of the switch statement you see in the diff of > _mesa_base_tex_format(). > It seems that the note about what inspired this change is confusing (and likely unnecessary). I'll leave it out in the v2. ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [Mesa-stable] [PATCH] mesa: Enable ASTC in GLES' [NUM_]COMPRESSED_TEXTURE_FORMATS queries
On Mon, Oct 26, 2015 at 4:30 PM, Ian Romanick wrote: > Reviewed-by: Ian Romanick > > On 10/21/2015 03:06 PM, Nanley Chery wrote: > > From: Nanley Chery > > > > In OpenGL ES, the COMPRESSED_TEXTURE_FORMATS query returns the set of > > supported specific compressed formats. Since ASTC formats fit within > > that category, include them in the set and update the > > NUM_COMPRESSED_TEXTURE_FORMATS query as well. > > > > This enables GLES2-based ASTC dEQP tests to run. See the Bugzilla for > > more info. > > > > Cc: "11.0" > > I think we were mistaken about this... ASTC isn't actually in 11.0, is it? > > You're right. It is not in 11.0. > > Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=92193 > > Reported-by: Tapani Pälli > > Suggested-by: Ian Romanick > > Signed-off-by: Nanley Chery > > --- > > src/mesa/main/texcompress.c | 85 > + > > 1 file changed, 63 insertions(+), 22 deletions(-) > > > > diff --git a/src/mesa/main/texcompress.c b/src/mesa/main/texcompress.c > > index 84973d3..9d22586 100644 > > --- a/src/mesa/main/texcompress.c > > +++ b/src/mesa/main/texcompress.c > > @@ -243,28 +243,6 @@ _mesa_gl_compressed_format_base_format(GLenum > format) > > *what GL_NUM_COMPRESSED_TEXTURE_FORMATS and > > *GL_COMPRESSED_TEXTURE_FORMATS return." > > * > > - * The KHR_texture_compression_astc_hdr spec says: > > - * > > - *"Interactions with OpenGL 4.2 > > - * > > - *OpenGL 4.2 supports the feature that compressed textures can > be > > - *compressed online, by passing the compressed texture format > enum as > > - *the internal format when uploading a texture using TexImage1D, > > - *TexImage2D or TexImage3D (see Section 3.9.3, Texture Image > > - *Specification, subsection Encoding of Special Internal > Formats). > > - * > > - *Due to the complexity of the ASTC compression algorithm, it > is not > > - *usually suitable for online use, and therefore ASTC support > will be > > - *limited to pre-compressed textures only. Where on-device > compression > > - *is required, a domain-specific limited compressor will > typically > > - *be used, and this is therefore not suitable for > implementation in > > - *the driver. > > - * > > - *In particular, the ASTC format specifiers will not be added to > > - *Table 3.14, and thus will not be accepted by the TexImage*D > > - *functions, and will not be returned by the (already > deprecated) > > - *COMPRESSED_TEXTURE_FORMATS query." > > - * > > * There is no formal spec for GL_ATI_texture_compression_3dc. Since > the > > * formats added by this extension are luminance-alpha formats, it is > > * reasonable to expect them to follow the same rules as > > @@ -396,6 +374,69 @@ _mesa_get_compressed_formats(struct gl_context > *ctx, GLint *formats) > > n += 10; > >} > > } > > + > > + /* The KHR_texture_compression_astc_hdr spec says: > > +* > > +*"Interactions with OpenGL 4.2 > > +* > > +*OpenGL 4.2 supports the feature that compressed textures > can be > > +*compressed online, by passing the compressed texture > format enum as > > +*the internal format when uploading a texture using > TexImage1D, > > +*TexImage2D or TexImage3D (see Section 3.9.3, Texture Image > > +*Specification, subsection Encoding of Special Internal > Formats). > > +* > > +*Due to the complexity of the ASTC compression algorithm, > it is not > > +*usually suitable for online use, and therefore ASTC > support will be > > +*limited to pre-compressed textures only. Where on-device > compression > > +*is required, a domain-specific limited compressor will > typically > > +*be used, and this is therefore not suitable for > implementation in > > +*the driver. > > +* > > +*In particular, the ASTC format specifiers will not be > added to > > +*Table 3.14, and thus will not be accepted by the TexImage*D > > +*functions, and will not be returned by the (already > deprecated) > > +*COMPRESSED_TEXTURE_FORMATS query." > > +* > > +* The ES and the desktop
[Mesa-dev] [PATCH] mesa/teximage: Fix ASTC-caused S3TC regression
From: Nanley Chery The ASTC spec forbids other compressed formats from being used against the targets: TEXTURE_CUBE_MAP_ARRAY and TEXTURE_3D. Because other compressed formats were previously supported for these targets in desktop GL, it's considered to be a spec bug and Mesa will diverge from this behavior for desktop GL. Fixes the following Piglit tests on Gen9: piglit.spec.arb_direct_state_access.getcompressedtextureimage piglit.spec.arb_get_texture_sub_image.arb_get_texture_sub_image-getcompressed piglit.spec.arb_texture_cube_map_array.fbo-generatemipmap-cubemap array s3tc_dxt1 piglit.spec.ext_texture_compression_s3tc.getteximage-targets cube_array s3tc Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=91927 Suggested-by: Neil Roberts Signed-off-by: Nanley Chery --- src/mesa/main/teximage.c | 7 +-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c index d9453e3..eccf009 100644 --- a/src/mesa/main/teximage.c +++ b/src/mesa/main/teximage.c @@ -1373,7 +1373,8 @@ _mesa_target_can_be_compressed(const struct gl_context *ctx, GLenum target, /* Throw an INVALID_OPERATION error if the target is * TEXTURE_CUBE_MAP_ARRAY and the format is not ASTC. */ - if (target_can_be_compresed && + /* FIXME: Correct the spec to restrict this behavior to GLES as well. */ + if (target_can_be_compresed && _mesa_is_gles(ctx) && ctx->Extensions.KHR_texture_compression_astc_ldr && layout != MESA_FORMAT_LAYOUT_ASTC) return write_error(error, GL_INVALID_OPERATION); @@ -1405,7 +1406,9 @@ _mesa_target_can_be_compressed(const struct gl_context *ctx, GLenum target, * the format is not ASTC. * See comment in switch case GL_TEXTURE_CUBE_MAP_ARRAY for more info. */ - if (ctx->Extensions.KHR_texture_compression_astc_ldr) + /* FIXME: Correct the spec to restrict this behavior to GLES as well. */ + if (_mesa_is_gles(ctx) && + ctx->Extensions.KHR_texture_compression_astc_ldr) return write_error(error, GL_INVALID_OPERATION); break; } -- 2.6.2 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH v2] mesa/teximage: Fix S3TC regression due to ASTC interaction
From: Nanley Chery A prior, literal reading of the ASTC spec led to the prohibition of some compressed formats being used against the targets: TEXTURE_CUBE_MAP_ARRAY and TEXTURE_3D. Since the spec does not specify interactions with other extensions for specific compressed textures, remove such interactions. Fixes the following Piglit tests on Gen9: piglit.spec.arb_direct_state_access.getcompressedtextureimage piglit.spec.arb_get_texture_sub_image.arb_get_texture_sub_image-getcompressed piglit.spec.arb_texture_cube_map_array.fbo-generatemipmap-cubemap array s3tc_dxt1 piglit.spec.ext_texture_compression_s3tc.getteximage-targets cube_array s3tc v2. Don't interact with other specific compressed formats (Ian). Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=91927 Suggested-by: Neil Roberts Signed-off-by: Nanley Chery --- I've reworded the commit message and changed the logic to remove the interactions with other compressed textures. src/mesa/main/teximage.c | 43 +++ 1 file changed, 15 insertions(+), 28 deletions(-) diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c index d9453e3..ac7599f 100644 --- a/src/mesa/main/teximage.c +++ b/src/mesa/main/teximage.c @@ -1333,21 +1333,6 @@ _mesa_target_can_be_compressed(const struct gl_context *ctx, GLenum target, break; case GL_PROXY_TEXTURE_CUBE_MAP_ARRAY: case GL_TEXTURE_CUBE_MAP_ARRAY: - /* From section 3.8.6, page 146 of OpenGL ES 3.0 spec: - * - *"The ETC2/EAC texture compression algorithm supports only - * two-dimensional images. If internalformat is an ETC2/EAC format, - * glCompressedTexImage3D will generate an INVALID_OPERATION error if - * target is not TEXTURE_2D_ARRAY." - * - * This should also be applicable for glTexStorage3D(). Other available - * targets for these functions are: TEXTURE_3D and TEXTURE_CUBE_MAP_ARRAY. - */ - if (layout == MESA_FORMAT_LAYOUT_ETC2 && _mesa_is_gles3(ctx)) -return write_error(error, GL_INVALID_OPERATION); - - target_can_be_compresed = ctx->Extensions.ARB_texture_cube_map_array; - /* From the KHR_texture_compression_astc_hdr spec: * * Add a second new column "3D Tex." which is empty for all non-ASTC @@ -1368,16 +1353,24 @@ _mesa_target_can_be_compressed(const struct gl_context *ctx, GLenum target, * 8.19 is *not* checked' * * The instances of above should say . + * + * ETC2/EAC formats are the only alternative in GLES and thus such errors + * have already been handled by normal ETC2/EAC behavior. */ - /* Throw an INVALID_OPERATION error if the target is - * TEXTURE_CUBE_MAP_ARRAY and the format is not ASTC. + /* From section 3.8.6, page 146 of OpenGL ES 3.0 spec: + * + *"The ETC2/EAC texture compression algorithm supports only + * two-dimensional images. If internalformat is an ETC2/EAC format, + * glCompressedTexImage3D will generate an INVALID_OPERATION error if + * target is not TEXTURE_2D_ARRAY." + * + * This should also be applicable for glTexStorage3D(). Other available + * targets for these functions are: TEXTURE_3D and TEXTURE_CUBE_MAP_ARRAY. */ - if (target_can_be_compresed && - ctx->Extensions.KHR_texture_compression_astc_ldr && - layout != MESA_FORMAT_LAYOUT_ASTC) - return write_error(error, GL_INVALID_OPERATION); - + if (layout == MESA_FORMAT_LAYOUT_ETC2 && _mesa_is_gles3(ctx)) +return write_error(error, GL_INVALID_OPERATION); + target_can_be_compresed = ctx->Extensions.ARB_texture_cube_map_array; break; case GL_TEXTURE_3D: switch (layout) { @@ -1401,12 +1394,6 @@ _mesa_target_can_be_compressed(const struct gl_context *ctx, GLenum target, return write_error(error, GL_INVALID_OPERATION); break; default: - /* Throw an INVALID_OPERATION error if the target is TEXTURE_3D and - * the format is not ASTC. - * See comment in switch case GL_TEXTURE_CUBE_MAP_ARRAY for more info. - */ - if (ctx->Extensions.KHR_texture_compression_astc_ldr) -return write_error(error, GL_INVALID_OPERATION); break; } default: -- 2.6.2 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH v2 01/18] mesa/extensions: Remove array sentinel
From: Nanley Chery Simplify future updates to the extension struct array by removing the sentinel. Signed-off-by: Nanley Chery --- src/mesa/main/extensions.c | 43 +-- 1 file changed, 25 insertions(+), 18 deletions(-) diff --git a/src/mesa/main/extensions.c b/src/mesa/main/extensions.c index b2c88c3..389bbb0 100644 --- a/src/mesa/main/extensions.c +++ b/src/mesa/main/extensions.c @@ -405,8 +405,6 @@ static const struct extension extension_table[] = { { "GL_SGIS_texture_edge_clamp", o(dummy_true), GLL,1997 }, { "GL_SGIS_texture_lod",o(dummy_true), GLL,1997 }, { "GL_SUN_multi_draw_arrays", o(dummy_true), GLL,1999 }, - - { 0, 0, 0, 0 }, }; @@ -421,14 +419,14 @@ static const struct extension extension_table[] = { static size_t name_to_offset(const char* name) { - const struct extension *i; + unsigned i; if (name == 0) return 0; - for (i = extension_table; i->name != 0; ++i) { - if (strcmp(name, i->name) == 0) -return i->offset; + for (i = 0; i < ARRAY_SIZE(extension_table); ++i) { + if (strcmp(name, extension_table[i].name) == 0) +return extension_table[i].offset; } return 0; @@ -441,15 +439,16 @@ name_to_offset(const char* name) static void override_extensions_in_context(struct gl_context *ctx) { - const struct extension *i; + unsigned i; const GLboolean *enables = (GLboolean*) &_mesa_extension_override_enables; const GLboolean *disables = (GLboolean*) &_mesa_extension_override_disables; GLboolean *ctx_ext = (GLboolean*)&ctx->Extensions; - for (i = extension_table; i->name != 0; ++i) { - size_t offset = i->offset; + for (i = 0; i < ARRAY_SIZE(extension_table); ++i) { + size_t offset = extension_table[i].offset; + assert(!enables[offset] || !disables[offset]); if (enables[offset]) { ctx_ext[offset] = 1; @@ -773,7 +772,7 @@ _mesa_make_extension_string(struct gl_context *ctx) /* String of extra extensions. */ char *extra_extensions = get_extension_override(ctx); GLboolean *base = (GLboolean *) &ctx->Extensions; - const struct extension *i; + unsigned k; unsigned j; unsigned maxYear = ~0; unsigned api_set = (1 << ctx->API); @@ -794,7 +793,9 @@ _mesa_make_extension_string(struct gl_context *ctx) /* Compute length of the extension string. */ count = 0; - for (i = extension_table; i->name != 0; ++i) { + for (k = 0; k < ARRAY_SIZE(extension_table); ++k) { + const struct extension *i = extension_table + k; + if (base[i->offset] && i->year <= maxYear && (i->api_set & api_set)) { @@ -824,11 +825,13 @@ _mesa_make_extension_string(struct gl_context *ctx) * expect will fit into that buffer. */ j = 0; - for (i = extension_table; i->name != 0; ++i) { + for (k = 0; k < ARRAY_SIZE(extension_table); ++k) { + const struct extension *i = extension_table + k; + if (base[i->offset] && i->year <= maxYear && (i->api_set & api_set)) { - extension_indices[j++] = i - extension_table; + extension_indices[j++] = k; } } assert(j == count); @@ -837,7 +840,7 @@ _mesa_make_extension_string(struct gl_context *ctx) /* Build the extension string.*/ for (j = 0; j < count; ++j) { - i = &extension_table[extension_indices[j]]; + const struct extension *i = &extension_table[extension_indices[j]]; assert(base[i->offset] && (i->api_set & api_set)); strcat(exts, i->name); strcat(exts, " "); @@ -858,7 +861,7 @@ GLuint _mesa_get_extension_count(struct gl_context *ctx) { GLboolean *base; - const struct extension *i; + unsigned k; unsigned api_set = (1 << ctx->API); if (_mesa_is_gles3(ctx)) api_set |= ES3; @@ -870,7 +873,9 @@ _mesa_get_extension_count(struct gl_context *ctx) return ctx->Extensions.Count; base = (GLboolean *) &ctx->Extensions; - for (i = extension_table; i->name != 0; ++i) { + for (k = 0; k < ARRAY_SIZE(extension_table); ++k) { + const struct extension *i = extension_table + k; + if (base[i->offset] && (i->api_set & api_set)) { ctx->Extensions.Count++; } @@ -886,7 +891,7 @@ _mesa_get_enabled_extension(struct gl_context *ctx, GLuint index) { const GLboolean *base; size_t n; - const struct extension *i; + unsigned k; unsigned api_set = (1 << ctx->API); if (_mesa_is_gles3(ctx)) api_set |= ES3; @@ -895,7 +900,9 @@ _mesa_
[Mesa-dev] [PATCH v2 02/18] mesa/extensions: Wrap array entries in macros
From: Nanley Chery Now that we're using macros, remove the redundant text from each entry. Remove comments between the entries to make editing easier and separate the sections with blank lines. Structure the EXT macros in a way that helps reviewers verify that no meaning has been altered. Signed-off-by: Nanley Chery --- src/mesa/main/extensions.c | 645 +++-- 1 file changed, 323 insertions(+), 322 deletions(-) diff --git a/src/mesa/main/extensions.c b/src/mesa/main/extensions.c index 389bbb0..fb4d791 100644 --- a/src/mesa/main/extensions.c +++ b/src/mesa/main/extensions.c @@ -83,328 +83,329 @@ struct extension { * \brief Table of supported OpenGL extensions for all API's. */ static const struct extension extension_table[] = { - /* ARB Extensions */ - { "GL_ARB_ES2_compatibility", o(ARB_ES2_compatibility), GL, 2009 }, - { "GL_ARB_ES3_compatibility", o(ARB_ES3_compatibility), GL, 2012 }, - { "GL_ARB_arrays_of_arrays",o(ARB_arrays_of_arrays), GL, 2012 }, - { "GL_ARB_base_instance", o(ARB_base_instance), GL, 2011 }, - { "GL_ARB_blend_func_extended", o(ARB_blend_func_extended), GL, 2009 }, - { "GL_ARB_buffer_storage", o(ARB_buffer_storage), GL, 2013 }, - { "GL_ARB_clear_buffer_object", o(dummy_true), GL, 2012 }, - { "GL_ARB_clear_texture", o(ARB_clear_texture), GL, 2013 }, - { "GL_ARB_clip_control",o(ARB_clip_control), GL, 2014 }, - { "GL_ARB_color_buffer_float", o(ARB_color_buffer_float), GL, 2004 }, - { "GL_ARB_compressed_texture_pixel_storage",o(dummy_true), GL, 2011 }, - { "GL_ARB_compute_shader", o(ARB_compute_shader), GL, 2012 }, - { "GL_ARB_conditional_render_inverted", o(ARB_conditional_render_inverted), GL, 2014 }, - { "GL_ARB_copy_buffer", o(dummy_true), GL, 2008 }, - { "GL_ARB_copy_image", o(ARB_copy_image), GL, 2012 }, - { "GL_ARB_conservative_depth", o(ARB_conservative_depth), GL, 2011 }, - { "GL_ARB_debug_output",o(dummy_true), GL, 2009 }, - { "GL_ARB_depth_buffer_float", o(ARB_depth_buffer_float), GL, 2008 }, - { "GL_ARB_depth_clamp", o(ARB_depth_clamp), GL, 2003 }, - { "GL_ARB_depth_texture", o(ARB_depth_texture), GLL,2001 }, - { "GL_ARB_derivative_control", o(ARB_derivative_control), GL, 2014 }, - { "GL_ARB_direct_state_access", o(dummy_true), GLC,2014 }, - { "GL_ARB_draw_buffers",o(dummy_true), GL, 2002 }, - { "GL_ARB_draw_buffers_blend", o(ARB_draw_buffers_blend), GL, 2009 }, - { "GL_ARB_draw_elements_base_vertex", o(ARB_draw_elements_base_vertex), GL, 2009 }, - { "GL_ARB_draw_indirect", o(ARB_draw_indirect), GLC,2010 }, - { "GL_ARB_draw_instanced", o(ARB_draw_instanced), GL, 2008 }, - { "GL_ARB_explicit_attrib_location", o(ARB_explicit_attrib_location),GL, 2009 }, - { "GL_ARB_explicit_uniform_location", o(ARB_explicit_uniform_location), GL, 2012 }, - { "GL_ARB_fragment_coord_conventions", o(ARB_fragment_coord_conventions), GL, 2009 }, - { "GL_ARB_fragment_layer_viewport", o(ARB_fragment_layer_viewport), GLC,2012 }, - { "GL_ARB_fragment_program",o(ARB_fragment_program),
[Mesa-dev] [PATCH v2 03/18] mesa/extensions: Move entries entries to seperate file
From: Nanley Chery With this infrastructure set in place, we can now reuse the entries to generate useful code. v2. Add the new file into Makefile.sources (Emil) Signed-off-by: Nanley Chery --- src/mesa/Makefile.sources| 1 + src/mesa/main/extensions.c | 321 +-- src/mesa/main/extensions_table.h | 320 ++ 3 files changed, 322 insertions(+), 320 deletions(-) create mode 100644 src/mesa/main/extensions_table.h diff --git a/src/mesa/Makefile.sources b/src/mesa/Makefile.sources index de0e330..778b92d 100644 --- a/src/mesa/Makefile.sources +++ b/src/mesa/Makefile.sources @@ -77,6 +77,7 @@ MAIN_FILES = \ main/execmem.c \ main/extensions.c \ main/extensions.h \ + main/extensions_table.h \ main/fbobject.c \ main/fbobject.h \ main/feedback.c \ diff --git a/src/mesa/main/extensions.c b/src/mesa/main/extensions.c index fb4d791..30f5b98 100644 --- a/src/mesa/main/extensions.c +++ b/src/mesa/main/extensions.c @@ -85,326 +85,7 @@ struct extension { static const struct extension extension_table[] = { #define EXT(name_str, driver_cap, api_flags, ) \ { .name = "GL_" #name_str, .offset = o(driver_cap), .api_set = api_flags, .year = }, -EXT(ARB_ES2_compatibility , ARB_ES2_compatibility , GL , 2009) -EXT(ARB_ES3_compatibility , ARB_ES3_compatibility , GL , 2012) -EXT(ARB_arrays_of_arrays, ARB_arrays_of_arrays , GL , 2012) -EXT(ARB_base_instance , ARB_base_instance , GL , 2011) -EXT(ARB_blend_func_extended , ARB_blend_func_extended , GL , 2009) -EXT(ARB_buffer_storage , ARB_buffer_storage , GL , 2013) -EXT(ARB_clear_buffer_object , dummy_true , GL , 2012) -EXT(ARB_clear_texture , ARB_clear_texture , GL , 2013) -EXT(ARB_clip_control, ARB_clip_control , GL , 2014) -EXT(ARB_color_buffer_float , ARB_color_buffer_float , GL , 2004) -EXT(ARB_compressed_texture_pixel_storage, dummy_true , GL , 2011) -EXT(ARB_compute_shader , ARB_compute_shader , GL , 2012) -EXT(ARB_conditional_render_inverted , ARB_conditional_render_inverted , GL , 2014) -EXT(ARB_copy_buffer , dummy_true , GL , 2008) -EXT(ARB_copy_image , ARB_copy_image , GL , 2012) -EXT(ARB_conservative_depth , ARB_conservative_depth , GL , 2011) -EXT(ARB_debug_output, dummy_true , GL , 2009) -EXT(ARB_depth_buffer_float , ARB_depth_buffer_float , GL , 2008) -EXT(ARB_depth_clamp , ARB_depth_clamp , GL , 2003) -EXT(ARB_depth_texture , ARB_depth_texture , GLL , 2001) -EXT(ARB_derivative_control , ARB_derivative_control , GL , 2014) -EXT(ARB_direct_state_access , dummy_true , GLC , 2014) -EXT(ARB_draw_buffers, dummy_true , GL , 2002) -EXT(ARB_draw_buffers_blend , ARB_draw_buffers_blend , GL , 2009) -EXT(ARB_draw_elements_base_vertex , ARB_draw_elements_base_vertex , GL , 2009) -EXT(ARB_draw_indirect , ARB_draw_indirect , GLC , 2010) -EXT(ARB_draw_instanced , ARB_draw_instanced , GL , 2008) -EXT(ARB_explicit_attrib_location, ARB_explicit_attrib_location , GL , 2009) -EXT(ARB_explicit_uniform_location , ARB_explicit_uniform_location , GL , 2012) -EXT(ARB_fragment_coord_conventions , ARB_fragment_coord_conventions , GL , 2009) -EXT(ARB_fragment_layer_viewport , ARB_fragment_layer_viewport , GLC , 2012) -EXT(ARB_fragme
[Mesa-dev] [PATCH v2 05/18] mesa/extensions: Create _mesa_extension_supported()
From: Nanley Chery Create a function which determines if an extension is supported in the current context. v2. Use common variable names (Emil) Insert new line between variables and return statement (Chad) Rename api_set variable to api_bit (Chad) Signed-off-by: Nanley Chery --- src/mesa/main/extensions.c | 18 ++ 1 file changed, 18 insertions(+) diff --git a/src/mesa/main/extensions.c b/src/mesa/main/extensions.c index 4fd7487..83c4921 100644 --- a/src/mesa/main/extensions.c +++ b/src/mesa/main/extensions.c @@ -426,6 +426,24 @@ typedef unsigned short extension_index; /** + * Given an extension enum, return whether or not the extension is supported + * dependent on the following factors: + * There's driver support and the OpenGL/ES version is at least that + * specified in the extension_table. + */ +static inline bool +_mesa_extension_supported(const struct gl_context *ctx, extension_index i) +{ + const bool *base = (bool *) &ctx->Extensions; + const struct extension *ext = extension_table + i; + const uint8_t api_bit = 1 << ctx->API; + + return (ext->api_set & api_bit) && + (ctx->Version >= ext->version[ctx->API]) && + base[ext->offset]; +} + +/** * Compare two entries of the extensions table. Sorts first by year, * then by name. * -- 2.6.2 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH v2 06/18] mesa/extensions: Use _mesa_extension_supported()
From: Nanley Chery Replace open-coded checks for extension support with _mesa_extension_supported(). Signed-off-by: Nanley Chery --- src/mesa/main/extensions.c | 54 src/mesa/main/extensions_table.h | 6 ++--- 2 files changed, 14 insertions(+), 46 deletions(-) diff --git a/src/mesa/main/extensions.c b/src/mesa/main/extensions.c index 83c4921..1ce73f3 100644 --- a/src/mesa/main/extensions.c +++ b/src/mesa/main/extensions.c @@ -49,8 +49,6 @@ enum { GL = (1 << API_OPENGL_COMPAT) | (1 << API_OPENGL_CORE), ES1 = 1 << API_OPENGLES, ES2 = 1 << API_OPENGLES2, - ES3 = 1 << (API_OPENGL_LAST + 1), - ES31 = 1 << (API_OPENGL_LAST + 2), }; /** @@ -485,15 +483,9 @@ _mesa_make_extension_string(struct gl_context *ctx) extension_index *extension_indices; /* String of extra extensions. */ char *extra_extensions = get_extension_override(ctx); - GLboolean *base = (GLboolean *) &ctx->Extensions; unsigned k; unsigned j; unsigned maxYear = ~0; - unsigned api_set = (1 << ctx->API); - if (_mesa_is_gles3(ctx)) - api_set |= ES3; - if (_mesa_is_gles31(ctx)) - api_set |= ES31; /* Check if the MESA_EXTENSION_MAX_YEAR env var is set */ { @@ -510,9 +502,8 @@ _mesa_make_extension_string(struct gl_context *ctx) for (k = 0; k < ARRAY_SIZE(extension_table); ++k) { const struct extension *i = extension_table + k; - if (base[i->offset] && - i->year <= maxYear && - (i->api_set & api_set)) { + if (i->year <= maxYear && + _mesa_extension_supported(ctx, k)) { length += strlen(i->name) + 1; /* +1 for space */ ++count; } @@ -540,11 +531,8 @@ _mesa_make_extension_string(struct gl_context *ctx) */ j = 0; for (k = 0; k < ARRAY_SIZE(extension_table); ++k) { - const struct extension *i = extension_table + k; - - if (base[i->offset] && - i->year <= maxYear && - (i->api_set & api_set)) { + if (extension_table[k].year <= maxYear && + _mesa_extension_supported(ctx, k)) { extension_indices[j++] = k; } } @@ -555,7 +543,7 @@ _mesa_make_extension_string(struct gl_context *ctx) /* Build the extension string.*/ for (j = 0; j < count; ++j) { const struct extension *i = &extension_table[extension_indices[j]]; - assert(base[i->offset] && (i->api_set & api_set)); + assert(_mesa_extension_supported(ctx, extension_indices[j])); strcat(exts, i->name); strcat(exts, " "); } @@ -574,25 +562,15 @@ _mesa_make_extension_string(struct gl_context *ctx) GLuint _mesa_get_extension_count(struct gl_context *ctx) { - GLboolean *base; unsigned k; - unsigned api_set = (1 << ctx->API); - if (_mesa_is_gles3(ctx)) - api_set |= ES3; - if (_mesa_is_gles31(ctx)) - api_set |= ES31; /* only count once */ if (ctx->Extensions.Count != 0) return ctx->Extensions.Count; - base = (GLboolean *) &ctx->Extensions; for (k = 0; k < ARRAY_SIZE(extension_table); ++k) { - const struct extension *i = extension_table + k; - - if (base[i->offset] && (i->api_set & api_set)) { + if (_mesa_extension_supported(ctx, k)) ctx->Extensions.Count++; - } } return ctx->Extensions.Count; } @@ -603,23 +581,13 @@ _mesa_get_extension_count(struct gl_context *ctx) const GLubyte * _mesa_get_enabled_extension(struct gl_context *ctx, GLuint index) { - const GLboolean *base; - size_t n; - unsigned k; - unsigned api_set = (1 << ctx->API); - if (_mesa_is_gles3(ctx)) - api_set |= ES3; - if (_mesa_is_gles31(ctx)) - api_set |= ES31; - - base = (GLboolean*) &ctx->Extensions; - n = 0; - for (k = 0; k < ARRAY_SIZE(extension_table); ++k) { - const struct extension *i = extension_table + k; + size_t n = 0; + unsigned i; - if (base[i->offset] && (i->api_set & api_set)) { + for (i = 0; i < ARRAY_SIZE(extension_table); ++i) { + if (_mesa_extension_supported(ctx, i)) { if (n == index) -return (const GLubyte*) i->name; +return (const GLubyte*) extension_table[i].name; else ++n; } diff --git a/src/mesa/main/extensions_table.h b/src/mesa/main/extensions_table.h index 24a0908..fecb402 100644 --- a/src/mesa/main/extensions_table.h +++ b/src/mesa/main/extensions_table.h @@ -167,7 +167,7 @@ EXT(EXT_rescale_normal , dummy_true EXT(EXT_secondary_color , dummy_true , GLL, 0, 0, 0, 0, 1999) EXT(EXT_separate_shader_objects , dummy_true ,
[Mesa-dev] [PATCH v2 04/18] mesa/extensions: Add extension::version
From: Nanley Chery Enable limiting advertised extension support by context version with finer granularity. v2. Use uint*t type for version and note the expected values (Emil) Use an 8-bit wide datatype. Reformat macro for better readability (Chad) Signed-off-by: Nanley Chery --- src/mesa/main/extensions.c | 18 +- src/mesa/main/extensions_table.h | 626 +++ 2 files changed, 329 insertions(+), 315 deletions(-) diff --git a/src/mesa/main/extensions.c b/src/mesa/main/extensions.c index 30f5b98..4fd7487 100644 --- a/src/mesa/main/extensions.c +++ b/src/mesa/main/extensions.c @@ -66,6 +66,12 @@ struct extension { /** Set of API's in which the extension exists, as a bitset. */ uint8_t api_set; + /** Minimum version the extension requires for the given API +* (see gl_api defined in mtypes.h). The value is equal to: +* 10 * major_version + minor_version +*/ + uint8_t version[API_OPENGL_LAST + 1]; + /** Year the extension was proposed or approved. Used to sort the * extension string chronologically. */ uint16_t year; @@ -83,8 +89,16 @@ struct extension { * \brief Table of supported OpenGL extensions for all API's. */ static const struct extension extension_table[] = { -#define EXT(name_str, driver_cap, api_flags, ) \ -{ .name = "GL_" #name_str, .offset = o(driver_cap), .api_set = api_flags, .year = }, +#define EXT(name_str, driver_cap, api_flags, gll_ver, glc_ver, gles_ver, gles2_ver, ) \ +{ .name = "GL_" #name_str, .offset = o(driver_cap), .api_set = api_flags, \ + .version = { \ +[API_OPENGL_COMPAT] = gll_ver, \ +[API_OPENGL_CORE] = glc_ver, \ +[API_OPENGLES] = gles_ver, \ +[API_OPENGLES2] = gles2_ver, \ + }, \ + .year = \ +}, #include "extensions_table.h" #undef EXT }; diff --git a/src/mesa/main/extensions_table.h b/src/mesa/main/extensions_table.h index 59f2224..24a0908 100644 --- a/src/mesa/main/extensions_table.h +++ b/src/mesa/main/extensions_table.h @@ -1,320 +1,320 @@ -EXT(ARB_ES2_compatibility , ARB_ES2_compatibility , GL , 2009) -EXT(ARB_ES3_compatibility , ARB_ES3_compatibility , GL , 2012) -EXT(ARB_arrays_of_arrays, ARB_arrays_of_arrays , GL , 2012) -EXT(ARB_base_instance , ARB_base_instance , GL , 2011) -EXT(ARB_blend_func_extended , ARB_blend_func_extended , GL , 2009) -EXT(ARB_buffer_storage , ARB_buffer_storage , GL , 2013) -EXT(ARB_clear_buffer_object , dummy_true , GL , 2012) -EXT(ARB_clear_texture , ARB_clear_texture , GL , 2013) -EXT(ARB_clip_control, ARB_clip_control , GL , 2014) -EXT(ARB_color_buffer_float , ARB_color_buffer_float , GL , 2004) -EXT(ARB_compressed_texture_pixel_storage, dummy_true , GL , 2011) -EXT(ARB_compute_shader , ARB_compute_shader , GL , 2012) -EXT(ARB_conditional_render_inverted , ARB_conditional_render_inverted , GL , 2014) -EXT(ARB_copy_buffer , dummy_true , GL , 2008) -EXT(ARB_copy_image , ARB_copy_image , GL , 2012) -EXT(ARB_conservative_depth , ARB_conservative_depth , GL , 2011) -EXT(ARB_debug_output, dummy_true , GL , 2009) -EXT(ARB_depth_buffer_float , ARB_depth_buffer_float , GL , 2008) -EXT(ARB_depth_clamp , ARB_depth_clamp , GL , 2003) -EXT(ARB_depth_texture , ARB_depth_texture , GLL , 2001) -EXT(ARB_derivative_control , ARB_derivative_control , GL , 2014) -EXT(ARB_direct_state_access , dummy_true , GLC , 2014) -EXT(ARB_draw_buffers, dummy_true , GL , 2002) -EXT(ARB_draw_buffers_blend , ARB_draw_buffers_blend
[Mesa-dev] [PATCH v2 13/18] mesa: Fix ASTC extension functionality leak into GLES 1
From: Nanley Chery Stop a leak of ASTC functionality into GLES 1 contexts. v2. Handle ASTC driver capability check in texcompress.c Signed-off-by: Nanley Chery --- src/mesa/main/glformats.c | 4 ++-- src/mesa/main/texcompress.c | 2 +- src/mesa/main/teximage.c| 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/mesa/main/glformats.c b/src/mesa/main/glformats.c index 5610de2..f37b5da 100644 --- a/src/mesa/main/glformats.c +++ b/src/mesa/main/glformats.c @@ -1331,7 +1331,7 @@ _mesa_is_compressed_format(const struct gl_context *ctx, GLenum format) return _mesa_is_desktop_gl(ctx) && ctx->Extensions.ARB_texture_compression_bptc; case MESA_FORMAT_LAYOUT_ASTC: - return ctx->Extensions.KHR_texture_compression_astc_ldr; + return _mesa_has_KHR_texture_compression_astc_ldr(ctx); default: return GL_FALSE; } @@ -2281,7 +2281,7 @@ _mesa_base_tex_format(const struct gl_context *ctx, GLint internalFormat) return base_compressed; } - if (ctx->Extensions.KHR_texture_compression_astc_ldr && + if (_mesa_has_KHR_texture_compression_astc_ldr(ctx) && _mesa_is_astc_format(internalFormat)) return GL_RGBA; diff --git a/src/mesa/main/texcompress.c b/src/mesa/main/texcompress.c index 59bb0e1..2cc8a72 100644 --- a/src/mesa/main/texcompress.c +++ b/src/mesa/main/texcompress.c @@ -401,7 +401,7 @@ _mesa_get_compressed_formats(struct gl_context *ctx, GLint *formats) * query returns the set of supported specific compressed formats. */ if (ctx->API == API_OPENGLES2 && - ctx->Extensions.KHR_texture_compression_astc_ldr) { + _mesa_has_KHR_texture_compression_astc_ldr(ctx)) { if (formats) { formats[n++] = GL_COMPRESSED_RGBA_ASTC_4x4_KHR; formats[n++] = GL_COMPRESSED_RGBA_ASTC_5x4_KHR; diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c index d9453e3..c14f941 100644 --- a/src/mesa/main/teximage.c +++ b/src/mesa/main/teximage.c @@ -1374,7 +1374,7 @@ _mesa_target_can_be_compressed(const struct gl_context *ctx, GLenum target, * TEXTURE_CUBE_MAP_ARRAY and the format is not ASTC. */ if (target_can_be_compresed && - ctx->Extensions.KHR_texture_compression_astc_ldr && + _mesa_has_KHR_texture_compression_astc_ldr(ctx) && layout != MESA_FORMAT_LAYOUT_ASTC) return write_error(error, GL_INVALID_OPERATION); @@ -1391,7 +1391,7 @@ _mesa_target_can_be_compressed(const struct gl_context *ctx, GLenum target, break; case MESA_FORMAT_LAYOUT_ASTC: target_can_be_compresed = - ctx->Extensions.KHR_texture_compression_astc_hdr; + _mesa_has_KHR_texture_compression_astc_hdr(ctx); /* Throw an INVALID_OPERATION error if the target is TEXTURE_3D and * and the hdr extension is not supported. @@ -1405,7 +1405,7 @@ _mesa_target_can_be_compressed(const struct gl_context *ctx, GLenum target, * the format is not ASTC. * See comment in switch case GL_TEXTURE_CUBE_MAP_ARRAY for more info. */ - if (ctx->Extensions.KHR_texture_compression_astc_ldr) + if (_mesa_has_KHR_texture_compression_astc_ldr(ctx)) return write_error(error, GL_INVALID_OPERATION); break; } -- 2.6.2 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH v2 07/18] mesa/extensions: Replace extension::api_set with ::version
From: Nanley Chery The api_set field has no users outside of _mesa_extension_supported(). Remove it and allow the version field to take its place. The brunt of the transformation was performed with the following vim commands: s/\(GL [^,]\+\),\s*\d*,\s*\d*\(,\s*\d*\)\(,\s*\d*\)/\1, GLL, GLC\2\3/g s/\(GLL [^,]\+\)\,\s*\d*/\1, GLL/g s/\(GLC [^,]\+\)\(,\s*\d*\),\s*\d*\(,\s*\d*\)\(,\s*\d*\)/\1\2, GLC\3\4/g s/\( ES1[^,]*\)\(,\s*\(\w\|\d\)\+\)\(,\s*\(\w\|\d\)\+\),\s*\d*/\1\2\4, ES1/g s/\( ES2[^,]*\)\(,\s*\(\w\|\d\)\+\)\(,\s*\(\w\|\d\)\+\)\(,\s*\(\w\|\d\)\+\),\s*\d*/\1\2\4\6, ES2/g Signed-off-by: Nanley Chery --- src/mesa/main/extensions.c | 21 +- src/mesa/main/extensions_table.h | 636 --- 2 files changed, 326 insertions(+), 331 deletions(-) diff --git a/src/mesa/main/extensions.c b/src/mesa/main/extensions.c index 1ce73f3..c7609be 100644 --- a/src/mesa/main/extensions.c +++ b/src/mesa/main/extensions.c @@ -42,15 +42,6 @@ struct gl_extensions _mesa_extension_override_disables; static char *extra_extensions = NULL; static char *cant_disable_extensions = NULL; -enum { - DISABLE = 0, - GLL = 1 << API_OPENGL_COMPAT, /* GL Legacy / Compatibility */ - GLC = 1 << API_OPENGL_CORE, /* GL Core */ - GL = (1 << API_OPENGL_COMPAT) | (1 << API_OPENGL_CORE), - ES1 = 1 << API_OPENGLES, - ES2 = 1 << API_OPENGLES2, -}; - /** * \brief An element of the \c extension_table. */ @@ -61,9 +52,6 @@ struct extension { /** Offset (in bytes) of the corresponding member in struct gl_extensions. */ size_t offset; - /** Set of API's in which the extension exists, as a bitset. */ - uint8_t api_set; - /** Minimum version the extension requires for the given API * (see gl_api defined in mtypes.h). The value is equal to: * 10 * major_version + minor_version @@ -87,8 +75,8 @@ struct extension { * \brief Table of supported OpenGL extensions for all API's. */ static const struct extension extension_table[] = { -#define EXT(name_str, driver_cap, api_flags, gll_ver, glc_ver, gles_ver, gles2_ver, ) \ -{ .name = "GL_" #name_str, .offset = o(driver_cap), .api_set = api_flags, \ +#define EXT(name_str, driver_cap, gll_ver, glc_ver, gles_ver, gles2_ver, ) \ +{ .name = "GL_" #name_str, .offset = o(driver_cap), \ .version = { \ [API_OPENGL_COMPAT] = gll_ver, \ [API_OPENGL_CORE] = glc_ver, \ @@ -434,11 +422,8 @@ _mesa_extension_supported(const struct gl_context *ctx, extension_index i) { const bool *base = (bool *) &ctx->Extensions; const struct extension *ext = extension_table + i; - const uint8_t api_bit = 1 << ctx->API; - return (ext->api_set & api_bit) && - (ctx->Version >= ext->version[ctx->API]) && - base[ext->offset]; + return (ctx->Version >= ext->version[ctx->API]) && base[ext->offset]; } /** diff --git a/src/mesa/main/extensions_table.h b/src/mesa/main/extensions_table.h index fecb402..c1b0192 100644 --- a/src/mesa/main/extensions_table.h +++ b/src/mesa/main/extensions_table.h @@ -1,320 +1,330 @@ -EXT(ARB_ES2_compatibility , ARB_ES2_compatibility , GL , 0, 0, 0, 0, 2009) -EXT(ARB_ES3_compatibility , ARB_ES3_compatibility , GL , 0, 0, 0, 0, 2012) -EXT(ARB_arrays_of_arrays, ARB_arrays_of_arrays , GL , 0, 0, 0, 0, 2012) -EXT(ARB_base_instance , ARB_base_instance , GL , 0, 0, 0, 0, 2011) -EXT(ARB_blend_func_extended , ARB_blend_func_extended , GL , 0, 0, 0, 0, 2009) -EXT(ARB_buffer_storage , ARB_buffer_storage , GL , 0, 0, 0, 0, 2013) -EXT(ARB_clear_buffer_object , dummy_true , GL , 0, 0, 0, 0, 2012) -EXT(ARB_clear_texture , ARB_clear_texture , GL , 0, 0, 0, 0, 2013) -EXT(ARB_clip_control, ARB_clip_control , GL , 0, 0, 0, 0, 2014) -EXT(ARB_color_buffer_float , ARB_color_buffer_float , GL , 0, 0, 0, 0, 2004) -EXT(ARB_compressed_texture_pixel_storage, dummy_true , GL , 0, 0, 0, 0, 2011) -EXT(ARB_compute_shader , ARB_compute_shader , GL , 0, 0, 0, 0, 2012) -EXT(ARB_conditional_render_inverted , ARB_conditional_render_inverted , GL , 0, 0, 0, 0, 2014) -EXT(ARB_copy_buffer ,