Apple's Metal examples alternate between using texture2D<float> and texture2D<half>, and I believe that the default pixel format of a MTKView is bgra8unorm. What determines if I should use float or half? Do I need to specify something on the CPU, or will textures using 128-bits-in-all float4s be converted into halfs automatically? How about the other way around if I pass-in a texture with a bgra8format? I am asking because I am trying to load textures using MTKTextureLoader as well as from plain byte data, and I'm not sure what format to use for the plain byte data so things are consistent. May I have clarification?
How to know which Metal texture format to use? short or half?
689 Views Asked by synchronizer At
1
There are 1 best solutions below
Related Questions in GRAPHICS
- Removing flashiness/ shakiness from scrolling text
- Algorithm for drawing tiles on screen
- Can this kind of SVG be simplified?
- Interactive bend image
- Plot: Add legend that overlay several Frames
- I made a function that uses graphics and I wanted to call it in the main it did not work
- Creating new shape palettes in ggplot2 and other R graphics
- How to move everything in Graphics2D by x,y coordinates.
- Java Graphics Dispose Method
- How can I convert PNG to GIF keeping the transparency?
- Java repaint() not calling paintComponent
- 1080p resolution is not detected by screen.bounds and reverts to 720p
- Creating a Texture2DArray and populate it with solid values
- paintComponent method not being called by repaint
- Dealing with and printing large text files
Related Questions in TEXTURES
- Can linear filtering be used for an FBO blit of an MSAA texture to non-MSAA texture?
- Texture mapping consuming physical memory
- Quality not proper while rendering it via threejs r71
- SDL2_image rendering not working properly
- Cocos2D 2.x: Running CCWave action makes sprite disappear
- Creating a Texture2DArray and populate it with solid values
- Projecting a texture from plane to object with Unity
- Textured cube renders blank in DirectX
- Programmatically generate texture for WebGL in JavaScript
- Unable to render a texture on a quad
- OpenGl with C++ - Textures
- Random Line Appearing on Moving Texture Node
- Load multiple OBJ-files together with multple textures
- LibGDX "GwtApplication: exception: Couldn't load image 'a.jpg'
- Android OpenGL es 2.0 Can not reload textures on object.
Related Questions in METAL
- How to get fragment coordinate in fragment shader in Metal?
- Porting OpenGL app to Metal API
- Using a Metal shader in SceneKit
- mathematical movable mesh in swift with SceneKit
- Z-Value, Z-Near and Z-Far Within Kernel Function
- Filling Float buffer in Metal
- Metal on iOS: `newCommandQueueWithMaxCommandBufferCount` not working
- Using the [[clip_distance]] attribute in a Metal shader?
- iOS: How to manually set a 2D Float data to MTLTexture or MPSImage?
- Loop unrolling in Metal kernels
- What is Explicit synchronization between GPU and CPU
- Why can't I bind an asset once in metal?
- Apple Metal without Interface Builder
- Metal Framework on macOS
- Implement a custom layer after a series of MPSCNNConvolution
Related Questions in METALKIT
- How to draw a 3D line using metalkit
- How to interleave Kernel/Vertex METAL Shaders
- Best way to "intercept" result of METAL vertex/fragment shader
- Ignore .metal files when building for iOS Simulator target
- Metal crashes on iOS 14
- SceneKit Metal shader compilation performance bug in iOS 14 workaround ideas
- How to know which Metal texture format to use? short or half?
- How to create a solid color texture in Metal?
- Synchronize CARenderer with .private MTLTextuer
- Metal Core Image Sampler pixel format
- CIContext options for HDR display
- How to check a MTKView supports display-P3 pixel formats in macOS?
- CIContext workingColorSpace for MTKView
- Metal Core Image kernels for Image statistics
- [[stitchable]] Metal core image CIKernel fails
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
It really depends on your use case.
Loading: You can probably safely load your data into a texture with the same format as that data. When your render destination has a different format, Metal will perform the conversion for you.
Intermediates: The format of intermediate textures should really depend on the "resolution" (as in "number of bits") you need, which depends on the input data and the color space. If you only handle sRGB data, 8-bit textures are probably enough (unless you do some complicated processing that requires a higher precision). If you want to support a wide gamut (e.g. in Display P3 color space), you need more precision (
halfshould be fine) and also want to be able to store values outside of the [0...255] range. On iOS I'd recommend usinghalffor memory efficiency (and since most devices don't support full float anyway), on macOSfloatis the default, I think.View: The pixel format of the view should really depend on the display. Most of the screens support the Display P3 color space now. For that, you should use the
bgra10_xrformat, since it's optimized for that case. Otherwisebgra8unormis fine.In general, you should be using a texture format with the smallest memory footprint that fits your use case.