|
85 | 85 | # endif |
86 | 86 | #endif |
87 | 87 | #if !defined(SV_Target1) |
88 | | -# if !defined(SHADER_API_XBOXONE) && !defined(SHADER_API_PSP2) |
| 88 | +# if !defined(SHADER_API_XBOXONE) |
89 | 89 | # define SV_Target1 COLOR1 |
90 | 90 | # endif |
91 | 91 | #endif |
92 | 92 | #if !defined(SV_Target2) |
93 | | -# if !defined(SHADER_API_XBOXONE) && !defined(SHADER_API_PSP2) |
| 93 | +# if !defined(SHADER_API_XBOXONE) |
94 | 94 | # define SV_Target2 COLOR2 |
95 | 95 | # endif |
96 | 96 | #endif |
97 | 97 | #if !defined(SV_Target3) |
98 | | -# if !defined(SHADER_API_XBOXONE) && !defined(SHADER_API_PSP2) |
| 98 | +# if !defined(SHADER_API_XBOXONE) |
99 | 99 | # define SV_Target3 COLOR3 |
100 | 100 | # endif |
101 | 101 | #endif |
|
125 | 125 | # endif |
126 | 126 | #endif |
127 | 127 |
|
128 | | -#if (defined(SHADER_API_GLES3) && !defined(SHADER_API_DESKTOP)) || defined(SHADER_API_GLES) || defined(SHADER_API_PSP2) || defined(SHADER_API_N3DS) |
| 128 | +#if (defined(SHADER_API_GLES3) && !defined(SHADER_API_DESKTOP)) || defined(SHADER_API_GLES) || defined(SHADER_API_N3DS) |
129 | 129 | #define UNITY_ALLOWED_MRT_COUNT 4 |
130 | 130 | #else |
131 | 131 | #define UNITY_ALLOWED_MRT_COUNT 8 |
132 | 132 | #endif |
133 | 133 |
|
134 | | -#if (SHADER_TARGET < 30) || defined(SHADER_API_GLES3) || defined(SHADER_API_GLES) || defined(SHADER_API_PSP2) || defined(SHADER_API_N3DS) |
| 134 | +#if (SHADER_TARGET < 30) || defined(SHADER_API_GLES3) || defined(SHADER_API_GLES) || defined(SHADER_API_N3DS) |
135 | 135 | //no fast coherent dynamic branching on these hardware |
136 | 136 | #else |
137 | 137 | #define UNITY_FAST_COHERENT_DYNAMIC_BRANCHING 1 |
|
164 | 164 | #define sampler3D_half sampler3D |
165 | 165 | #define Texture2D_half Texture2D |
166 | 166 | #define Texture2D_float Texture2D |
| 167 | +#define Texture2DArray_half Texture2DArray |
| 168 | +#define Texture2DArray_float Texture2DArray |
| 169 | +#define Texture2DMS_half Texture2DMS |
| 170 | +#define Texture2DMS_float Texture2DMS |
167 | 171 | #define TextureCube_half TextureCube |
168 | 172 | #define TextureCube_float TextureCube |
| 173 | +#define TextureCubeArray_half TextureCubeArray |
| 174 | +#define TextureCubeArray_float TextureCubeArray |
169 | 175 | #define Texture3D_float Texture3D |
170 | 176 | #define Texture3D_half Texture3D |
171 | 177 | #endif |
|
254 | 260 | #define asuint(x) asint(x) |
255 | 261 | #endif |
256 | 262 |
|
257 | | -#if defined(SHADER_API_PSP2) |
258 | | -// The PSP2 cg compiler does not define uint<N> |
259 | | -#define uint2 unsigned int2 |
260 | | -#define uint3 unsigned int3 |
261 | | -#define uint4 unsigned int4 |
262 | | -#endif |
263 | | - |
264 | 263 | // specifically for samplers that are provided as arguments to entry functions |
265 | 264 | #if defined(SHADER_API_PSSL) |
266 | 265 | #define SAMPLER_UNIFORM uniform |
|
270 | 269 | #endif |
271 | 270 |
|
272 | 271 | #if defined(SHADER_API_PSSL) |
| 272 | +// variable modifiers |
| 273 | +#define nointerpolation nointerp |
| 274 | +#define noperspective nopersp |
| 275 | + |
273 | 276 | #define CBUFFER_START(name) ConstantBuffer name { |
274 | 277 | #define CBUFFER_END }; |
275 | 278 | #elif defined(SHADER_API_D3D11) |
|
304 | 307 | #define UNITY_REQUIRE_ADVANCED_BLEND(mode) |
305 | 308 | #endif |
306 | 309 |
|
307 | | - |
308 | | -#if defined(SHADER_API_PSP2) |
309 | | - // For tex2Dproj the PSP2 cg compiler doesn't like casting half3/4 to |
310 | | - // float3/4 with swizzle (optimizer generates invalid assembly), so declare |
311 | | - // explicit versions for half3/4 |
312 | | - half4 tex2Dproj(sampler2D s, in half3 t) { return tex2D(s, t.xy / t.z); } |
313 | | - half4 tex2Dproj(sampler2D s, in half4 t) { return tex2D(s, t.xy / t.w); } |
314 | | - |
315 | | - // As above but for sampling from single component textures, e.g. depth textures. |
316 | | - // NOTE that hardware PCF does not work with these versions, currently we have to ensure |
317 | | - // that tex coords for shadow sampling use float, not half; and for some reason casting half |
318 | | - // to float and using tex2Dproj also does not work. |
319 | | - half4 tex2DprojShadow(sampler2D s, in half3 t) { return tex2D<float>(s, t.xy / t.z); } |
320 | | - half4 tex2DprojShadow(sampler2D s, in half4 t) { return tex2D<float>(s, t.xy / t.w); } |
321 | | - |
322 | | - // ...and versions of tex2DprojShadow for float uv. |
323 | | - half4 tex2DprojShadow(sampler2D s, in float3 t) { return tex2Dproj<float>(s, t); } |
324 | | - half4 tex2DprojShadow(sampler2D s, in float4 t) { return tex2Dproj<float>(s, t); } |
325 | | -#endif |
326 | | - |
327 | | - |
328 | | -#if defined(SHADER_API_PSP2) |
329 | | -#define UNITY_BUGGY_TEX2DPROJ4 |
330 | | -#define UNITY_PROJ_COORD(a) (a).xyw |
331 | | -#else |
332 | 310 | #define UNITY_PROJ_COORD(a) a |
333 | | -#endif |
334 | | - |
335 | 311 |
|
336 | 312 | // Depth texture sampling helpers. |
337 | 313 | // On most platforms you can just sample them, but some (e.g. PSP2) need special handling. |
|
340 | 316 | // SAMPLE_DEPTH_TEXTURE_PROJ(sampler,uv): projected sample |
341 | 317 | // SAMPLE_DEPTH_TEXTURE_LOD(sampler,uv): sample with LOD level |
342 | 318 |
|
343 | | -#if defined(SHADER_API_PSP2) |
344 | | - half SAMPLE_DEPTH_TEXTURE(sampler2D s, float4 uv) { return tex2D<float>(s, (float3)uv); } |
345 | | - half SAMPLE_DEPTH_TEXTURE(sampler2D s, float3 uv) { return tex2D<float>(s, uv); } |
346 | | - half SAMPLE_DEPTH_TEXTURE(sampler2D s, float2 uv) { return tex2D<float>(s, uv); } |
347 | | -# define SAMPLE_DEPTH_TEXTURE_PROJ(sampler, uv) (tex2DprojShadow(sampler, uv)) |
348 | | -# define SAMPLE_DEPTH_TEXTURE_LOD(sampler, uv) (tex2Dlod<float>(sampler, uv)) |
349 | | -# define SAMPLE_RAW_DEPTH_TEXTURE(sampler, uv) SAMPLE_DEPTH_TEXTURE(sampler, uv) |
350 | | -# define SAMPLE_RAW_DEPTH_TEXTURE_PROJ(sampler, uv) SAMPLE_DEPTH_TEXTURE_PROJ(sampler, uv) |
351 | | -# define SAMPLE_RAW_DEPTH_TEXTURE_LOD(sampler, uv) SAMPLE_DEPTH_TEXTURE_LOD(sampler, uv) |
352 | | - half SAMPLE_DEPTH_CUBE_TEXTURE(samplerCUBE s, float3 uv) { return texCUBE<float>(s, uv); } |
353 | | -#else |
354 | 319 | // Sample depth, just the red component. |
355 | 320 | # define SAMPLE_DEPTH_TEXTURE(sampler, uv) (tex2D(sampler, uv).r) |
356 | 321 | # define SAMPLE_DEPTH_TEXTURE_PROJ(sampler, uv) (tex2Dproj(sampler, uv).r) |
|
360 | 325 | # define SAMPLE_RAW_DEPTH_TEXTURE_PROJ(sampler, uv) (tex2Dproj(sampler, uv)) |
361 | 326 | # define SAMPLE_RAW_DEPTH_TEXTURE_LOD(sampler, uv) (tex2Dlod(sampler, uv)) |
362 | 327 | # define SAMPLE_DEPTH_CUBE_TEXTURE(sampler, uv) (texCUBE(sampler, uv).r) |
363 | | -#endif |
364 | 328 |
|
365 | 329 | // Deprecated; use SAMPLE_DEPTH_TEXTURE & SAMPLE_DEPTH_TEXTURE_PROJ instead |
366 | | -#if defined(SHADER_API_PSP2) |
367 | | -# define UNITY_SAMPLE_DEPTH(value) (value).r |
368 | | -#else |
369 | | -# define UNITY_SAMPLE_DEPTH(value) (value).r |
370 | | -#endif |
| 330 | +#define UNITY_SAMPLE_DEPTH(value) (value).r |
371 | 331 |
|
372 | 332 |
|
373 | 333 | // Macros to declare and sample shadow maps. |
|
411 | 371 | #define UNITY_SAMPLE_SHADOW(tex,coord) tex.SampleCmpLOD0(sampler##tex,(coord).xy,(coord).z) |
412 | 372 | #define UNITY_SAMPLE_SHADOW_PROJ(tex,coord) tex.SampleCmpLOD0(sampler##tex,(coord).xy/(coord).w,(coord).z/(coord).w) |
413 | 373 | #define UNITY_SAMPLE_TEXCUBE_SHADOW(tex,coord) tex.SampleCmpLOD0(sampler##tex,(coord).xyz,(coord).w) |
414 | | -#elif defined(SHADER_API_PSP2) |
415 | | - // Vita |
416 | | - #define UNITY_DECLARE_SHADOWMAP(tex) sampler2D tex |
417 | | - #define UNITY_DECLARE_TEXCUBE_SHADOWMAP(tex) samplerCUBE tex |
418 | | - // tex2d shadow comparison on Vita returns 0 instead of 1 when shadowCoord.z >= 1 causing artefacts in some tests. |
419 | | - // Clamping Z to the range 0.0 <= Z < 1.0 solves this. |
420 | | - #define UNITY_SAMPLE_SHADOW(tex,coord) tex2D<float>(tex, float3((coord).xy, clamp((coord).z, 0.0, 0.999999))) |
421 | | - #define UNITY_SAMPLE_SHADOW_PROJ(tex,coord) tex2DprojShadow(tex, coord) |
422 | | - #define UNITY_SAMPLE_TEXCUBE_SHADOW(tex,coord) texCUBE<float>(tex, float3((coord).xyz, clamp((coord).w, 0.0, 0.999999))) |
423 | 374 | #else |
424 | 375 | // Fallback / No built-in shadowmap comparison sampling: regular texture sample and do manual depth comparison |
425 | 376 | #define UNITY_DECLARE_SHADOWMAP(tex) sampler2D_float tex |
|
631 | 582 | #endif |
632 | 583 |
|
633 | 584 |
|
634 | | -// Declare position that is also available for read in fragment shader |
635 | | -#if defined(SHADER_API_PSP2) && defined(SHADER_STAGE_FRAGMENT) && SHADER_TARGET >= 30 |
636 | | -#define UNITY_POSITION(pos) float4 pos : VPOS |
637 | | -#else |
638 | 585 | // On D3D reading screen space coordinates from fragment shader requires SM3.0 |
639 | 586 | #define UNITY_POSITION(pos) float4 pos : SV_POSITION |
640 | | -#endif |
641 | 587 |
|
642 | 588 | // Kept for backwards-compatibility |
643 | 589 | #define UNITY_ATTEN_CHANNEL r |
644 | 590 |
|
645 | | -#if defined(SHADER_API_D3D11) || defined(SHADER_API_PSP2) || defined(SHADER_API_PSSL) || defined(SHADER_API_METAL) || defined(SHADER_API_VULKAN) || defined(SHADER_API_SWITCH) |
| 591 | +#if defined(SHADER_API_D3D11) || defined(SHADER_API_PSSL) || defined(SHADER_API_METAL) || defined(SHADER_API_VULKAN) || defined(SHADER_API_SWITCH) |
646 | 592 | #define UNITY_UV_STARTS_AT_TOP 1 |
647 | 593 | #endif |
648 | 594 |
|
|
665 | 611 | // UNITY_ENABLE_REFLECTION_BUFFERS - render reflection probes in deferred way, when using deferred shading |
666 | 612 |
|
667 | 613 |
|
668 | | -#if defined(SHADER_API_PSP2) |
669 | | -// To get acceptable precision from the SGX interpolators when decoding RGBM type |
670 | | -// textures we have to disable sRGB reads and then convert to gamma space in the shader |
671 | | -// explicitly. |
672 | | -#define UNITY_FORCE_LINEAR_READ_FOR_RGBM |
673 | | -#endif |
674 | | - |
675 | | - |
676 | 614 | // On most platforms, use floating point render targets to store depth of point |
677 | 615 | // light shadowmaps. However, on some others they either have issues, or aren't widely |
678 | 616 | // supported; in which case fallback to encoding depth into RGBA channels. |
679 | 617 | // Make sure this define matches GraphicsCaps.useRGBAForPointShadows. |
680 | | -#if defined(SHADER_API_GLES) || defined(SHADER_API_GLES3) || defined(SHADER_API_PSP2) |
| 618 | +#if defined(SHADER_API_GLES) || defined(SHADER_API_GLES3) |
681 | 619 | #define UNITY_USE_RGBA_FOR_POINT_SHADOWS |
682 | 620 | #endif |
683 | 621 |
|
|
730 | 668 | #endif |
731 | 669 |
|
732 | 670 | // define use to identify platform with modern feature like texture 3D with filtering, texture array etc... |
733 | | -#define UNITY_SM40_PLUS_PLATFORM (!((SHADER_TARGET < 30) || defined (SHADER_API_MOBILE) || defined (SHADER_API_PSP2) || defined(SHADER_API_GLES))) |
| 671 | +#define UNITY_SM40_PLUS_PLATFORM (!((SHADER_TARGET < 30) || defined (SHADER_API_MOBILE) || defined(SHADER_API_GLES))) |
734 | 672 |
|
735 | 673 | // Ability to manually set descriptor set and binding numbers (Vulkan only) |
736 | 674 | #if defined(SHADER_API_VULKAN) |
|
0 commit comments