minor refactor
This commit is contained in:
@@ -1,5 +1,11 @@
|
||||
#include "DeferredRenderableComponent.h"
|
||||
#include "WickedEngine.h"
|
||||
#include "wiRenderer.h"
|
||||
#include "wiImage.h"
|
||||
#include "wiImageEffects.h"
|
||||
#include "wiCamera.h"
|
||||
#include "wiStencilRef.h"
|
||||
#include "wiHelper.h"
|
||||
#include "wiTextureHelper.h"
|
||||
|
||||
DeferredRenderableComponent::DeferredRenderableComponent(){
|
||||
}
|
||||
@@ -12,7 +18,7 @@ void DeferredRenderableComponent::Initialize()
|
||||
setSSREnabled(true);
|
||||
setSSAOEnabled(true);
|
||||
|
||||
setPreferredThreadingCount(4);
|
||||
setPreferredThreadingCount(0);
|
||||
}
|
||||
void DeferredRenderableComponent::Load()
|
||||
{
|
||||
|
||||
@@ -1,5 +1,10 @@
|
||||
#include "ForwardRenderableComponent.h"
|
||||
#include "WickedEngine.h"
|
||||
#include "wiRenderer.h"
|
||||
#include "wiImage.h"
|
||||
#include "wiImageEffects.h"
|
||||
#include "wiCamera.h"
|
||||
#include "wiStencilRef.h"
|
||||
#include "wiHelper.h"
|
||||
|
||||
ForwardRenderableComponent::ForwardRenderableComponent(){
|
||||
}
|
||||
@@ -13,7 +18,7 @@ void ForwardRenderableComponent::Initialize()
|
||||
setSSAOEnabled(false);
|
||||
setShadowsEnabled(false);
|
||||
|
||||
setPreferredThreadingCount(4);
|
||||
setPreferredThreadingCount(0);
|
||||
}
|
||||
void ForwardRenderableComponent::Load()
|
||||
{
|
||||
|
||||
@@ -1,5 +1,11 @@
|
||||
#include "Renderable3DSceneComponent.h"
|
||||
#include "WickedEngine.h"
|
||||
#include "wiRenderer.h"
|
||||
#include "wiImage.h"
|
||||
#include "wiImageEffects.h"
|
||||
#include "wiCamera.h"
|
||||
#include "wiStencilRef.h"
|
||||
#include "wiHelper.h"
|
||||
#include "wiTextureHelper.h"
|
||||
|
||||
Renderable3DSceneComponent::Renderable3DSceneComponent()
|
||||
{
|
||||
|
||||
@@ -19,6 +19,8 @@
|
||||
#include "wiCpuInfo.h"
|
||||
#include "wiLoader.h"
|
||||
#include "wiParticle.h"
|
||||
#include "wiEmittedParticle.h"
|
||||
#include "wiHairParticle.h"
|
||||
#include "wiRenderer.h"
|
||||
#include "wiDirectInput.h"
|
||||
#include "wiXInput.h"
|
||||
@@ -38,6 +40,7 @@
|
||||
#include "wiPHYSICS.h"
|
||||
#include "wiBULLET.h"
|
||||
#include "wiGraphicsThreads.h"
|
||||
#include "wiStencilRef.h"
|
||||
|
||||
#include "RenderableComponent.h"
|
||||
#include "Renderable3DSceneComponent.h"
|
||||
|
||||
@@ -588,6 +588,7 @@
|
||||
<ClInclude Include="RenderableComponent.h" />
|
||||
<ClInclude Include="Renderable3DSceneComponent.h" />
|
||||
<ClInclude Include="wiGraphicsThreads.h" />
|
||||
<ClInclude Include="wiStencilRef.h" />
|
||||
<ClInclude Include="wiTextureHelper.h" />
|
||||
<ClInclude Include="WickedEngine.h" />
|
||||
<ClInclude Include="wiCpuInfo.h" />
|
||||
|
||||
@@ -1414,6 +1414,9 @@
|
||||
<ClInclude Include="wiGraphicsThreads.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="wiStencilRef.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="..\io_export_wicked_wi_bin.py" />
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#include "wiRenderTarget.h"
|
||||
#include "wiDepthTarget.h"
|
||||
#include "wiGraphicsThreads.h"
|
||||
#include "wiStencilRef.h"
|
||||
|
||||
struct HitSphere;
|
||||
class wiParticle;
|
||||
@@ -275,15 +276,6 @@ struct VertexGroup{
|
||||
VertexGroup(string n){name=n;}
|
||||
void addVertex(const VertexRef& vRef){vertices.insert(pair<int,float>(vRef.index,vRef.weight));}
|
||||
};
|
||||
enum STENCILREF{
|
||||
STENCILREF_EMPTY,
|
||||
STENCILREF_SKY,
|
||||
STENCILREF_DEFAULT,
|
||||
STENCILREF_TRANSPARENT,
|
||||
STENCILREF_CHARACTER,
|
||||
STENCILREF_SHADELESS,
|
||||
STENCILREF_SKIN,
|
||||
};
|
||||
struct Mesh{
|
||||
string name;
|
||||
string parent;
|
||||
|
||||
@@ -18,6 +18,4 @@ public:
|
||||
static void ChangeRasterizer(){wireRender=!wireRender;}
|
||||
};
|
||||
|
||||
#include "wiEmittedParticle.h"
|
||||
#include "wiHairParticle.h"
|
||||
|
||||
|
||||
@@ -962,10 +962,10 @@ public:
|
||||
static D3D11_BUFFER_DESC desc;
|
||||
buffer->GetDesc(&desc);
|
||||
static HRESULT hr;
|
||||
if(dataSize>(int)desc.ByteWidth){ //recreate the buffer if new datasize exceeds buffer size [SLOW][TEST!!!!]
|
||||
if (dataSize>(int)desc.ByteWidth){ //recreate the buffer if new datasize exceeds buffer size [SLOW][TEST!!!!]
|
||||
buffer->Release();
|
||||
desc.ByteWidth=dataSize*2;
|
||||
hr=graphicsDevice->CreateBuffer( &desc, nullptr, &buffer );
|
||||
desc.ByteWidth = dataSize * 2;
|
||||
hr = graphicsDevice->CreateBuffer(&desc, nullptr, &buffer);
|
||||
}
|
||||
if(desc.Usage == D3D11_USAGE_DYNAMIC){
|
||||
static D3D11_MAPPED_SUBRESOURCE mappedResource;
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
#pragma once
|
||||
|
||||
enum STENCILREF{
|
||||
STENCILREF_EMPTY,
|
||||
STENCILREF_SKY,
|
||||
STENCILREF_DEFAULT,
|
||||
STENCILREF_TRANSPARENT,
|
||||
STENCILREF_CHARACTER,
|
||||
STENCILREF_SHADELESS,
|
||||
STENCILREF_SKIN,
|
||||
};
|
||||
@@ -12,46 +12,34 @@ public:
|
||||
{}
|
||||
~wiTaskThread() { stop(); join(); }
|
||||
|
||||
// wake up the thread and execute the task
|
||||
void wakeup() {
|
||||
auto lock = std::unique_lock<std::mutex>(m_wakemutex);
|
||||
//std::cout << "main: sending wakeup signal..." << std::endl;
|
||||
m_wakeup = true;
|
||||
m_wakecond.notify_one();
|
||||
}
|
||||
// wait for the task to complete
|
||||
void wait() {
|
||||
auto lock = std::unique_lock<std::mutex>(m_waitmutex);
|
||||
//std::cout << "main: waiting for task completion..." << std::endl;
|
||||
while (m_wakeup)
|
||||
m_waitcond.wait(lock);
|
||||
//std::cout << "main: task completed!" << std::endl;
|
||||
}
|
||||
|
||||
// ask the thread to stop
|
||||
void stop() {
|
||||
auto lock = std::unique_lock<std::mutex>(m_wakemutex);
|
||||
//std::cout << "main: sending stop signal..." << std::endl;
|
||||
m_stop = true;
|
||||
m_wakecond.notify_one();
|
||||
}
|
||||
// wait for the thread to actually be stopped
|
||||
void join() {
|
||||
//std::cout << "main: waiting for join..." << std::endl;
|
||||
m_thread.join();
|
||||
//std::cout << "main: joined!" << std::endl;
|
||||
}
|
||||
|
||||
private:
|
||||
std::function<void ()> m_task;
|
||||
|
||||
// wake up the thread
|
||||
bool m_wakeup;
|
||||
bool m_stop;
|
||||
std::mutex m_wakemutex;
|
||||
std::condition_variable m_wakecond;
|
||||
|
||||
// wait for the thread to finish its task
|
||||
std::mutex m_waitmutex;
|
||||
std::condition_variable m_waitcond;
|
||||
|
||||
@@ -61,25 +49,17 @@ private:
|
||||
while (true) {
|
||||
{
|
||||
auto lock = std::unique_lock<std::mutex>(m_wakemutex);
|
||||
//std::cout << "thread: waiting for wakeup or stop signal..." << std::endl;
|
||||
while (!m_wakeup && !m_stop)
|
||||
m_wakecond.wait(lock);
|
||||
if (m_stop) {
|
||||
//std::cout << "thread: got stop signal!" << std::endl;
|
||||
return;
|
||||
}
|
||||
//std::cout << "thread: got wakeup signal!" << std::endl;
|
||||
}
|
||||
|
||||
//std::cout << "thread: running the task..." << std::endl;
|
||||
// you should probably do something cleaner than catch (...)
|
||||
// just ensure that no exception propagates from m_task() to taskFunc()
|
||||
try { m_task(); } catch (...) {}
|
||||
//std::cout << "thread: task completed!" << std::endl;
|
||||
|
||||
{
|
||||
auto lock = std::unique_lock<std::mutex>(m_waitmutex);
|
||||
//std::cout << "thread: sending task completed signal..." << std::endl;
|
||||
m_wakeup = false;
|
||||
m_waitcond.notify_all();
|
||||
}
|
||||
|
||||
@@ -72,6 +72,9 @@ _________________________________________________________
|
||||
- Optimize image rendering
|
||||
- Rewrite camera class
|
||||
- Decouple API from wiRenderer
|
||||
- Add a Loading Screen Component Template
|
||||
- 2D Renderable Component Template (after optimized image rendering)
|
||||
- Multithreaded rendering bug after refactor (flashing geometry)(turned off for the time being)
|
||||
Other:
|
||||
- Cleanup
|
||||
- Documentation
|
||||
|
||||
Reference in New Issue
Block a user