renewed tessellation support

This commit is contained in:
turanszkij
2016-09-12 22:25:35 +02:00
parent 9a15325477
commit e76c03e37b
20 changed files with 266 additions and 176 deletions
+1
View File
@@ -29,6 +29,7 @@
#define CBSLOT_RENDERER_SPOTLIGHT 13
#define CBSLOT_RENDERER_VOLUMELIGHT 11
#define CBSLOT_RENDERER_DECAL 11
#define CBSLOT_RENDERER_TESSELLATION 11
#define CBSLOT_OTHER_EMITTEDPARTICLE 11
#define CBSLOT_OTHER_HAIRPARTICLE 11
+4 -4
View File
@@ -90,8 +90,8 @@ void DeferredRenderableComponent::Render()
}
void DeferredRenderableComponent::RenderScene(GRAPHICSTHREAD threadID){
static const int tessellationQuality = 0;
void DeferredRenderableComponent::RenderScene(GRAPHICSTHREAD threadID)
{
wiImageEffects fx((float)wiRenderer::GetDevice()->GetScreenWidth(), (float)wiRenderer::GetDevice()->GetScreenHeight());
rtGBuffer.Activate(threadID, 0, 0, 0, 0);
@@ -99,7 +99,7 @@ void DeferredRenderableComponent::RenderScene(GRAPHICSTHREAD threadID){
wiRenderer::SetClipPlane(XMFLOAT4(0, 0, 0, 0), threadID);
wiRenderer::DrawWorld(wiRenderer::getCamera(), false, tessellationQuality, threadID, false
wiRenderer::DrawWorld(wiRenderer::getCamera(), getTessellationEnabled(), threadID, false
, SHADERTYPE_DEFERRED, rtReflection.GetTexture(), true);
}
@@ -263,7 +263,7 @@ void DeferredRenderableComponent::setPreferredThreadingCount(unsigned short valu
{
Renderable3DComponent::setPreferredThreadingCount(value);
if (!wiRenderer::GetDevice()->GetMultithreadingSupport())
if (!wiRenderer::GetDevice()->CheckCapability(GraphicsDevice::GRAPHICSDEVICE_CAPABILITY_MULTITHREADED_RENDERING))
{
if (value > 1)
wiHelper::messageBox("Multithreaded rendering not supported by your hardware! Falling back to single threading!", "Caution");
@@ -48,6 +48,7 @@ Luna<DeferredRenderableComponent_BindLua>::FunctionType DeferredRenderableCompon
lunamethod(Renderable3DComponent_BindLua, SetDepthOfFieldEnabled),
lunamethod(Renderable3DComponent_BindLua, SetStereogramEnabled),
lunamethod(Renderable3DComponent_BindLua, SetEyeAdaptionEnabled),
lunamethod(Renderable3DComponent_BindLua, SetTessellationEnabled),
lunamethod(Renderable3DComponent_BindLua, SetDepthOfFieldFocus),
lunamethod(Renderable3DComponent_BindLua, SetDepthOfFieldStrength),
+2 -2
View File
@@ -77,7 +77,7 @@ void ForwardRenderableComponent::RenderScene(GRAPHICSTHREAD threadID)
wiRenderer::SetClipPlane(XMFLOAT4(0, 0, 0, 0), threadID);
wiRenderer::DrawWorld(wiRenderer::getCamera(), false, 0, threadID
wiRenderer::DrawWorld(wiRenderer::getCamera(), getTessellationEnabled(), threadID
, false, SHADERTYPE_FORWARD
, nullptr, true);
wiRenderer::DrawSky(threadID);
@@ -103,7 +103,7 @@ void ForwardRenderableComponent::setPreferredThreadingCount(unsigned short value
{
Renderable3DComponent::setPreferredThreadingCount(value);
if (!wiRenderer::GetDevice()->GetMultithreadingSupport())
if (!wiRenderer::GetDevice()->CheckCapability(GraphicsDevice::GRAPHICSDEVICE_CAPABILITY_MULTITHREADED_RENDERING))
{
if (value > 1)
wiHelper::messageBox("Multithreaded rendering not supported by your hardware! Falling back to single threading!", "Caution");
@@ -48,6 +48,7 @@ Luna<ForwardRenderableComponent_BindLua>::FunctionType ForwardRenderableComponen
lunamethod(Renderable3DComponent_BindLua, SetDepthOfFieldEnabled),
lunamethod(Renderable3DComponent_BindLua, SetStereogramEnabled),
lunamethod(Renderable3DComponent_BindLua, SetEyeAdaptionEnabled),
lunamethod(Renderable3DComponent_BindLua, SetTessellationEnabled),
lunamethod(Renderable3DComponent_BindLua, SetDepthOfFieldFocus),
lunamethod(Renderable3DComponent_BindLua, SetDepthOfFieldStrength),
+3 -2
View File
@@ -55,6 +55,7 @@ void Renderable3DComponent::setProperties()
setDepthOfFieldEnabled(false);
setStereogramEnabled(false);
setEyeAdaptionEnabled(false);
setTessellationEnabled(false);
setPreferredThreadingCount(0);
}
@@ -209,7 +210,7 @@ void Renderable3DComponent::RenderReflections(GRAPHICSTHREAD threadID)
wiRenderer::SetClipPlane(water, threadID);
wiRenderer::DrawWorld(wiRenderer::getRefCamera(), false, 0, threadID
wiRenderer::DrawWorld(wiRenderer::getRefCamera(), false, threadID
, true, SHADERTYPE_TEXTURE
, nullptr, getHairParticlesReflectionEnabled());
wiRenderer::DrawSky(threadID,true);
@@ -242,7 +243,7 @@ void Renderable3DComponent::RenderSecondaryScene(wiRenderTarget& mainRT, wiRende
if (getLensFlareEnabled())
{
rtLensFlare.Activate(threadID);
if (!wiRenderer::GetRasterizer())
if (!wiRenderer::IsWireRender())
wiRenderer::DrawLensFlares(threadID);
}
+4
View File
@@ -3,6 +3,7 @@
#include "wiTaskThread.h"
#include "wiRenderer.h"
#include "wiWaterPlane.h"
#include "wiGraphicsDevice.h"
#include <atomic>
class Renderable3DComponent :
@@ -42,6 +43,7 @@ private:
bool depthOfFieldEnabled;
bool stereogramEnabled;
bool eyeAdaptionEnabled;
bool tessellationEnabled;
protected:
wiRenderTarget
@@ -107,6 +109,7 @@ public:
inline bool getDepthOfFieldEnabled(){ return depthOfFieldEnabled; }
inline bool getStereogramEnabled() { return stereogramEnabled; }
inline bool getEyeAdaptionEnabled() { return eyeAdaptionEnabled; }
inline bool getTessellationEnabled() { return tessellationEnabled && wiRenderer::GetDevice()->CheckCapability(wiGraphicsTypes::GraphicsDevice::GRAPHICSDEVICE_CAPABILITY_TESSELLATION); }
inline unsigned int getThreadingCount(){ return (unsigned int)workerThreads.size(); }
@@ -143,6 +146,7 @@ public:
inline void setDepthOfFieldEnabled(bool value){ depthOfFieldEnabled = value; }
inline void setStereogramEnabled(bool value) { stereogramEnabled = value; }
inline void setEyeAdaptionEnabled(bool value) { eyeAdaptionEnabled = value; }
inline void setTessellationEnabled(bool value) { tessellationEnabled = value; }
virtual void setPreferredThreadingCount(unsigned short value);
@@ -49,6 +49,7 @@ Luna<Renderable3DComponent_BindLua>::FunctionType Renderable3DComponent_BindLua:
lunamethod(Renderable3DComponent_BindLua, SetDepthOfFieldEnabled),
lunamethod(Renderable3DComponent_BindLua, SetStereogramEnabled),
lunamethod(Renderable3DComponent_BindLua, SetEyeAdaptionEnabled),
lunamethod(Renderable3DComponent_BindLua, SetTessellationEnabled),
lunamethod(Renderable3DComponent_BindLua, SetDepthOfFieldFocus),
lunamethod(Renderable3DComponent_BindLua, SetDepthOfFieldStrength),
@@ -315,6 +316,21 @@ int Renderable3DComponent_BindLua::SetEyeAdaptionEnabled(lua_State* L)
wiLua::SError(L, "SetEyeAdaptionEnabled(bool value) not enough arguments!");
return 0;
}
int Renderable3DComponent_BindLua::SetTessellationEnabled(lua_State* L)
{
if (component == nullptr)
{
wiLua::SError(L, "SetTessellationEnabled(bool value) component is null!");
return 0;
}
if (wiLua::SGetArgCount(L) > 0)
{
((Renderable3DComponent*)component)->setTessellationEnabled(wiLua::SGetBool(L, 1));
}
else
wiLua::SError(L, "SetTessellationEnabled(bool value) not enough arguments!");
return 0;
}
int Renderable3DComponent_BindLua::SetDepthOfFieldFocus(lua_State* L)
@@ -33,6 +33,7 @@ public:
int SetDepthOfFieldEnabled(lua_State* L);
int SetStereogramEnabled(lua_State* L);
int SetEyeAdaptionEnabled(lua_State* L);
int SetTessellationEnabled(lua_State* L);
int SetDepthOfFieldFocus(lua_State* L);
int SetDepthOfFieldStrength(lua_State* L);
+2 -1
View File
@@ -50,7 +50,8 @@ struct LightOutputType
return Out;
#define DEFERREDLIGHT_ENVIRONMENTALLIGHT \
#define DEFERREDLIGHT_ENVIRONMENTALLIGHT \
diffuse = 0; \
specular = EnvironmentReflection(N, V, P, roughness, f0);
#endif // _LIGHTHF_
+21 -21
View File
@@ -10,28 +10,23 @@ struct ConstantOutputType
float3 f3B1 : POSITION1;
float3 f3B2 : POSITION2;
float3 f3N0 : NORMAL0;
float3 f3N1 : NORMAL1;
float3 f3N2 : NORMAL2;
float4 f4N0 : NORMAL0;
float4 f4N1 : NORMAL1;
float4 f4N2 : NORMAL2;
};
struct HullOutputType
{
float3 pos : POSITION;
float3 tex : TEXCOORD0;
float3 nor : NORMAL;
float3 vel : TEXCOORD1;
float3 pos : POSITION;
float3 tex : TEXCOORD0;
float3 nor : NORMAL;
float3 vel : TEXCOORD1;
nointerpolation float3 instanceColor : INSTANCECOLOR;
nointerpolation float dither : DITHER;
};
float3 GetLightDirection(float3 pos3D, float3 lightPos)
{
return normalize(pos3D - lightPos);
}
//=================================================================================================================================
// Utility phong functions
@@ -47,9 +42,9 @@ float3 PhongGeometry(float u, float v, float w, ConstantOutputType hsc)
// Find local space point
float3 p = w * hsc.f3B0 + u * hsc.f3B1 + v * hsc.f3B2;
// Find projected vectors
float3 c0 = project(p, hsc.f3B0, hsc.f3N0);
float3 c1 = project(p, hsc.f3B1, hsc.f3N1);
float3 c2 = project(p, hsc.f3B2, hsc.f3N2);
float3 c0 = project(p, hsc.f3B0, hsc.f4N0);
float3 c1 = project(p, hsc.f3B1, hsc.f4N1);
float3 c2 = project(p, hsc.f3B2, hsc.f4N2);
// Interpolate
float3 q = w * c0 + u * c1 + v * c2;
// For blending between tessellated and untessellated model:
@@ -58,10 +53,10 @@ float3 PhongGeometry(float u, float v, float w, ConstantOutputType hsc)
}
// Computes the normal of a point in the Phong Tessellated triangle
float3 PhongNormal(float u, float v, float w, ConstantOutputType hsc)
float4 PhongNormal(float u, float v, float w, ConstantOutputType hsc)
{
// Interpolate
return normalize(w * hsc.f3N0 + u * hsc.f3N1 + v * hsc.f3N2);
return normalize(w * hsc.f4N0 + u * hsc.f4N1 + v * hsc.f4N2);
}
////////////////////////////////////////////////////////////////////////////////
@@ -74,7 +69,7 @@ PixelInputType main(ConstantOutputType input, float3 uvwCoord : SV_DomainLocatio
float4 vertexPosition;
float3 vertexNormal;
float4 vertexNormal;
float2 vertexTex;
float3 vertexVel;
@@ -104,7 +99,7 @@ PixelInputType main(ConstantOutputType input, float3 uvwCoord : SV_DomainLocatio
Out.pos = Out.pos2D = mul( vertexPosition, g_xCamera_VP );
Out.pos3D = vertexPosition.xyz;
Out.tex = vertexTex.xy;
Out.nor = vertexNormal;
Out.nor = normalize(vertexNormal);
/*float2x3 tanbin = tangentBinormal(Out.nor);
Out.tan=tanbin[0];
Out.bin=tanbin[1];*/
@@ -124,6 +119,11 @@ PixelInputType main(ConstantOutputType input, float3 uvwCoord : SV_DomainLocatio
//Out.vel += (Out.pos.xyz-mul(vertexPosition,xPrevViewProjection).xyz)*0.10;
//Out.mat = mat;
Out.ao = vertexNormal.w;
Out.instanceColor = patch[0].instanceColor.rgb;
Out.dither = patch[0].dither;
return Out;
}
+29 -20
View File
@@ -1,15 +1,20 @@
cbuffer tessBuf:register(b0)
#include "globals.hlsli"
#define g_f4Eye g_xCamera_CamPos
CBUFFER(TessellationCB, CBSLOT_RENDERER_TESSELLATION)
{
float4 g_f4Eye;
float4 g_f4TessFactors;
};
struct HullInputType
{
float3 f3Position : POSITION;
float3 tex : TEXCOORD0;
float3 f3Normal : NORMAL;
float3 vel : TEXCOORD1;
float3 f3Position : POSITION;
float3 tex : TEXCOORD0;
float4 f4Normal : NORMAL;
float3 vel : TEXCOORD1;
nointerpolation float3 instanceColor : INSTANCECOLOR;
nointerpolation float dither : DITHER;
};
//The ConstantOutputType structure is what will be the output from the patch constant function.
@@ -25,18 +30,20 @@ struct ConstantOutputType
float3 f3B1 : POSITION1;
float3 f3B2 : POSITION2;
float3 f3N0 : NORMAL0;
float3 f3N1 : NORMAL1;
float3 f3N2 : NORMAL2;
float4 f4N0 : NORMAL0;
float4 f4N1 : NORMAL1;
float4 f4N2 : NORMAL2;
};
//The HullOutputType structure is what will be the output from the hull shader.
struct HullOutputType
{
float3 pos : POSITION;
float3 tex : TEXCOORD0;
float3 nor : NORMAL;
float3 vel : TEXCOORD1;
float3 pos : POSITION;
float3 tex : TEXCOORD0;
float4 nor : NORMAL;
float3 vel : TEXCOORD1;
nointerpolation float3 instanceColor : INSTANCECOLOR;
nointerpolation float dither : DITHER;
};
@@ -101,9 +108,9 @@ ConstantOutputType PatchConstantFunction(InputPatch<HullInputType, 3> I)
O.f3B1 = I[1].f3Position;
O.f3B2 = I[2].f3Position;
O.f3N0 = I[0].f3Normal;
O.f3N1 = I[1].f3Normal;
O.f3N2 = I[2].f3Normal;
O.f4N0 = I[0].f4Normal;
O.f4N1 = I[1].f4Normal;
O.f4N2 = I[2].f4Normal;
return O;
}
@@ -120,10 +127,12 @@ HullOutputType main(InputPatch<HullInputType, 3> patch, uint pointId : SV_Output
{
HullOutputType Out = (HullOutputType)0;
Out.pos = patch[pointId].f3Position.xyz;
Out.tex = patch[pointId].tex;
Out.nor = patch[pointId].f3Normal.xyz;
Out.vel = patch[pointId].vel.xyz;
Out.pos = patch[pointId].f3Position.xyz;
Out.tex = patch[pointId].tex;
Out.nor = patch[pointId].f4Normal;
Out.vel = patch[pointId].vel.xyz;
Out.instanceColor = patch[pointId].instanceColor.rgb;
Out.dither = patch[pointId].dither;
return Out;
}
+10 -5
View File
@@ -3,10 +3,12 @@
struct HullInputType
{
float3 pos : POSITION0;
float3 tex : TEXCOORD0;
float3 nor : NORMAL;
float3 vel : TEXCOORD1;
float3 pos : POSITION0;
float3 tex : TEXCOORD0;
float4 nor : NORMAL;
float3 vel : TEXCOORD1;
nointerpolation float3 instanceColor : INSTANCECOLOR;
nointerpolation float dither : DITHER;
};
@@ -35,8 +37,11 @@ HullInputType main(Input input)
Out.pos=pos.xyz;
Out.tex=input.tex.xyz;
Out.nor = normalize(normal);
Out.nor.xyz = normalize(normal);
Out.nor.w = input.nor.w;
Out.instanceColor = input.color_dither.rgb;
Out.dither = input.color_dither.a;
return Out;
}
+1
View File
@@ -69,6 +69,7 @@ enum CBTYPES
CBTYPE_CUBEMAPRENDER,
CBTYPE_SHADOW,
CBTYPE_CLIPPLANE,
CBTYPE_TESSELLATION,
CBTYPE_LAST
};
+8 -2
View File
@@ -48,8 +48,6 @@ namespace wiGraphicsTypes
virtual void ExecuteDeferredContexts() = 0;
virtual void FinishCommandList(GRAPHICSTHREAD thread) = 0;
virtual bool GetMultithreadingSupport() = 0;
bool GetVSyncEnabled() { return VSYNC; }
void SetVSyncEnabled(bool value) { VSYNC = value; }
long GetFrameCount() { return FRAMECOUNT; }
@@ -62,6 +60,14 @@ namespace wiGraphicsTypes
virtual Texture2D GetBackBuffer() = 0;
enum GRAPHICSDEVICE_CAPABILITY
{
GRAPHICSDEVICE_CAPABILITY_TESSELLATION,
GRAPHICSDEVICE_CAPABILITY_MULTITHREADED_RENDERING,
GRAPHICSDEVICE_CAPABILITY_COUNT,
};
virtual bool CheckCapability(GRAPHICSDEVICE_CAPABILITY capability) = 0;
///////////////Thread-sensitive////////////////////////
virtual void BindViewports(UINT NumViewports, const ViewPort *pViewports, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE) = 0;
+17
View File
@@ -208,6 +208,23 @@ Texture2D GraphicsDevice_DX11::GetBackBuffer()
return result;
}
bool GraphicsDevice_DX11::CheckCapability(GRAPHICSDEVICE_CAPABILITY capability)
{
switch (capability)
{
case wiGraphicsTypes::GraphicsDevice::GRAPHICSDEVICE_CAPABILITY_TESSELLATION:
return DX11;
break;
case wiGraphicsTypes::GraphicsDevice::GRAPHICSDEVICE_CAPABILITY_MULTITHREADED_RENDERING:
return DEFERREDCONTEXT_SUPPORT;
break;
case wiGraphicsTypes::GraphicsDevice::GRAPHICSDEVICE_CAPABILITY_COUNT:
break;
default:
break;
}
}
// Engine -> Native converters
inline UINT _ParseBindFlags(UINT value)
+86 -86
View File
@@ -41,104 +41,104 @@ namespace wiGraphicsTypes
~GraphicsDevice_DX11();
virtual HRESULT CreateBuffer(const GPUBufferDesc *pDesc, const SubresourceData* pInitialData, GPUBuffer *ppBuffer);
virtual HRESULT CreateTexture1D();
virtual HRESULT CreateTexture2D(const Texture2DDesc* pDesc, const SubresourceData *pInitialData, Texture2D **ppTexture2D);
virtual HRESULT CreateTexture3D();
virtual HRESULT CreateTextureCube(const Texture2DDesc* pDesc, const SubresourceData *pInitialData, TextureCube **ppTextureCube);
virtual HRESULT CreateShaderResourceView(Texture2D* pTexture);
virtual HRESULT CreateRenderTargetView(Texture2D* pTexture);
virtual HRESULT CreateDepthStencilView(Texture2D* pTexture);
virtual HRESULT CreateBuffer(const GPUBufferDesc *pDesc, const SubresourceData* pInitialData, GPUBuffer *ppBuffer) override;
virtual HRESULT CreateTexture1D() override;
virtual HRESULT CreateTexture2D(const Texture2DDesc* pDesc, const SubresourceData *pInitialData, Texture2D **ppTexture2D) override;
virtual HRESULT CreateTexture3D() override;
virtual HRESULT CreateTextureCube(const Texture2DDesc* pDesc, const SubresourceData *pInitialData, TextureCube **ppTextureCube) override;
virtual HRESULT CreateShaderResourceView(Texture2D* pTexture) override;
virtual HRESULT CreateRenderTargetView(Texture2D* pTexture) override;
virtual HRESULT CreateDepthStencilView(Texture2D* pTexture) override;
virtual HRESULT CreateInputLayout(const VertexLayoutDesc *pInputElementDescs, UINT NumElements,
const void *pShaderBytecodeWithInputSignature, SIZE_T BytecodeLength, VertexLayout *pInputLayout);
virtual HRESULT CreateVertexShader(const void *pShaderBytecode, SIZE_T BytecodeLength, ClassLinkage* pClassLinkage, VertexShader *pVertexShader);
virtual HRESULT CreatePixelShader(const void *pShaderBytecode, SIZE_T BytecodeLength, ClassLinkage* pClassLinkage, PixelShader *pPixelShader);
virtual HRESULT CreateGeometryShader(const void *pShaderBytecode, SIZE_T BytecodeLength, ClassLinkage* pClassLinkage, GeometryShader *pGeometryShader);
const void *pShaderBytecodeWithInputSignature, SIZE_T BytecodeLength, VertexLayout *pInputLayout) override;
virtual HRESULT CreateVertexShader(const void *pShaderBytecode, SIZE_T BytecodeLength, ClassLinkage* pClassLinkage, VertexShader *pVertexShader) override;
virtual HRESULT CreatePixelShader(const void *pShaderBytecode, SIZE_T BytecodeLength, ClassLinkage* pClassLinkage, PixelShader *pPixelShader) override;
virtual HRESULT CreateGeometryShader(const void *pShaderBytecode, SIZE_T BytecodeLength, ClassLinkage* pClassLinkage, GeometryShader *pGeometryShader) override;
virtual HRESULT CreateGeometryShaderWithStreamOutput(const void *pShaderBytecode, SIZE_T BytecodeLength, const StreamOutDeclaration *pSODeclaration,
UINT NumEntries, const UINT *pBufferStrides, UINT NumStrides, UINT RasterizedStream, ClassLinkage* pClassLinkage, GeometryShader *pGeometryShader);
virtual HRESULT CreateHullShader(const void *pShaderBytecode, SIZE_T BytecodeLength, ClassLinkage* pClassLinkage, HullShader *pHullShader);
virtual HRESULT CreateDomainShader(const void *pShaderBytecode, SIZE_T BytecodeLength, ClassLinkage* pClassLinkage, DomainShader *pDomainShader);
virtual HRESULT CreateComputeShader(const void *pShaderBytecode, SIZE_T BytecodeLength, ClassLinkage* pClassLinkage, ComputeShader *pComputeShader);
virtual HRESULT CreateBlendState(const BlendStateDesc *pBlendStateDesc, BlendState *pBlendState);
virtual HRESULT CreateDepthStencilState(const DepthStencilStateDesc *pDepthStencilStateDesc, DepthStencilState *pDepthStencilState);
virtual HRESULT CreateRasterizerState(const RasterizerStateDesc *pRasterizerStateDesc, RasterizerState *pRasterizerState);
virtual HRESULT CreateSamplerState(const SamplerDesc *pSamplerDesc, Sampler *pSamplerState);
UINT NumEntries, const UINT *pBufferStrides, UINT NumStrides, UINT RasterizedStream, ClassLinkage* pClassLinkage, GeometryShader *pGeometryShader) override;
virtual HRESULT CreateHullShader(const void *pShaderBytecode, SIZE_T BytecodeLength, ClassLinkage* pClassLinkage, HullShader *pHullShader) override;
virtual HRESULT CreateDomainShader(const void *pShaderBytecode, SIZE_T BytecodeLength, ClassLinkage* pClassLinkage, DomainShader *pDomainShader) override;
virtual HRESULT CreateComputeShader(const void *pShaderBytecode, SIZE_T BytecodeLength, ClassLinkage* pClassLinkage, ComputeShader *pComputeShader) override;
virtual HRESULT CreateBlendState(const BlendStateDesc *pBlendStateDesc, BlendState *pBlendState) override;
virtual HRESULT CreateDepthStencilState(const DepthStencilStateDesc *pDepthStencilStateDesc, DepthStencilState *pDepthStencilState) override;
virtual HRESULT CreateRasterizerState(const RasterizerStateDesc *pRasterizerStateDesc, RasterizerState *pRasterizerState) override;
virtual HRESULT CreateSamplerState(const SamplerDesc *pSamplerDesc, Sampler *pSamplerState) override;
virtual void PresentBegin();
virtual void PresentEnd();
virtual void PresentBegin() override;
virtual void PresentEnd() override;
virtual void ExecuteDeferredContexts();
virtual void FinishCommandList(GRAPHICSTHREAD thread);
virtual void ExecuteDeferredContexts() override;
virtual void FinishCommandList(GRAPHICSTHREAD thread) override;
virtual bool GetMultithreadingSupport() { return DEFERREDCONTEXT_SUPPORT; }
virtual void SetScreenWidth(int value) override;
virtual void SetScreenHeight(int value) override;
virtual void SetScreenWidth(int value);
virtual void SetScreenHeight(int value);
virtual Texture2D GetBackBuffer() override;
virtual Texture2D GetBackBuffer();
virtual bool CheckCapability(GRAPHICSDEVICE_CAPABILITY capability) override;
///////////////Thread-sensitive////////////////////////
virtual void BindViewports(UINT NumViewports, const ViewPort *pViewports, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE);
virtual void BindRenderTargets(UINT NumViews, Texture2D* const *ppRenderTargetViews, Texture2D* depthStencilTexture, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE);
virtual void ClearRenderTarget(Texture2D* pTexture, const FLOAT ColorRGBA[4], GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE);
virtual void ClearDepthStencil(Texture2D* pTexture, UINT ClearFlags, FLOAT Depth, UINT8 Stencil, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE);
virtual void BindResourcePS(const GPUResource* resource, int slot, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE);
virtual void BindResourceVS(const GPUResource* resource, int slot, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE);
virtual void BindResourceGS(const GPUResource* resource, int slot, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE);
virtual void BindResourceDS(const GPUResource* resource, int slot, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE);
virtual void BindResourceHS(const GPUResource* resource, int slot, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE);
virtual void BindResourceCS(const GPUResource* resource, int slot, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE);
virtual void BindUnorderedAccessResourceCS(const GPUUnorderedResource* buffer, int slot, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE);
virtual void UnBindResources(int slot, int num, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE);
virtual void UnBindUnorderedAccessResources(int slot, int num, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE);
virtual void BindSamplerPS(const Sampler* sampler, int slot, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE);
virtual void BindSamplerVS(const Sampler* sampler, int slot, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE);
virtual void BindSamplerGS(const Sampler* sampler, int slot, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE);
virtual void BindSamplerHS(const Sampler* sampler, int slot, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE);
virtual void BindSamplerDS(const Sampler* sampler, int slot, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE);
virtual void BindSamplerCS(const Sampler* sampler, int slot, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE);
virtual void BindConstantBufferPS(const GPUBuffer* buffer, int slot, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE);
virtual void BindConstantBufferVS(const GPUBuffer* buffer, int slot, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE);
virtual void BindConstantBufferGS(const GPUBuffer* buffer, int slot, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE);
virtual void BindConstantBufferDS(const GPUBuffer* buffer, int slot, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE);
virtual void BindConstantBufferHS(const GPUBuffer* buffer, int slot, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE);
virtual void BindConstantBufferCS(const GPUBuffer* buffer, int slot, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE);
virtual void BindVertexBuffer(const GPUBuffer* vertexBuffer, int slot, UINT stride, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE);
virtual void BindIndexBuffer(const GPUBuffer* indexBuffer, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE);
virtual void BindPrimitiveTopology(PRIMITIVETOPOLOGY type, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE);
virtual void BindVertexLayout(const VertexLayout* layout, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE);
virtual void BindBlendState(const BlendState* state, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE);
virtual void BindBlendStateEx(const BlendState* state, const XMFLOAT4& blendFactor = XMFLOAT4(1, 1, 1, 1), UINT sampleMask = 0xffffffff, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE);
virtual void BindDepthStencilState(const DepthStencilState* state, UINT stencilRef, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE);
virtual void BindRasterizerState(const RasterizerState* state, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE);
virtual void BindStreamOutTarget(const GPUBuffer* buffer, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE);
virtual void BindPS(const PixelShader* shader, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE);
virtual void BindVS(const VertexShader* shader, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE);
virtual void BindGS(const GeometryShader* shader, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE);
virtual void BindHS(const HullShader* shader, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE);
virtual void BindDS(const DomainShader* shader, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE);
virtual void BindCS(const ComputeShader* shader, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE);
virtual void Draw(int vertexCount, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE);
virtual void DrawIndexed(int indexCount, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE);
virtual void DrawInstanced(int vertexCount, int instanceCount, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE);
virtual void DrawIndexedInstanced(int indexCount, int instanceCount, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE);
virtual void Dispatch(UINT threadGroupCountX, UINT threadGroupCountY, UINT threadGroupCountZ, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE);
virtual void GenerateMips(Texture* texture, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE);
virtual void CopyTexture2D(Texture2D* pDst, const Texture2D* pSrc, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE);
virtual void UpdateBuffer(GPUBuffer* buffer, const void* data, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE, int dataSize = -1);
virtual GPUBuffer* DownloadBuffer(GPUBuffer* buffer, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE);
virtual void Map(GPUBuffer* resource, UINT subResource, MAP mapType, UINT mapFlags, MappedSubresource* mappedResource, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE);
virtual void Unmap(GPUBuffer* resource, UINT subResource, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE);
virtual void SetScissorRects(UINT numRects, const Rect* rects = nullptr, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE);
virtual void BindViewports(UINT NumViewports, const ViewPort *pViewports, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE) override;
virtual void BindRenderTargets(UINT NumViews, Texture2D* const *ppRenderTargetViews, Texture2D* depthStencilTexture, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE) override;
virtual void ClearRenderTarget(Texture2D* pTexture, const FLOAT ColorRGBA[4], GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE) override;
virtual void ClearDepthStencil(Texture2D* pTexture, UINT ClearFlags, FLOAT Depth, UINT8 Stencil, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE) override;
virtual void BindResourcePS(const GPUResource* resource, int slot, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE) override;
virtual void BindResourceVS(const GPUResource* resource, int slot, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE) override;
virtual void BindResourceGS(const GPUResource* resource, int slot, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE) override;
virtual void BindResourceDS(const GPUResource* resource, int slot, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE) override;
virtual void BindResourceHS(const GPUResource* resource, int slot, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE) override;
virtual void BindResourceCS(const GPUResource* resource, int slot, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE) override;
virtual void BindUnorderedAccessResourceCS(const GPUUnorderedResource* buffer, int slot, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE) override;
virtual void UnBindResources(int slot, int num, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE) override;
virtual void UnBindUnorderedAccessResources(int slot, int num, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE) override;
virtual void BindSamplerPS(const Sampler* sampler, int slot, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE) override;
virtual void BindSamplerVS(const Sampler* sampler, int slot, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE) override;
virtual void BindSamplerGS(const Sampler* sampler, int slot, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE) override;
virtual void BindSamplerHS(const Sampler* sampler, int slot, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE) override;
virtual void BindSamplerDS(const Sampler* sampler, int slot, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE) override;
virtual void BindSamplerCS(const Sampler* sampler, int slot, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE) override;
virtual void BindConstantBufferPS(const GPUBuffer* buffer, int slot, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE) override;
virtual void BindConstantBufferVS(const GPUBuffer* buffer, int slot, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE) override;
virtual void BindConstantBufferGS(const GPUBuffer* buffer, int slot, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE) override;
virtual void BindConstantBufferDS(const GPUBuffer* buffer, int slot, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE) override;
virtual void BindConstantBufferHS(const GPUBuffer* buffer, int slot, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE) override;
virtual void BindConstantBufferCS(const GPUBuffer* buffer, int slot, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE) override;
virtual void BindVertexBuffer(const GPUBuffer* vertexBuffer, int slot, UINT stride, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE) override;
virtual void BindIndexBuffer(const GPUBuffer* indexBuffer, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE) override;
virtual void BindPrimitiveTopology(PRIMITIVETOPOLOGY type, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE) override;
virtual void BindVertexLayout(const VertexLayout* layout, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE) override;
virtual void BindBlendState(const BlendState* state, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE) override;
virtual void BindBlendStateEx(const BlendState* state, const XMFLOAT4& blendFactor = XMFLOAT4(1, 1, 1, 1), UINT sampleMask = 0xffffffff, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE) override;
virtual void BindDepthStencilState(const DepthStencilState* state, UINT stencilRef, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE) override;
virtual void BindRasterizerState(const RasterizerState* state, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE) override;
virtual void BindStreamOutTarget(const GPUBuffer* buffer, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE) override;
virtual void BindPS(const PixelShader* shader, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE) override;
virtual void BindVS(const VertexShader* shader, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE) override;
virtual void BindGS(const GeometryShader* shader, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE) override;
virtual void BindHS(const HullShader* shader, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE) override;
virtual void BindDS(const DomainShader* shader, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE) override;
virtual void BindCS(const ComputeShader* shader, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE) override;
virtual void Draw(int vertexCount, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE) override;
virtual void DrawIndexed(int indexCount, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE) override;
virtual void DrawInstanced(int vertexCount, int instanceCount, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE) override;
virtual void DrawIndexedInstanced(int indexCount, int instanceCount, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE) override;
virtual void Dispatch(UINT threadGroupCountX, UINT threadGroupCountY, UINT threadGroupCountZ, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE) override;
virtual void GenerateMips(Texture* texture, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE) override;
virtual void CopyTexture2D(Texture2D* pDst, const Texture2D* pSrc, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE) override;
virtual void UpdateBuffer(GPUBuffer* buffer, const void* data, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE, int dataSize = -1) override;
virtual GPUBuffer* DownloadBuffer(GPUBuffer* buffer, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE) override;
virtual void Map(GPUBuffer* resource, UINT subResource, MAP mapType, UINT mapFlags, MappedSubresource* mappedResource, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE) override;
virtual void Unmap(GPUBuffer* resource, UINT subResource, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE) override;
virtual void SetScissorRects(UINT numRects, const Rect* rects = nullptr, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE) override;
virtual HRESULT CreateTextureFromFile(const string& fileName, Texture2D **ppTexture, bool mipMaps = true, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE);
virtual HRESULT SaveTexturePNG(const string& fileName, Texture2D *pTexture, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE);
virtual HRESULT SaveTextureDDS(const string& fileName, Texture *pTexture, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE);
virtual HRESULT CreateTextureFromFile(const string& fileName, Texture2D **ppTexture, bool mipMaps = true, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE) override;
virtual HRESULT SaveTexturePNG(const string& fileName, Texture2D *pTexture, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE) override;
virtual HRESULT SaveTextureDDS(const string& fileName, Texture *pTexture, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE) override;
virtual void EventBegin(const wchar_t* name, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE);
virtual void EventEnd(GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE);
virtual void SetMarker(const wchar_t* name, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE);
virtual void EventBegin(const wchar_t* name, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE) override;
virtual void EventEnd(GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE) override;
virtual void SetMarker(const wchar_t* name, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE) override;
};
}
+4
View File
@@ -373,6 +373,8 @@ struct Mesh{
float impostorDistance;
static wiGraphicsTypes::GPUBuffer impostorVB;
float tessellationFactor;
Mesh(){
init();
}
@@ -417,10 +419,12 @@ struct Mesh{
calculatedAO = false;
armatureName = "";
impostorDistance = 100.0f;
tessellationFactor = 0.0f;
}
bool hasArmature()const { return armature != nullptr; }
bool hasImpostor()const { return impostorTarget.IsInitialized(); }
float getTessellationFactor() { return tessellationFactor; }
void Serialize(wiArchive& archive);
};
struct Cullable
+44 -30
View File
@@ -574,6 +574,9 @@ void wiRenderer::LoadBuffers()
bd.ByteWidth = sizeof(CubeMapRenderCB);
GetDevice()->CreateBuffer(&bd, NULL, constantBuffers[CBTYPE_CUBEMAPRENDER]);
bd.ByteWidth = sizeof(TessellationCB);
GetDevice()->CreateBuffer(&bd, NULL, constantBuffers[CBTYPE_TESSELLATION]);
@@ -2687,10 +2690,12 @@ void wiRenderer::SetSpotLightShadowProps(int shadowMapCount, int resolution)
}
void wiRenderer::DrawWorld(Camera* camera, bool DX11Eff, int tessF, GRAPHICSTHREAD threadID
void wiRenderer::DrawWorld(Camera* camera, bool tessellation, GRAPHICSTHREAD threadID
, bool isReflection, SHADERTYPE shaderType
, Texture2D* refRes, bool grass)
{
tessellation = tessellation && GetDevice()->CheckCapability(GraphicsDevice::GRAPHICSDEVICE_CAPABILITY_TESSELLATION);
CulledCollection culledRenderer;
CulledList culledObjects;
if(spTree)
@@ -2738,34 +2743,6 @@ void wiRenderer::DrawWorld(Camera* camera, bool DX11Eff, int tessF, GRAPHICSTHRE
GetDevice()->EventBegin(L"DrawWorld", threadID);
if(DX11Eff && tessF)
GetDevice()->BindPrimitiveTopology(PATCHLIST,threadID);
else
GetDevice()->BindPrimitiveTopology(TRIANGLELIST,threadID);
GetDevice()->BindVertexLayout(vertexLayouts[VLTYPE_EFFECT],threadID);
if(DX11Eff && tessF)
GetDevice()->BindVS(vertexShaders[VSTYPE_OBJECT],threadID);
else
{
if (isReflection)
{
GetDevice()->BindVS(vertexShaders[VSTYPE_OBJECT_REFLECTION], threadID);
}
else
{
GetDevice()->BindVS(vertexShaders[VSTYPE_OBJECT10], threadID);
}
}
if(DX11Eff && tessF)
GetDevice()->BindHS(hullShaders[HSTYPE_OBJECT],threadID);
else
GetDevice()->BindHS(nullptr,threadID);
if(DX11Eff && tessF)
GetDevice()->BindDS(domainShaders[DSTYPE_OBJECT],threadID);
else
GetDevice()->BindDS(nullptr,threadID);
if (wireRender)
GetDevice()->BindPS(pixelShaders[PSTYPE_SIMPLEST], threadID);
@@ -2790,6 +2767,43 @@ void wiRenderer::DrawWorld(Camera* camera, bool DX11Eff, int tessF, GRAPHICSTHRE
Mesh* mesh = iter->first;
CulledObjectList& visibleInstances = iter->second;
float tessF = mesh->getTessellationFactor();
if (tessellation && tessF)
GetDevice()->BindPrimitiveTopology(PATCHLIST, threadID);
else
GetDevice()->BindPrimitiveTopology(TRIANGLELIST, threadID);
GetDevice()->BindVertexLayout(vertexLayouts[VLTYPE_EFFECT], threadID);
if (tessellation && tessF)
GetDevice()->BindVS(vertexShaders[VSTYPE_OBJECT], threadID);
else
{
if (isReflection)
{
GetDevice()->BindVS(vertexShaders[VSTYPE_OBJECT_REFLECTION], threadID);
}
else
{
GetDevice()->BindVS(vertexShaders[VSTYPE_OBJECT10], threadID);
}
}
if (tessellation && tessF)
{
TessellationCB tessCB;
tessCB.tessellationFactors = XMFLOAT4(tessF, tessF, tessF, tessF);
GetDevice()->UpdateBuffer(constantBuffers[CBTYPE_TESSELLATION], &tessCB, threadID);
GetDevice()->BindConstantBufferHS(constantBuffers[CBTYPE_TESSELLATION], CBSLOT_RENDERER_TESSELLATION, threadID);
GetDevice()->BindHS(hullShaders[HSTYPE_OBJECT], threadID);
}
else
GetDevice()->BindHS(nullptr, threadID);
if (tessellation && tessF)
GetDevice()->BindDS(domainShaders[DSTYPE_OBJECT], threadID);
else
GetDevice()->BindDS(nullptr, threadID);
float impostorDistance = mesh->impostorDistance;
if (mesh->hasImpostor())
@@ -2968,7 +2982,7 @@ void wiRenderer::DrawWorld(Camera* camera, bool DX11Eff, int tessF, GRAPHICSTHRE
}
GetDevice()->BindPS(pixelShaders[realPS], threadID);
}
if(DX11Eff)
if(tessellation)
GetDevice()->BindResourceDS(subset.material->GetDisplacementMap(), TEXSLOT_ONDEMAND5,threadID);
GetDevice()->DrawIndexedInstanced((int)subset.subsetIndices.size(),k,threadID);
+11 -3
View File
@@ -246,6 +246,14 @@ protected:
ALIGN_16
};
GFX_STRUCT TessellationCB
{
XMFLOAT4 tessellationFactors;
CB_SETBINDSLOT(CBSLOT_RENDERER_TESSELLATION)
ALIGN_16
};
// Resource Buffers:
struct ShaderBoneType
@@ -310,8 +318,8 @@ public:
static void DrawWaterRipples(GRAPHICSTHREAD threadID);
static void SetGameSpeed(float value){GameSpeed=value; if(GameSpeed<0) GameSpeed=0;};
static float GetGameSpeed();
static void ChangeRasterizer(){wireRender=!wireRender;};
static bool GetRasterizer(){return wireRender;};
static void SetWireRender(bool value) { wireRender = value; }
static bool IsWireRender() { return wireRender; }
static void ToggleDebugSpheres(){debugSpheres=!debugSpheres;}
static void SetToDrawDebugSpheres(bool param){debugSpheres=param;}
static bool GetToDrawDebugSpheres() { return debugSpheres; }
@@ -359,7 +367,7 @@ public:
static void DrawSky(GRAPHICSTHREAD threadID, bool isReflection = false);
static void DrawSun(GRAPHICSTHREAD threadID);
static void DrawWorld(Camera* camera, bool DX11Eff, int tessF, GRAPHICSTHREAD threadID
static void DrawWorld(Camera* camera, bool tessellation, GRAPHICSTHREAD threadID
, bool isReflection, SHADERTYPE shaderType, wiGraphicsTypes::Texture2D* refRes, bool grass);
static void ClearShadowMaps(GRAPHICSTHREAD threadID);
static void DrawForShadowMap(GRAPHICSTHREAD threadID);