OpenGLRenderer: Minor fixes
This commit is contained in:
parent
e7a2573221
commit
7fe60026be
|
|
@ -4,8 +4,8 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#ifndef NAZARA_OPENGLRENDERER_OPENGLWINDOWFRAMEBUFFER_HPP
|
||||
#define NAZARA_OPENGLRENDERER_OPENGLWINDOWFRAMEBUFFER_HPP
|
||||
#ifndef NAZARA_OPENGLRENDERER_OPENGLFBOFRAMEBUFFER_HPP
|
||||
#define NAZARA_OPENGLRENDERER_OPENGLFBOFRAMEBUFFER_HPP
|
||||
|
||||
#include <Nazara/Prerequisites.hpp>
|
||||
#include <Nazara/OpenGLRenderer/OpenGLFramebuffer.hpp>
|
||||
|
|
@ -42,4 +42,4 @@ namespace Nz
|
|||
|
||||
#include <Nazara/OpenGLRenderer/OpenGLFboFramebuffer.hpp>
|
||||
|
||||
#endif // NAZARA_OPENGLRENDERER_OpenGLWindowFramebuffer_HPP
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -13,7 +13,6 @@
|
|||
#include <Nazara/OpenGLRenderer/Wrapper/Framebuffer.hpp>
|
||||
#include <Nazara/OpenGLRenderer/Wrapper/Loader.hpp>
|
||||
#include <Nazara/OpenGLRenderer/Wrapper/Program.hpp>
|
||||
#include <Nazara/OpenGLRenderer/Wrapper/RenderBuffer.hpp>
|
||||
#include <Nazara/OpenGLRenderer/Wrapper/Sampler.hpp>
|
||||
#include <Nazara/OpenGLRenderer/Wrapper/Shader.hpp>
|
||||
#include <Nazara/OpenGLRenderer/Wrapper/Texture.hpp>
|
||||
|
|
|
|||
|
|
@ -34,6 +34,7 @@ typedef void (GL_APIENTRYP PFNGLSPECIALIZESHADERARBPROC) (GLuint shader, const G
|
|||
cb(glBlitFramebuffer, PFNGLBLITFRAMEBUFFERPROC) \
|
||||
cb(glBufferData, PFNGLBUFFERDATAPROC) \
|
||||
cb(glBufferSubData, PFNGLBUFFERSUBDATAPROC) \
|
||||
cb(glCheckFramebufferStatus, PFNGLCHECKFRAMEBUFFERSTATUSPROC) \
|
||||
cb(glClear, PFNGLCLEARPROC) \
|
||||
cb(glClearBufferfi, PFNGLCLEARBUFFERFIPROC) \
|
||||
cb(glClearBufferfv, PFNGLCLEARBUFFERFVPROC) \
|
||||
|
|
@ -41,15 +42,14 @@ typedef void (GL_APIENTRYP PFNGLSPECIALIZESHADERARBPROC) (GLuint shader, const G
|
|||
cb(glClearColor, PFNGLCLEARCOLORPROC) \
|
||||
cb(glClearDepthf, PFNGLCLEARDEPTHFPROC) \
|
||||
cb(glClearStencil, PFNGLCLEARSTENCILPROC) \
|
||||
cb(glCreateProgram, PFNGLCREATEPROGRAMPROC) \
|
||||
cb(glCreateShader, PFNGLCREATESHADERPROC) \
|
||||
cb(glCheckFramebufferStatus, PFNGLCHECKFRAMEBUFFERSTATUSPROC) \
|
||||
cb(glColorMask, PFNGLCOLORMASKPROC) \
|
||||
cb(glCompileShader, PFNGLCOMPILESHADERPROC) \
|
||||
cb(glCompressedTexSubImage2D, PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC) \
|
||||
cb(glCompressedTexSubImage3D, PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC) \
|
||||
cb(glCompileShader, PFNGLCOMPILESHADERPROC) \
|
||||
cb(glCopyBufferSubData, PFNGLCOPYBUFFERSUBDATAPROC) \
|
||||
cb(glCopyTexSubImage2D, PFNGLCOPYTEXSUBIMAGE2DPROC) \
|
||||
cb(glCreateProgram, PFNGLCREATEPROGRAMPROC) \
|
||||
cb(glCreateShader, PFNGLCREATESHADERPROC) \
|
||||
cb(glCullFace, PFNGLCULLFACEPROC) \
|
||||
cb(glDeleteBuffers, PFNGLDELETEBUFFERSPROC) \
|
||||
cb(glDeleteFramebuffers, PFNGLDELETEFRAMEBUFFERSPROC) \
|
||||
|
|
@ -76,14 +76,14 @@ typedef void (GL_APIENTRYP PFNGLSPECIALIZESHADERARBPROC) (GLuint shader, const G
|
|||
cb(glFramebufferRenderbuffer, PFNGLFRAMEBUFFERRENDERBUFFERPROC) \
|
||||
cb(glFramebufferTexture2D, PFNGLFRAMEBUFFERTEXTURE2DPROC) \
|
||||
cb(glFramebufferTextureLayer, PFNGLFRAMEBUFFERTEXTURELAYERPROC) \
|
||||
cb(glGenerateMipmap, PFNGLGENERATEMIPMAPPROC) \
|
||||
cb(glGenBuffers, PFNGLGENBUFFERSPROC) \
|
||||
cb(glGenFramebuffers, PFNGLGENFRAMEBUFFERSPROC) \
|
||||
cb(glGenRenderbuffers, PFNGLGENRENDERBUFFERSPROC) \
|
||||
cb(glGenQueries, PFNGLGENQUERIESPROC) \
|
||||
cb(glGenRenderbuffers, PFNGLGENRENDERBUFFERSPROC) \
|
||||
cb(glGenSamplers, PFNGLGENSAMPLERSPROC) \
|
||||
cb(glGenTextures, PFNGLGENTEXTURESPROC) \
|
||||
cb(glGenVertexArrays, PFNGLGENVERTEXARRAYSPROC) \
|
||||
cb(glGenerateMipmap, PFNGLGENERATEMIPMAPPROC) \
|
||||
cb(glGetActiveUniform, PFNGLGETACTIVEUNIFORMPROC) \
|
||||
cb(glGetBooleanv, PFNGLGETBOOLEANVPROC) \
|
||||
cb(glGetBufferParameteriv, PFNGLGETBUFFERPARAMETERIVPROC) \
|
||||
|
|
@ -91,20 +91,20 @@ typedef void (GL_APIENTRYP PFNGLSPECIALIZESHADERARBPROC) (GLuint shader, const G
|
|||
cb(glGetFloatv, PFNGLGETFLOATVPROC) \
|
||||
cb(glGetIntegerv, PFNGLGETINTEGERVPROC) \
|
||||
cb(glGetProgramBinary, PFNGLGETPROGRAMBINARYPROC) \
|
||||
cb(glGetProgramiv, PFNGLGETPROGRAMIVPROC) \
|
||||
cb(glGetProgramInfoLog, PFNGLGETPROGRAMINFOLOGPROC) \
|
||||
cb(glGetQueryiv, PFNGLGETQUERYIVPROC) \
|
||||
cb(glGetProgramiv, PFNGLGETPROGRAMIVPROC) \
|
||||
cb(glGetQueryObjectuiv, PFNGLGETQUERYOBJECTUIVPROC) \
|
||||
cb(glGetQueryiv, PFNGLGETQUERYIVPROC) \
|
||||
cb(glGetShaderInfoLog, PFNGLGETSHADERINFOLOGPROC) \
|
||||
cb(glGetShaderiv, PFNGLGETSHADERIVPROC) \
|
||||
cb(glGetShaderSource, PFNGLGETSHADERSOURCEPROC) \
|
||||
cb(glGetShaderiv, PFNGLGETSHADERIVPROC) \
|
||||
cb(glGetString, PFNGLGETSTRINGPROC) \
|
||||
cb(glGetStringi, PFNGLGETSTRINGIPROC) \
|
||||
cb(glGetTexParameterfv, PFNGLGETTEXPARAMETERFVPROC) \
|
||||
cb(glGetTexParameteriv, PFNGLGETTEXPARAMETERIVPROC) \
|
||||
cb(glGetUniformLocation, PFNGLGETUNIFORMLOCATIONPROC) \
|
||||
cb(glGetUniformfv, PFNGLGETUNIFORMFVPROC) \
|
||||
cb(glGetUniformiv, PFNGLGETUNIFORMIVPROC) \
|
||||
cb(glGetUniformLocation, PFNGLGETUNIFORMLOCATIONPROC) \
|
||||
cb(glIsEnabled, PFNGLISENABLEDPROC) \
|
||||
cb(glLineWidth, PFNGLLINEWIDTHPROC) \
|
||||
cb(glLinkProgram, PFNGLLINKPROGRAMPROC) \
|
||||
|
|
@ -136,8 +136,8 @@ typedef void (GL_APIENTRYP PFNGLSPECIALIZESHADERARBPROC) (GLuint shader, const G
|
|||
cb(glTexSubImage2D, PFNGLTEXSUBIMAGE2DPROC) \
|
||||
cb(glTexSubImage3D, PFNGLTEXSUBIMAGE3DPROC) \
|
||||
cb(glUniform1f, PFNGLUNIFORM1FPROC) \
|
||||
cb(glUniform1i, PFNGLUNIFORM1IPROC) \
|
||||
cb(glUniform1fv, PFNGLUNIFORM1FVPROC) \
|
||||
cb(glUniform1i, PFNGLUNIFORM1IPROC) \
|
||||
cb(glUniform1iv, PFNGLUNIFORM1IVPROC) \
|
||||
cb(glUniform2fv, PFNGLUNIFORM2FVPROC) \
|
||||
cb(glUniform2iv, PFNGLUNIFORM2IVPROC) \
|
||||
|
|
@ -151,8 +151,8 @@ typedef void (GL_APIENTRYP PFNGLSPECIALIZESHADERARBPROC) (GLuint shader, const G
|
|||
cb(glValidateProgram, PFNGLVALIDATEPROGRAMPROC) \
|
||||
cb(glVertexAttrib4f, PFNGLVERTEXATTRIB4FPROC) \
|
||||
cb(glVertexAttribDivisor, PFNGLVERTEXATTRIBDIVISORPROC) \
|
||||
cb(glVertexAttribPointer, PFNGLVERTEXATTRIBPOINTERPROC) \
|
||||
cb(glVertexAttribIPointer, PFNGLVERTEXATTRIBIPOINTERPROC) \
|
||||
cb(glVertexAttribPointer, PFNGLVERTEXATTRIBPOINTERPROC) \
|
||||
cb(glViewport, PFNGLVIEWPORTPROC) \
|
||||
\
|
||||
extCb(glDebugMessageCallback, PFNGLDEBUGMESSAGECALLBACKPROC) \
|
||||
|
|
|
|||
|
|
@ -1,47 +0,0 @@
|
|||
// Copyright (C) 2020 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine - OpenGL Renderer"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NAZARA_OPENGLRENDERER_VKFENCE_HPP
|
||||
#define NAZARA_OPENGLRENDERER_VKFENCE_HPP
|
||||
|
||||
#include <Nazara/Prerequisites.hpp>
|
||||
#include <Nazara/OpenGLRenderer/Wrapper/DeviceObject.hpp>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
namespace Vk
|
||||
{
|
||||
class Fence : public DeviceObject<Fence, VkFence, VkFenceCreateInfo, VK_OBJECT_TYPE_FENCE>
|
||||
{
|
||||
friend DeviceObject;
|
||||
|
||||
public:
|
||||
Fence() = default;
|
||||
Fence(const Fence&) = delete;
|
||||
Fence(Fence&&) = default;
|
||||
~Fence() = default;
|
||||
|
||||
using DeviceObject::Create;
|
||||
inline bool Create(Device& device, VkFenceCreateFlags flags = 0, const VkAllocationCallbacks* allocator = nullptr);
|
||||
|
||||
inline bool Reset();
|
||||
|
||||
inline bool Wait();
|
||||
inline bool Wait(UInt64 timeout, bool* didTimeout = nullptr);
|
||||
|
||||
Fence& operator=(const Fence&) = delete;
|
||||
Fence& operator=(Fence&&) = delete;
|
||||
|
||||
private:
|
||||
static inline VkResult CreateHelper(Device& device, const VkFenceCreateInfo* createInfo, const VkAllocationCallbacks* allocator, VkFence* handle);
|
||||
static inline void DestroyHelper(Device& device, VkFence handle, const VkAllocationCallbacks* allocator);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
#include <Nazara/OpenGLRenderer/Wrapper/Fence.inl>
|
||||
|
||||
#endif // NAZARA_OPENGLRENDERER_VKFENCE_HPP
|
||||
|
|
@ -1,68 +0,0 @@
|
|||
// Copyright (C) 2020 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine - OpenGL Renderer"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#include <Nazara/OpenGLRenderer/Wrapper/Fence.hpp>
|
||||
#include <Nazara/OpenGLRenderer/Debug.hpp>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
namespace Vk
|
||||
{
|
||||
inline bool Fence::Create(Device& device, VkFenceCreateFlags flags, const VkAllocationCallbacks* allocator)
|
||||
{
|
||||
VkFenceCreateInfo createInfo =
|
||||
{
|
||||
VK_STRUCTURE_TYPE_FENCE_CREATE_INFO,
|
||||
nullptr,
|
||||
flags
|
||||
};
|
||||
|
||||
return Create(device, createInfo, allocator);
|
||||
}
|
||||
|
||||
inline bool Fence::Reset()
|
||||
{
|
||||
m_lastErrorCode = m_device->vkResetFences(*m_device, 1U, &m_handle);
|
||||
if (m_lastErrorCode != VK_SUCCESS)
|
||||
{
|
||||
NazaraError("Failed to reset fence: " + TranslateOpenGLError(m_lastErrorCode));
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
inline bool Fence::Wait()
|
||||
{
|
||||
return Wait(std::numeric_limits<UInt64>::max());
|
||||
}
|
||||
|
||||
inline bool Fence::Wait(UInt64 timeout, bool* didTimeout)
|
||||
{
|
||||
m_lastErrorCode = m_device->vkWaitForFences(*m_device, 1U, &m_handle, VK_TRUE, timeout);
|
||||
if (m_lastErrorCode != VK_SUCCESS && m_lastErrorCode != VK_TIMEOUT)
|
||||
{
|
||||
NazaraError("Failed to wait for fence: " + TranslateOpenGLError(m_lastErrorCode));
|
||||
return false;
|
||||
}
|
||||
|
||||
if (didTimeout)
|
||||
*didTimeout = (m_lastErrorCode == VK_TIMEOUT);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
inline VkResult Fence::CreateHelper(Device& device, const VkFenceCreateInfo* createInfo, const VkAllocationCallbacks* allocator, VkFence* handle)
|
||||
{
|
||||
return device.vkCreateFence(device, createInfo, allocator, handle);
|
||||
}
|
||||
|
||||
inline void Fence::DestroyHelper(Device& device, VkFence handle, const VkAllocationCallbacks* allocator)
|
||||
{
|
||||
return device.vkDestroyFence(device, handle, allocator);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#include <Nazara/OpenGLRenderer/DebugOff.hpp>
|
||||
|
|
@ -71,7 +71,7 @@ namespace Nz
|
|||
if constexpr (std::is_same_v<T, BeginDebugRegionData>)
|
||||
{
|
||||
if (context->glPushDebugGroup)
|
||||
context->glPushDebugGroup(GL_DEBUG_SOURCE_APPLICATION, 0, command.regionName.size(), command.regionName.data());
|
||||
context->glPushDebugGroup(GL_DEBUG_SOURCE_APPLICATION, 0, GLsizei(command.regionName.size()), command.regionName.data());
|
||||
}
|
||||
else if constexpr (std::is_same_v<T, CopyBufferData>)
|
||||
{
|
||||
|
|
@ -143,11 +143,12 @@ namespace Nz
|
|||
|
||||
void OpenGLCommandBuffer::ApplyStates(const GL::Context& context, const DrawStates& states)
|
||||
{
|
||||
states.shaderBindings->Apply(context);
|
||||
states.pipeline->Apply(context);
|
||||
|
||||
states.pipeline->FlipY(states.shouldFlipY);
|
||||
|
||||
states.shaderBindings->Apply(context);
|
||||
|
||||
if (states.scissorRegion)
|
||||
context.SetScissorBox(states.scissorRegion->x, states.scissorRegion->y, states.scissorRegion->width, states.scissorRegion->height);
|
||||
|
||||
|
|
|
|||
|
|
@ -51,10 +51,10 @@ namespace Nz
|
|||
const auto& bindingDesc = layoutInfo.bindings[binding.bindingIndex];
|
||||
|
||||
std::size_t resourceIndex = 0;
|
||||
for (std::size_t i = binding.bindingIndex; i > 0; --i)
|
||||
for (std::size_t j = binding.bindingIndex; j > 0; --j)
|
||||
{
|
||||
// Use i-1 to prevent underflow in for loop
|
||||
if (layoutInfo.bindings[i - 1].type == bindingDesc.type)
|
||||
// Use j-1 to prevent underflow in for loop
|
||||
if (layoutInfo.bindings[j - 1].type == bindingDesc.type)
|
||||
resourceIndex++;
|
||||
}
|
||||
|
||||
|
|
@ -99,7 +99,7 @@ namespace Nz
|
|||
const UniformBufferBinding& uboBinding = std::get<UniformBufferBinding>(binding.content);
|
||||
|
||||
auto& uboDescriptor = m_owner.GetUniformBufferDescriptor(m_poolIndex, m_bindingIndex, resourceIndex);
|
||||
uboDescriptor.bindingIndex = binding.bindingIndex;
|
||||
uboDescriptor.bindingIndex = static_cast<UInt32>(binding.bindingIndex);
|
||||
uboDescriptor.offset = uboBinding.offset;
|
||||
uboDescriptor.size = uboBinding.range;
|
||||
|
||||
|
|
|
|||
|
|
@ -125,7 +125,7 @@ namespace Nz
|
|||
|
||||
std::string code = writer.Generate(shaderStage, shaderAst, states);
|
||||
|
||||
shader.SetSource(code.data(), code.size());
|
||||
shader.SetSource(code.data(), GLint(code.size()));
|
||||
shader.Compile();
|
||||
|
||||
CheckCompilationStatus(shader);
|
||||
|
|
|
|||
|
|
@ -214,6 +214,9 @@ namespace Nz::GL
|
|||
unit.buffer = buffer;
|
||||
unit.offset = offset;
|
||||
unit.size = size;
|
||||
|
||||
// glBindBufferRange does replace the currently bound buffer
|
||||
m_state.bufferTargets[UnderlyingCast(BufferTarget::Uniform)] = buffer;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue