-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Pre-release pass #123
Comments
That's the intention.
I'm not sure I'm parsing your question correctly. The placement of mipPadding and wording in the spec. shows it is only used for non-supercompressed data. That takes care of one way to parse the question. If the question rather is "is mipPadding needed when you independently inflate a supercompressed level?" then the answer is yes. The purpose is to match GPU API alignment requirements and thus enable use of mmapping.
The original OpenGL cube mapping extension explicitly states that the coordinate system within the cube is left-handed, i.e. not aligned with OpenGL. Perhaps my interpretation of the equations for direction to face/UV mapping is wrong but they appear to constitute a left-handed coordinate system with +Y up and require that the images have a top down orientation. Vulkan has exactly the same equations so yes, the cube coordinate system is aligned with neither.
That is exactly what I am trying to achieve.
It depends how big it is. Let's discuss when we see it.
Would you care to take a stab at it? How best to create a flowchart? Is there some Asciidoctor way or must we create an image for inclusion? I'll take care of the language fixes you've pointed out. |
I've fixed the typos and checked off the items above. Hope my edits to the issue stick. |
OK, looks like I was confused by the text before
Let's say there's a KTX2 file without supercompression applied. Its layout would be:
Let's apply zstd to it. The layout would change to:
Now, to mmap inflated data at runtime, an application would need to manually add required padding between levels, right? |
In libktx, if I am inflating the entire texture I do manually add the padding so levels are aligned correctly. I think this detail is outside the scope of the spec., perhaps an informative note or tip?
Please check the equations in the specs. I'd like confirmation of my interpretation. While I'm confident that they define a left-handed system and that images need to have a top-down orientation, I am less confident about +Y being up. I may have been influenced by all the examples I've looked at having the sky as the +Y image. For example all the cube maps at http://www.humus.name. |
I think we should emphasize that supercompressed payload does not include padding that would be present otherwise.
Will do. |
@lexaknyazev I've been looking at how to create the flowchart you suggested. The best tool among those supported by asciidoctor-diagram is Mermaid. Unfortunately it has a dependency on Puppeteer and headless Chromium which is huge (> 116MB). I think that is too big. Do you have any suggestions? |
|
|
In a .basis file Like .basis, KTX says the flag is only used for animation sequences. So I think the current sense of the flag is correct. Only if there was some reason to set the flag for non-animated array textures would there be reason to change. I can't see any purpose for the flag in a non-animated array.
I can't see 1D array textures being an issue. I'm consulting Rich about cube map array textures. |
An I-Frame is just a regular slice that could be used in any texture type, while a P-Frame could exist only in a video sequence. My point is that the flag is technically present in all slices and is always unset in non-animated assets. So an extra rule is needed to "define" this flag only for animated assets. FWIW, the transcoder does not even check for this flag (currently) and assumes that only the first frame is an I-Frame while all subsequent frames are P-Frames.
1D arrays have pixel height of For cube map arrays, the transcoder has to either maintain 6 parallel video streams or to flatten a cube map array to a 2D array (the latter may be sub-optimal). |
Only in KTX, so we can distinguish 1D textures from 2D textures with a height of 1. In reality they have a height of 1. the only reason for needing to distinguish is to select the desired OpenGL texture target.
There is such a rule. Are you saying you want to remove that rule?
Yes, of course. I momentarily forgot. It's block compressed textures that are the issue whether or not they are supercompressed. I think there are some words somewhere about following restrictions laid out in the relevant KDFS section for the format. I think it is only a minority of formats where the pixel size has to be rounded to block size. Most of them allow exact pixel sizes with the remaining pixels in a the last block being ignored somehow. |
In my opinion, having the flag set for P-Frames would simplify the definitions so that such a rule could be removed.
|
It doesn't change much. Here's the rewrite:
I okay with this change so I have done it. The code impact is minimal. I kept the same value as the .basis cSliceDescFrameIsIFrame so I can just xor between them. |
Do you remember why we added these requirements? I see Vulkan doesn't place any format-related restrictions on image extents not even for PVRTC1 so it seems like a good idea to relax these. Do any of the OpenGL extensions place restrictions on the image width & height for CompressedTexImage* or TexStorage* functions? Should I just remove these 3 bullet items?
|
WEBGL_compressed_texture_s3tc has this restriction not found in OpenGL: When level equals zero width and height must be a multiple of 4. When level is greater than 0 width and height must be 0, 1, 2 or a multiple of 4. I am trying to find out why. But in view of this maybe we should leave the restrictions in place. |
I think that these restrictions should be removed anyway. As long as libktx (or an alternative implementation) is aware of compressed block sizes and an application is aware of runtime API limitations, the latter could figure out how to load such a texture. The file format design shouldn't be bound to the decades-old platform-specific issues. The spec should still avoid any ambiguity wrt unaligned dimensions. For example, 5x5 BC1 should normatively take 4 blocks (filled 4x4, 4x1, 1x4, 1x1) with 39 pixels unused. We may need to clarify how orientation metadata should be treated for unused pixels. We may need to double-check if any special care is needed for PVRTC. |
Any clever ideas on how to do this? The obvious rounding up to the next multiple of the block size will result in edge artifacts.
Where does the 1x1 come into it? Do we need to do this. Don't the format specs already discuss how to handle partially filled blocks?
What do you mean?
Please do. |
I don't think there's any universal solution. Textures are usually shipped within an application rather than on their own, so it's developer's responsibility to avoid unaligned BC1 on WebGL.
The issue is with
In the 5x5 example above, where is the origin for |
The spec says - in the description of KTXorientation -
So the full block would be at the
Please propose something. |
@lexaknyazev Please look at the cube map issue discussed earlier in this issue. |
@lexaknyazev there are 2 items remaining to be checked off:
(I've checked these items in the discussion above and repeated them here so as to avoid having to repeatedly scroll through the long discussion.) For the first, please review and make any suggestions for improvement. For the second, I think you created an informative flowchart. Please add it to the spec. |
@lexaknyazev do you still want to add the informative flowchart? If so, please submit a PR. Please review the cubemap orientation stuff and suggest any changes you think necessary. I want to close this issue. |
We have a separate document on transcode target selection now. |
Cubemaps
The tables given in OpenGL and Vulkan specs are a bit more subtle. They define origins for each face without explicitly orienting the whole cube or even stating its handedness. Still, the "skybox" example is likely the easiest way to visualize it:
Anyway, these details are applicable only when KTX cannot make any assumptions about a coordinate system that a particular application may use during texel fetches from a cubemap. Moreover, although KTX uses top-left origin by default, it could be altered by So, the two configurations are possible for applications that use
These could be normatively defined either by copying the Vulkan / OpenGL table here or by making a simple set of labeled images with per-face origins marked.
The correct section number is 16.5.3.
All OpenGL specs include the following statement: OpenGL does not force left- or right-handedness on any of its coordinates systems. KTX shouldn't suggest otherwise. The notion of OpenGL's object space being right-handed is more like a legacy convention rather than a fixed definition. If anything, it's possible to say that the clip space is left-handed, but with
This effect is described above. Applications that for whatever reason supply right-handed
This is a much stronger statement than the Vulkan spec implies since its clip space has been fully configurable since the beginning.
This basically describes an opinionated "Y+ up" to "Y+ down" transformation that may sometimes be irrelevant because different engines may have different internal conventions. Suggestions:
|
Thank you. I have no problem rephrasing API specific statements. As to your other points I need to take some time to think about them. This stuff makes my head spin. The number 1 issue for me is having a single cubemap that be displayed correctly on Vulkan and OpenGL in, preferably, their default coordinate systems. Here correctly means that the rendered result reflects ground truth. The genesis for these comments is that I have found cubemap files that have been hacked to make them work on Vulkan (+Y and -Y images were swapped). When rendered with Vulkan's default coordinate system this results in +X and -X being swapped with respect to ground truth. I discovered this because one of the cubemaps is a place I know in Yokohama and when I saw it I when "Whoops. The Landmark Tower should be on the right not the left." There is absolutely no need to swap +Y and -Y images to get the correct results. |
The uploaded cubemap texture cannot be displayed on its own without some minimal vertex/shaders setup. At that point, applications usually make all kinds of opinionated choices that virtually erase the notion of "default coordinate systems". The best thing KTX spec can do here is to clearly define its own coordinate system for cubemaps: left-handed, Y+ up, top-left face origins. Then it would be application's responsibility to correctly sample input KTX data. |
Okay, let's define our own coordinate system. I agree with making left-handed the default. I'd like to keep orientation metadata though. Please sketch up a skybox visualization example. |
This feature adds another level of indirection on top of already confusing subject. Should we keep it, it's probably better to explicitly list all faces four times ( It seems to me that the whole "Cubemap Orientation" topic deserves its own appendix (with illustrations and API hints) to not bloat the main spec text. The normative language should simply state the order of faces and the default coordinate system. |
The image above denotes the proposed KTX cubemap coordinate system that is directly compatible with Vulkan / OpenGL cube sampler, assuming that the latter receives correct left-handed inputs. The |
I agree the topic should be in an appendix. The order of the faces is as now and the default coordinate system is top left origin, also as now, right? What did you use to draw the figure you included above? can you make an SVG version? |
You mean have 4 versions of the image you created? |
I've made the appendix. Please review PR #148.
The weekly updates change section numbers. This spec. uses links to internal anchors so even if the section number has changed, clicking the link will take you to the right place. |
Right.
Initially, my plan was to mark per-face origins on the cube. Now that faces are shown explicitly, I think one image is enough.
Will look into that. |
The last piece of this was just committed in PR #148. |
mipPadding
would be empty?row_of_blocks
,format-specific-number-of-bytes
,texel block size
(several places).The text was updated successfully, but these errors were encountered: