Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
5563 | serge | 1 | Resources and derived objects |
2 | ============================= |
||
3 | |||
4 | Resources represent objects that hold data: textures and buffers. |
||
5 | |||
6 | They are mostly modelled after the resources in Direct3D 10/11, but with a |
||
7 | different transfer/update mechanism, and more features for OpenGL support. |
||
8 | |||
9 | Resources can be used in several ways, and it is required to specify all planned uses through an appropriate set of bind flags. |
||
10 | |||
11 | TODO: write much more on resources |
||
12 | |||
13 | Transfers |
||
14 | --------- |
||
15 | |||
16 | Transfers are the mechanism used to access resources with the CPU. |
||
17 | |||
18 | OpenGL: OpenGL supports mapping buffers and has inline transfer functions for both buffers and textures |
||
19 | |||
20 | D3D11: D3D11 lacks transfers, but has special resource types that are mappable to the CPU address space |
||
21 | |||
22 | TODO: write much more on transfers |
||
23 | |||
24 | Resource targets |
||
25 | ---------------- |
||
26 | |||
27 | Resource targets determine the type of a resource. |
||
28 | |||
29 | Note that drivers may not actually have the restrictions listed regarding |
||
30 | coordinate normalization and wrap modes, and in fact efficient OpenCL |
||
31 | support will probably require drivers that don't have any of them, which |
||
32 | will probably be advertised with an appropriate cap. |
||
33 | |||
34 | TODO: document all targets. Note that both 3D and cube have restrictions |
||
35 | that depend on the hardware generation. |
||
36 | |||
37 | |||
38 | PIPE_BUFFER |
||
39 | ^^^^^^^^^^^ |
||
40 | |||
41 | Buffer resource: can be used as a vertex, index, constant buffer |
||
42 | (appropriate bind flags must be requested). |
||
43 | |||
44 | Buffers do not really have a format, it's just bytes, but they are required |
||
45 | to have their type set to a R8 format (without a specific "just byte" format, |
||
46 | R8_UINT would probably make the most sense, but for historic reasons R8_UNORM |
||
47 | is ok too). (This is just to make some shared buffer/texture code easier so |
||
48 | format size can be queried.) |
||
49 | width0 serves as size, most other resource properties don't apply but must be |
||
50 | set appropriately (depth0/height0/array_size must be 1, last_level 0). |
||
51 | |||
52 | They can be bound to stream output if supported. |
||
53 | TODO: what about the restrictions lifted by the several later GL transform feedback extensions? How does one advertise that in Gallium? |
||
54 | |||
55 | They can be also be bound to a shader stage (for sampling) as usual by |
||
56 | creating an appropriate sampler view, if the driver supports PIPE_CAP_TEXTURE_BUFFER_OBJECTS. |
||
57 | This supports larger width than a 1d texture would |
||
58 | (TODO limit currently unspecified, minimum must be at least 65536). |
||
59 | Only the "direct fetch" sample opcodes are supported (TGSI_OPCODE_TXF, |
||
60 | TGSI_OPCODE_SAMPLE_I) so the sampler state (coord wrapping etc.) |
||
61 | is mostly ignored (with SAMPLE_I there's no sampler state at all). |
||
62 | |||
63 | They can be also be bound to the framebuffer (only as color render target, not |
||
64 | depth buffer, also there cannot be a depth buffer bound at the same time) as usual |
||
65 | by creating an appropriate view (this is not usable in OpenGL). |
||
66 | TODO there's no CAP bit currently for this, there's also unspecified size etc. limits |
||
67 | TODO: is there any chance of supporting GL pixel buffer object acceleration with this? |
||
68 | |||
69 | |||
70 | OpenGL: vertex buffers in GL 1.5 or GL_ARB_vertex_buffer_object |
||
71 | |||
72 | - Binding to stream out requires GL 3.0 or GL_NV_transform_feedback |
||
73 | - Binding as constant buffers requires GL 3.1 or GL_ARB_uniform_buffer_object |
||
74 | - Binding to a sampling stage requires GL 3.1 or GL_ARB_texture_buffer_object |
||
75 | |||
76 | D3D11: buffer resources |
||
77 | - Binding to a render target requires D3D_FEATURE_LEVEL_10_0 |
||
78 | |||
79 | PIPE_TEXTURE_1D / PIPE_TEXTURE_1D_ARRAY |
||
80 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
||
81 | 1D surface accessed with normalized coordinates. |
||
82 | 1D array textures are supported depending on PIPE_CAP_MAX_TEXTURE_ARRAY_LAYERS. |
||
83 | |||
84 | - If PIPE_CAP_NPOT_TEXTURES is not supported, |
||
85 | width must be a power of two |
||
86 | - height0 must be 1 |
||
87 | - depth0 must be 1 |
||
88 | - array_size must be 1 for PIPE_TEXTURE_1D |
||
89 | - Mipmaps can be used |
||
90 | - Must use normalized coordinates |
||
91 | |||
92 | OpenGL: GL_TEXTURE_1D in GL 1.0 |
||
93 | |||
94 | - PIPE_CAP_NPOT_TEXTURES is equivalent to GL 2.0 or GL_ARB_texture_non_power_of_two |
||
95 | |||
96 | D3D11: 1D textures in D3D_FEATURE_LEVEL_10_0 |
||
97 | |||
98 | PIPE_TEXTURE_RECT |
||
99 | ^^^^^^^^^^^^^^^^^ |
||
100 | 2D surface with OpenGL GL_TEXTURE_RECTANGLE semantics. |
||
101 | |||
102 | - depth0 must be 1 |
||
103 | - array_size must be 1 |
||
104 | - last_level must be 0 |
||
105 | - Must use unnormalized coordinates |
||
106 | - Must use a clamp wrap mode |
||
107 | |||
108 | OpenGL: GL_TEXTURE_RECTANGLE in GL 3.1 or GL_ARB_texture_rectangle or GL_NV_texture_rectangle |
||
109 | |||
110 | OpenCL: can create OpenCL images based on this, that can then be sampled arbitrarily |
||
111 | |||
112 | D3D11: not supported (only PIPE_TEXTURE_2D with normalized coordinates is supported) |
||
113 | |||
114 | PIPE_TEXTURE_2D / PIPE_TEXTURE_2D_ARRAY |
||
115 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
||
116 | 2D surface accessed with normalized coordinates. |
||
117 | 2D array textures are supported depending on PIPE_CAP_MAX_TEXTURE_ARRAY_LAYERS. |
||
118 | |||
119 | - If PIPE_CAP_NPOT_TEXTURES is not supported, |
||
120 | width and height must be powers of two |
||
121 | - depth0 must be 1 |
||
122 | - array_size must be 1 for PIPE_TEXTURE_2D |
||
123 | - Mipmaps can be used |
||
124 | - Must use normalized coordinates |
||
125 | - No special restrictions on wrap modes |
||
126 | |||
127 | OpenGL: GL_TEXTURE_2D in GL 1.0 |
||
128 | |||
129 | - PIPE_CAP_NPOT_TEXTURES is equivalent to GL 2.0 or GL_ARB_texture_non_power_of_two |
||
130 | |||
131 | OpenCL: can create OpenCL images based on this, that can then be sampled arbitrarily |
||
132 | |||
133 | D3D11: 2D textures |
||
134 | |||
135 | - PIPE_CAP_NPOT_TEXTURES is equivalent to D3D_FEATURE_LEVEL_9_3 |
||
136 | |||
137 | PIPE_TEXTURE_3D |
||
138 | ^^^^^^^^^^^^^^^ |
||
139 | |||
140 | 3-dimensional array of texels. |
||
141 | Mipmap dimensions are reduced in all 3 coordinates. |
||
142 | |||
143 | - If PIPE_CAP_NPOT_TEXTURES is not supported, |
||
144 | width, height and depth must be powers of two |
||
145 | - array_size must be 1 |
||
146 | - Must use normalized coordinates |
||
147 | |||
148 | OpenGL: GL_TEXTURE_3D in GL 1.2 or GL_EXT_texture3D |
||
149 | |||
150 | - PIPE_CAP_NPOT_TEXTURES is equivalent to GL 2.0 or GL_ARB_texture_non_power_of_two |
||
151 | |||
152 | D3D11: 3D textures |
||
153 | |||
154 | - PIPE_CAP_NPOT_TEXTURES is equivalent to D3D_FEATURE_LEVEL_10_0 |
||
155 | |||
156 | PIPE_TEXTURE_CUBE / PIPE_TEXTURE_CUBE_ARRAY |
||
157 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
||
158 | |||
159 | Cube maps consist of 6 2D faces. |
||
160 | The 6 surfaces form an imaginary cube, and sampling happens by mapping an |
||
161 | input 3-vector to the point of the cube surface in that direction. |
||
162 | Cube map arrays are supported depending on PIPE_CAP_CUBE_MAP_ARRAY. |
||
163 | |||
164 | Sampling may be optionally seamless if a driver supports it (PIPE_CAP_SEAMLESS_CUBE_MAP), |
||
165 | resulting in filtering taking samples from multiple surfaces near to the edge. |
||
166 | |||
167 | - Width and height must be equal |
||
168 | - depth0 must be 1 |
||
169 | - array_size must be a multiple of 6 |
||
170 | - If PIPE_CAP_NPOT_TEXTURES is not supported, |
||
171 | width and height must be powers of two |
||
172 | - Must use normalized coordinates |
||
173 | |||
174 | OpenGL: GL_TEXTURE_CUBE_MAP in GL 1.3 or EXT_texture_cube_map |
||
175 | |||
176 | - PIPE_CAP_NPOT_TEXTURES is equivalent to GL 2.0 or GL_ARB_texture_non_power_of_two |
||
177 | - Seamless cube maps require GL 3.2 or GL_ARB_seamless_cube_map or GL_AMD_seamless_cubemap_per_texture |
||
178 | - Cube map arrays require GL 4.0 or GL_ARB_texture_cube_map_array |
||
179 | |||
180 | D3D11: 2D array textures with the D3D11_RESOURCE_MISC_TEXTURECUBE flag |
||
181 | |||
182 | - PIPE_CAP_NPOT_TEXTURES is equivalent to D3D_FEATURE_LEVEL_10_0 |
||
183 | - Cube map arrays require D3D_FEATURE_LEVEL_10_1 |
||
184 | |||
185 | Surfaces |
||
186 | -------- |
||
187 | |||
188 | Surfaces are views of a resource that can be bound as a framebuffer to serve as the render target or depth buffer. |
||
189 | |||
190 | TODO: write much more on surfaces |
||
191 | |||
192 | OpenGL: FBOs are collections of surfaces in GL 3.0 or GL_ARB_framebuffer_object |
||
193 | |||
194 | D3D11: render target views and depth/stencil views |
||
195 | |||
196 | Sampler views |
||
197 | ------------- |
||
198 | |||
199 | Sampler views are views of a resource that can be bound to a pipeline stage to be sampled from shaders. |
||
200 | |||
201 | TODO: write much more on sampler views |
||
202 | |||
203 | OpenGL: texture objects are actually sampler view and resource in a single unit |
||
204 | |||
205 | D3D11: shader resource views |