mirror of https://github.com/AxioDL/boo.git
IGraphicsDataToken and IGraphicsCommandQueue::stopRenderer()
This commit is contained in:
parent
32d4797ac6
commit
d145e15ecb
|
@ -58,7 +58,6 @@ public:
|
||||||
|
|
||||||
/* Creates a new context on current thread!! Call from client loading thread */
|
/* Creates a new context on current thread!! Call from client loading thread */
|
||||||
virtual IGraphicsDataFactory* getLoadContextDataFactory()=0;
|
virtual IGraphicsDataFactory* getLoadContextDataFactory()=0;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,25 +18,31 @@ enum class EMouseButton
|
||||||
Aux2 = 5
|
Aux2 = 5
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct SWindowCoord
|
||||||
|
{
|
||||||
|
int pixel[2];
|
||||||
|
int virtualPixel[2];
|
||||||
|
float norm[2];
|
||||||
|
};
|
||||||
|
|
||||||
struct SWindowRect
|
struct SWindowRect
|
||||||
{
|
{
|
||||||
int location[2];
|
int location[2];
|
||||||
int size[2];
|
int size[2];
|
||||||
bool operator !=(const SWindowRect& other) const
|
bool operator!=(const SWindowRect& other) const
|
||||||
{
|
{
|
||||||
return location[0] != other.location[0] ||
|
return location[0] != other.location[0] ||
|
||||||
location[1] != other.location[1] ||
|
location[1] != other.location[1] ||
|
||||||
size[0] != other.size[0] ||
|
size[0] != other.size[0] ||
|
||||||
size[1] != other.size[1];
|
size[1] != other.size[1];
|
||||||
}
|
}
|
||||||
bool operator ==(const SWindowRect& other) const {return !(*this != other);}
|
bool operator==(const SWindowRect& other) const {return !(*this != other);}
|
||||||
};
|
|
||||||
|
|
||||||
struct SWindowCoord
|
bool coordInRect(const SWindowCoord& coord) const
|
||||||
{
|
{
|
||||||
int pixel[2];
|
return coord.pixel[0] >= location[0] && coord.pixel[0] < location[0] + size[0] &&
|
||||||
int virtualPixel[2];
|
coord.pixel[1] >= location[1] && coord.pixel[1] < location[1] + size[1];
|
||||||
float norm[2];
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct STouchCoord
|
struct STouchCoord
|
||||||
|
@ -246,7 +252,6 @@ public:
|
||||||
|
|
||||||
/* Creates a new context on current thread!! Call from client loading thread */
|
/* Creates a new context on current thread!! Call from client loading thread */
|
||||||
virtual IGraphicsDataFactory* getLoadContextDataFactory()=0;
|
virtual IGraphicsDataFactory* getLoadContextDataFactory()=0;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,9 +17,11 @@ class GLDataFactory : public IGraphicsDataFactory
|
||||||
struct GLData* m_deferredData = nullptr;
|
struct GLData* m_deferredData = nullptr;
|
||||||
std::unordered_set<struct GLData*> m_committedData;
|
std::unordered_set<struct GLData*> m_committedData;
|
||||||
std::vector<int> m_texUnis;
|
std::vector<int> m_texUnis;
|
||||||
|
void destroyData(IGraphicsData*);
|
||||||
|
void destroyAllData();
|
||||||
public:
|
public:
|
||||||
GLDataFactory(IGraphicsContext* parent);
|
GLDataFactory(IGraphicsContext* parent);
|
||||||
~GLDataFactory() {}
|
~GLDataFactory() {destroyAllData();}
|
||||||
|
|
||||||
Platform platform() const {return Platform::OGL;}
|
Platform platform() const {return Platform::OGL;}
|
||||||
const SystemChar* platformName() const {return _S("OGL");}
|
const SystemChar* platformName() const {return _S("OGL");}
|
||||||
|
@ -54,9 +56,7 @@ public:
|
||||||
size_t texCount, ITexture** texs);
|
size_t texCount, ITexture** texs);
|
||||||
|
|
||||||
void reset();
|
void reset();
|
||||||
IGraphicsData* commit();
|
IGraphicsDataToken commit();
|
||||||
void destroyData(IGraphicsData*);
|
|
||||||
void destroyAllData();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,6 +38,8 @@ struct IGraphicsCommandQueue
|
||||||
|
|
||||||
virtual void resolveDisplay(ITextureR* source)=0;
|
virtual void resolveDisplay(ITextureR* source)=0;
|
||||||
virtual void execute()=0;
|
virtual void execute()=0;
|
||||||
|
|
||||||
|
virtual void stopRenderer()=0;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
|
|
||||||
namespace boo
|
namespace boo
|
||||||
{
|
{
|
||||||
|
struct IGraphicsCommandQueue;
|
||||||
|
|
||||||
struct IGraphicsBuffer
|
struct IGraphicsBuffer
|
||||||
{
|
{
|
||||||
|
@ -145,12 +146,9 @@ struct IShaderPipeline {};
|
||||||
* as a reference */
|
* as a reference */
|
||||||
struct IShaderDataBinding {};
|
struct IShaderDataBinding {};
|
||||||
|
|
||||||
/** Opaque token for maintaining ownership of factory-created resources
|
/** Opaque object for maintaining ownership of factory-created resources */
|
||||||
* deletion of this token triggers mass-deallocation of the factory's
|
struct IGraphicsData {};
|
||||||
* resource batch. */
|
class IGraphicsDataToken;
|
||||||
struct IGraphicsData
|
|
||||||
{
|
|
||||||
};
|
|
||||||
|
|
||||||
/** Used by platform shader pipeline constructors */
|
/** Used by platform shader pipeline constructors */
|
||||||
enum class BlendFactor
|
enum class BlendFactor
|
||||||
|
@ -220,11 +218,55 @@ struct IGraphicsDataFactory
|
||||||
size_t texCount, ITexture** texs)=0;
|
size_t texCount, ITexture** texs)=0;
|
||||||
|
|
||||||
virtual void reset()=0;
|
virtual void reset()=0;
|
||||||
virtual IGraphicsData* commit()=0;
|
virtual IGraphicsDataToken commit()=0;
|
||||||
|
|
||||||
|
private:
|
||||||
|
friend class IGraphicsDataToken;
|
||||||
virtual void destroyData(IGraphicsData*)=0;
|
virtual void destroyData(IGraphicsData*)=0;
|
||||||
virtual void destroyAllData()=0;
|
virtual void destroyAllData()=0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/** Opaque token for maintaining ownership of factory-created resources
|
||||||
|
* deletion of this token triggers mass-deallocation of the factory's
|
||||||
|
* IGraphicsData. */
|
||||||
|
class IGraphicsDataToken
|
||||||
|
{
|
||||||
|
friend class GLDataFactory;
|
||||||
|
friend class D3D12DataFactory;
|
||||||
|
friend class D3D11DataFactory;
|
||||||
|
friend class MetalDataFactory;
|
||||||
|
IGraphicsDataFactory* m_factory = nullptr;
|
||||||
|
IGraphicsData* m_data = nullptr;
|
||||||
|
IGraphicsDataToken(IGraphicsDataFactory* factory, IGraphicsData* data)
|
||||||
|
: m_factory(factory), m_data(data) {}
|
||||||
|
void doDestroy()
|
||||||
|
{
|
||||||
|
if (m_factory && m_data)
|
||||||
|
m_factory->destroyData(m_data);
|
||||||
|
}
|
||||||
|
public:
|
||||||
|
IGraphicsDataToken() = default;
|
||||||
|
IGraphicsDataToken(const IGraphicsDataToken& other) = delete;
|
||||||
|
IGraphicsDataToken(IGraphicsDataToken&& other)
|
||||||
|
{
|
||||||
|
m_factory = other.m_factory;
|
||||||
|
other.m_factory = nullptr;
|
||||||
|
m_data = other.m_data;
|
||||||
|
other.m_data = nullptr;
|
||||||
|
}
|
||||||
|
IGraphicsDataToken& operator=(const IGraphicsDataToken& other) = delete;
|
||||||
|
IGraphicsDataToken& operator=(IGraphicsDataToken&& other)
|
||||||
|
{
|
||||||
|
doDestroy();
|
||||||
|
m_factory = other.m_factory;
|
||||||
|
other.m_factory = nullptr;
|
||||||
|
m_data = other.m_data;
|
||||||
|
other.m_data = nullptr;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
~IGraphicsDataToken() {doDestroy();}
|
||||||
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // IGFXDATAFACTORY_HPP
|
#endif // IGFXDATAFACTORY_HPP
|
||||||
|
|
|
@ -557,7 +557,7 @@ void GLDataFactory::reset()
|
||||||
m_deferredData = new struct GLData();
|
m_deferredData = new struct GLData();
|
||||||
}
|
}
|
||||||
|
|
||||||
IGraphicsData* GLDataFactory::commit()
|
IGraphicsDataToken GLDataFactory::commit()
|
||||||
{
|
{
|
||||||
GLData* retval = m_deferredData;
|
GLData* retval = m_deferredData;
|
||||||
m_deferredData = new struct GLData();
|
m_deferredData = new struct GLData();
|
||||||
|
@ -566,7 +566,7 @@ IGraphicsData* GLDataFactory::commit()
|
||||||
While this isn't strictly required, some drivers might behave
|
While this isn't strictly required, some drivers might behave
|
||||||
differently */
|
differently */
|
||||||
glFlush();
|
glFlush();
|
||||||
return retval;
|
return IGraphicsDataToken(this, retval);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GLDataFactory::destroyData(IGraphicsData* d)
|
void GLDataFactory::destroyData(IGraphicsData* d)
|
||||||
|
@ -900,13 +900,18 @@ struct GLCommandQueue : IGraphicsCommandQueue
|
||||||
m_initlk.unlock();
|
m_initlk.unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
~GLCommandQueue()
|
void stopRenderer()
|
||||||
{
|
{
|
||||||
m_running = false;
|
m_running = false;
|
||||||
m_cv.notify_one();
|
m_cv.notify_one();
|
||||||
m_thr.join();
|
m_thr.join();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
~GLCommandQueue()
|
||||||
|
{
|
||||||
|
if (m_running) stopRenderer();
|
||||||
|
}
|
||||||
|
|
||||||
void setShaderDataBinding(IShaderDataBinding* binding)
|
void setShaderDataBinding(IShaderDataBinding* binding)
|
||||||
{
|
{
|
||||||
std::vector<Command>& cmds = m_cmdBufs[m_fillBuf];
|
std::vector<Command>& cmds = m_cmdBufs[m_fillBuf];
|
||||||
|
|
|
@ -60,7 +60,7 @@ static Window GetWindowOfEvent(XEvent* event, bool& windowEvent)
|
||||||
case ButtonRelease:
|
case ButtonRelease:
|
||||||
{
|
{
|
||||||
windowEvent = true;
|
windowEvent = true;
|
||||||
return event->xbutton.window;;
|
return event->xbutton.window;
|
||||||
}
|
}
|
||||||
case MotionNotify:
|
case MotionNotify:
|
||||||
{
|
{
|
||||||
|
@ -290,7 +290,6 @@ public:
|
||||||
XNextEvent(m_xDisp, &event);
|
XNextEvent(m_xDisp, &event);
|
||||||
bool windowEvent;
|
bool windowEvent;
|
||||||
Window evWindow = GetWindowOfEvent(&event, windowEvent);
|
Window evWindow = GetWindowOfEvent(&event, windowEvent);
|
||||||
//fprintf(stderr, "EVENT %d\n", XCB_EVENT_RESPONSE_TYPE(event));
|
|
||||||
if (windowEvent)
|
if (windowEvent)
|
||||||
{
|
{
|
||||||
auto window = m_windows.find(evWindow);
|
auto window = m_windows.find(evWindow);
|
||||||
|
|
|
@ -25,7 +25,7 @@
|
||||||
|
|
||||||
#include "XlibCommon.hpp"
|
#include "XlibCommon.hpp"
|
||||||
|
|
||||||
#define REF_DPMM 3.7824 /* 96 DPI */
|
#define REF_DPMM 3.78138
|
||||||
#define FS_ATOM "_NET_WM_STATE_FULLSCREEN"
|
#define FS_ATOM "_NET_WM_STATE_FULLSCREEN"
|
||||||
|
|
||||||
#define MWM_HINTS_FUNCTIONS (1L << 0)
|
#define MWM_HINTS_FUNCTIONS (1L << 0)
|
||||||
|
|
|
@ -377,7 +377,7 @@ struct TestApplicationCallback : IApplicationCallback
|
||||||
factory->newShaderDataBinding(pipeline, vfmt, vbo, nullptr, nullptr, 0, nullptr, 1, &texture);
|
factory->newShaderDataBinding(pipeline, vfmt, vbo, nullptr, nullptr, 0, nullptr, 1, &texture);
|
||||||
|
|
||||||
/* Commit objects */
|
/* Commit objects */
|
||||||
IGraphicsData* data = factory->commit();
|
IGraphicsDataToken data = factory->commit();
|
||||||
|
|
||||||
/* Return control to client */
|
/* Return control to client */
|
||||||
lk.unlock();
|
lk.unlock();
|
||||||
|
@ -458,6 +458,7 @@ struct TestApplicationCallback : IApplicationCallback
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gfxQ->stopRenderer();
|
||||||
m_cv.notify_one();
|
m_cv.notify_one();
|
||||||
loaderThread.join();
|
loaderThread.join();
|
||||||
return 0;
|
return 0;
|
||||||
|
|
Loading…
Reference in New Issue