OpenGL and Metal fixes

This commit is contained in:
Jack Andersen 2017-03-05 13:34:24 -10:00
parent a547eb9dbb
commit 3b7a5781f5
2 changed files with 20 additions and 6 deletions

View File

@ -421,11 +421,25 @@ class GLShaderPipeline : public IShaderPipeline
GLShaderPipeline() = default; GLShaderPipeline() = default;
public: public:
operator bool() const {return m_prog != 0;} operator bool() const {return m_prog != 0;}
~GLShaderPipeline() { glDeleteProgram(m_prog); } ~GLShaderPipeline() { if (m_prog) glDeleteProgram(m_prog); }
GLShaderPipeline& operator=(const GLShaderPipeline&) = delete; GLShaderPipeline& operator=(const GLShaderPipeline&) = delete;
GLShaderPipeline(const GLShaderPipeline&) = delete; GLShaderPipeline(const GLShaderPipeline&) = delete;
GLShaderPipeline& operator=(GLShaderPipeline&& other) = default; GLShaderPipeline& operator=(GLShaderPipeline&& other)
GLShaderPipeline(GLShaderPipeline&& other) = default; {
m_vert = std::move(other.m_vert);
m_frag = std::move(other.m_frag);
m_prog = other.m_prog;
other.m_prog = 0;
m_sfactor = other.m_sfactor;
m_dfactor = other.m_dfactor;
m_drawPrim = other.m_drawPrim;
m_depthTest = other.m_depthTest;
m_depthWrite = other.m_depthWrite;
m_backfaceCulling = other.m_backfaceCulling;
m_uniLocs = std::move(other.m_uniLocs);
return *this;
}
GLShaderPipeline(GLShaderPipeline&& other) { *this = std::move(other); }
GLuint bind() const GLuint bind() const
{ {

View File

@ -25,8 +25,8 @@ class MetalDataFactoryImpl;
struct MetalShareableShader : IShareableShader<MetalDataFactoryImpl, MetalShareableShader> struct MetalShareableShader : IShareableShader<MetalDataFactoryImpl, MetalShareableShader>
{ {
id<MTLFunction> m_shader; id<MTLFunction> m_shader;
MetalShareableShader(MetalDataFactoryImpl& fac, uint64_t key, id<MTLFunction> s) MetalShareableShader(MetalDataFactoryImpl& fac, uint64_t srcKey, id<MTLFunction> s)
: IShareableShader(fac, key), m_shader(s) {} : IShareableShader(fac, srcKey, 0), m_shader(s) {}
}; };
class MetalDataFactoryImpl : public MetalDataFactory class MetalDataFactoryImpl : public MetalDataFactory
@ -58,7 +58,7 @@ public:
GraphicsDataToken commitTransaction(const std::function<bool(IGraphicsDataFactory::Context& ctx)>&); GraphicsDataToken commitTransaction(const std::function<bool(IGraphicsDataFactory::Context& ctx)>&);
GraphicsBufferPoolToken newBufferPool(); GraphicsBufferPoolToken newBufferPool();
void _unregisterShareableShader(uint64_t key) { m_sharedShaders.erase(key); } void _unregisterShareableShader(uint64_t srcKey, uint64_t binKey) { m_sharedShaders.erase(srcKey); }
}; };
ThreadLocalPtr<struct MetalData> MetalDataFactoryImpl::m_deferredData; ThreadLocalPtr<struct MetalData> MetalDataFactoryImpl::m_deferredData;