diff --git a/WickedEngine/WickedEngine_SHARED.vcxitems.filters b/WickedEngine/WickedEngine_SHARED.vcxitems.filters
index 29bad3d27..1853a5ce8 100644
--- a/WickedEngine/WickedEngine_SHARED.vcxitems.filters
+++ b/WickedEngine/WickedEngine_SHARED.vcxitems.filters
@@ -165,9 +165,6 @@
ENGINE
-
- ENGINE
-
ENGINE
@@ -1026,6 +1023,9 @@
ENGINE\Graphics
+
+ ENGINE\Graphics
+
@@ -1157,9 +1157,6 @@
ENGINE
-
- ENGINE
-
ENGINE
@@ -1781,6 +1778,9 @@
ENGINE\Graphics
+
+ ENGINE\Graphics
+
diff --git a/WickedEngine/wiEmittedParticle.cpp b/WickedEngine/wiEmittedParticle.cpp
index 7841430e5..3ea52830b 100644
--- a/WickedEngine/wiEmittedParticle.cpp
+++ b/WickedEngine/wiEmittedParticle.cpp
@@ -236,20 +236,23 @@ void wiEmittedParticle::Draw(Camera* camera, GRAPHICSTHREAD threadID, int FLAG)
if(!points.empty()){
- if(camera->frustum.CheckBox(bounding_box->corners)){
+ if(camera->frustum.CheckBox(bounding_box->corners))
+ {
+ GraphicsDevice* device = wiRenderer::GetDevice();
+ device->EventBegin(L"EmittedParticle");
vector renderPoints=vector(points.begin(),points.end());
- wiRenderer::GetDevice()->UpdateBuffer(vertexBuffer,renderPoints.data(),threadID,sizeof(Point)* renderPoints.size());
+ device->UpdateBuffer(vertexBuffer,renderPoints.data(),threadID,sizeof(Point)* renderPoints.size());
bool additive = (material->blendFlag==BLENDMODE_ADDITIVE || material->premultipliedTexture);
- wiRenderer::GetDevice()->BindPrimitiveTopology(PRIMITIVETOPOLOGY::POINTLIST,threadID);
- wiRenderer::GetDevice()->BindVertexLayout(vertexLayout,threadID);
- wiRenderer::GetDevice()->BindPS(wireRender?simplestPS:pixelShader,threadID);
- wiRenderer::GetDevice()->BindVS(vertexShader,threadID);
- wiRenderer::GetDevice()->BindGS(geometryShader,threadID);
+ device->BindPrimitiveTopology(PRIMITIVETOPOLOGY::POINTLIST,threadID);
+ device->BindVertexLayout(vertexLayout,threadID);
+ device->BindPS(wireRender?simplestPS:pixelShader,threadID);
+ device->BindVS(vertexShader,threadID);
+ device->BindGS(geometryShader,threadID);
- //wiRenderer::GetDevice()->BindResourcePS(depth,1,threadID);
+ //device->BindResourcePS(depth,1,threadID);
ConstantBuffer cb;
cb.mAdd.x = additive;
@@ -257,22 +260,23 @@ void wiEmittedParticle::Draw(Camera* camera, GRAPHICSTHREAD threadID, int FLAG)
cb.mMotionBlurAmount = motionBlurAmount;
- wiRenderer::GetDevice()->UpdateBuffer(constantBuffer,&cb,threadID);
- wiRenderer::GetDevice()->BindConstantBufferGS(constantBuffer, CB_GETBINDSLOT(ConstantBuffer),threadID);
+ device->UpdateBuffer(constantBuffer,&cb,threadID);
+ device->BindConstantBufferGS(constantBuffer, CB_GETBINDSLOT(ConstantBuffer),threadID);
- wiRenderer::GetDevice()->BindRasterizerState(wireRender?wireFrameRS:rasterizerState,threadID);
- wiRenderer::GetDevice()->BindDepthStencilState(depthStencilState,1,threadID);
+ device->BindRasterizerState(wireRender?wireFrameRS:rasterizerState,threadID);
+ device->BindDepthStencilState(depthStencilState,1,threadID);
- wiRenderer::GetDevice()->BindBlendState((additive?blendStateAdd:blendStateAlpha),threadID);
+ device->BindBlendState((additive?blendStateAdd:blendStateAlpha),threadID);
- wiRenderer::GetDevice()->BindVertexBuffer(vertexBuffer,0,sizeof(Point),threadID);
+ device->BindVertexBuffer(vertexBuffer,0,sizeof(Point),threadID);
if(!wireRender && material->texture)
- wiRenderer::GetDevice()->BindResourcePS(material->texture,TEXSLOT_ONDEMAND0,threadID);
- wiRenderer::GetDevice()->Draw(renderPoints.size(),threadID);
+ device->BindResourcePS(material->texture,TEXSLOT_ONDEMAND0,threadID);
+ device->Draw(renderPoints.size(),threadID);
- wiRenderer::GetDevice()->BindGS(nullptr,threadID);
+ device->BindGS(nullptr,threadID);
+ device->EventEnd();
}
}
}
diff --git a/WickedEngine/wiFont.cpp b/WickedEngine/wiFont.cpp
index 54c0509c2..45383744c 100644
--- a/WickedEngine/wiFont.cpp
+++ b/WickedEngine/wiFont.cpp
@@ -261,31 +261,36 @@ void wiFont::Draw(GRAPHICSTHREAD threadID){
ModifyGeo(text, newProps, style, threadID);
- if(text.length()>0){
+ if(text.length()>0)
+ {
+ GraphicsDevice* device = wiRenderer::GetDevice();
+ device->EventBegin(L"Font");
- wiRenderer::GetDevice()->BindPrimitiveTopology(PRIMITIVETOPOLOGY::TRIANGLELIST,threadID);
- wiRenderer::GetDevice()->BindVertexLayout(vertexLayout,threadID);
- wiRenderer::GetDevice()->BindVS(vertexShader,threadID);
- wiRenderer::GetDevice()->BindPS(pixelShader,threadID);
+ device->BindPrimitiveTopology(PRIMITIVETOPOLOGY::TRIANGLELIST,threadID);
+ device->BindVertexLayout(vertexLayout,threadID);
+ device->BindVS(vertexShader,threadID);
+ device->BindPS(pixelShader,threadID);
ConstantBuffer cb;
- cb.mProjection = XMMatrixTranspose( XMMatrixOrthographicLH((float)wiRenderer::GetDevice()->GetScreenWidth(),(float)wiRenderer::GetDevice()->GetScreenHeight(),0,100) );
+ cb.mProjection = XMMatrixTranspose( XMMatrixOrthographicLH((float)device->GetScreenWidth(),(float)device->GetScreenHeight(),0,100) );
cb.mTrans = XMMatrixTranspose(XMMatrixTranslation(newProps.posX, newProps.posY, 0));
- cb.mDimensions = XMFLOAT4((float)wiRenderer::GetDevice()->GetScreenWidth(), (float)wiRenderer::GetDevice()->GetScreenHeight(), 0, 0);
+ cb.mDimensions = XMFLOAT4((float)device->GetScreenWidth(), (float)device->GetScreenHeight(), 0, 0);
- wiRenderer::GetDevice()->UpdateBuffer(constantBuffer,&cb,threadID);
+ device->UpdateBuffer(constantBuffer,&cb,threadID);
- wiRenderer::GetDevice()->BindRasterizerState(rasterizerState,threadID);
- wiRenderer::GetDevice()->BindDepthStencilState(depthStencilState,1,threadID);
+ device->BindRasterizerState(rasterizerState,threadID);
+ device->BindDepthStencilState(depthStencilState,1,threadID);
- wiRenderer::GetDevice()->BindBlendState(blendState,threadID);
- wiRenderer::GetDevice()->BindVertexBuffer(vertexBuffer,0,sizeof(Vertex),threadID);
- wiRenderer::GetDevice()->BindIndexBuffer(indexBuffer,threadID);
+ device->BindBlendState(blendState,threadID);
+ device->BindVertexBuffer(vertexBuffer,0,sizeof(Vertex),threadID);
+ device->BindIndexBuffer(indexBuffer,threadID);
- wiRenderer::GetDevice()->BindResourcePS(fontStyles[style].texture,TEXSLOT_ONDEMAND0,threadID);
- wiRenderer::GetDevice()->DrawIndexed(text.length()*6,threadID);
+ device->BindResourcePS(fontStyles[style].texture,TEXSLOT_ONDEMAND0,threadID);
+ device->DrawIndexed(text.length()*6,threadID);
+
+ device->EventEnd();
}
}
diff --git a/WickedEngine/wiHairParticle.cpp b/WickedEngine/wiHairParticle.cpp
index f9d7655e7..d19c37c56 100644
--- a/WickedEngine/wiHairParticle.cpp
+++ b/WickedEngine/wiHairParticle.cpp
@@ -399,21 +399,24 @@ void wiHairParticle::Draw(Camera* camera, GRAPHICSTHREAD threadID)
if(!culledPatches.empty())
{
+ GraphicsDevice* device = wiRenderer::GetDevice();
+ device->EventBegin(L"HairParticle");
+
Texture2D* texture = material->texture;
- wiRenderer::GetDevice()->BindPrimitiveTopology(PRIMITIVETOPOLOGY::POINTLIST,threadID);
- wiRenderer::GetDevice()->BindVertexLayout(il,threadID);
- wiRenderer::GetDevice()->BindPS(texture?qps:ps,threadID);
- wiRenderer::GetDevice()->BindVS(vs,threadID);
+ device->BindPrimitiveTopology(PRIMITIVETOPOLOGY::POINTLIST,threadID);
+ device->BindVertexLayout(il,threadID);
+ device->BindPS(texture?qps:ps,threadID);
+ device->BindVS(vs,threadID);
if(texture){
- wiRenderer::GetDevice()->BindResourcePS(texture,TEXSLOT_ONDEMAND0,threadID);
- wiRenderer::GetDevice()->BindResourceGS(texture,TEXSLOT_ONDEMAND0,threadID);
+ device->BindResourcePS(texture,TEXSLOT_ONDEMAND0,threadID);
+ device->BindResourceGS(texture,TEXSLOT_ONDEMAND0,threadID);
- wiRenderer::GetDevice()->BindBlendState(bs,threadID);
+ device->BindBlendState(bs,threadID);
}
else
- wiRenderer::GetDevice()->BindRasterizerState(ncrs,threadID);
+ device->BindRasterizerState(ncrs,threadID);
ConstantBuffer gcb;
@@ -421,10 +424,10 @@ void wiHairParticle::Draw(Camera* camera, GRAPHICSTHREAD threadID)
gcb.color=material->diffuseColor;
gcb.drawdistance = (float)LOD[2];
- wiRenderer::GetDevice()->UpdateBuffer(cbgs,&gcb,threadID);
- wiRenderer::GetDevice()->BindConstantBufferGS(cbgs, CB_GETBINDSLOT(ConstantBuffer),threadID);
+ device->UpdateBuffer(cbgs,&gcb,threadID);
+ device->BindConstantBufferGS(cbgs, CB_GETBINDSLOT(ConstantBuffer),threadID);
- wiRenderer::GetDevice()->BindDepthStencilState(dss,STENCILREF_DEFAULT,threadID);
+ device->BindDepthStencilState(dss,STENCILREF_DEFAULT,threadID);
for(int i=0;i<3;++i){
@@ -432,11 +435,11 @@ void wiHairParticle::Draw(Camera* camera, GRAPHICSTHREAD threadID)
renderPoints.reserve(MAX_PARTICLES);
if(texture){
- wiRenderer::GetDevice()->BindGS(i<2?qgs[0]:qgs[1],threadID);
- wiRenderer::GetDevice()->BindRasterizerState(i<2?ncrs:rs,threadID);
+ device->BindGS(i<2?qgs[0]:qgs[1],threadID);
+ device->BindRasterizerState(i<2?ncrs:rs,threadID);
}
else
- wiRenderer::GetDevice()->BindGS(gs[i],threadID);
+ device->BindGS(gs[i],threadID);
CulledList::iterator iter = culledPatches.begin();
while(iter != culledPatches.end()){
Cullable* culled = *iter;
@@ -453,12 +456,14 @@ void wiHairParticle::Draw(Camera* camera, GRAPHICSTHREAD threadID)
++iter;
}
- wiRenderer::GetDevice()->UpdateBuffer(vb[i],renderPoints.data(),threadID,sizeof(Point)*renderPoints.size());
- wiRenderer::GetDevice()->BindVertexBuffer(vb[i],0,sizeof(Point),threadID);
- wiRenderer::GetDevice()->Draw(renderPoints.size(),threadID);
+ device->UpdateBuffer(vb[i],renderPoints.data(),threadID,sizeof(Point)*renderPoints.size());
+ device->BindVertexBuffer(vb[i],0,sizeof(Point),threadID);
+ device->Draw(renderPoints.size(),threadID);
}
- wiRenderer::GetDevice()->BindGS(nullptr,threadID);
+ device->BindGS(nullptr,threadID);
+
+ device->EventEnd();
}
}
diff --git a/WickedEngine/wiImage.cpp b/WickedEngine/wiImage.cpp
index c9729b9df..6c99ede82 100644
--- a/WickedEngine/wiImage.cpp
+++ b/WickedEngine/wiImage.cpp
@@ -210,38 +210,38 @@ void wiImage::BindPersistentState(GRAPHICSTHREAD threadID)
wiRenderer::GetDevice()->UNLOCK();
}
-void wiImage::Draw(Texture2D* texture, const wiImageEffects& effects){
- Draw(texture,effects,GRAPHICSTHREAD_IMMEDIATE);
-}
void wiImage::Draw(Texture2D* texture, const wiImageEffects& effects,GRAPHICSTHREAD threadID)
{
+ GraphicsDevice* device = wiRenderer::GetDevice();
+ device->EventBegin(L"Image");
bool fullScreenEffect = false;
- wiRenderer::GetDevice()->BindVertexLayout(nullptr, threadID);
- wiRenderer::GetDevice()->BindVertexBuffer(nullptr, 0, 0, threadID);
- wiRenderer::GetDevice()->BindIndexBuffer(nullptr, threadID);
- wiRenderer::GetDevice()->BindPrimitiveTopology(PRIMITIVETOPOLOGY::TRIANGLESTRIP, threadID);
- wiRenderer::GetDevice()->BindRasterizerState(rasterizerState, threadID);
+ device->BindVertexLayout(nullptr, threadID);
+ device->BindVertexBuffer(nullptr, 0, 0, threadID);
+ device->BindIndexBuffer(nullptr, threadID);
+ device->BindPrimitiveTopology(PRIMITIVETOPOLOGY::TRIANGLESTRIP, threadID);
+ device->BindRasterizerState(rasterizerState, threadID);
- wiRenderer::GetDevice()->BindResourcePS(texture, TEXSLOT_ONDEMAND0, threadID);
+ device->BindResourcePS(texture, TEXSLOT_ONDEMAND0, threadID);
if (effects.blendFlag == BLENDMODE_ALPHA)
- wiRenderer::GetDevice()->BindBlendState(blendState, threadID);
+ device->BindBlendState(blendState, threadID);
else if (effects.blendFlag == BLENDMODE_ADDITIVE)
- wiRenderer::GetDevice()->BindBlendState(blendStateAdd, threadID);
+ device->BindBlendState(blendStateAdd, threadID);
else if (effects.blendFlag == BLENDMODE_OPAQUE)
- wiRenderer::GetDevice()->BindBlendState(blendStateNoBlend, threadID);
+ device->BindBlendState(blendStateNoBlend, threadID);
else if (effects.blendFlag == BLENDMODE_MAX)
- wiRenderer::GetDevice()->BindBlendState(blendStateAvg, threadID);
+ device->BindBlendState(blendStateAvg, threadID);
else
- wiRenderer::GetDevice()->BindBlendState(blendState, threadID);
+ device->BindBlendState(blendState, threadID);
if (effects.presentFullScreen)
{
- wiRenderer::GetDevice()->BindVS(screenVS, threadID);
- wiRenderer::GetDevice()->BindPS(screenPS, threadID);
- wiRenderer::GetDevice()->Draw(3, threadID);
+ device->BindVS(screenVS, threadID);
+ device->BindPS(screenPS, threadID);
+ device->Draw(3, threadID);
+ device->EventEnd();
return;
}
@@ -251,13 +251,13 @@ void wiImage::Draw(Texture2D* texture, const wiImageEffects& effects,GRAPHICSTHR
switch (effects.stencilComp)
{
case COMPARISON_LESS:
- wiRenderer::GetDevice()->BindDepthStencilState(depthStencilStateLess, effects.stencilRef, threadID);
+ device->BindDepthStencilState(depthStencilStateLess, effects.stencilRef, threadID);
break;
case COMPARISON_GREATER:
- wiRenderer::GetDevice()->BindDepthStencilState(depthStencilStateGreater, effects.stencilRef, threadID);
+ device->BindDepthStencilState(depthStencilStateGreater, effects.stencilRef, threadID);
break;
default:
- wiRenderer::GetDevice()->BindDepthStencilState(depthNoStencilState, effects.stencilRef, threadID);
+ device->BindDepthStencilState(depthNoStencilState, effects.stencilRef, threadID);
break;
}
}
@@ -265,10 +265,10 @@ void wiImage::Draw(Texture2D* texture, const wiImageEffects& effects,GRAPHICSTHR
if(!effects.blur){
if(!effects.process.active && !effects.bloom.separate && !effects.sunPos.x && !effects.sunPos.y){
if(effects.typeFlag==SCREEN){
- cb.mViewProjection = XMMatrixTranspose(XMMatrixOrthographicLH((float)wiRenderer::GetDevice()->GetScreenWidth(), (float)wiRenderer::GetDevice()->GetScreenHeight(), 0, 100));
- cb.mTrans = XMMatrixTranspose(XMMatrixTranslation(wiRenderer::GetDevice()->GetScreenWidth() / 2 - effects.siz.x / 2, -wiRenderer::GetDevice()->GetScreenHeight() / 2 + effects.siz.y / 2, 0) * XMMatrixRotationZ(effects.rotation)
- * XMMatrixTranslation(-wiRenderer::GetDevice()->GetScreenWidth() / 2 + effects.pos.x + effects.siz.x*0.5f, wiRenderer::GetDevice()->GetScreenHeight() / 2 + effects.pos.y - effects.siz.y*0.5f, 0)); //AUTO ORIGIN CORRECTION APPLIED! NO FURTHER TRANSLATIONS NEEDED!
- cb.mDimensions = XMFLOAT4((float)wiRenderer::GetDevice()->GetScreenWidth(), (float)wiRenderer::GetDevice()->GetScreenHeight(), effects.siz.x, effects.siz.y);
+ cb.mViewProjection = XMMatrixTranspose(XMMatrixOrthographicLH((float)device->GetScreenWidth(), (float)device->GetScreenHeight(), 0, 100));
+ cb.mTrans = XMMatrixTranspose(XMMatrixTranslation(device->GetScreenWidth() / 2 - effects.siz.x / 2, -device->GetScreenHeight() / 2 + effects.siz.y / 2, 0) * XMMatrixRotationZ(effects.rotation)
+ * XMMatrixTranslation(-device->GetScreenWidth() / 2 + effects.pos.x + effects.siz.x*0.5f, device->GetScreenHeight() / 2 + effects.pos.y - effects.siz.y*0.5f, 0)); //AUTO ORIGIN CORRECTION APPLIED! NO FURTHER TRANSLATIONS NEEDED!
+ cb.mDimensions = XMFLOAT4((float)device->GetScreenWidth(), (float)device->GetScreenHeight(), effects.siz.x, effects.siz.y);
}
else if(effects.typeFlag==WORLD){
cb.mViewProjection = XMMatrixTranspose( wiRenderer::getCamera()->GetView() * wiRenderer::getCamera()->GetProjection() );
@@ -314,40 +314,40 @@ void wiImage::Draw(Texture2D* texture, const wiImageEffects& effects,GRAPHICSTHR
cb.mNormalmapSeparate = normalmapmode;
cb.mMipLevel = effects.mipLevel;
- wiRenderer::GetDevice()->UpdateBuffer(constantBuffer,&cb,threadID);
+ device->UpdateBuffer(constantBuffer,&cb,threadID);
- wiRenderer::GetDevice()->BindVS(vertexShader, threadID);
- wiRenderer::GetDevice()->BindPS(pixelShader, threadID);
+ device->BindVS(vertexShader, threadID);
+ device->BindPS(pixelShader, threadID);
fullScreenEffect = false;
}
else if(!effects.sunPos.x && !effects.sunPos.y){
- wiRenderer::GetDevice()->BindVS(screenVS, threadID);
+ device->BindVS(screenVS, threadID);
fullScreenEffect = true;
if(effects.process.outline)
- wiRenderer::GetDevice()->BindPS(outlinePS,threadID);
+ device->BindPS(outlinePS,threadID);
else if(effects.process.motionBlur)
- wiRenderer::GetDevice()->BindPS(motionBlurPS,threadID);
+ device->BindPS(motionBlurPS,threadID);
else if(effects.process.dofStrength)
- wiRenderer::GetDevice()->BindPS(dofPS,threadID);
+ device->BindPS(dofPS,threadID);
else if(effects.process.fxaa)
- wiRenderer::GetDevice()->BindPS(fxaaPS,threadID);
+ device->BindPS(fxaaPS,threadID);
else if(effects.process.ssao)
- wiRenderer::GetDevice()->BindPS(ssaoPS,threadID);
+ device->BindPS(ssaoPS,threadID);
else if(effects.process.linDepth)
- wiRenderer::GetDevice()->BindPS(linDepthPS, threadID);
+ device->BindPS(linDepthPS, threadID);
else if (effects.process.colorGrade)
- wiRenderer::GetDevice()->BindPS(colorGradePS, threadID);
+ device->BindPS(colorGradePS, threadID);
else if (effects.process.ssr)
- wiRenderer::GetDevice()->BindPS(ssrPS, threadID);
+ device->BindPS(ssrPS, threadID);
else if (effects.process.stereogram)
- wiRenderer::GetDevice()->BindPS(stereogramPS, threadID);
+ device->BindPS(stereogramPS, threadID);
else if (effects.process.tonemap)
- wiRenderer::GetDevice()->BindPS(tonemapPS, threadID);
+ device->BindPS(tonemapPS, threadID);
else if(effects.process.ssss.x + effects.process.ssss.y > 0)
- wiRenderer::GetDevice()->BindPS(ssssPS,threadID);
+ device->BindPS(ssssPS,threadID);
else if(effects.bloom.separate)
- wiRenderer::GetDevice()->BindPS(bloomSeparatePS,threadID);
+ device->BindPS(bloomSeparatePS,threadID);
else
wiHelper::messageBox("Postprocess branch not implemented!");
@@ -360,11 +360,11 @@ void wiImage::Draw(Texture2D* texture, const wiImageEffects& effects,GRAPHICSTHR
prcb.params1[2] = effects.bloom.saturation;
prcb.params1[3] = effects.process.ssss.y;
- wiRenderer::GetDevice()->UpdateBuffer(processCb, &prcb, threadID);
+ device->UpdateBuffer(processCb, &prcb, threadID);
}
else{
- wiRenderer::GetDevice()->BindVS(screenVS,threadID);
- wiRenderer::GetDevice()->BindPS(shaftPS,threadID);
+ device->BindVS(screenVS,threadID);
+ device->BindPS(shaftPS,threadID);
fullScreenEffect = true;
//Density|Weight|Decay|Exposure
@@ -375,23 +375,23 @@ void wiImage::Draw(Texture2D* texture, const wiImageEffects& effects,GRAPHICSTHR
prcb.params1[0] = effects.sunPos.x;
prcb.params1[1] = effects.sunPos.y;
- wiRenderer::GetDevice()->UpdateBuffer(processCb,&prcb,threadID);
+ device->UpdateBuffer(processCb,&prcb,threadID);
}
- wiRenderer::GetDevice()->BindResourcePS(effects.maskMap, TEXSLOT_ONDEMAND1, threadID);
- wiRenderer::GetDevice()->BindResourcePS(effects.distortionMap, TEXSLOT_ONDEMAND2, threadID);
- wiRenderer::GetDevice()->BindResourcePS(effects.refractionSource, TEXSLOT_ONDEMAND3, threadID);
+ device->BindResourcePS(effects.maskMap, TEXSLOT_ONDEMAND1, threadID);
+ device->BindResourcePS(effects.distortionMap, TEXSLOT_ONDEMAND2, threadID);
+ device->BindResourcePS(effects.refractionSource, TEXSLOT_ONDEMAND3, threadID);
}
else{ //BLUR
- wiRenderer::GetDevice()->BindVS(screenVS,threadID);
+ device->BindVS(screenVS,threadID);
fullScreenEffect = true;
if(effects.blurDir==0){
- wiRenderer::GetDevice()->BindPS(blurHPS,threadID);
- prcb.params1[3] = 1.0f / wiRenderer::GetDevice()->GetScreenWidth();
+ device->BindPS(blurHPS,threadID);
+ prcb.params1[3] = 1.0f / device->GetScreenWidth();
}
else{
- wiRenderer::GetDevice()->BindPS(blurVPS,threadID);
- prcb.params1[3] = 1.0f / wiRenderer::GetDevice()->GetScreenHeight();
+ device->BindPS(blurVPS,threadID);
+ prcb.params1[3] = 1.0f / device->GetScreenHeight();
}
static float weight0 = 1.0f;
@@ -408,38 +408,40 @@ void wiImage::Draw(Texture2D* texture, const wiImageEffects& effects,GRAPHICSTHR
prcb.params1[1] = effects.blur;
prcb.params1[2] = effects.mipLevel;
- wiRenderer::GetDevice()->UpdateBuffer(processCb, &prcb, threadID);
+ device->UpdateBuffer(processCb, &prcb, threadID);
}
if(effects.quality==QUALITY_NEAREST){
if (effects.sampleFlag == SAMPLEMODE_MIRROR)
- wiRenderer::GetDevice()->BindSamplerPS(wiRenderer::samplers[SSLOT_POINT_MIRROR], SSLOT_ONDEMAND0, threadID);
+ device->BindSamplerPS(wiRenderer::samplers[SSLOT_POINT_MIRROR], SSLOT_ONDEMAND0, threadID);
else if (effects.sampleFlag == SAMPLEMODE_WRAP)
- wiRenderer::GetDevice()->BindSamplerPS(wiRenderer::samplers[SSLOT_POINT_WRAP], SSLOT_ONDEMAND0, threadID);
+ device->BindSamplerPS(wiRenderer::samplers[SSLOT_POINT_WRAP], SSLOT_ONDEMAND0, threadID);
else if (effects.sampleFlag == SAMPLEMODE_CLAMP)
- wiRenderer::GetDevice()->BindSamplerPS(wiRenderer::samplers[SSLOT_POINT_CLAMP], SSLOT_ONDEMAND0, threadID);
+ device->BindSamplerPS(wiRenderer::samplers[SSLOT_POINT_CLAMP], SSLOT_ONDEMAND0, threadID);
}
else if(effects.quality==QUALITY_BILINEAR){
if (effects.sampleFlag == SAMPLEMODE_MIRROR)
- wiRenderer::GetDevice()->BindSamplerPS(wiRenderer::samplers[SSLOT_LINEAR_MIRROR], SSLOT_ONDEMAND0, threadID);
+ device->BindSamplerPS(wiRenderer::samplers[SSLOT_LINEAR_MIRROR], SSLOT_ONDEMAND0, threadID);
else if (effects.sampleFlag == SAMPLEMODE_WRAP)
- wiRenderer::GetDevice()->BindSamplerPS(wiRenderer::samplers[SSLOT_LINEAR_WRAP], SSLOT_ONDEMAND0, threadID);
+ device->BindSamplerPS(wiRenderer::samplers[SSLOT_LINEAR_WRAP], SSLOT_ONDEMAND0, threadID);
else if (effects.sampleFlag == SAMPLEMODE_CLAMP)
- wiRenderer::GetDevice()->BindSamplerPS(wiRenderer::samplers[SSLOT_LINEAR_CLAMP], SSLOT_ONDEMAND0, threadID);
+ device->BindSamplerPS(wiRenderer::samplers[SSLOT_LINEAR_CLAMP], SSLOT_ONDEMAND0, threadID);
}
else if(effects.quality==QUALITY_ANISOTROPIC){
if (effects.sampleFlag == SAMPLEMODE_MIRROR)
- wiRenderer::GetDevice()->BindSamplerPS(wiRenderer::samplers[SSLOT_ANISO_MIRROR], SSLOT_ONDEMAND0, threadID);
+ device->BindSamplerPS(wiRenderer::samplers[SSLOT_ANISO_MIRROR], SSLOT_ONDEMAND0, threadID);
else if (effects.sampleFlag == SAMPLEMODE_WRAP)
- wiRenderer::GetDevice()->BindSamplerPS(wiRenderer::samplers[SSLOT_ANISO_WRAP], SSLOT_ONDEMAND0, threadID);
+ device->BindSamplerPS(wiRenderer::samplers[SSLOT_ANISO_WRAP], SSLOT_ONDEMAND0, threadID);
else if (effects.sampleFlag == SAMPLEMODE_CLAMP)
- wiRenderer::GetDevice()->BindSamplerPS(wiRenderer::samplers[SSLOT_ANISO_CLAMP], SSLOT_ONDEMAND0, threadID);
+ device->BindSamplerPS(wiRenderer::samplers[SSLOT_ANISO_CLAMP], SSLOT_ONDEMAND0, threadID);
}
- wiRenderer::GetDevice()->Draw((fullScreenEffect ? 3 : 4), threadID);
+ device->Draw((fullScreenEffect ? 3 : 4), threadID);
+
+ device->EventEnd();
}
void wiImage::DrawDeferred(Texture2D* lightmap, Texture2D* ao, GRAPHICSTHREAD threadID, int stencilRef){
diff --git a/WickedEngine/wiImage.h b/WickedEngine/wiImage.h
index 5c22b093a..159eaa485 100644
--- a/WickedEngine/wiImage.h
+++ b/WickedEngine/wiImage.h
@@ -66,8 +66,7 @@ private:
public:
wiImage();
- static void Draw(wiGraphicsTypes::Texture2D* texture, const wiImageEffects& effects);
- static void Draw(wiGraphicsTypes::Texture2D* texture, const wiImageEffects& effects,GRAPHICSTHREAD threadID);
+ static void Draw(wiGraphicsTypes::Texture2D* texture, const wiImageEffects& effects,GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE);
static void DrawDeferred(wiGraphicsTypes::Texture2D* lightmap, wiGraphicsTypes::Texture2D* ao, GRAPHICSTHREAD threadID, int stencilref = 0);
diff --git a/WickedEngine/wiLensFlare.cpp b/WickedEngine/wiLensFlare.cpp
index 98792a22d..114c7311a 100644
--- a/WickedEngine/wiLensFlare.cpp
+++ b/WickedEngine/wiLensFlare.cpp
@@ -31,42 +31,47 @@ void wiLensFlare::CleanUp(){
}
void wiLensFlare::Draw(GRAPHICSTHREAD threadID, const XMVECTOR& lightPos, vector& rims){
- if(!rims.empty()){
+ if(!rims.empty())
+ {
+ GraphicsDevice* device = wiRenderer::GetDevice();
+ device->EventBegin(L"LensFlare");
- wiRenderer::GetDevice()->BindPrimitiveTopology(POINTLIST,threadID);
- wiRenderer::GetDevice()->BindVertexLayout(inputLayout,threadID);
- wiRenderer::GetDevice()->BindPS(pixelShader,threadID);
- wiRenderer::GetDevice()->BindVS(vertexShader,threadID);
- wiRenderer::GetDevice()->BindGS(geometryShader,threadID);
+ device->BindPrimitiveTopology(POINTLIST,threadID);
+ device->BindVertexLayout(inputLayout,threadID);
+ device->BindPS(pixelShader,threadID);
+ device->BindVS(vertexShader,threadID);
+ device->BindGS(geometryShader,threadID);
ConstantBuffer cb;
- cb.mSunPos = lightPos / XMVectorSet((float)wiRenderer::GetDevice()->GetScreenWidth(), (float)wiRenderer::GetDevice()->GetScreenHeight(), 1, 1);
- cb.mScreen = XMFLOAT4((float)wiRenderer::GetDevice()->GetScreenWidth(), (float)wiRenderer::GetDevice()->GetScreenHeight(), 0, 0);
+ cb.mSunPos = lightPos / XMVectorSet((float)device->GetScreenWidth(), (float)device->GetScreenHeight(), 1, 1);
+ cb.mScreen = XMFLOAT4((float)device->GetScreenWidth(), (float)device->GetScreenHeight(), 0, 0);
- wiRenderer::GetDevice()->UpdateBuffer(constantBuffer,&cb,threadID);
- wiRenderer::GetDevice()->BindConstantBufferGS(constantBuffer, CB_GETBINDSLOT(ConstantBuffer),threadID);
+ device->UpdateBuffer(constantBuffer,&cb,threadID);
+ device->BindConstantBufferGS(constantBuffer, CB_GETBINDSLOT(ConstantBuffer),threadID);
- wiRenderer::GetDevice()->BindRasterizerState(rasterizerState,threadID);
- wiRenderer::GetDevice()->BindDepthStencilState(depthStencilState,1,threadID);
- wiRenderer::GetDevice()->BindBlendState(blendState,threadID);
+ device->BindRasterizerState(rasterizerState,threadID);
+ device->BindDepthStencilState(depthStencilState,1,threadID);
+ device->BindBlendState(blendState,threadID);
- //wiRenderer::GetDevice()->BindResourceGS(depthMap,0,threadID);
+ //device->BindResourceGS(depthMap,0,threadID);
int i=0;
for(Texture2D* x : rims){
if(x!=nullptr){
- wiRenderer::GetDevice()->BindResourcePS(x, TEXSLOT_ONDEMAND0 + i, threadID);
- wiRenderer::GetDevice()->BindResourceGS(x, TEXSLOT_ONDEMAND0 + i, threadID);
+ device->BindResourcePS(x, TEXSLOT_ONDEMAND0 + i, threadID);
+ device->BindResourceGS(x, TEXSLOT_ONDEMAND0 + i, threadID);
i++;
}
}
- wiRenderer::GetDevice()->Draw(i,threadID);
+ device->Draw(i,threadID);
- wiRenderer::GetDevice()->BindGS(nullptr,threadID);
+ device->BindGS(nullptr,threadID);
+
+ device->EventEnd();
}
}
diff --git a/WickedEngine/wiRenderer.cpp b/WickedEngine/wiRenderer.cpp
index 2a0d1d38a..ee39bf3b3 100644
--- a/WickedEngine/wiRenderer.cpp
+++ b/WickedEngine/wiRenderer.cpp
@@ -1334,6 +1334,8 @@ void wiRenderer::UpdateRenderData(GRAPHICSTHREAD threadID)
&& mesh->sOutBuffer.IsValid() && mesh->meshVertBuff.IsValid())
{
#ifdef USE_GPU_SKINNING
+ GetDevice()->EventBegin(L"Skinning");
+
if (!streamOutSetUp)
{
streamOutSetUp = true;
@@ -1368,6 +1370,8 @@ void wiRenderer::UpdateRenderData(GRAPHICSTHREAD threadID)
GetDevice()->BindVertexBuffer(&mesh->meshVertBuff, 0, sizeof(SkinnedVertex), threadID);
GetDevice()->BindStreamOutTarget(&mesh->sOutBuffer, threadID);
GetDevice()->Draw(mesh->vertices.size(), threadID);
+
+ GetDevice()->EventEnd();
#else
// Doing skinning on the CPU
for (int vi = 0; vi < mesh->skinnedVertices.size(); ++vi)
@@ -1498,6 +1502,8 @@ void wiRenderer::DrawDebugSpheres(Camera* camera, GRAPHICSTHREAD threadID)
void wiRenderer::DrawDebugBoneLines(Camera* camera, GRAPHICSTHREAD threadID)
{
if(debugBoneLines){
+ GetDevice()->EventBegin(L"DebugBoneLines");
+
GetDevice()->BindPrimitiveTopology(LINELIST,threadID);
GetDevice()->BindVertexLayout(vertexLayouts[VLTYPE_LINE],threadID);
@@ -1519,6 +1525,8 @@ void wiRenderer::DrawDebugBoneLines(Camera* camera, GRAPHICSTHREAD threadID)
GetDevice()->BindVertexBuffer(&boneLines[i]->vertexBuffer, 0, sizeof(XMFLOAT3A), threadID);
GetDevice()->Draw(2, threadID);
}
+
+ GetDevice()->EventEnd();
}
}
void wiRenderer::DrawDebugLines(Camera* camera, GRAPHICSTHREAD threadID)
@@ -1526,6 +1534,8 @@ void wiRenderer::DrawDebugLines(Camera* camera, GRAPHICSTHREAD threadID)
if (linesTemp.empty())
return;
+ GetDevice()->EventBegin(L"DebugLines");
+
GetDevice()->BindPrimitiveTopology(LINELIST, threadID);
GetDevice()->BindVertexLayout(vertexLayouts[VLTYPE_LINE], threadID);
@@ -1551,10 +1561,14 @@ void wiRenderer::DrawDebugLines(Camera* camera, GRAPHICSTHREAD threadID)
for (Lines* x : linesTemp)
delete x;
linesTemp.clear();
+
+ GetDevice()->EventEnd();
}
void wiRenderer::DrawDebugBoxes(Camera* camera, GRAPHICSTHREAD threadID)
{
if(debugBoxes){
+ GetDevice()->EventBegin(L"DebugBoxes");
+
GetDevice()->BindPrimitiveTopology(LINELIST,threadID);
GetDevice()->BindVertexLayout(vertexLayouts[VLTYPE_LINE],threadID);
@@ -1579,6 +1593,7 @@ void wiRenderer::DrawDebugBoxes(Camera* camera, GRAPHICSTHREAD threadID)
GetDevice()->DrawIndexed(24,threadID);
}
+ GetDevice()->EventEnd();
}
}
@@ -1607,7 +1622,15 @@ void wiRenderer::DrawSoftPremulParticles(Camera* camera, GRAPHICSTHREAD threadID
e->DrawPremul(camera, threadID, dark);
}
}
-void wiRenderer::DrawTrails(GRAPHICSTHREAD threadID, Texture2D* refracRes){
+void wiRenderer::DrawTrails(GRAPHICSTHREAD threadID, Texture2D* refracRes)
+{
+ if (objectsWithTrails.empty())
+ {
+ return;
+ }
+
+ GetDevice()->EventBegin(L"RibbonTrails");
+
GetDevice()->BindPrimitiveTopology(TRIANGLESTRIP,threadID);
GetDevice()->BindVertexLayout(vertexLayouts[VLTYPE_TRAIL],threadID);
@@ -1676,6 +1699,8 @@ void wiRenderer::DrawTrails(GRAPHICSTHREAD threadID, Texture2D* refracRes){
}
}
}
+
+ GetDevice()->EventEnd();
}
void wiRenderer::DrawImagesAdd(GRAPHICSTHREAD threadID, Texture2D* refracRes){
imagesRTAdd.Activate(threadID,0,0,0,1);
@@ -1733,133 +1758,129 @@ void wiRenderer::DrawLights(Camera* camera, GRAPHICSTHREAD threadID, unsigned in
if(!culledObjects.empty())
{
-
+ GetDevice()->EventBegin(L"Light Render");
GetDevice()->BindPrimitiveTopology(TRIANGLELIST,threadID);
-
- //BindResourcePS(depth,0,threadID);
- //BindResourcePS(normal,1,threadID);
- //BindResourcePS(material,2,threadID);
- GetDevice()->BindBlendState(blendStates[BSTYPE_ADDITIVE],threadID);
- GetDevice()->BindDepthStencilState(depthStencils[DSSTYPE_STENCILREAD],stencilRef,threadID);
- GetDevice()->BindRasterizerState(rasterizers[RSTYPE_BACK],threadID);
+ GetDevice()->BindBlendState(blendStates[BSTYPE_ADDITIVE],threadID);
+ GetDevice()->BindDepthStencilState(depthStencils[DSSTYPE_STENCILREAD],stencilRef,threadID);
+ GetDevice()->BindRasterizerState(rasterizers[RSTYPE_BACK],threadID);
- GetDevice()->BindVertexLayout(nullptr, threadID);
- GetDevice()->BindVertexBuffer(nullptr, 0, 0, threadID);
- GetDevice()->BindIndexBuffer(nullptr, threadID);
+ GetDevice()->BindVertexLayout(nullptr, threadID);
+ GetDevice()->BindVertexBuffer(nullptr, 0, 0, threadID);
+ GetDevice()->BindIndexBuffer(nullptr, threadID);
- GetDevice()->BindConstantBufferPS(constantBuffers[CBTYPE_POINTLIGHT], CB_GETBINDSLOT(PointLightCB), threadID);
- GetDevice()->BindConstantBufferVS(constantBuffers[CBTYPE_POINTLIGHT], CB_GETBINDSLOT(PointLightCB), threadID);
+ GetDevice()->BindConstantBufferPS(constantBuffers[CBTYPE_POINTLIGHT], CB_GETBINDSLOT(PointLightCB), threadID);
+ GetDevice()->BindConstantBufferVS(constantBuffers[CBTYPE_POINTLIGHT], CB_GETBINDSLOT(PointLightCB), threadID);
- GetDevice()->BindConstantBufferPS(constantBuffers[CBTYPE_SPOTLIGHT], CB_GETBINDSLOT(SpotLightCB), threadID);
- GetDevice()->BindConstantBufferVS(constantBuffers[CBTYPE_SPOTLIGHT], CB_GETBINDSLOT(SpotLightCB), threadID);
+ GetDevice()->BindConstantBufferPS(constantBuffers[CBTYPE_SPOTLIGHT], CB_GETBINDSLOT(SpotLightCB), threadID);
+ GetDevice()->BindConstantBufferVS(constantBuffers[CBTYPE_SPOTLIGHT], CB_GETBINDSLOT(SpotLightCB), threadID);
- for(int type=0;type<3;++type){
+ for(int type=0;type<3;++type){
- GetDevice()->BindVS(vertexShaders[VSTYPE_DIRLIGHT + type],threadID);
+ GetDevice()->BindVS(vertexShaders[VSTYPE_DIRLIGHT + type],threadID);
- switch (type)
- {
- case 0:
- if (SOFTSHADOW)
+ switch (type)
{
- GetDevice()->BindPS(pixelShaders[PSTYPE_DIRLIGHT_SOFT], threadID);
- }
- else
- {
- GetDevice()->BindPS(pixelShaders[PSTYPE_DIRLIGHT], threadID);
- }
- break;
- case 1:
- GetDevice()->BindPS(pixelShaders[PSTYPE_POINTLIGHT], threadID);
- break;
- case 2:
- GetDevice()->BindPS(pixelShaders[PSTYPE_SPOTLIGHT], threadID);
- break;
- default:
- break;
- }
-
-
- for(Cullable* c : culledObjects){
- Light* l = (Light*)c;
- if (l->type != type)
- continue;
-
- if(type==0) //dir
- {
- DirectionalLightCB lcb;
- lcb.direction=XMVector3Normalize(
- -XMVector3Transform( XMVectorSet(0,-1,0,1), XMMatrixRotationQuaternion( XMLoadFloat4(&l->rotation) ) )
- );
- lcb.col=XMFLOAT4(l->color.x*l->enerDis.x,l->color.y*l->enerDis.x,l->color.z*l->enerDis.x,1);
- lcb.mBiasResSoftshadow=XMFLOAT4(l->shadowBias,(float)SHADOWMAPRES,(float)SOFTSHADOW,0);
- for (unsigned int shmap = 0; shmap < l->shadowMaps_dirLight.size(); ++shmap){
- lcb.mShM[shmap]=l->shadowCam[shmap].getVP();
- if(l->shadowMaps_dirLight[shmap].depth)
- GetDevice()->BindResourcePS(l->shadowMaps_dirLight[shmap].depth->GetTexture(),TEXSLOT_SHADOW0+shmap,threadID);
- }
- GetDevice()->UpdateBuffer(constantBuffers[CBTYPE_DIRLIGHT],&lcb,threadID);
-
- GetDevice()->Draw(3, threadID);
- }
- else if(type==1) //point
- {
- PointLightCB lcb;
- lcb.pos=l->translation;
- lcb.col=l->color;
- lcb.enerdis=l->enerDis;
- lcb.enerdis.w = 0.f;
-
- if (l->shadow && l->shadowMap_index>=0)
+ case 0:
+ if (SOFTSHADOW)
{
- lcb.enerdis.w = 1.f;
- if(Light::shadowMaps_pointLight[l->shadowMap_index].depth)
- GetDevice()->BindResourcePS(Light::shadowMaps_pointLight[l->shadowMap_index].depth->GetTexture(), TEXSLOT_SHADOW_CUBE, threadID);
+ GetDevice()->BindPS(pixelShaders[PSTYPE_DIRLIGHT_SOFT], threadID);
}
- GetDevice()->UpdateBuffer(constantBuffers[CBTYPE_POINTLIGHT], &lcb, threadID);
-
- GetDevice()->Draw(240, threadID);
+ else
+ {
+ GetDevice()->BindPS(pixelShaders[PSTYPE_DIRLIGHT], threadID);
+ }
+ break;
+ case 1:
+ GetDevice()->BindPS(pixelShaders[PSTYPE_POINTLIGHT], threadID);
+ break;
+ case 2:
+ GetDevice()->BindPS(pixelShaders[PSTYPE_SPOTLIGHT], threadID);
+ break;
+ default:
+ break;
}
- else if(type==2) //spot
- {
- SpotLightCB lcb;
- const float coneS=(const float)(l->enerDis.z/0.7853981852531433);
- XMMATRIX world,rot;
- world = XMMatrixTranspose(
- XMMatrixScaling(coneS*l->enerDis.y,l->enerDis.y,coneS*l->enerDis.y)*
- XMMatrixRotationQuaternion( XMLoadFloat4( &l->rotation ) )*
- XMMatrixTranslationFromVector( XMLoadFloat3(&l->translation) )
+
+
+ for(Cullable* c : culledObjects){
+ Light* l = (Light*)c;
+ if (l->type != type)
+ continue;
+
+ if(type==0) //dir
+ {
+ DirectionalLightCB lcb;
+ lcb.direction=XMVector3Normalize(
+ -XMVector3Transform( XMVectorSet(0,-1,0,1), XMMatrixRotationQuaternion( XMLoadFloat4(&l->rotation) ) )
);
- rot=XMMatrixRotationQuaternion( XMLoadFloat4(&l->rotation) );
- lcb.direction=XMVector3Normalize(
- -XMVector3Transform( XMVectorSet(0,-1,0,1), rot )
- );
- lcb.world=world;
- lcb.mBiasResSoftshadow=XMFLOAT4(l->shadowBias,(float)SPOTLIGHTSHADOWRES,(float)SOFTSHADOW,0);
- lcb.mShM = XMMatrixIdentity();
- lcb.col=l->color;
- lcb.enerdis=l->enerDis;
- lcb.enerdis.z=(float)cos(l->enerDis.z/2.0);
+ lcb.col=XMFLOAT4(l->color.x*l->enerDis.x,l->color.y*l->enerDis.x,l->color.z*l->enerDis.x,1);
+ lcb.mBiasResSoftshadow=XMFLOAT4(l->shadowBias,(float)SHADOWMAPRES,(float)SOFTSHADOW,0);
+ for (unsigned int shmap = 0; shmap < l->shadowMaps_dirLight.size(); ++shmap){
+ lcb.mShM[shmap]=l->shadowCam[shmap].getVP();
+ if(l->shadowMaps_dirLight[shmap].depth)
+ GetDevice()->BindResourcePS(l->shadowMaps_dirLight[shmap].depth->GetTexture(),TEXSLOT_SHADOW0+shmap,threadID);
+ }
+ GetDevice()->UpdateBuffer(constantBuffers[CBTYPE_DIRLIGHT],&lcb,threadID);
- if (l->shadow && l->shadowMap_index>=0)
- {
- lcb.mShM = l->shadowCam[0].getVP();
- if(Light::shadowMaps_spotLight[l->shadowMap_index].depth)
- GetDevice()->BindResourcePS(Light::shadowMaps_spotLight[l->shadowMap_index].depth->GetTexture(), TEXSLOT_SHADOW0, threadID);
+ GetDevice()->Draw(3, threadID);
}
- GetDevice()->UpdateBuffer(constantBuffers[CBTYPE_SPOTLIGHT], &lcb, threadID);
+ else if(type==1) //point
+ {
+ PointLightCB lcb;
+ lcb.pos=l->translation;
+ lcb.col=l->color;
+ lcb.enerdis=l->enerDis;
+ lcb.enerdis.w = 0.f;
- GetDevice()->Draw(192, threadID);
+ if (l->shadow && l->shadowMap_index>=0)
+ {
+ lcb.enerdis.w = 1.f;
+ if(Light::shadowMaps_pointLight[l->shadowMap_index].depth)
+ GetDevice()->BindResourcePS(Light::shadowMaps_pointLight[l->shadowMap_index].depth->GetTexture(), TEXSLOT_SHADOW_CUBE, threadID);
+ }
+ GetDevice()->UpdateBuffer(constantBuffers[CBTYPE_POINTLIGHT], &lcb, threadID);
+
+ GetDevice()->Draw(240, threadID);
+ }
+ else if(type==2) //spot
+ {
+ SpotLightCB lcb;
+ const float coneS=(const float)(l->enerDis.z/0.7853981852531433);
+ XMMATRIX world,rot;
+ world = XMMatrixTranspose(
+ XMMatrixScaling(coneS*l->enerDis.y,l->enerDis.y,coneS*l->enerDis.y)*
+ XMMatrixRotationQuaternion( XMLoadFloat4( &l->rotation ) )*
+ XMMatrixTranslationFromVector( XMLoadFloat3(&l->translation) )
+ );
+ rot=XMMatrixRotationQuaternion( XMLoadFloat4(&l->rotation) );
+ lcb.direction=XMVector3Normalize(
+ -XMVector3Transform( XMVectorSet(0,-1,0,1), rot )
+ );
+ lcb.world=world;
+ lcb.mBiasResSoftshadow=XMFLOAT4(l->shadowBias,(float)SPOTLIGHTSHADOWRES,(float)SOFTSHADOW,0);
+ lcb.mShM = XMMatrixIdentity();
+ lcb.col=l->color;
+ lcb.enerdis=l->enerDis;
+ lcb.enerdis.z=(float)cos(l->enerDis.z/2.0);
+
+ if (l->shadow && l->shadowMap_index>=0)
+ {
+ lcb.mShM = l->shadowCam[0].getVP();
+ if(Light::shadowMaps_spotLight[l->shadowMap_index].depth)
+ GetDevice()->BindResourcePS(Light::shadowMaps_spotLight[l->shadowMap_index].depth->GetTexture(), TEXSLOT_SHADOW0, threadID);
+ }
+ GetDevice()->UpdateBuffer(constantBuffers[CBTYPE_SPOTLIGHT], &lcb, threadID);
+
+ GetDevice()->Draw(192, threadID);
+ }
}
+
+
}
-
-
- }
-
+ GetDevice()->EventEnd();
}
}
void wiRenderer::DrawVolumeLights(Camera* camera, GRAPHICSTHREAD threadID)
@@ -1868,12 +1889,13 @@ void wiRenderer::DrawVolumeLights(Camera* camera, GRAPHICSTHREAD threadID)
frustum.ConstructFrustum(min(camera->zFarP, GetScene().worldInfo.fogSEH.y), camera->Projection, camera->View);
- CulledList culledObjects;
- if(spTree_lights)
- wiSPTree::getVisible(spTree_lights->root,frustum,culledObjects);
+ CulledList culledObjects;
+ if(spTree_lights)
+ wiSPTree::getVisible(spTree_lights->root,frustum,culledObjects);
- if(!culledObjects.empty())
- {
+ if(!culledObjects.empty())
+ {
+ GetDevice()->EventBegin(L"Light Volume Render");
GetDevice()->BindPrimitiveTopology(TRIANGLELIST,threadID);
GetDevice()->BindVertexLayout(nullptr);
@@ -1948,6 +1970,7 @@ void wiRenderer::DrawVolumeLights(Camera* camera, GRAPHICSTHREAD threadID)
}
+ GetDevice()->EventEnd();
}
}
@@ -2003,6 +2026,7 @@ void wiRenderer::ClearShadowMaps(GRAPHICSTHREAD threadID){
void wiRenderer::DrawForShadowMap(GRAPHICSTHREAD threadID)
{
if (GameSpeed) {
+ GetDevice()->EventBegin(L"ShadowMap Render");
CulledList culledLights;
if (spTree_lights)
@@ -2354,6 +2378,8 @@ void wiRenderer::DrawForShadowMap(GRAPHICSTHREAD threadID)
GetDevice()->BindGS(nullptr, threadID);
}
}
+
+ GetDevice()->EventEnd();
}
}
@@ -2454,7 +2480,7 @@ void wiRenderer::DrawWorld(Camera* camera, bool DX11Eff, int tessF, GRAPHICSTHRE
}
}
- wiRenderer::GetDevice()->EventBegin(L"Draw Models");
+ GetDevice()->EventBegin(L"DrawWorld");
if(DX11Eff && tessF)
GetDevice()->BindPrimitiveTopology(PATCHLIST,threadID);
@@ -2617,6 +2643,7 @@ void wiRenderer::DrawWorldTransparent(Camera* camera, Texture2D* refracRes, Text
// }
//}
+ GetDevice()->EventBegin(L"DrawWorld Transparent");
for(Cullable* object : culledObjects)
culledRenderer[((Object*)object)->mesh].insert((Object*)object);
@@ -2733,6 +2760,8 @@ void wiRenderer::DrawWorldTransparent(Camera* camera, Texture2D* refracRes, Text
m++;
}
}
+
+ GetDevice()->EventEnd();
}
}
@@ -2788,6 +2817,8 @@ void wiRenderer::DrawDecals(Camera* camera, GRAPHICSTHREAD threadID)
if (model->decals.empty())
continue;
+ GetDevice()->EventBegin(L"Decals");
+
if (!boundCB)
{
boundCB = true;
@@ -2834,6 +2865,8 @@ void wiRenderer::DrawDecals(Camera* camera, GRAPHICSTHREAD threadID)
}
}
+
+ GetDevice()->EventEnd();
}
}
diff --git a/WickedEngine/wiVersion.cpp b/WickedEngine/wiVersion.cpp
index 04e1783d2..2cde58ed8 100644
--- a/WickedEngine/wiVersion.cpp
+++ b/WickedEngine/wiVersion.cpp
@@ -7,7 +7,7 @@ namespace wiVersion
// minor features, major bug fixes
const int minor = 7;
// minor bug fixes, alterations, refactors
- const int revision = 8;
+ const int revision = 9;
long GetVersion()