#ifndef SHADERPARAMETER_H_ #define SHADERPARAMETER_H_ // this file is handling difference between platforms by defining macros #define COLOR0_C COLOR0 #define COLOR1_C COLOR1 #ifdef __CGC__ // VPOS HLSL's semantic is named WPOS on CG #define VPOS WPOS #endif #if defined(_NX_) || defined(__CGC__) #define BoneMatrix float3x4 #else #define BoneMatrix float4x3 #endif #define ITF_CONST const #if defined(_NX_) || defined(__PSSL__) || defined(VK_SHADERS) #define ITF_ALL2(vector) (float)all((bool2)vector) #define ITF_ALL3(vector) (float)all((bool3)vector) #define ITF_ALL4(vector) (float)all((bool4)vector) #define ITF_ANY2(vector) (float)any((bool2)vector) #define ITF_ANY3(vector) (float)any((bool3)vector) #define ITF_ANY4(vector) (float)any((bool4)vector) #else #define ITF_ALL2(vector) all(vector) #define ITF_ALL3(vector) all(vector) #define ITF_ALL4(vector) all(vector) #define ITF_ANY2(vector) any(vector) #define ITF_ANY3(vector) any(vector) #define ITF_ANY4(vector) any(vector) #endif #if ((defined(ITF_WIN32) || defined(ITF_WIN64)) && defined(DX11_SHADERS)) || defined(__PSSL__) #define REGISTER_SAMPLER(name, samp_num) \ Texture2D text_##name##samp_num : register(t##samp_num); \ SamplerState samp_##name##samp_num : register(s##samp_num); #define TEXTURE_READ_2D(name, samp_num, uv) text_##name##samp_num.Sample(samp_##name##samp_num, uv) #ifdef __PSSL__ #define PS_OUT_COLOR S_TARGET_OUTPUT0 #define VS_OUT_POS S_POSITION #else #define PS_OUT_COLOR SV_TARGET #define VS_OUT_POS SV_POSITION #endif #elif defined (DX12_SHADERS) // we use dynamic texturing. Texture declarations will be uints instead of textures, to index the textures dynamic array // also, register spaces are different between vertex & pixel Texture2D dynTextures[] : register(t0); cbuffer cbuf_samplers : register(b10) { uint textIDs[8]; }; #define REGISTER_SAMPLER(name, samp_num) \ SamplerState samp_##name##samp_num : register(s##samp_num); \ #define TEXTURE_READ_2D(name, samp_num, uv) dynTextures[textIDs[samp_num]].Sample(samp_##name##samp_num, uv) #define PS_OUT_COLOR SV_TARGET #define VS_OUT_POS SV_POSITION #elif (_NX_) #define REGISTER_SAMPLER(name, samp_num) sampler name##samp_num : register(s##samp_num); #define TEXTURE_READ_2D(name, samp_num, uv) tex2D(name##samp_num, uv) #define PS_OUT_COLOR SV_TARGET #define VS_OUT_POS SV_POSITION #else #define REGISTER_SAMPLER(name, samp_num) sampler name##samp_num : register(s##samp_num); #define TEXTURE_READ_2D(name, samp_num, uv) tex2D(name##samp_num, uv) #define PS_OUT_COLOR COLOR0 #define VS_OUT_POS POSITION #endif #endif