1 | /* |
2 | Simple DirectMedia Layer |
3 | Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org> |
4 | |
5 | This software is provided 'as-is', without any express or implied |
6 | warranty. In no event will the authors be held liable for any damages |
7 | arising from the use of this software. |
8 | |
9 | Permission is granted to anyone to use this software for any purpose, |
10 | including commercial applications, and to alter it and redistribute it |
11 | freely, subject to the following restrictions: |
12 | |
13 | 1. The origin of this software must not be misrepresented; you must not |
14 | claim that you wrote the original software. If you use this software |
15 | in a product, an acknowledgment in the product documentation would be |
16 | appreciated but is not required. |
17 | 2. Altered source versions must be plainly marked as such, and must not be |
18 | misrepresented as being the original software. |
19 | 3. This notice may not be removed or altered from any source distribution. |
20 | */ |
21 | #include "../../SDL_internal.h" |
22 | |
23 | #if SDL_VIDEO_RENDER_VITA_GLES2 && !SDL_RENDER_DISABLED |
24 | |
25 | #include "SDL_video.h" |
26 | #include "SDL_opengles2.h" |
27 | #include "SDL_shaders_gles2vita.h" |
28 | #include "SDL_stdinc.h" |
29 | |
30 | /* While Vita is gles2-compliant, shaders should be in Cg format, not glsl */ |
31 | |
32 | /************************************************************************************************* |
33 | * Vertex/fragment shader source * |
34 | *************************************************************************************************/ |
35 | /* Notes on a_angle: |
36 | * It is a vector containing sin and cos for rotation matrix |
37 | * To get correct rotation for most cases when a_angle is disabled cos |
38 | value is decremented by 1.0 to get proper output with 0.0 which is |
39 | default value |
40 | */ |
41 | static const Uint8 VITA_GLES2_VertexSrc_Default_[] = " \ |
42 | struct _Output { \ |
43 | float2 v_texCoord : TEXCOORD0; \ |
44 | float4 position : POSITION; \ |
45 | float pointsize : PSIZE; \ |
46 | }; \ |
47 | \ |
48 | _Output main( \ |
49 | uniform float4x4 u_projection, \ |
50 | float2 a_position, \ |
51 | float2 a_texCoord, \ |
52 | float2 a_angle, \ |
53 | float2 a_center \ |
54 | ) \ |
55 | { \ |
56 | _Output OUT; \ |
57 | \ |
58 | float s = a_angle[0]; \ |
59 | float c = a_angle[1] + 1.0; \ |
60 | float2x2 rotationMatrix = float2x2(c, s, -s, c); \ |
61 | float2 position = mul((a_position - a_center) + a_center, rotationMatrix); \ |
62 | \ |
63 | OUT.v_texCoord = a_texCoord; \ |
64 | OUT.position = mul(float4(position, 0.0, 1.0), u_projection);\ |
65 | OUT.pointsize = 1.0; \ |
66 | return OUT; \ |
67 | } \ |
68 | " ; |
69 | |
70 | static const Uint8 VITA_GLES2_FragmentSrc_SolidSrc_[] = " \ |
71 | float4 main(uniform float4 u_color : COLOR) : COLOR \ |
72 | { \ |
73 | return u_color; \ |
74 | } \ |
75 | " ; |
76 | |
77 | static const Uint8 VITA_GLES2_FragmentSrc_TextureABGRSrc_[] = " \ |
78 | float4 main(uniform sampler2D u_texture, uniform float4 u_color : COLOR, float2 v_texCoord : TEXCOORD0 ) : COLOR \ |
79 | { \ |
80 | float4 color = tex2D(u_texture, v_texCoord); \ |
81 | return color * u_color; \ |
82 | } \ |
83 | " ; |
84 | |
85 | /* ARGB to ABGR conversion */ |
86 | static const Uint8 VITA_GLES2_FragmentSrc_TextureARGBSrc_[] = " \ |
87 | float4 main(uniform sampler2D u_texture, uniform float4 u_color : COLOR, float2 v_texCoord : TEXCOORD0 ) : COLOR \ |
88 | { \ |
89 | float4 abgr = tex2D(u_texture, v_texCoord); \ |
90 | float4 color = abgr; \ |
91 | color.r = abgr.b; \ |
92 | color.b = abgr.r; \ |
93 | return color * u_color; \ |
94 | } \ |
95 | " ; |
96 | |
97 | /* RGB to ABGR conversion */ |
98 | static const Uint8 VITA_GLES2_FragmentSrc_TextureRGBSrc_[] = " \ |
99 | float4 main(uniform sampler2D u_texture, uniform float4 u_color : COLOR, float2 v_texCoord : TEXCOORD0 ) : COLOR \ |
100 | { \ |
101 | float4 abgr = tex2D(u_texture, v_texCoord); \ |
102 | float4 color = abgr; \ |
103 | color.r = abgr.b; \ |
104 | color.b = abgr.r; \ |
105 | color.a = 1.0; \ |
106 | return color * u_color; \ |
107 | } \ |
108 | " ; |
109 | |
110 | /* BGR to ABGR conversion */ |
111 | static const Uint8 VITA_GLES2_FragmentSrc_TextureBGRSrc_[] = " \ |
112 | float4 main(uniform sampler2D u_texture, uniform float4 u_color : COLOR, float2 v_texCoord : TEXCOORD0 ) : COLOR \ |
113 | { \ |
114 | float4 abgr = tex2D(u_texture, v_texCoord); \ |
115 | float4 color = abgr; \ |
116 | color.a = 1.0; \ |
117 | return color * u_color; \ |
118 | } \ |
119 | " ; |
120 | |
121 | // VITA : TODO |
122 | |
123 | #define JPEG_SHADER_CONSTANTS \ |
124 | "// YUV offset \n" \ |
125 | "const vec3 offset = vec3(0, -0.501960814, -0.501960814);\n" \ |
126 | "\n" \ |
127 | "// RGB coefficients \n" \ |
128 | "const mat3 matrix = mat3( 1, 1, 1,\n" \ |
129 | " 0, -0.3441, 1.772,\n" \ |
130 | " 1.402, -0.7141, 0);\n" \ |
131 | |
132 | #define BT601_SHADER_CONSTANTS \ |
133 | "// YUV offset \n" \ |
134 | "const vec3 offset = vec3(-0.0627451017, -0.501960814, -0.501960814);\n" \ |
135 | "\n" \ |
136 | "// RGB coefficients \n" \ |
137 | "const mat3 matrix = mat3( 1.1644, 1.1644, 1.1644,\n" \ |
138 | " 0, -0.3918, 2.0172,\n" \ |
139 | " 1.596, -0.813, 0);\n" \ |
140 | |
141 | #define BT709_SHADER_CONSTANTS \ |
142 | "// YUV offset \n" \ |
143 | "const vec3 offset = vec3(-0.0627451017, -0.501960814, -0.501960814);\n" \ |
144 | "\n" \ |
145 | "// RGB coefficients \n" \ |
146 | "const mat3 matrix = mat3( 1.1644, 1.1644, 1.1644,\n" \ |
147 | " 0, -0.2132, 2.1124,\n" \ |
148 | " 1.7927, -0.5329, 0);\n" \ |
149 | |
150 | |
151 | #define YUV_SHADER_PROLOGUE \ |
152 | "precision mediump float;\n" \ |
153 | "uniform sampler2D u_texture;\n" \ |
154 | "uniform sampler2D u_texture_u;\n" \ |
155 | "uniform sampler2D u_texture_v;\n" \ |
156 | "uniform vec4 u_color;\n" \ |
157 | "varying vec2 v_texCoord;\n" \ |
158 | "\n" \ |
159 | |
160 | #define YUV_SHADER_BODY \ |
161 | "\n" \ |
162 | "void main()\n" \ |
163 | "{\n" \ |
164 | " mediump vec3 yuv;\n" \ |
165 | " lowp vec3 rgb;\n" \ |
166 | "\n" \ |
167 | " // Get the YUV values \n" \ |
168 | " yuv.x = texture2D(u_texture, v_texCoord).r;\n" \ |
169 | " yuv.y = texture2D(u_texture_u, v_texCoord).r;\n" \ |
170 | " yuv.z = texture2D(u_texture_v, v_texCoord).r;\n" \ |
171 | "\n" \ |
172 | " // Do the color transform \n" \ |
173 | " yuv += offset;\n" \ |
174 | " rgb = matrix * yuv;\n" \ |
175 | "\n" \ |
176 | " // That was easy. :) \n" \ |
177 | " gl_FragColor = vec4(rgb, 1);\n" \ |
178 | " gl_FragColor *= u_color;\n" \ |
179 | "}" \ |
180 | |
181 | #define NV12_SHADER_BODY \ |
182 | "\n" \ |
183 | "void main()\n" \ |
184 | "{\n" \ |
185 | " mediump vec3 yuv;\n" \ |
186 | " lowp vec3 rgb;\n" \ |
187 | "\n" \ |
188 | " // Get the YUV values \n" \ |
189 | " yuv.x = texture2D(u_texture, v_texCoord).r;\n" \ |
190 | " yuv.yz = texture2D(u_texture_u, v_texCoord).ra;\n" \ |
191 | "\n" \ |
192 | " // Do the color transform \n" \ |
193 | " yuv += offset;\n" \ |
194 | " rgb = matrix * yuv;\n" \ |
195 | "\n" \ |
196 | " // That was easy. :) \n" \ |
197 | " gl_FragColor = vec4(rgb, 1);\n" \ |
198 | " gl_FragColor *= u_color;\n" \ |
199 | "}" \ |
200 | |
201 | #define NV21_SHADER_BODY \ |
202 | "\n" \ |
203 | "void main()\n" \ |
204 | "{\n" \ |
205 | " mediump vec3 yuv;\n" \ |
206 | " lowp vec3 rgb;\n" \ |
207 | "\n" \ |
208 | " // Get the YUV values \n" \ |
209 | " yuv.x = texture2D(u_texture, v_texCoord).r;\n" \ |
210 | " yuv.yz = texture2D(u_texture_u, v_texCoord).ar;\n" \ |
211 | "\n" \ |
212 | " // Do the color transform \n" \ |
213 | " yuv += offset;\n" \ |
214 | " rgb = matrix * yuv;\n" \ |
215 | "\n" \ |
216 | " // That was easy. :) \n" \ |
217 | " gl_FragColor = vec4(rgb, 1);\n" \ |
218 | " gl_FragColor *= u_color;\n" \ |
219 | "}" \ |
220 | |
221 | /* YUV to ABGR conversion */ |
222 | static const Uint8 VITA_GLES2_FragmentSrc_TextureYUVJPEGSrc_[] = \ |
223 | YUV_SHADER_PROLOGUE \ |
224 | JPEG_SHADER_CONSTANTS \ |
225 | YUV_SHADER_BODY \ |
226 | ; |
227 | static const Uint8 VITA_GLES2_FragmentSrc_TextureYUVBT601Src_[] = \ |
228 | YUV_SHADER_PROLOGUE \ |
229 | BT601_SHADER_CONSTANTS \ |
230 | YUV_SHADER_BODY \ |
231 | ; |
232 | static const Uint8 VITA_GLES2_FragmentSrc_TextureYUVBT709Src_[] = \ |
233 | YUV_SHADER_PROLOGUE \ |
234 | BT709_SHADER_CONSTANTS \ |
235 | YUV_SHADER_BODY \ |
236 | ; |
237 | |
238 | /* NV12 to ABGR conversion */ |
239 | static const Uint8 VITA_GLES2_FragmentSrc_TextureNV12JPEGSrc_[] = \ |
240 | YUV_SHADER_PROLOGUE \ |
241 | JPEG_SHADER_CONSTANTS \ |
242 | NV12_SHADER_BODY \ |
243 | ; |
244 | static const Uint8 VITA_GLES2_FragmentSrc_TextureNV12BT601Src_[] = \ |
245 | YUV_SHADER_PROLOGUE \ |
246 | BT601_SHADER_CONSTANTS \ |
247 | NV12_SHADER_BODY \ |
248 | ; |
249 | static const Uint8 VITA_GLES2_FragmentSrc_TextureNV12BT709Src_[] = \ |
250 | YUV_SHADER_PROLOGUE \ |
251 | BT709_SHADER_CONSTANTS \ |
252 | NV12_SHADER_BODY \ |
253 | ; |
254 | |
255 | /* NV21 to ABGR conversion */ |
256 | static const Uint8 VITA_GLES2_FragmentSrc_TextureNV21JPEGSrc_[] = \ |
257 | YUV_SHADER_PROLOGUE \ |
258 | JPEG_SHADER_CONSTANTS \ |
259 | NV21_SHADER_BODY \ |
260 | ; |
261 | static const Uint8 VITA_GLES2_FragmentSrc_TextureNV21BT601Src_[] = \ |
262 | YUV_SHADER_PROLOGUE \ |
263 | BT601_SHADER_CONSTANTS \ |
264 | NV21_SHADER_BODY \ |
265 | ; |
266 | static const Uint8 VITA_GLES2_FragmentSrc_TextureNV21BT709Src_[] = \ |
267 | YUV_SHADER_PROLOGUE \ |
268 | BT709_SHADER_CONSTANTS \ |
269 | NV21_SHADER_BODY \ |
270 | ; |
271 | |
272 | /* Custom Android video format texture */ |
273 | static const Uint8 VITA_GLES2_FragmentSrc_TextureExternalOESSrc_[] = " \ |
274 | #extension GL_OES_EGL_image_external : require\n\ |
275 | precision mediump float; \ |
276 | uniform samplerExternalOES u_texture; \ |
277 | uniform vec4 u_color; \ |
278 | varying vec2 v_texCoord; \ |
279 | \ |
280 | void main() \ |
281 | { \ |
282 | gl_FragColor = texture2D(u_texture, v_texCoord); \ |
283 | gl_FragColor *= u_color; \ |
284 | } \ |
285 | " ; |
286 | |
287 | static const VITA_GLES2_ShaderInstance VITA_GLES2_VertexSrc_Default = { |
288 | GL_VERTEX_SHADER, |
289 | VITA_GLES2_SOURCE_SHADER, |
290 | sizeof(VITA_GLES2_VertexSrc_Default_), |
291 | VITA_GLES2_VertexSrc_Default_ |
292 | }; |
293 | |
294 | static const VITA_GLES2_ShaderInstance VITA_GLES2_FragmentSrc_SolidSrc = { |
295 | GL_FRAGMENT_SHADER, |
296 | VITA_GLES2_SOURCE_SHADER, |
297 | sizeof(VITA_GLES2_FragmentSrc_SolidSrc_), |
298 | VITA_GLES2_FragmentSrc_SolidSrc_ |
299 | }; |
300 | |
301 | static const VITA_GLES2_ShaderInstance VITA_GLES2_FragmentSrc_TextureABGRSrc = { |
302 | GL_FRAGMENT_SHADER, |
303 | VITA_GLES2_SOURCE_SHADER, |
304 | sizeof(VITA_GLES2_FragmentSrc_TextureABGRSrc_), |
305 | VITA_GLES2_FragmentSrc_TextureABGRSrc_ |
306 | }; |
307 | |
308 | static const VITA_GLES2_ShaderInstance VITA_GLES2_FragmentSrc_TextureARGBSrc = { |
309 | GL_FRAGMENT_SHADER, |
310 | VITA_GLES2_SOURCE_SHADER, |
311 | sizeof(VITA_GLES2_FragmentSrc_TextureARGBSrc_), |
312 | VITA_GLES2_FragmentSrc_TextureARGBSrc_ |
313 | }; |
314 | |
315 | static const VITA_GLES2_ShaderInstance VITA_GLES2_FragmentSrc_TextureRGBSrc = { |
316 | GL_FRAGMENT_SHADER, |
317 | VITA_GLES2_SOURCE_SHADER, |
318 | sizeof(VITA_GLES2_FragmentSrc_TextureRGBSrc_), |
319 | VITA_GLES2_FragmentSrc_TextureRGBSrc_ |
320 | }; |
321 | |
322 | static const VITA_GLES2_ShaderInstance VITA_GLES2_FragmentSrc_TextureBGRSrc = { |
323 | GL_FRAGMENT_SHADER, |
324 | VITA_GLES2_SOURCE_SHADER, |
325 | sizeof(VITA_GLES2_FragmentSrc_TextureBGRSrc_), |
326 | VITA_GLES2_FragmentSrc_TextureBGRSrc_ |
327 | }; |
328 | |
329 | static const VITA_GLES2_ShaderInstance VITA_GLES2_FragmentSrc_TextureYUVJPEGSrc = { |
330 | GL_FRAGMENT_SHADER, |
331 | VITA_GLES2_SOURCE_SHADER, |
332 | sizeof(VITA_GLES2_FragmentSrc_TextureYUVJPEGSrc_), |
333 | VITA_GLES2_FragmentSrc_TextureYUVJPEGSrc_ |
334 | }; |
335 | |
336 | static const VITA_GLES2_ShaderInstance VITA_GLES2_FragmentSrc_TextureYUVBT601Src = { |
337 | GL_FRAGMENT_SHADER, |
338 | VITA_GLES2_SOURCE_SHADER, |
339 | sizeof(VITA_GLES2_FragmentSrc_TextureYUVBT601Src_), |
340 | VITA_GLES2_FragmentSrc_TextureYUVBT601Src_ |
341 | }; |
342 | |
343 | static const VITA_GLES2_ShaderInstance VITA_GLES2_FragmentSrc_TextureYUVBT709Src = { |
344 | GL_FRAGMENT_SHADER, |
345 | VITA_GLES2_SOURCE_SHADER, |
346 | sizeof(VITA_GLES2_FragmentSrc_TextureYUVBT709Src_), |
347 | VITA_GLES2_FragmentSrc_TextureYUVBT709Src_ |
348 | }; |
349 | |
350 | static const VITA_GLES2_ShaderInstance VITA_GLES2_FragmentSrc_TextureNV12JPEGSrc = { |
351 | GL_FRAGMENT_SHADER, |
352 | VITA_GLES2_SOURCE_SHADER, |
353 | sizeof(VITA_GLES2_FragmentSrc_TextureNV12JPEGSrc_), |
354 | VITA_GLES2_FragmentSrc_TextureNV12JPEGSrc_ |
355 | }; |
356 | |
357 | static const VITA_GLES2_ShaderInstance VITA_GLES2_FragmentSrc_TextureNV12BT601Src = { |
358 | GL_FRAGMENT_SHADER, |
359 | VITA_GLES2_SOURCE_SHADER, |
360 | sizeof(VITA_GLES2_FragmentSrc_TextureNV12BT601Src_), |
361 | VITA_GLES2_FragmentSrc_TextureNV12BT601Src_ |
362 | }; |
363 | |
364 | static const VITA_GLES2_ShaderInstance VITA_GLES2_FragmentSrc_TextureNV21BT709Src = { |
365 | GL_FRAGMENT_SHADER, |
366 | VITA_GLES2_SOURCE_SHADER, |
367 | sizeof(VITA_GLES2_FragmentSrc_TextureNV21BT709Src_), |
368 | VITA_GLES2_FragmentSrc_TextureNV21BT709Src_ |
369 | }; |
370 | |
371 | static const VITA_GLES2_ShaderInstance VITA_GLES2_FragmentSrc_TextureNV21JPEGSrc = { |
372 | GL_FRAGMENT_SHADER, |
373 | VITA_GLES2_SOURCE_SHADER, |
374 | sizeof(VITA_GLES2_FragmentSrc_TextureNV21JPEGSrc_), |
375 | VITA_GLES2_FragmentSrc_TextureNV21JPEGSrc_ |
376 | }; |
377 | |
378 | static const VITA_GLES2_ShaderInstance VITA_GLES2_FragmentSrc_TextureNV21BT601Src = { |
379 | GL_FRAGMENT_SHADER, |
380 | VITA_GLES2_SOURCE_SHADER, |
381 | sizeof(VITA_GLES2_FragmentSrc_TextureNV21BT601Src_), |
382 | VITA_GLES2_FragmentSrc_TextureNV21BT601Src_ |
383 | }; |
384 | |
385 | static const VITA_GLES2_ShaderInstance VITA_GLES2_FragmentSrc_TextureNV12BT709Src = { |
386 | GL_FRAGMENT_SHADER, |
387 | VITA_GLES2_SOURCE_SHADER, |
388 | sizeof(VITA_GLES2_FragmentSrc_TextureNV12BT709Src_), |
389 | VITA_GLES2_FragmentSrc_TextureNV12BT709Src_ |
390 | }; |
391 | |
392 | static const VITA_GLES2_ShaderInstance VITA_GLES2_FragmentSrc_TextureExternalOESSrc = { |
393 | GL_FRAGMENT_SHADER, |
394 | VITA_GLES2_SOURCE_SHADER, |
395 | sizeof(VITA_GLES2_FragmentSrc_TextureExternalOESSrc_), |
396 | VITA_GLES2_FragmentSrc_TextureExternalOESSrc_ |
397 | }; |
398 | |
399 | |
400 | /************************************************************************************************* |
401 | * Vertex/fragment shader definitions * |
402 | *************************************************************************************************/ |
403 | |
404 | static VITA_GLES2_Shader VITA_GLES2_VertexShader_Default = { |
405 | 1, |
406 | { |
407 | &VITA_GLES2_VertexSrc_Default |
408 | } |
409 | }; |
410 | |
411 | static VITA_GLES2_Shader VITA_GLES2_FragmentShader_SolidSrc = { |
412 | 1, |
413 | { |
414 | &VITA_GLES2_FragmentSrc_SolidSrc |
415 | } |
416 | }; |
417 | |
418 | static VITA_GLES2_Shader VITA_GLES2_FragmentShader_TextureABGRSrc = { |
419 | 1, |
420 | { |
421 | &VITA_GLES2_FragmentSrc_TextureABGRSrc |
422 | } |
423 | }; |
424 | |
425 | static VITA_GLES2_Shader VITA_GLES2_FragmentShader_TextureARGBSrc = { |
426 | 1, |
427 | { |
428 | &VITA_GLES2_FragmentSrc_TextureARGBSrc |
429 | } |
430 | }; |
431 | |
432 | static VITA_GLES2_Shader VITA_GLES2_FragmentShader_TextureRGBSrc = { |
433 | 1, |
434 | { |
435 | &VITA_GLES2_FragmentSrc_TextureRGBSrc |
436 | } |
437 | }; |
438 | |
439 | static VITA_GLES2_Shader VITA_GLES2_FragmentShader_TextureBGRSrc = { |
440 | 1, |
441 | { |
442 | &VITA_GLES2_FragmentSrc_TextureBGRSrc |
443 | } |
444 | }; |
445 | |
446 | static VITA_GLES2_Shader VITA_GLES2_FragmentShader_TextureYUVJPEGSrc = { |
447 | 1, |
448 | { |
449 | &VITA_GLES2_FragmentSrc_TextureYUVJPEGSrc |
450 | } |
451 | }; |
452 | |
453 | static VITA_GLES2_Shader VITA_GLES2_FragmentShader_TextureYUVBT601Src = { |
454 | 1, |
455 | { |
456 | &VITA_GLES2_FragmentSrc_TextureYUVBT601Src |
457 | } |
458 | }; |
459 | |
460 | static VITA_GLES2_Shader VITA_GLES2_FragmentShader_TextureYUVBT709Src = { |
461 | 1, |
462 | { |
463 | &VITA_GLES2_FragmentSrc_TextureYUVBT709Src |
464 | } |
465 | }; |
466 | |
467 | static VITA_GLES2_Shader VITA_GLES2_FragmentShader_TextureNV12JPEGSrc = { |
468 | 1, |
469 | { |
470 | &VITA_GLES2_FragmentSrc_TextureNV12JPEGSrc |
471 | } |
472 | }; |
473 | |
474 | static VITA_GLES2_Shader VITA_GLES2_FragmentShader_TextureNV12BT601Src = { |
475 | 1, |
476 | { |
477 | &VITA_GLES2_FragmentSrc_TextureNV12BT601Src |
478 | } |
479 | }; |
480 | |
481 | static VITA_GLES2_Shader VITA_GLES2_FragmentShader_TextureNV12BT709Src = { |
482 | 1, |
483 | { |
484 | &VITA_GLES2_FragmentSrc_TextureNV12BT709Src |
485 | } |
486 | }; |
487 | |
488 | static VITA_GLES2_Shader VITA_GLES2_FragmentShader_TextureNV21JPEGSrc = { |
489 | 1, |
490 | { |
491 | &VITA_GLES2_FragmentSrc_TextureNV21JPEGSrc |
492 | } |
493 | }; |
494 | |
495 | static VITA_GLES2_Shader VITA_GLES2_FragmentShader_TextureNV21BT601Src = { |
496 | 1, |
497 | { |
498 | &VITA_GLES2_FragmentSrc_TextureNV21BT601Src |
499 | } |
500 | }; |
501 | |
502 | static VITA_GLES2_Shader VITA_GLES2_FragmentShader_TextureNV21BT709Src = { |
503 | 1, |
504 | { |
505 | &VITA_GLES2_FragmentSrc_TextureNV21BT709Src |
506 | } |
507 | }; |
508 | |
509 | static VITA_GLES2_Shader VITA_GLES2_FragmentShader_TextureExternalOESSrc = { |
510 | 1, |
511 | { |
512 | &VITA_GLES2_FragmentSrc_TextureExternalOESSrc |
513 | } |
514 | }; |
515 | |
516 | |
517 | /************************************************************************************************* |
518 | * Shader selector * |
519 | *************************************************************************************************/ |
520 | |
521 | const VITA_GLES2_Shader *VITA_GLES2_GetShader(VITA_GLES2_ShaderType type) |
522 | { |
523 | switch (type) { |
524 | case VITA_GLES2_SHADER_VERTEX_DEFAULT: |
525 | return &VITA_GLES2_VertexShader_Default; |
526 | case VITA_GLES2_SHADER_FRAGMENT_SOLID_SRC: |
527 | return &VITA_GLES2_FragmentShader_SolidSrc; |
528 | case VITA_GLES2_SHADER_FRAGMENT_TEXTURE_ABGR_SRC: |
529 | return &VITA_GLES2_FragmentShader_TextureABGRSrc; |
530 | case VITA_GLES2_SHADER_FRAGMENT_TEXTURE_ARGB_SRC: |
531 | return &VITA_GLES2_FragmentShader_TextureARGBSrc; |
532 | case VITA_GLES2_SHADER_FRAGMENT_TEXTURE_RGB_SRC: |
533 | return &VITA_GLES2_FragmentShader_TextureRGBSrc; |
534 | case VITA_GLES2_SHADER_FRAGMENT_TEXTURE_BGR_SRC: |
535 | return &VITA_GLES2_FragmentShader_TextureBGRSrc; |
536 | case VITA_GLES2_SHADER_FRAGMENT_TEXTURE_YUV_JPEG_SRC: |
537 | return &VITA_GLES2_FragmentShader_TextureYUVJPEGSrc; |
538 | case VITA_GLES2_SHADER_FRAGMENT_TEXTURE_YUV_BT601_SRC: |
539 | return &VITA_GLES2_FragmentShader_TextureYUVBT601Src; |
540 | case VITA_GLES2_SHADER_FRAGMENT_TEXTURE_YUV_BT709_SRC: |
541 | return &VITA_GLES2_FragmentShader_TextureYUVBT709Src; |
542 | case VITA_GLES2_SHADER_FRAGMENT_TEXTURE_NV12_JPEG_SRC: |
543 | return &VITA_GLES2_FragmentShader_TextureNV12JPEGSrc; |
544 | case VITA_GLES2_SHADER_FRAGMENT_TEXTURE_NV12_BT601_SRC: |
545 | return &VITA_GLES2_FragmentShader_TextureNV12BT601Src; |
546 | case VITA_GLES2_SHADER_FRAGMENT_TEXTURE_NV12_BT709_SRC: |
547 | return &VITA_GLES2_FragmentShader_TextureNV12BT709Src; |
548 | case VITA_GLES2_SHADER_FRAGMENT_TEXTURE_NV21_JPEG_SRC: |
549 | return &VITA_GLES2_FragmentShader_TextureNV21JPEGSrc; |
550 | case VITA_GLES2_SHADER_FRAGMENT_TEXTURE_NV21_BT601_SRC: |
551 | return &VITA_GLES2_FragmentShader_TextureNV21BT601Src; |
552 | case VITA_GLES2_SHADER_FRAGMENT_TEXTURE_NV21_BT709_SRC: |
553 | return &VITA_GLES2_FragmentShader_TextureNV21BT709Src; |
554 | case VITA_GLES2_SHADER_FRAGMENT_TEXTURE_EXTERNAL_OES_SRC: |
555 | return &VITA_GLES2_FragmentShader_TextureExternalOESSrc; |
556 | default: |
557 | return NULL; |
558 | } |
559 | } |
560 | |
561 | #endif /* SDL_VIDEO_RENDER_VITA_GLES2 && !SDL_RENDER_DISABLED */ |
562 | |
563 | /* vi: set ts=4 sw=4 expandtab: */ |
564 | |