OpenGL: Random stuff I forgot
This commit is contained in:
parent
2ea03fe05f
commit
332278dded
|
|
@ -31,6 +31,7 @@ namespace Nz
|
||||||
bool Create(RendererImpl* renderer, RenderSurface* surface, const Vector2ui& size, const RenderWindowParameters& parameters) override;
|
bool Create(RendererImpl* renderer, RenderSurface* surface, const Vector2ui& size, const RenderWindowParameters& parameters) override;
|
||||||
std::unique_ptr<CommandPool> CreateCommandPool(QueueType queueType) override;
|
std::unique_ptr<CommandPool> CreateCommandPool(QueueType queueType) override;
|
||||||
|
|
||||||
|
inline GL::Context& GetContext();
|
||||||
const OpenGLFramebuffer& GetFramebuffer() const override;
|
const OpenGLFramebuffer& GetFramebuffer() const override;
|
||||||
const OpenGLRenderPass& GetRenderPass() const override;
|
const OpenGLRenderPass& GetRenderPass() const override;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,10 +3,16 @@
|
||||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||||
|
|
||||||
#include <Nazara/OpenGLRenderer/OpenGLRenderWindow.hpp>
|
#include <Nazara/OpenGLRenderer/OpenGLRenderWindow.hpp>
|
||||||
|
#include <cassert>
|
||||||
#include <Nazara/OpenGLRenderer/Debug.hpp>
|
#include <Nazara/OpenGLRenderer/Debug.hpp>
|
||||||
|
|
||||||
namespace Nz
|
namespace Nz
|
||||||
{
|
{
|
||||||
|
inline GL::Context& OpenGLRenderWindow::GetContext()
|
||||||
|
{
|
||||||
|
assert(m_context);
|
||||||
|
return *m_context;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#include <Nazara/OpenGLRenderer/DebugOff.hpp>
|
#include <Nazara/OpenGLRenderer/DebugOff.hpp>
|
||||||
|
|
|
||||||
|
|
@ -16,10 +16,13 @@
|
||||||
|
|
||||||
namespace Nz
|
namespace Nz
|
||||||
{
|
{
|
||||||
|
inline GLenum ToOpenGL(BlendFunc blendFunc);
|
||||||
|
inline GLenum ToOpenGL(FaceSide filter);
|
||||||
inline GLenum ToOpenGL(SamplerFilter filter);
|
inline GLenum ToOpenGL(SamplerFilter filter);
|
||||||
inline GLenum ToOpenGL(SamplerFilter minFilter, SamplerMipmapMode mipmapFilter);
|
inline GLenum ToOpenGL(SamplerFilter minFilter, SamplerMipmapMode mipmapFilter);
|
||||||
inline GLenum ToOpenGL(SamplerWrap wrapMode);
|
inline GLenum ToOpenGL(SamplerWrap wrapMode);
|
||||||
inline GLenum ToOpenGL(ShaderStageType stageType);
|
inline GLenum ToOpenGL(ShaderStageType stageType);
|
||||||
|
inline GLenum ToOpenGL(StencilOperation stencilOp);
|
||||||
inline GLenum ToOpenGL(GL::BufferTarget bufferTarget);
|
inline GLenum ToOpenGL(GL::BufferTarget bufferTarget);
|
||||||
inline GLenum ToOpenGL(GL::TextureTarget bufferTarget);
|
inline GLenum ToOpenGL(GL::TextureTarget bufferTarget);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,61 @@
|
||||||
|
|
||||||
namespace Nz
|
namespace Nz
|
||||||
{
|
{
|
||||||
GLenum ToOpenGL(SamplerFilter filter)
|
inline GLenum ToOpenGL(BlendFunc blendFunc)
|
||||||
|
{
|
||||||
|
switch (blendFunc)
|
||||||
|
{
|
||||||
|
case BlendFunc_DestAlpha: return GL_DST_ALPHA;
|
||||||
|
case BlendFunc_DestColor: return GL_DST_COLOR;
|
||||||
|
case BlendFunc_SrcAlpha: return GL_SRC_ALPHA;
|
||||||
|
case BlendFunc_SrcColor: return GL_SRC_COLOR;
|
||||||
|
case BlendFunc_InvDestAlpha: return GL_ONE_MINUS_DST_ALPHA;
|
||||||
|
case BlendFunc_InvDestColor: return GL_ONE_MINUS_DST_COLOR;
|
||||||
|
case BlendFunc_InvSrcAlpha: return GL_ONE_MINUS_SRC_ALPHA;
|
||||||
|
case BlendFunc_InvSrcColor: return GL_ONE_MINUS_SRC_COLOR;
|
||||||
|
case BlendFunc_One: return GL_ONE;
|
||||||
|
case BlendFunc_Zero: return GL_ZERO;
|
||||||
|
}
|
||||||
|
|
||||||
|
NazaraError("Unhandled BlendFunc 0x" + String::Number(UnderlyingCast(blendFunc), 16));
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
|
inline GLenum ToOpenGL(FaceSide filter)
|
||||||
|
{
|
||||||
|
switch (filter)
|
||||||
|
{
|
||||||
|
case FaceSide_None:
|
||||||
|
break;
|
||||||
|
|
||||||
|
case FaceSide_Back: return GL_BACK;
|
||||||
|
case FaceSide_Front: return GL_FRONT;
|
||||||
|
case FaceSide_FrontAndBack: return GL_FRONT_AND_BACK;
|
||||||
|
}
|
||||||
|
|
||||||
|
NazaraError("Unhandled FaceSide 0x" + String::Number(UnderlyingCast(filter), 16));
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
|
inline GLenum ToOpenGL(RendererComparison comparison)
|
||||||
|
{
|
||||||
|
switch (comparison)
|
||||||
|
{
|
||||||
|
case RendererComparison_Always: return GL_ALWAYS;
|
||||||
|
case RendererComparison_Equal: return GL_EQUAL;
|
||||||
|
case RendererComparison_Greater: return GL_GREATER;
|
||||||
|
case RendererComparison_GreaterOrEqual: return GL_GEQUAL;
|
||||||
|
case RendererComparison_Less: return GL_LESS;
|
||||||
|
case RendererComparison_LessOrEqual: return GL_LEQUAL;
|
||||||
|
case RendererComparison_Never: return GL_NEVER;
|
||||||
|
case RendererComparison_NotEqual: return GL_NOTEQUAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
NazaraError("Unhandled RendererComparison 0x" + String::Number(UnderlyingCast(comparison), 16));
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
|
inline GLenum ToOpenGL(SamplerFilter filter)
|
||||||
{
|
{
|
||||||
switch (filter)
|
switch (filter)
|
||||||
{
|
{
|
||||||
|
|
@ -22,7 +76,7 @@ namespace Nz
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
GLenum ToOpenGL(SamplerFilter minFilter, SamplerMipmapMode mipmapFilter)
|
inline GLenum ToOpenGL(SamplerFilter minFilter, SamplerMipmapMode mipmapFilter)
|
||||||
{
|
{
|
||||||
switch (minFilter)
|
switch (minFilter)
|
||||||
{
|
{
|
||||||
|
|
@ -55,7 +109,7 @@ namespace Nz
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
GLenum ToOpenGL(SamplerWrap wrapMode)
|
inline GLenum ToOpenGL(SamplerWrap wrapMode)
|
||||||
{
|
{
|
||||||
switch (wrapMode)
|
switch (wrapMode)
|
||||||
{
|
{
|
||||||
|
|
@ -68,7 +122,7 @@ namespace Nz
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
GLenum ToOpenGL(ShaderStageType stageType)
|
inline GLenum ToOpenGL(ShaderStageType stageType)
|
||||||
{
|
{
|
||||||
switch (stageType)
|
switch (stageType)
|
||||||
{
|
{
|
||||||
|
|
@ -80,7 +134,25 @@ namespace Nz
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
GLenum ToOpenGL(GL::BufferTarget bufferTarget)
|
inline GLenum ToOpenGL(StencilOperation stencilOp)
|
||||||
|
{
|
||||||
|
switch (stencilOp)
|
||||||
|
{
|
||||||
|
case StencilOperation_Decrement: return GL_DECR;
|
||||||
|
case StencilOperation_DecrementNoClamp: return GL_DECR_WRAP;
|
||||||
|
case StencilOperation_Increment: return GL_INCR;
|
||||||
|
case StencilOperation_IncrementNoClamp: return GL_INCR_WRAP;
|
||||||
|
case StencilOperation_Invert: return GL_INVERT;
|
||||||
|
case StencilOperation_Keep: return GL_KEEP;
|
||||||
|
case StencilOperation_Replace: return GL_REPLACE;
|
||||||
|
case StencilOperation_Zero: return GL_ZERO;
|
||||||
|
}
|
||||||
|
|
||||||
|
NazaraError("Unhandled StencilOperation 0x" + String::Number(UnderlyingCast(stencilOp), 16));
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
|
inline GLenum ToOpenGL(GL::BufferTarget bufferTarget)
|
||||||
{
|
{
|
||||||
switch (bufferTarget)
|
switch (bufferTarget)
|
||||||
{
|
{
|
||||||
|
|
@ -98,7 +170,7 @@ namespace Nz
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
GLenum ToOpenGL(GL::TextureTarget textureTarget)
|
inline GLenum ToOpenGL(GL::TextureTarget textureTarget)
|
||||||
{
|
{
|
||||||
switch (textureTarget)
|
switch (textureTarget)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,7 @@ typedef void (GL_APIENTRYP PFNGLSPECIALIZESHADERARBPROC) (GLuint shader, const G
|
||||||
cb(glBeginQuery, PFNGLBEGINQUERYPROC) \
|
cb(glBeginQuery, PFNGLBEGINQUERYPROC) \
|
||||||
cb(glBindAttribLocation, PFNGLBINDATTRIBLOCATIONPROC) \
|
cb(glBindAttribLocation, PFNGLBINDATTRIBLOCATIONPROC) \
|
||||||
cb(glBindBuffer, PFNGLBINDBUFFERPROC) \
|
cb(glBindBuffer, PFNGLBINDBUFFERPROC) \
|
||||||
|
cb(glBindBufferRange, PFNGLBINDBUFFERRANGEPROC) \
|
||||||
cb(glBindFramebuffer, PFNGLBINDFRAMEBUFFERPROC) \
|
cb(glBindFramebuffer, PFNGLBINDFRAMEBUFFERPROC) \
|
||||||
cb(glBindRenderbuffer, PFNGLBINDRENDERBUFFERPROC) \
|
cb(glBindRenderbuffer, PFNGLBINDRENDERBUFFERPROC) \
|
||||||
cb(glBindSampler, PFNGLBINDSAMPLERPROC) \
|
cb(glBindSampler, PFNGLBINDSAMPLERPROC) \
|
||||||
|
|
@ -43,9 +44,10 @@ typedef void (GL_APIENTRYP PFNGLSPECIALIZESHADERARBPROC) (GLuint shader, const G
|
||||||
cb(glColorMask, PFNGLCOLORMASKPROC) \
|
cb(glColorMask, PFNGLCOLORMASKPROC) \
|
||||||
cb(glCompressedTexSubImage2D, PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC) \
|
cb(glCompressedTexSubImage2D, PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC) \
|
||||||
cb(glCompressedTexSubImage3D, PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC) \
|
cb(glCompressedTexSubImage3D, PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC) \
|
||||||
cb(glCullFace, PFNGLCULLFACEPROC) \
|
|
||||||
cb(glCompileShader, PFNGLCOMPILESHADERPROC) \
|
cb(glCompileShader, PFNGLCOMPILESHADERPROC) \
|
||||||
|
cb(glCopyBufferSubData, PFNGLCOPYBUFFERSUBDATAPROC) \
|
||||||
cb(glCopyTexSubImage2D, PFNGLCOPYTEXSUBIMAGE2DPROC) \
|
cb(glCopyTexSubImage2D, PFNGLCOPYTEXSUBIMAGE2DPROC) \
|
||||||
|
cb(glCullFace, PFNGLCULLFACEPROC) \
|
||||||
cb(glDeleteBuffers, PFNGLDELETEBUFFERSPROC) \
|
cb(glDeleteBuffers, PFNGLDELETEBUFFERSPROC) \
|
||||||
cb(glDeleteFramebuffers, PFNGLDELETEFRAMEBUFFERSPROC) \
|
cb(glDeleteFramebuffers, PFNGLDELETEFRAMEBUFFERSPROC) \
|
||||||
cb(glDeleteProgram, PFNGLDELETEPROGRAMPROC) \
|
cb(glDeleteProgram, PFNGLDELETEPROGRAMPROC) \
|
||||||
|
|
@ -123,7 +125,9 @@ typedef void (GL_APIENTRYP PFNGLSPECIALIZESHADERARBPROC) (GLuint shader, const G
|
||||||
cb(glTexImage2D, PFNGLTEXIMAGE2DPROC) \
|
cb(glTexImage2D, PFNGLTEXIMAGE2DPROC) \
|
||||||
cb(glTexImage3D, PFNGLTEXIMAGE3DPROC) \
|
cb(glTexImage3D, PFNGLTEXIMAGE3DPROC) \
|
||||||
cb(glTexParameterf, PFNGLTEXPARAMETERFPROC) \
|
cb(glTexParameterf, PFNGLTEXPARAMETERFPROC) \
|
||||||
|
cb(glTexParameterfv, PFNGLTEXPARAMETERFVPROC) \
|
||||||
cb(glTexParameteri, PFNGLTEXPARAMETERIPROC) \
|
cb(glTexParameteri, PFNGLTEXPARAMETERIPROC) \
|
||||||
|
cb(glTexParameteriv, PFNGLTEXPARAMETERIVPROC) \
|
||||||
cb(glTexStorage2D, PFNGLTEXSTORAGE2DPROC) \
|
cb(glTexStorage2D, PFNGLTEXSTORAGE2DPROC) \
|
||||||
cb(glTexStorage3D, PFNGLTEXSTORAGE3DPROC) \
|
cb(glTexStorage3D, PFNGLTEXSTORAGE3DPROC) \
|
||||||
cb(glTexSubImage2D, PFNGLTEXSUBIMAGE2DPROC) \
|
cb(glTexSubImage2D, PFNGLTEXSUBIMAGE2DPROC) \
|
||||||
|
|
|
||||||
|
|
@ -4,8 +4,8 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#ifndef NAZARA_OPENGLRENDERER_GLSHADER_HPP
|
#ifndef NAZARA_OPENGLRENDERER_GLPROGRAM_HPP
|
||||||
#define NAZARA_OPENGLRENDERER_GLSHADER_HPP
|
#define NAZARA_OPENGLRENDERER_GLPROGRAM_HPP
|
||||||
|
|
||||||
#include <Nazara/Prerequisites.hpp>
|
#include <Nazara/Prerequisites.hpp>
|
||||||
#include <Nazara/Core/MovableValue.hpp>
|
#include <Nazara/Core/MovableValue.hpp>
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,11 @@ namespace Nz::GL
|
||||||
Texture(Texture&&) noexcept = default;
|
Texture(Texture&&) noexcept = default;
|
||||||
~Texture() = default;
|
~Texture() = default;
|
||||||
|
|
||||||
|
inline void SetParameterf(GLenum pname, GLfloat param);
|
||||||
|
inline void SetParameteri(GLenum pname, GLint param);
|
||||||
|
inline void SetParameterfv(GLenum pname, const GLfloat* param);
|
||||||
|
inline void SetParameteriv(GLenum pname, const GLint* param);
|
||||||
|
|
||||||
inline void TexImage2D(GLint level, GLint internalFormat, GLsizei width, GLsizei height, GLint border);
|
inline void TexImage2D(GLint level, GLint internalFormat, GLsizei width, GLsizei height, GLint border);
|
||||||
inline void TexImage2D(GLint level, GLint internalFormat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void* data);
|
inline void TexImage2D(GLint level, GLint internalFormat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void* data);
|
||||||
inline void TexSubImage2D(GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void* data);
|
inline void TexSubImage2D(GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void* data);
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,38 @@
|
||||||
|
|
||||||
namespace Nz::GL
|
namespace Nz::GL
|
||||||
{
|
{
|
||||||
|
inline void Texture::SetParameterf(GLenum pname, GLfloat param)
|
||||||
|
{
|
||||||
|
assert(m_objectId);
|
||||||
|
|
||||||
|
const Context& context = EnsureDeviceContext();
|
||||||
|
context.glTexParameterf(m_objectId, pname, param);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void Texture::SetParameteri(GLenum pname, GLint param)
|
||||||
|
{
|
||||||
|
assert(m_objectId);
|
||||||
|
|
||||||
|
const Context& context = EnsureDeviceContext();
|
||||||
|
context.glTexParameteri(m_objectId, pname, param);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void Texture::SetParameterfv(GLenum pname, const GLfloat* param)
|
||||||
|
{
|
||||||
|
assert(m_objectId);
|
||||||
|
|
||||||
|
const Context& context = EnsureDeviceContext();
|
||||||
|
context.glTexParameterfv(m_objectId, pname, param);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void Texture::SetParameteriv(GLenum pname, const GLint* param)
|
||||||
|
{
|
||||||
|
assert(m_objectId);
|
||||||
|
|
||||||
|
const Context& context = EnsureDeviceContext();
|
||||||
|
context.glTexParameteriv(m_objectId, pname, param);
|
||||||
|
}
|
||||||
|
|
||||||
inline void Texture::TexImage2D(GLint level, GLint internalFormat, GLsizei width, GLsizei height, GLint border)
|
inline void Texture::TexImage2D(GLint level, GLint internalFormat, GLsizei width, GLsizei height, GLint border)
|
||||||
{
|
{
|
||||||
return TexImage2D(level, internalFormat, width, height, border, GL_RGB, GL_UNSIGNED_BYTE, nullptr);
|
return TexImage2D(level, internalFormat, width, height, border, GL_RGB, GL_UNSIGNED_BYTE, nullptr);
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@ namespace Nz
|
||||||
public:
|
public:
|
||||||
inline RenderBufferView(AbstractBuffer* buffer);
|
inline RenderBufferView(AbstractBuffer* buffer);
|
||||||
inline RenderBufferView(AbstractBuffer* buffer, UInt64 offset, UInt64 size);
|
inline RenderBufferView(AbstractBuffer* buffer, UInt64 offset, UInt64 size);
|
||||||
RenderBufferView(const RenderBufferView&) = delete;
|
RenderBufferView(const RenderBufferView&) = default;
|
||||||
RenderBufferView(RenderBufferView&&) = default;
|
RenderBufferView(RenderBufferView&&) = default;
|
||||||
~RenderBufferView() = default;
|
~RenderBufferView() = default;
|
||||||
|
|
||||||
|
|
@ -26,7 +26,7 @@ namespace Nz
|
||||||
inline UInt64 GetOffset() const;
|
inline UInt64 GetOffset() const;
|
||||||
inline UInt64 GetSize() const;
|
inline UInt64 GetSize() const;
|
||||||
|
|
||||||
RenderBufferView& operator=(const RenderBufferView&) = delete;
|
RenderBufferView& operator=(const RenderBufferView&) = default;
|
||||||
RenderBufferView& operator=(RenderBufferView&&) = default;
|
RenderBufferView& operator=(RenderBufferView&&) = default;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
||||||
|
|
@ -41,7 +41,6 @@ namespace Nz
|
||||||
Allocation& operator=(Allocation&&) = default;
|
Allocation& operator=(Allocation&&) = default;
|
||||||
|
|
||||||
void* mappedPtr;
|
void* mappedPtr;
|
||||||
UInt64 offset;
|
|
||||||
UInt64 size;
|
UInt64 size;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@
|
||||||
|
|
||||||
namespace Nz
|
namespace Nz
|
||||||
{
|
{
|
||||||
VkBufferUsageFlags ToVulkan(BufferType bufferType)
|
inline VkBufferUsageFlags ToVulkan(BufferType bufferType)
|
||||||
{
|
{
|
||||||
switch (bufferType)
|
switch (bufferType)
|
||||||
{
|
{
|
||||||
|
|
@ -23,7 +23,7 @@ namespace Nz
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
VkFormat ToVulkan(ComponentType componentType)
|
inline VkFormat ToVulkan(ComponentType componentType)
|
||||||
{
|
{
|
||||||
switch (componentType)
|
switch (componentType)
|
||||||
{
|
{
|
||||||
|
|
@ -47,7 +47,7 @@ namespace Nz
|
||||||
return VK_FORMAT_UNDEFINED;
|
return VK_FORMAT_UNDEFINED;
|
||||||
}
|
}
|
||||||
|
|
||||||
VkCullModeFlagBits ToVulkan(FaceSide faceSide)
|
inline VkCullModeFlagBits ToVulkan(FaceSide faceSide)
|
||||||
{
|
{
|
||||||
switch (faceSide)
|
switch (faceSide)
|
||||||
{
|
{
|
||||||
|
|
@ -74,7 +74,7 @@ namespace Nz
|
||||||
return VK_POLYGON_MODE_FILL;
|
return VK_POLYGON_MODE_FILL;
|
||||||
}
|
}
|
||||||
|
|
||||||
VkPrimitiveTopology ToVulkan(PrimitiveMode primitiveMode)
|
inline VkPrimitiveTopology ToVulkan(PrimitiveMode primitiveMode)
|
||||||
{
|
{
|
||||||
switch (primitiveMode)
|
switch (primitiveMode)
|
||||||
{
|
{
|
||||||
|
|
@ -108,7 +108,7 @@ namespace Nz
|
||||||
return VK_COMPARE_OP_NEVER;
|
return VK_COMPARE_OP_NEVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
VkFilter ToVulkan(SamplerFilter samplerFilter)
|
inline VkFilter ToVulkan(SamplerFilter samplerFilter)
|
||||||
{
|
{
|
||||||
switch (samplerFilter)
|
switch (samplerFilter)
|
||||||
{
|
{
|
||||||
|
|
@ -120,7 +120,7 @@ namespace Nz
|
||||||
return VK_FILTER_NEAREST;
|
return VK_FILTER_NEAREST;
|
||||||
}
|
}
|
||||||
|
|
||||||
VkSamplerMipmapMode ToVulkan(SamplerMipmapMode samplerMipmap)
|
inline VkSamplerMipmapMode ToVulkan(SamplerMipmapMode samplerMipmap)
|
||||||
{
|
{
|
||||||
switch (samplerMipmap)
|
switch (samplerMipmap)
|
||||||
{
|
{
|
||||||
|
|
@ -132,7 +132,7 @@ namespace Nz
|
||||||
return VK_SAMPLER_MIPMAP_MODE_NEAREST;
|
return VK_SAMPLER_MIPMAP_MODE_NEAREST;
|
||||||
}
|
}
|
||||||
|
|
||||||
VkSamplerAddressMode ToVulkan(SamplerWrap samplerWrap)
|
inline VkSamplerAddressMode ToVulkan(SamplerWrap samplerWrap)
|
||||||
{
|
{
|
||||||
switch (samplerWrap)
|
switch (samplerWrap)
|
||||||
{
|
{
|
||||||
|
|
@ -145,7 +145,7 @@ namespace Nz
|
||||||
return VK_SAMPLER_ADDRESS_MODE_REPEAT;
|
return VK_SAMPLER_ADDRESS_MODE_REPEAT;
|
||||||
}
|
}
|
||||||
|
|
||||||
VkDescriptorType ToVulkan(ShaderBindingType bindingType)
|
inline VkDescriptorType ToVulkan(ShaderBindingType bindingType)
|
||||||
{
|
{
|
||||||
switch (bindingType)
|
switch (bindingType)
|
||||||
{
|
{
|
||||||
|
|
@ -157,7 +157,7 @@ namespace Nz
|
||||||
return VK_DESCRIPTOR_TYPE_SAMPLER;
|
return VK_DESCRIPTOR_TYPE_SAMPLER;
|
||||||
}
|
}
|
||||||
|
|
||||||
VkShaderStageFlagBits ToVulkan(ShaderStageType stageType)
|
inline VkShaderStageFlagBits ToVulkan(ShaderStageType stageType)
|
||||||
{
|
{
|
||||||
switch (stageType)
|
switch (stageType)
|
||||||
{
|
{
|
||||||
|
|
@ -169,7 +169,7 @@ namespace Nz
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
VkShaderStageFlags ToVulkan(ShaderStageTypeFlags stageType)
|
inline VkShaderStageFlags ToVulkan(ShaderStageTypeFlags stageType)
|
||||||
{
|
{
|
||||||
VkShaderStageFlags shaderStageBits = 0;
|
VkShaderStageFlags shaderStageBits = 0;
|
||||||
|
|
||||||
|
|
@ -184,7 +184,7 @@ namespace Nz
|
||||||
return shaderStageBits;
|
return shaderStageBits;
|
||||||
}
|
}
|
||||||
|
|
||||||
VkStencilOp ToVulkan(StencilOperation stencilOp)
|
inline VkStencilOp ToVulkan(StencilOperation stencilOp)
|
||||||
{
|
{
|
||||||
switch (stencilOp)
|
switch (stencilOp)
|
||||||
{
|
{
|
||||||
|
|
@ -202,7 +202,7 @@ namespace Nz
|
||||||
return VK_STENCIL_OP_KEEP;
|
return VK_STENCIL_OP_KEEP;
|
||||||
}
|
}
|
||||||
|
|
||||||
VkVertexInputRate ToVulkan(VertexInputRate inputRate)
|
inline VkVertexInputRate ToVulkan(VertexInputRate inputRate)
|
||||||
{
|
{
|
||||||
switch (inputRate)
|
switch (inputRate)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,7 @@ namespace Nz
|
||||||
struct VulkanAllocation : Allocation
|
struct VulkanAllocation : Allocation
|
||||||
{
|
{
|
||||||
VkBuffer buffer;
|
VkBuffer buffer;
|
||||||
|
UInt64 offset;
|
||||||
};
|
};
|
||||||
|
|
||||||
inline VulkanUploadPool(Vk::Device& device, UInt64 blockSize);
|
inline VulkanUploadPool(Vk::Device& device, UInt64 blockSize);
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@
|
||||||
#include <Nazara/OpenGLRenderer/OpenGLDevice.hpp>
|
#include <Nazara/OpenGLRenderer/OpenGLDevice.hpp>
|
||||||
#include <Nazara/Renderer/CommandPool.hpp>
|
#include <Nazara/Renderer/CommandPool.hpp>
|
||||||
#include <Nazara/OpenGLRenderer/OpenGLBuffer.hpp>
|
#include <Nazara/OpenGLRenderer/OpenGLBuffer.hpp>
|
||||||
|
#include <Nazara/OpenGLRenderer/OpenGLRenderPipeline.hpp>
|
||||||
#include <Nazara/OpenGLRenderer/OpenGLRenderPipelineLayout.hpp>
|
#include <Nazara/OpenGLRenderer/OpenGLRenderPipelineLayout.hpp>
|
||||||
#include <Nazara/OpenGLRenderer/OpenGLShaderStage.hpp>
|
#include <Nazara/OpenGLRenderer/OpenGLShaderStage.hpp>
|
||||||
#include <Nazara/OpenGLRenderer/OpenGLTexture.hpp>
|
#include <Nazara/OpenGLRenderer/OpenGLTexture.hpp>
|
||||||
|
|
@ -25,7 +26,10 @@ namespace Nz
|
||||||
m_contexts.insert(m_referenceContext.get());
|
m_contexts.insert(m_referenceContext.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
OpenGLDevice::~OpenGLDevice() = default;
|
OpenGLDevice::~OpenGLDevice()
|
||||||
|
{
|
||||||
|
m_referenceContext.reset();
|
||||||
|
}
|
||||||
|
|
||||||
std::unique_ptr<GL::Context> OpenGLDevice::CreateContext(const GL::ContextParams& params) const
|
std::unique_ptr<GL::Context> OpenGLDevice::CreateContext(const GL::ContextParams& params) const
|
||||||
{
|
{
|
||||||
|
|
@ -55,7 +59,7 @@ namespace Nz
|
||||||
|
|
||||||
std::unique_ptr<RenderPipeline> OpenGLDevice::InstantiateRenderPipeline(RenderPipelineInfo pipelineInfo)
|
std::unique_ptr<RenderPipeline> OpenGLDevice::InstantiateRenderPipeline(RenderPipelineInfo pipelineInfo)
|
||||||
{
|
{
|
||||||
return {};
|
return std::make_unique<OpenGLRenderPipeline>(*this, std::move(pipelineInfo));
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<RenderPipelineLayout> OpenGLDevice::InstantiateRenderPipelineLayout(RenderPipelineLayoutInfo pipelineLayoutInfo)
|
std::shared_ptr<RenderPipelineLayout> OpenGLDevice::InstantiateRenderPipelineLayout(RenderPipelineLayoutInfo pipelineLayoutInfo)
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@
|
||||||
|
|
||||||
#include <Nazara/OpenGLRenderer/OpenGLRenderWindow.hpp>
|
#include <Nazara/OpenGLRenderer/OpenGLRenderWindow.hpp>
|
||||||
#include <Nazara/OpenGLRenderer/DummySurface.hpp>
|
#include <Nazara/OpenGLRenderer/DummySurface.hpp>
|
||||||
|
#include <Nazara/OpenGLRenderer/OpenGLCommandPool.hpp>
|
||||||
#include <Nazara/OpenGLRenderer/OpenGLRenderer.hpp>
|
#include <Nazara/OpenGLRenderer/OpenGLRenderer.hpp>
|
||||||
#include <Nazara/Renderer/CommandPool.hpp>
|
#include <Nazara/Renderer/CommandPool.hpp>
|
||||||
#include <Nazara/OpenGLRenderer/Debug.hpp>
|
#include <Nazara/OpenGLRenderer/Debug.hpp>
|
||||||
|
|
@ -11,7 +12,8 @@
|
||||||
namespace Nz
|
namespace Nz
|
||||||
{
|
{
|
||||||
OpenGLRenderWindow::OpenGLRenderWindow() :
|
OpenGLRenderWindow::OpenGLRenderWindow() :
|
||||||
m_currentFrame(0)
|
m_currentFrame(0),
|
||||||
|
m_framebuffer(*this)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -33,12 +35,18 @@ namespace Nz
|
||||||
if (!m_context)
|
if (!m_context)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
constexpr std::size_t RenderImageCount = 2;
|
||||||
|
|
||||||
|
m_renderImage.reserve(RenderImageCount);
|
||||||
|
for (std::size_t i = 0; i < RenderImageCount; ++i)
|
||||||
|
m_renderImage.emplace_back(*this);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<CommandPool> OpenGLRenderWindow::CreateCommandPool(QueueType queueType)
|
std::unique_ptr<CommandPool> OpenGLRenderWindow::CreateCommandPool(QueueType queueType)
|
||||||
{
|
{
|
||||||
return {};
|
return std::make_unique<OpenGLCommandPool>();
|
||||||
}
|
}
|
||||||
|
|
||||||
const OpenGLFramebuffer& OpenGLRenderWindow::GetFramebuffer() const
|
const OpenGLFramebuffer& OpenGLRenderWindow::GetFramebuffer() const
|
||||||
|
|
|
||||||
|
|
@ -49,6 +49,19 @@ namespace Nz::GL
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Context::BindFramebuffer(FramebufferTarget target, GLuint fbo) const
|
||||||
|
{
|
||||||
|
auto& currentFbo = (target == FramebufferTarget::Draw) ? m_state.boundDrawFBO : m_state.boundReadFBO;
|
||||||
|
if (currentFbo != fbo)
|
||||||
|
{
|
||||||
|
if (!SetCurrentContext(this))
|
||||||
|
throw std::runtime_error("failed to activate context");
|
||||||
|
|
||||||
|
glBindFramebuffer((target == FramebufferTarget::Draw) ? GL_DRAW_FRAMEBUFFER : GL_READ_FRAMEBUFFER, fbo);
|
||||||
|
currentFbo = fbo;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void Context::BindSampler(UInt32 textureUnit, GLuint sampler) const
|
void Context::BindSampler(UInt32 textureUnit, GLuint sampler) const
|
||||||
{
|
{
|
||||||
if (textureUnit >= m_state.textureUnits.size())
|
if (textureUnit >= m_state.textureUnits.size())
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue