Kav/Effects/HLSL/Macros.fxh

58 lines
1.8 KiB
Plaintext
Raw Normal View History

2020-08-05 03:50:44 +00:00
//-----------------------------------------------------------------------------
// Macros.fxh
//
// Microsoft XNA Community Game Platform
// Copyright (C) Microsoft Corporation. All rights reserved.
//-----------------------------------------------------------------------------
#ifdef SM4
// Macros for targetting shader model 4.0 (DX11)
#define BEGIN_CONSTANTS cbuffer Parameters : register(b0) {
#define MATRIX_CONSTANTS }; cbuffer ProjectionMatrix : register(b1) {
#define END_CONSTANTS };
#define _vs(r)
#define _ps(r)
#define _cb(r) : packoffset(r)
#define DECLARE_TEXTURE(Name, index) \
Texture2D<float4> Name : register(t##index); \
sampler Name##Sampler : register(s##index)
#define DECLARE_CUBEMAP(Name, index) \
TextureCube<float4> Name : register(t##index); \
sampler Name##Sampler : register(s##index)
#define SAMPLE_TEXTURE(Name, texCoord) Name.Sample(Name##Sampler, texCoord)
#define SAMPLE_CUBEMAP(Name, texCoord) Name.Sample(Name##Sampler, texCoord)
#define SAMPLE_CUBEMAP_LOD(Name, texCoord) Name.SampleLevel(Name##Sampler, texCoord.xyz, texCoord.w)
#else
// Macros for targetting shader model 2.0 (DX9)
#define BEGIN_CONSTANTS
#define MATRIX_CONSTANTS
#define END_CONSTANTS
#define _vs(r) : register(vs, r)
#define _ps(r) : register(ps, r)
#define _cb(r)
#define DECLARE_TEXTURE(Name, index) \
texture2D Name; \
sampler Name##Sampler : register(s##index) = sampler_state { Texture = (Name); };
#define DECLARE_CUBEMAP(Name, index) \
textureCUBE Name; \
sampler Name##Sampler : register(s##index) = sampler_state { Texture = (Name); };
#define SAMPLE_TEXTURE(Name, texCoord) tex2D(Name##Sampler, texCoord)
#define SAMPLE_CUBEMAP(Name, texCoord) texCUBE(Name##Sampler, texCoord)
#define SAMPLE_CUBEMAP_LOD(Name, texCoord) texCUBElod(Name##Sampler, texCoord)
#endif