sampler refactor - part1

This commit is contained in:
turanszkij
2016-01-30 18:29:21 +01:00
parent 14cbdfc57e
commit e0ab36ea46
7 changed files with 61 additions and 23 deletions
+2 -2
View File
@@ -23,7 +23,7 @@
// On demand buffers:
// These are bound on demand and alive for undefined time
// These are bound on demand and alive until another is bound at the same slot
#define CBSLOT_RENDERER_CUBEMAPRENDER 11
#define CBSLOT_RENDERER_POINTLIGHT 12
#define CBSLOT_RENDERER_SPOTLIGHT 13
@@ -56,7 +56,7 @@
// Shader:
//////////
// Automatically binds constantbuffers in the shader side:
// Automatically binds constantbuffers on the shader side:
// Needs macro expansion
#define CBUFFER_X(name, slot) cbuffer name : register(b ## slot)
#define CBUFFER(name, slot) CBUFFER_X(name, slot)
+43
View File
@@ -0,0 +1,43 @@
#ifndef _SAMPLER_MAPPING_H_
#define _SAMPLER_MAPPING_H_
// Slot matchings:
////////////////////////////////////////////////////
// Persistent samplers
// These are bound once and are alive forever
#define SSLOT_LINEAR_CLAMP 4
#define SSLOT_LINEAR_WRAP 5
#define SSLOT_LINEAR_MIRROR 6
#define SSLOT_POINT_CLAMP 7
#define SSLOT_POINT_WRAP 8
#define SSLOT_POINT_MIRROR 9
#define SSLOT_ANISO_CLAMP 10
#define SSLOT_ANISO_WRAP 11
#define SSLOT_ANISO_MIRROR 12
#define SSLOT_SHADOWCOMP 13
#define SSLOT_RESERVED0 14
#define SSLOT_RESERVED1 15
// On demand samplers:
// These are bound on demand and alive until another is bound at the same slot
#define SSLOT_ONDEMAND0 0
#define SSLOT_ONDEMAND1 1
#define SSLOT_ONDEMAND2 2
#define SSLOT_ONDEMAND3 3
///////////////////////////
// Helpers:
///////////////////////////
// Shader:
//////////
// Automatically binds samplers on the shader side:
// Needs macro expansion
#define SAMPLERSTATE_X(name, slot) SamplerState name : register(s ## slot);
#define SAMPLERSTATE(name, slot) SAMPLERSTATE_X(name, slot)
#define SAMPLERCOMPARISONSTATE_X(name, slot) SamplerComparisonState name : register(s ## slot);
#define SAMPLERCOMPARISONSTATE(name, slot) SAMPLERCOMPARISONSTATE_X(name, slot)
#endif // _SAMPLER_MAPPING_H_
+1 -1
View File
@@ -502,6 +502,7 @@
<ClInclude Include="ConstantBufferMapping.h" />
<ClInclude Include="DeferredRenderableComponent_BindLua.h" />
<ClInclude Include="ForwardRenderableComponent_BindLua.h" />
<ClInclude Include="SamplerMapping.h" />
<ClInclude Include="wiGraphicsAPI.h" />
<ClInclude Include="LoadingScreenComponent_BindLua.h" />
<ClInclude Include="MainComponent_BindLua.h" />
@@ -858,7 +859,6 @@
<None Include="postProcessHF.hlsli" />
<None Include="quad.hlsli" />
<None Include="reconstructPositionHF.hlsli" />
<None Include="samplersHF.hlsli" />
<None Include="skinningHF.hlsli" />
<None Include="skyHF.hlsli" />
<None Include="sOHF.hlsli" />
+3 -3
View File
@@ -1789,6 +1789,9 @@
<ClInclude Include="ConstantBufferMapping.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="SamplerMapping.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="..\io_export_wicked_wi_bin.py" />
@@ -1870,9 +1873,6 @@
<None Include="reconstructPositionHF.hlsli">
<Filter>shaders\headers</Filter>
</None>
<None Include="samplersHF.hlsli">
<Filter>shaders\headers</Filter>
</None>
<None Include="skinningHF.hlsli">
<Filter>shaders\headers</Filter>
</None>
+12
View File
@@ -1,6 +1,18 @@
#ifndef _SHADERDEF_CONSTANTBUFFERS_
#define _SHADERDEF_CONSTANTBUFFERS_
#include "ConstantBufferMapping.h"
#include "SamplerMapping.h"
SAMPLERSTATE( sampler_linear_clamp, SSLOT_LINEAR_CLAMP )
SAMPLERSTATE( sampler_linear_wrap, SSLOT_LINEAR_WRAP )
SAMPLERSTATE( sampler_linear_mirror, SSLOT_LINEAR_MIRROR )
SAMPLERSTATE( sampler_point_clamp, SSLOT_POINT_CLAMP )
SAMPLERSTATE( sampler_point_wrap, SSLOT_POINT_WRAP )
SAMPLERSTATE( sampler_point_mirror, SSLOT_POINT_MIRROR )
SAMPLERSTATE( sampler_aniso_clamp, SSLOT_ANISO_CLAMP )
SAMPLERSTATE( sampler_aniso_wrap, SSLOT_ANISO_WRAP )
SAMPLERSTATE( sampler_aniso_mirror, SSLOT_ANISO_MIRROR )
SAMPLERCOMPARISONSTATE( sampler_shadow_cmp, SSLOT_SHADOWCOMP )
CBUFFER(WorldCB, CBSLOT_RENDERER_WORLD)
{
-10
View File
@@ -1,10 +0,0 @@
SamplerState sampler_linear_clamp :register(s0);
SamplerState sampler_linear_wrap :register(s1);
SamplerState sampler_linear_mirror :register(s2);
SamplerState sampler_point_clamp :register(s3);
SamplerState sampler_point_wrap :register(s4);
SamplerState sampler_point_mirror :register(s5);
SamplerState sampler_aniso_clamp :register(s6);
SamplerState sampler_aniso_wrap :register(s7);
SamplerState sampler_aniso_mirror :register(s8);
SamplerState sampler_cmp :register(s9);
-7
View File
@@ -661,11 +661,6 @@ public:
resource = nullptr;
}
//static void UpdatePerWorldCB(DeviceContext context);
//static void UpdatePerFrameCB(DeviceContext context);
//static void UpdatePerRenderCB(DeviceContext context, int tessF);
//static void UpdatePerViewCB(DeviceContext context, Camera* camera, Camera* refCamera, const XMFLOAT4& newClipPlane = XMFLOAT4(0,0,0,0));
//static void UpdatePerEffectCB(DeviceContext context, const XMFLOAT4& blackoutBlackWhiteInvCol, const XMFLOAT4 colorMask);
static void UpdateWorldCB(DeviceContext context);
static void UpdateFrameCB(DeviceContext context);
static void UpdateCameraCB(DeviceContext context);
@@ -675,7 +670,6 @@ public:
static void DrawSun(DeviceContext context);
static void DrawWorld(Camera* camera, bool DX11Eff, int tessF, DeviceContext context
, bool BlackOut, bool isReflection, SHADERTYPE shaded, TextureView refRes, bool grass, GRAPHICSTHREAD thread);
//static void DrawForSO(DeviceContext context);
static void ClearShadowMaps(DeviceContext context);
static void DrawForShadowMap(DeviceContext context);
static void DrawWorldTransparent(Camera* camera, TextureView refracRes, TextureView refRes
@@ -736,7 +730,6 @@ public:
string DIRECTORY;
struct Picked
{
Object* object;