diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index 1f5b7f1ce..0d863512c 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -27,6 +27,8 @@ jobs: - name: Add MSBuild to PATH uses: microsoft/setup-msbuild@v3 + with: + msbuild-architecture: x64 - name: Generate premake5 solution working-directory: ${{env.SOLUTION_FILE_PATH}} @@ -34,4 +36,4 @@ jobs: - name: Build working-directory: ${{env.GITHUB_WORKSPACE}} - run: msbuild /m /p:Configuration=${{ matrix.configuration }} ${{env.SOLUTION_FILE_PATH}} /p:Platform=x64 + run: msbuild /m /p:Configuration=${{ matrix.configuration }} ${{env.SOLUTION_FILE_PATH}} /p:Platform=x64 /p:PreferredToolArchitecture=x64 diff --git a/.github/workflows/windows_release.yml b/.github/workflows/windows_release.yml index 9f4d27cbb..225c6ab9c 100644 --- a/.github/workflows/windows_release.yml +++ b/.github/workflows/windows_release.yml @@ -16,6 +16,8 @@ jobs: - name: Add MSBuild to PATH uses: microsoft/setup-msbuild@v3 + with: + msbuild-architecture: x64 - name: Make Release Build run: .\Scripts\Windows\MakeReleaseBuild.bat --no-open diff --git a/Dependencies/baregl/LICENSE b/Dependencies/baregl/LICENSE new file mode 100644 index 000000000..69e1154d2 --- /dev/null +++ b/Dependencies/baregl/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2025 Adrien Givry. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/Dependencies/baregl/include/baregl/BareGL.h b/Dependencies/baregl/include/baregl/BareGL.h new file mode 100644 index 000000000..6200a9a7d --- /dev/null +++ b/Dependencies/baregl/include/baregl/BareGL.h @@ -0,0 +1,22 @@ +/** +* @project: baregl +* @author: Adrien Givry +* @licence: MIT +*/ + +#pragma once + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + diff --git a/Dependencies/baregl/include/baregl/Buffer.h b/Dependencies/baregl/include/baregl/Buffer.h new file mode 100644 index 000000000..e282c49e8 --- /dev/null +++ b/Dependencies/baregl/include/baregl/Buffer.h @@ -0,0 +1,84 @@ +/** +* @project: baregl +* @author: Adrien Givry +* @licence: MIT +*/ + +#pragma once + +#include +#include +#include +#include + +#include + +namespace baregl +{ + /** + * Represents a buffer, used to store data on the GPU + */ + class Buffer final : public detail::NativeObject + { + public: + /** + * Creates a buffer + */ + Buffer(); + + /** + * Destroys the buffer + */ + ~Buffer(); + + /** + * Allocates memory for the buffer + * @param p_size + * @param p_usage + * @return The size of the allocated memory in bytes + */ + uint64_t Allocate(uint64_t p_size, types::EAccessSpecifier p_usage = types::EAccessSpecifier::STATIC_DRAW); + + /** + * Uploads data to the buffer + * @param p_data + * @param p_range + */ + void Upload(const void* p_data, std::optional p_range = std::nullopt); + + /** + * Returns true if the buffer is valid (properly allocated) + */ + bool IsValid() const; + + /** + * Returns true if the buffer is empty + */ + bool IsEmpty() const; + + /** + * Returns the size of the allocated buffer in bytes + */ + uint64_t GetSize() const; + + /** + * Binds the buffer + * @param p_type Type of the buffer to bind + * @param p_index (Optional) Index to bind the buffer to + */ + void Bind( + types::EBufferType p_type, + std::optional p_index = std::nullopt + ); + + /** + * Unbinds the buffer + */ + void Unbind(); + + protected: + uint64_t m_allocatedBytes = 0; + std::optional m_boundAs = std::nullopt; + std::optional m_bindIndex = std::nullopt; + }; +} diff --git a/Sources/OvRendering/include/OvRendering/HAL/Common/TBackend.h b/Dependencies/baregl/include/baregl/Context.h similarity index 63% rename from Sources/OvRendering/include/OvRendering/HAL/Common/TBackend.h rename to Dependencies/baregl/include/baregl/Context.h index 1a3e5cd28..588493335 100644 --- a/Sources/OvRendering/include/OvRendering/HAL/Common/TBackend.h +++ b/Dependencies/baregl/include/baregl/Context.h @@ -1,50 +1,46 @@ /** -* @project: Overload -* @author: Overload Tech. +* @project: baregl +* @author: Adrien Givry * @licence: MIT */ #pragma once -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -namespace OvRendering::HAL +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +namespace baregl { /** - * Backend class that wraps the selected graphics API's context. + * High-level interface for interacting with the OpenGL context. */ - template - class TBackend final + class Context final { public: /** - * Initializes the backend. - * @param debug Indicates whether to enable debug mode. - * @return An optional pipeline state. + * Initializes the OpenGL context. + * @param p_desc Settings to use when creating the context */ - std::optional Init(bool p_debug); + Context(const baregl::data::ContextDesc& p_desc = {}); /** - * Notifies the backend that a frame is about to be rendered. + * Destructor for the OpenGL context. */ - void OnFrameStarted(); - - /** - * Notifies the backend that the current frame is finished. - * This can be used for synchronization purposes, profiling, etc. - */ - void OnFrameCompleted(); + ~Context(); /** * Clears the specified buffers. @@ -69,8 +65,8 @@ namespace OvRendering::HAL uint32_t p_y, uint32_t p_width, uint32_t p_height, - Settings::EPixelDataFormat p_format, - Settings::EPixelDataType p_type, + types::EPixelDataFormat p_format, + types::EPixelDataType p_type, void* p_data ); @@ -79,7 +75,7 @@ namespace OvRendering::HAL * @param p_primitiveMode Specifies the kind of primitives to render. * @param p_indexCount The number of elements to render. */ - void DrawElements(Settings::EPrimitiveMode p_primitiveMode, uint32_t p_indexCount); + void DrawElements(types::EPrimitiveMode p_primitiveMode, uint32_t p_indexCount); /** * Renders multiple instances of a set of elements. @@ -87,14 +83,14 @@ namespace OvRendering::HAL * @param p_indexCount The number of elements to render. * @param p_instances The number of instances to render. */ - void DrawElementsInstanced(Settings::EPrimitiveMode p_primitiveMode, uint32_t p_indexCount, uint32_t p_instances); + void DrawElementsInstanced(types::EPrimitiveMode p_primitiveMode, uint32_t p_indexCount, uint32_t p_instances); /** * Renders primitives from array data without indexing. * @param p_primitiveMode Specifies the kind of primitives to render. * @param p_vertexCount The number of vertices to render. */ - void DrawArrays(Settings::EPrimitiveMode p_primitiveMode, uint32_t p_vertexCount); + void DrawArrays(types::EPrimitiveMode p_primitiveMode, uint32_t p_vertexCount); /** * Renders multiple instances of a set of vertices. @@ -102,7 +98,23 @@ namespace OvRendering::HAL * @param p_vertexCount The number of vertices to render. * @param p_instances The number of instances to render. */ - void DrawArraysInstanced(Settings::EPrimitiveMode p_primitiveMode, uint32_t p_vertexCount, uint32_t p_instances); + void DrawArraysInstanced(types::EPrimitiveMode p_primitiveMode, uint32_t p_vertexCount, uint32_t p_instances); + + /** + * Dispatches the current active program for execution. + * @note only applicable for compute shaders. + * @param p_x Number of groups in the X dimension + * @param p_y Number of groups in the Y dimension + * @param p_z Number of groups in the Z dimension + */ + void DispatchCompute(uint32_t p_x, uint32_t p_y, uint32_t p_z) const; + + /** + * Defines a barrier ordering the memory transactions issued prior to the command + * relative to those issued after the barrier. + * @param p_barriers + */ + void MemoryBarrier(types::EMemoryBarrierFlags p_barriers) const; /** * Sets the clear color for the color buffer. @@ -123,21 +135,21 @@ namespace OvRendering::HAL * Specifies the rasterization mode. * @param p_rasterizationMode The desired rasterization mode. */ - void SetRasterizationMode(Settings::ERasterizationMode p_rasterizationMode); + void SetRasterizationMode(types::ERasterizationMode p_rasterizationMode); /** * Enables or disables a specific rendering capability. * @param p_capability The rendering capability to modify. * @param p_value True to enable, false to disable. */ - void SetCapability(Settings::ERenderingCapability p_capability, bool p_value); + void SetCapability(types::ERenderingCapability p_capability, bool p_value); /** * Retrieves the status of a rendering capability. * @param p_capability The rendering capability to query. * @return True if enabled, false otherwise. */ - bool GetCapability(Settings::ERenderingCapability p_capability); + bool GetCapability(types::ERenderingCapability p_capability); /** * Sets the stencil test function and reference value. @@ -145,13 +157,13 @@ namespace OvRendering::HAL * @param p_reference The reference value for the stencil test. * @param p_mask A mask that is ANDed with both the reference value and the stored stencil value. */ - void SetStencilAlgorithm(OvRendering::Settings::EComparaisonAlgorithm p_algorithm, int32_t p_reference, uint32_t p_mask); + void SetStencilAlgorithm(baregl::types::EComparaisonAlgorithm p_algorithm, int32_t p_reference, uint32_t p_mask); /** * Sets the depth comparison function. * @param p_algorithm The depth comparison function to use. */ - void SetDepthAlgorithm(OvRendering::Settings::EComparaisonAlgorithm p_algorithm); + void SetDepthAlgorithm(baregl::types::EComparaisonAlgorithm p_algorithm); /** * Controls the writing of individual bits in the stencil planes. @@ -166,9 +178,9 @@ namespace OvRendering::HAL * @param p_bothPass Action to take when both the stencil test and depth test pass. */ void SetStencilOperations( - Settings::EOperation p_stencilFail, - Settings::EOperation p_depthFail, - Settings::EOperation p_bothPass + types::EOperation p_stencilFail, + types::EOperation p_depthFail, + types::EOperation p_bothPass ); /** @@ -177,8 +189,8 @@ namespace OvRendering::HAL * @param p_destinationFactor The destination blending factor. */ void SetBlendingFunction( - Settings::EBlendingFactor p_sourceFactor, - Settings::EBlendingFactor p_destinationFactor + types::EBlendingFactor p_sourceFactor, + types::EBlendingFactor p_destinationFactor ); /** @@ -186,14 +198,14 @@ namespace OvRendering::HAL * @param p_equation The blending equation to use. */ void SetBlendingEquation( - Settings::EBlendingEquation p_equation + types::EBlendingEquation p_equation ); /** * Specifies whether front- or back-facing facets can be culled. * @param p_cullFace Specifies the faces to cull. */ - void SetCullFace(Settings::ECullFace p_cullFace); + void SetCullFace(types::ECullFace p_cullFace); /** * Enables or disables writing into the depth buffer. @@ -220,30 +232,20 @@ namespace OvRendering::HAL void SetViewport(uint32_t p_x, uint32_t p_y, uint32_t p_width, uint32_t p_height); /** - * Retrieves the name of the graphics vendor. - * @return A string containing the vendor name. - */ - std::string GetVendor(); - - /** - * Retrieves the name of the graphics hardware. - * @return A string containing the hardware name. + * Returns the value or values for a given parameter + * @return Query result */ - std::string GetHardware(); + template + requires (data::GetResult::non_indexed) + data::GetResultType Get(); /** - * Retrieves the version of the graphics API in use. - * @return A string containing the API version. + * Returns the value or values for a given parameter at a given index + * @param p_index + * @return Query result */ - std::string GetVersion(); - - /** - * Retrieves the version of the shading language. - * @return A string containing the shading language version. - */ - std::string GetShadingLanguageVersion(); - - private: - Context m_context; + template + requires (data::GetResult::indexed) + data::GetResultType Get(uint32_t p_index); }; } diff --git a/Sources/OvRendering/include/OvRendering/HAL/Common/TFramebuffer.h b/Dependencies/baregl/include/baregl/Framebuffer.h similarity index 59% rename from Sources/OvRendering/include/OvRendering/HAL/Common/TFramebuffer.h rename to Dependencies/baregl/include/baregl/Framebuffer.h index 5130efe3d..231aed62c 100644 --- a/Sources/OvRendering/include/OvRendering/HAL/Common/TFramebuffer.h +++ b/Dependencies/baregl/include/baregl/Framebuffer.h @@ -1,63 +1,57 @@ /** -* @project: Overload -* @author: Overload Tech. +* @project: baregl +* @author: Adrien Givry * @licence: MIT */ #pragma once +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include #include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -namespace OvRendering::HAL +namespace baregl { - template - using TFramebufferAttachment = std::variant< - std::shared_ptr>, - std::shared_ptr> + using FramebufferAttachment = std::variant< + std::shared_ptr, + std::shared_ptr >; /** - * Represents a framebuffer, used to store render data for the graphics backend to use. + * Represents a framebuffer, used to store render data for the graphics context to use. */ - template - class TFramebuffer + class Framebuffer final : public detail::NativeObject { public: - using Attachment = TFramebufferAttachment; - template static constexpr bool IsSupportedAttachmentType = - std::same_as> || - std::same_as>; + std::same_as || + std::same_as; /** * Creates a framebuffer. * @param p_debugName A name used to identify the framebuffer for debugging purposes */ - TFramebuffer(std::string_view p_debugName = std::string_view{}); + Framebuffer(std::string_view p_debugName = std::string_view{}); /** * Destroys the framebuffer. */ - ~TFramebuffer(); + ~Framebuffer(); /** * Binds the framebuffer. @@ -98,7 +92,7 @@ namespace OvRendering::HAL template requires IsSupportedAttachmentType void Attach(std::shared_ptr p_toAttach, - Settings::EFramebufferAttachment p_attachment, + types::EFramebufferAttachment p_attachment, uint32_t p_index = 0, std::optional p_layer = std::nullopt ); @@ -110,8 +104,8 @@ namespace OvRendering::HAL */ template requires IsSupportedAttachmentType - OvTools::Utils::OptRef GetAttachment( - OvRendering::Settings::EFramebufferAttachment p_attachment, + std::optional> GetAttachment( + baregl::types::EFramebufferAttachment p_attachment, uint32_t p_index = 0 ) const; @@ -128,17 +122,11 @@ namespace OvRendering::HAL void SetTargetReadBuffer(std::optional p_index); /** - * Returns the ID the buffer. - */ - uint32_t GetID() const; - - /** - * Returns the size of the given attachment. + * Returns the size of the framebuffer * @param p_attachment + * @param p_index */ - std::pair GetSize( - Settings::EFramebufferAttachment p_attachment = Settings::EFramebufferAttachment::COLOR - ) const; + std::pair GetSize() const; /** * Blits the framebuffer to the back buffer. @@ -162,8 +150,8 @@ namespace OvRendering::HAL uint32_t p_y, uint32_t p_width, uint32_t p_height, - Settings::EPixelDataFormat p_format, - Settings::EPixelDataType p_type, + types::EPixelDataFormat p_format, + types::EPixelDataType p_type, void* p_data ) const; @@ -173,6 +161,8 @@ namespace OvRendering::HAL const std::string& GetDebugName() const; protected: - FramebufferContext m_context; + bool m_valid = false; + std::string m_debugName; + std::unordered_map m_attachments; }; } diff --git a/Sources/OvRendering/include/OvRendering/HAL/Common/TRenderbuffer.h b/Dependencies/baregl/include/baregl/Renderbuffer.h similarity index 61% rename from Sources/OvRendering/include/OvRendering/HAL/Common/TRenderbuffer.h rename to Dependencies/baregl/include/baregl/Renderbuffer.h index 7ade61d44..ebb4860cb 100644 --- a/Sources/OvRendering/include/OvRendering/HAL/Common/TRenderbuffer.h +++ b/Dependencies/baregl/include/baregl/Renderbuffer.h @@ -1,32 +1,31 @@ /** -* @project: Overload -* @author: Overload Tech. +* @project: baregl +* @author: Adrien Givry * @licence: MIT */ #pragma once -#include -#include +#include +#include -namespace OvRendering::HAL +namespace baregl { /** - * Represents a renderbuffer, used to store render data for the graphics backend to use. + * Represents a renderbuffer, used to store render data for the graphics context to use. */ - template - class TRenderbuffer final + class Renderbuffer final : public detail::NativeObject { public: /** * Create the render buffer */ - TRenderbuffer(); + Renderbuffer(); /** * Destructor */ - ~TRenderbuffer(); + ~Renderbuffer(); /** * Bind the framebuffer @@ -38,18 +37,13 @@ namespace OvRendering::HAL */ void Unbind() const; - /** - * Returns the ID of the render buffer object - */ - uint32_t GetID() const; - /** * Uploads the buffer configuration to the GPU * @param p_width * @param p_height * @param p_format */ - void Allocate(uint16_t p_width, uint16_t p_height, Settings::EInternalFormat p_format); + void Allocate(uint16_t p_width, uint16_t p_height, types::EInternalFormat p_format); /** * Returns true if the render buffer has been properly allocated @@ -74,6 +68,9 @@ namespace OvRendering::HAL uint16_t GetHeight() const; private: - Context m_context; + uint16_t m_width = 0; + uint16_t m_height = 0; + types::EInternalFormat m_format = types::EInternalFormat::RGBA; + bool m_allocated = false; }; } diff --git a/Sources/OvRendering/include/OvRendering/HAL/Common/TShaderProgram.h b/Dependencies/baregl/include/baregl/ShaderProgram.h similarity index 50% rename from Sources/OvRendering/include/OvRendering/HAL/Common/TShaderProgram.h rename to Dependencies/baregl/include/baregl/ShaderProgram.h index a734ddef4..366c2511c 100644 --- a/Sources/OvRendering/include/OvRendering/HAL/Common/TShaderProgram.h +++ b/Dependencies/baregl/include/baregl/ShaderProgram.h @@ -1,66 +1,65 @@ /** -* @project: Overload -* @author: Overload Tech. +* @project: baregl +* @author: Adrien Givry * @licence: MIT */ #pragma once +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include #include +#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -#include - -namespace OvRendering::HAL +namespace baregl { template concept SupportedUniformType = std::same_as || std::same_as || - std::same_as || - std::same_as || - std::same_as || - std::same_as || - std::same_as; + std::same_as || + std::same_as || + std::same_as || + std::same_as || + std::same_as || + std::same_as; /** * Represents a shader program, used to link shader stages together. */ - template - class TShaderProgram final + class ShaderProgram final : public detail::NativeObject { public: /** * Creates a shader program. */ - TShaderProgram(); + ShaderProgram(); /** * Destroys a shader program. */ - ~TShaderProgram(); + ~ShaderProgram(); /** * Attaches a shader stage to the program. * @param p_shader */ - void Attach(const TShaderStage& p_shader); + void Attach(const ShaderStage& p_shader); /** * Detaches a shader stage to the program. * @param p_shader */ - void Detach(const TShaderStage& p_shader); + void Detach(const ShaderStage& p_shader); /** * Detaches all shader stages from the program. @@ -71,7 +70,7 @@ namespace OvRendering::HAL * Links the shader stages together. * @return The linking result */ - Settings::ShaderLinkingResult Link(); + baregl::data::ShaderLinkingResult Link(); /** * Binds the program. @@ -83,13 +82,9 @@ namespace OvRendering::HAL */ void Unbind() const; - /** - * Returns the ID of the program. - */ - uint32_t GetID() const; - /** * Sends a uniform value associated with the given name to the GPU. + * @note The shader program must be bound before calling SetUniform * @param p_name * @param p_value */ @@ -98,6 +93,7 @@ namespace OvRendering::HAL /** * Returns the value of a uniform associated with the given name. + * @note The shader program must be bound before calling GetUniform * @param p_name * @param p_value */ @@ -108,19 +104,19 @@ namespace OvRendering::HAL * Returns information about the uniform identified by the given name or std::nullopt if not found. * @param p_name */ - OvTools::Utils::OptRef GetUniformInfo(const std::string& p_name) const; - - /** - * Queries the uniforms from the program and caches them in memory. - */ - void QueryUniforms(); + std::optional> GetUniformInfo(const std::string& p_name) const; /** * Returns the uniforms associated with this program. */ - const std::unordered_map& GetUniforms() const; + const std::unordered_map& GetUniforms() const; + + private: + void QueryUniforms(); private: - ProgramContext m_context; + std::unordered_map m_uniforms; + std::unordered_map m_uniformsLocationCache; + std::vector> m_attachedShaders; }; } diff --git a/Dependencies/baregl/include/baregl/ShaderStage.h b/Dependencies/baregl/include/baregl/ShaderStage.h new file mode 100644 index 000000000..dd76efecd --- /dev/null +++ b/Dependencies/baregl/include/baregl/ShaderStage.h @@ -0,0 +1,53 @@ +/** +* @project: baregl +* @author: Adrien Givry +* @licence: MIT +*/ + +#pragma once + +#include +#include +#include + +namespace baregl +{ + /** + * Represents a part of a shader program that is responsible for a specific stage (vertex, fragment, geometry, etc.). + */ + class ShaderStage final : public detail::NativeObject + { + public: + /** + * Creates a shader stage of the given type. + * @param p_type + */ + ShaderStage(types::EShaderType p_type); + + /** + * Destructor of the shader stage. + */ + ~ShaderStage(); + + /** + * Uploads the shader source to the graphics context memory. + * @param p_source + */ + void Upload(const std::string& p_source) const; + + /** + * Compiles the uploaded shader source. + * @note Use this method after uploading the shader source. + * @return The compilation result. + */ + data::ShaderCompilationResult Compile() const; + + /** + * Returns the type of shader stage. + */ + types::EShaderType GetType() const; + + private: + types::EShaderType m_type; + }; +} diff --git a/Dependencies/baregl/include/baregl/Texture.h b/Dependencies/baregl/include/baregl/Texture.h new file mode 100644 index 000000000..280a0c11e --- /dev/null +++ b/Dependencies/baregl/include/baregl/Texture.h @@ -0,0 +1,123 @@ +/** +* @project: baregl +* @author: Adrien Givry +* @licence: MIT +*/ + +#pragma once + +#include +#include +#include +#include +#include +#include + +#include +#include + +namespace baregl +{ + /** + * Represents a texture, used to store image data for the graphics context to use. + */ + class Texture final : public detail::NativeObject + { + public: + /** + * Creates a texture. + * @param p_type The type of the texture (2D, Cube, etc.) + * @param p_debugName A name used to identify the texture for debugging purposes + */ + Texture(types::ETextureType p_type, std::string_view p_debugName = std::string_view{}); + + /** + * Destroys the texture. + */ + ~Texture(); + + /** + * Binds the texture to the given slot. + * @param p_slot Optional slot to bind the texture to. + */ + void Bind(std::optional p_slot = std::nullopt) const; + + /** + * Binds the texture to the given slot as an image texture. + * @param p_slot Slot to bind the texture to. + * @param p_access The level of access the shader has to the image. + * @param p_format The format that the shader will treat the image as. + * @param p_level Mipmap level of the texture that will be bound. + * @param p_layer Optional layer of the texture to bind. + */ + void Bind(uint32_t p_slot, types::EImageAccessSpecifier p_access, types::EInternalFormat p_format, uint32_t p_level = 0, std::optional p_layer = std::nullopt) const; + + /** + * Unbinds the texture. + */ + void Unbind() const; + + /** + * Returns the texture type. + */ + types::ETextureType GetType() const; + + /** + * Allocates memory for the texture. + * @param p_desc + */ + void Allocate(const data::TextureDesc& p_desc); + + /** + * Returns true if the texture has been properly allocated. + */ + bool IsValid() const; + + /** + * Returns true if the texture is mutable. + */ + bool IsMutable() const; + + /** + * Uploads data to the texture. + * @param p_data Pointer to the data to upload. + * @param p_format Format of the data. + * @param p_type Type of the pixel data. + */ + void Upload(const void* p_data, types::EFormat p_format, types::EPixelDataType p_type); + + /** + * Resizes the texture. + * @param p_width + * @param p_height + */ + void Resize(uint32_t p_width, uint32_t p_height); + + /** + * Returns the texture descriptor structure. + */ + const data::TextureDesc& GetDesc() const; + + /** + * Generates mipmaps for the texture. + */ + void GenerateMipmaps() const; + + /** + * Sets the border color for the texture. + * @param p_color + */ + void SetBorderColor(const math::Vec4& p_color); + + /** + * Returns the debug name of the texture. + */ + const std::string& GetDebugName() const; + + private: + const uint32_t m_type; + data::TextureDesc m_desc; + bool m_allocated = false; + std::string m_debugName; + }; +} diff --git a/Dependencies/baregl/include/baregl/VertexArray.h b/Dependencies/baregl/include/baregl/VertexArray.h new file mode 100644 index 000000000..43939b375 --- /dev/null +++ b/Dependencies/baregl/include/baregl/VertexArray.h @@ -0,0 +1,67 @@ +/** +* @project: baregl +* @author: Adrien Givry +* @licence: MIT +*/ + +#pragma once + +#include +#include +#include +#include + +namespace baregl +{ + /** + * Represents a vertex array, used to describe a vertex layout to the graphics context. + */ + class VertexArray final : public detail::NativeObject + { + public: + /** + * Creates the vertex array. + */ + VertexArray(); + + /** + * Destroys the vertex array. + */ + ~VertexArray(); + + /** + * Returns true if the vertex array is valid (non-empty layout). + */ + bool IsValid() const; + + /** + * Sets the vertex attribute layout. + * @param p_attributes + * @param p_vertexBuffer + * @param p_indexBuffer + */ + void SetLayout( + data::VertexAttributeLayout p_attributes, + Buffer& p_vertexBuffer, + Buffer& p_indexBuffer + ); + + /** + * Resets the vertex attribute layout. + */ + void ResetLayout(); + + /** + * Binds the vertex array. + */ + void Bind() const; + + /** + * Unbinds the vertex array. + */ + void Unbind() const; + + private: + uint32_t m_attributeCount = 0; + }; +} diff --git a/Dependencies/baregl/include/baregl/data/BufferMemoryRange.h b/Dependencies/baregl/include/baregl/data/BufferMemoryRange.h new file mode 100644 index 000000000..7d9962d98 --- /dev/null +++ b/Dependencies/baregl/include/baregl/data/BufferMemoryRange.h @@ -0,0 +1,21 @@ +/** +* @project: baregl +* @author: Adrien Givry +* @licence: MIT +*/ + +#pragma once + +#include + +namespace baregl::data +{ + /** + * Struct representing a range of memory in a buffer. + */ + struct BufferMemoryRange + { + uint64_t offset; + uint64_t size; + }; +} diff --git a/Dependencies/baregl/include/baregl/data/ContextDesc.h b/Dependencies/baregl/include/baregl/data/ContextDesc.h new file mode 100644 index 000000000..31fb51768 --- /dev/null +++ b/Dependencies/baregl/include/baregl/data/ContextDesc.h @@ -0,0 +1,19 @@ +/** +* @project: baregl +* @author: Adrien Givry +* @licence: MIT +*/ + +#pragma once + +namespace baregl::data +{ + /** + * Struct that holds settings used when creating an OpenGL context + */ + struct ContextDesc + { + bool debug = false; + }; +} + diff --git a/Dependencies/baregl/include/baregl/data/GetResult.h b/Dependencies/baregl/include/baregl/data/GetResult.h new file mode 100644 index 000000000..bbebc9f51 --- /dev/null +++ b/Dependencies/baregl/include/baregl/data/GetResult.h @@ -0,0 +1,100 @@ +/** + * @project: baregl + * @author: Adrien Givry + * @licence: MIT + */ + +#pragma once + +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace baregl::data +{ + template struct GetResult; + + enum class EGetIndexing + { + INDEXED, + NOT_INDEXED, + BOTH + }; + + template + struct FixedCount + { + static constexpr bool dynamic = false; + static constexpr std::size_t value = N; + }; + + template + struct DynamicCount + { + static constexpr bool dynamic = true; + static constexpr types::EGetParameter parameter = P; + }; + + template + struct CountSpecTraits; + + template + struct CountSpecTraits> + { + static constexpr bool dynamic = false; + static constexpr std::size_t count = N; + static constexpr types::EGetParameter dynamic_count_parameter = types::EGetParameter::PATCH_VERTICES; + }; + + template + struct CountSpecTraits> + { + static constexpr bool dynamic = true; + static constexpr std::size_t count = 0; + static constexpr types::EGetParameter dynamic_count_parameter = P; + }; + + #define DECLARE_GET_RESULT(PARAM, GET_TYPE, COUNT_SPEC, INDEXING, ...) \ + template <> struct GetResult { \ + using count_spec = COUNT_SPEC; \ + using count_traits = CountSpecTraits; \ + using value_type = __VA_ARGS__; \ + using type = std::conditional_t, value_type>; \ + using get_type = GET_TYPE; \ + static constexpr std::size_t count = count_traits::count; \ + static constexpr EGetIndexing indexing = EGetIndexing::INDEXING; \ + static constexpr bool non_indexed = indexing != EGetIndexing::INDEXED; \ + static constexpr bool indexed = indexing != EGetIndexing::NOT_INDEXED; \ + static constexpr bool dynamic_count = count_traits::dynamic; \ + static constexpr types::EGetParameter dynamic_count_parameter = count_traits::dynamic_count_parameter; \ + }; + + BAREGL_GET_RESULTS(DECLARE_GET_RESULT) + + #undef DECLARE_GET_RESULT + + template + using GetResultType = typename GetResult

::type; +} diff --git a/Dependencies/baregl/include/baregl/data/GetResultList.h b/Dependencies/baregl/include/baregl/data/GetResultList.h new file mode 100644 index 000000000..21912d8b0 --- /dev/null +++ b/Dependencies/baregl/include/baregl/data/GetResultList.h @@ -0,0 +1,381 @@ +/** + * @project: baregl + * @author: Adrien Givry + * @licence: MIT + */ + +#pragma once + +#define BAREGL_GET_RESULTS(X) \ + X(PATCH_VERTICES, int, baregl::data::FixedCount<1>, NOT_INDEXED, int) \ + X(PATCH_DEFAULT_OUTER_LEVEL, float, baregl::data::FixedCount<4>, NOT_INDEXED, std::array) \ + X(PATCH_DEFAULT_INNER_LEVEL, float, baregl::data::FixedCount<2>, NOT_INDEXED, std::array) \ + X(ELEMENT_ARRAY_BUFFER_BINDING, int, baregl::data::FixedCount<1>, NOT_INDEXED, uint32_t) \ + X(VERTEX_BINDING_OFFSET, int64_t, baregl::data::FixedCount<1>, BOTH, std::intptr_t) \ + X(VERTEX_BINDING_STRIDE, int, baregl::data::FixedCount<1>, BOTH, int) \ + X(VERTEX_BINDING_DIVISOR, int, baregl::data::FixedCount<1>, BOTH, int) \ + X(VERTEX_BINDING_BUFFER, int, baregl::data::FixedCount<1>, BOTH, uint32_t) \ + X(ARRAY_BUFFER_BINDING, int, baregl::data::FixedCount<1>, NOT_INDEXED, uint32_t) \ + X(DRAW_INDIRECT_BUFFER_BINDING, int, baregl::data::FixedCount<1>, NOT_INDEXED, int) \ + X(VERTEX_ARRAY_BINDING, int, baregl::data::FixedCount<1>, NOT_INDEXED, uint32_t) \ + X(PRIMITIVE_RESTART, bool, baregl::data::FixedCount<1>, NOT_INDEXED, bool) \ + X(PRIMITIVE_RESTART_FIXED_INDEX, bool, baregl::data::FixedCount<1>, NOT_INDEXED, bool) \ + X(PRIMITIVE_RESTART_INDEX, int, baregl::data::FixedCount<1>, NOT_INDEXED, int) \ + X(VIEWPORT, int, baregl::data::FixedCount<4>, BOTH, std::array) \ + X(DEPTH_RANGE, double, baregl::data::FixedCount<2>, NOT_INDEXED, std::array) \ + X(CLIP_DISTANCE0, bool, baregl::data::FixedCount<1>, NOT_INDEXED, bool) \ + X(CLIP_DISTANCE1, bool, baregl::data::FixedCount<1>, NOT_INDEXED, bool) \ + X(CLIP_DISTANCE2, bool, baregl::data::FixedCount<1>, NOT_INDEXED, bool) \ + X(CLIP_DISTANCE3, bool, baregl::data::FixedCount<1>, NOT_INDEXED, bool) \ + X(CLIP_DISTANCE4, bool, baregl::data::FixedCount<1>, NOT_INDEXED, bool) \ + X(CLIP_DISTANCE5, bool, baregl::data::FixedCount<1>, NOT_INDEXED, bool) \ + X(CLIP_DISTANCE6, bool, baregl::data::FixedCount<1>, NOT_INDEXED, bool) \ + X(CLIP_DISTANCE7, bool, baregl::data::FixedCount<1>, NOT_INDEXED, bool) \ + X(CLIP_ORIGIN, int, baregl::data::FixedCount<1>, NOT_INDEXED, int) \ + X(CLIP_DEPTH_MODE, int, baregl::data::FixedCount<1>, NOT_INDEXED, int) \ + X(DEPTH_CLAMP, bool, baregl::data::FixedCount<1>, NOT_INDEXED, bool) \ + X(TRANSFORM_FEEDBACK_BINDING, int, baregl::data::FixedCount<1>, NOT_INDEXED, int) \ + X(CLAMP_READ_COLOR, int, baregl::data::FixedCount<1>, NOT_INDEXED, int) \ + X(PROVOKING_VERTEX, int, baregl::data::FixedCount<1>, NOT_INDEXED, types::EProvokingVertexConvention) \ + X(RASTERIZER_DISCARD, bool, baregl::data::FixedCount<1>, NOT_INDEXED, bool) \ + X(POINT_SIZE, float, baregl::data::FixedCount<1>, NOT_INDEXED, float) \ + X(POINT_FADE_THRESHOLD_SIZE, float, baregl::data::FixedCount<1>, NOT_INDEXED, float) \ + X(POINT_SPRITE_COORD_ORIGIN, int, baregl::data::FixedCount<1>, NOT_INDEXED, int) \ + X(LINE_WIDTH, float, baregl::data::FixedCount<1>, NOT_INDEXED, float) \ + X(LINE_SMOOTH, bool, baregl::data::FixedCount<1>, NOT_INDEXED, bool) \ + X(CULL_FACE, bool, baregl::data::FixedCount<1>, NOT_INDEXED, bool) \ + X(CULL_FACE_MODE, int, baregl::data::FixedCount<1>, NOT_INDEXED, types::ECullFace) \ + X(FRONT_FACE, int, baregl::data::FixedCount<1>, NOT_INDEXED, int) \ + X(POLYGON_SMOOTH, bool, baregl::data::FixedCount<1>, NOT_INDEXED, bool) \ + X(POLYGON_MODE, int, baregl::data::FixedCount<2>, NOT_INDEXED, types::ERasterizationMode) \ + X(POLYGON_OFFSET_FACTOR, float, baregl::data::FixedCount<1>, NOT_INDEXED, float) \ + X(POLYGON_OFFSET_UNITS, float, baregl::data::FixedCount<1>, NOT_INDEXED, float) \ + X(POLYGON_OFFSET_POINT, bool, baregl::data::FixedCount<1>, NOT_INDEXED, bool) \ + X(POLYGON_OFFSET_LINE, bool, baregl::data::FixedCount<1>, NOT_INDEXED, bool) \ + X(POLYGON_OFFSET_FILL, bool, baregl::data::FixedCount<1>, NOT_INDEXED, bool) \ + X(MULTISAMPLE, bool, baregl::data::FixedCount<1>, NOT_INDEXED, bool) \ + X(SAMPLE_ALPHA_TO_COVERAGE, bool, baregl::data::FixedCount<1>, NOT_INDEXED, bool) \ + X(SAMPLE_ALPHA_TO_ONE, bool, baregl::data::FixedCount<1>, NOT_INDEXED, bool) \ + X(SAMPLE_COVERAGE, bool, baregl::data::FixedCount<1>, NOT_INDEXED, bool) \ + X(SAMPLE_COVERAGE_VALUE, float, baregl::data::FixedCount<1>, NOT_INDEXED, float) \ + X(SAMPLE_COVERAGE_INVERT, bool, baregl::data::FixedCount<1>, NOT_INDEXED, bool) \ + X(SAMPLE_SHADING, bool, baregl::data::FixedCount<1>, NOT_INDEXED, bool) \ + X(MIN_SAMPLE_SHADING_VALUE, float, baregl::data::FixedCount<1>, NOT_INDEXED, float) \ + X(SAMPLE_MASK, bool, baregl::data::FixedCount<1>, NOT_INDEXED, bool) \ + X(SAMPLE_MASK_VALUE, int, baregl::data::FixedCount<1>, BOTH, int) \ + X(TEXTURE_BINDING_1D, int, baregl::data::FixedCount<1>, NOT_INDEXED, uint32_t) \ + X(TEXTURE_BINDING_2D, int, baregl::data::FixedCount<1>, NOT_INDEXED, uint32_t) \ + X(TEXTURE_BINDING_3D, int, baregl::data::FixedCount<1>, NOT_INDEXED, uint32_t) \ + X(TEXTURE_BINDING_1D_ARRAY, int, baregl::data::FixedCount<1>, NOT_INDEXED, uint32_t) \ + X(TEXTURE_BINDING_2D_ARRAY, int, baregl::data::FixedCount<1>, NOT_INDEXED, uint32_t) \ + X(TEXTURE_BINDING_CUBE_MAP_ARRAY, int, baregl::data::FixedCount<1>, NOT_INDEXED, int) \ + X(TEXTURE_BINDING_RECTANGLE, int, baregl::data::FixedCount<1>, NOT_INDEXED, uint32_t) \ + X(TEXTURE_BINDING_BUFFER, int, baregl::data::FixedCount<1>, NOT_INDEXED, uint32_t) \ + X(TEXTURE_BINDING_CUBE_MAP, int, baregl::data::FixedCount<1>, NOT_INDEXED, uint32_t) \ + X(TEXTURE_BINDING_2D_MULTISAMPLE, int, baregl::data::FixedCount<1>, NOT_INDEXED, uint32_t) \ + X(TEXTURE_BINDING_2D_MULTISAMPLE_ARRAY, int, baregl::data::FixedCount<1>, NOT_INDEXED, uint32_t) \ + X(SAMPLER_BINDING, int, baregl::data::FixedCount<1>, NOT_INDEXED, uint32_t) \ + X(ACTIVE_TEXTURE, int, baregl::data::FixedCount<1>, NOT_INDEXED, types::ETextureUnit) \ + X(SCISSOR_TEST, bool, baregl::data::FixedCount<1>, NOT_INDEXED, bool) \ + X(SCISSOR_BOX, int, baregl::data::FixedCount<4>, NOT_INDEXED, std::array) \ + X(STENCIL_TEST, bool, baregl::data::FixedCount<1>, NOT_INDEXED, bool) \ + X(STENCIL_FUNC, int, baregl::data::FixedCount<1>, NOT_INDEXED, types::EComparaisonAlgorithm) \ + X(STENCIL_VALUE_MASK, int, baregl::data::FixedCount<1>, NOT_INDEXED, int) \ + X(STENCIL_REF, int, baregl::data::FixedCount<1>, NOT_INDEXED, int) \ + X(STENCIL_FAIL, int, baregl::data::FixedCount<1>, NOT_INDEXED, types::EOperation) \ + X(STENCIL_PASS_DEPTH_FAIL, int, baregl::data::FixedCount<1>, NOT_INDEXED, types::EOperation) \ + X(STENCIL_PASS_DEPTH_PASS, int, baregl::data::FixedCount<1>, NOT_INDEXED, types::EOperation) \ + X(STENCIL_BACK_FUNC, int, baregl::data::FixedCount<1>, NOT_INDEXED, types::EComparaisonAlgorithm) \ + X(STENCIL_BACK_VALUE_MASK, int, baregl::data::FixedCount<1>, NOT_INDEXED, int) \ + X(STENCIL_BACK_REF, int, baregl::data::FixedCount<1>, NOT_INDEXED, int) \ + X(STENCIL_BACK_FAIL, int, baregl::data::FixedCount<1>, NOT_INDEXED, types::EOperation) \ + X(STENCIL_BACK_PASS_DEPTH_FAIL, int, baregl::data::FixedCount<1>, NOT_INDEXED, types::EOperation) \ + X(STENCIL_BACK_PASS_DEPTH_PASS, int, baregl::data::FixedCount<1>, NOT_INDEXED, types::EOperation) \ + X(DEPTH_TEST, bool, baregl::data::FixedCount<1>, NOT_INDEXED, bool) \ + X(DEPTH_FUNC, int, baregl::data::FixedCount<1>, NOT_INDEXED, types::EComparaisonAlgorithm) \ + X(BLEND, bool, baregl::data::FixedCount<1>, NOT_INDEXED, bool) \ + X(BLEND_SRC_RGB, int, baregl::data::FixedCount<1>, NOT_INDEXED, types::EBlendingFactor) \ + X(BLEND_SRC_ALPHA, int, baregl::data::FixedCount<1>, NOT_INDEXED, types::EBlendingFactor) \ + X(BLEND_DST_RGB, int, baregl::data::FixedCount<1>, NOT_INDEXED, types::EBlendingFactor) \ + X(BLEND_DST_ALPHA, int, baregl::data::FixedCount<1>, NOT_INDEXED, types::EBlendingFactor) \ + X(BLEND_EQUATION_RGB, int, baregl::data::FixedCount<1>, NOT_INDEXED, types::EBlendingEquation) \ + X(BLEND_EQUATION_ALPHA, int, baregl::data::FixedCount<1>, NOT_INDEXED, types::EBlendingEquation) \ + X(BLEND_COLOR, float, baregl::data::FixedCount<4>, NOT_INDEXED, std::array) \ + X(FRAMEBUFFER_SRGB, bool, baregl::data::FixedCount<1>, NOT_INDEXED, bool) \ + X(DITHER, bool, baregl::data::FixedCount<1>, NOT_INDEXED, bool) \ + X(COLOR_LOGIC_OP, bool, baregl::data::FixedCount<1>, NOT_INDEXED, bool) \ + X(LOGIC_OP_MODE, int, baregl::data::FixedCount<1>, NOT_INDEXED, types::ELogicOperation) \ + X(COLOR_WRITEMASK, bool, baregl::data::FixedCount<4>, NOT_INDEXED, std::array) \ + X(DEPTH_WRITEMASK, bool, baregl::data::FixedCount<1>, NOT_INDEXED, bool) \ + X(STENCIL_WRITEMASK, int, baregl::data::FixedCount<1>, NOT_INDEXED, int) \ + X(STENCIL_BACK_WRITEMASK, int, baregl::data::FixedCount<1>, NOT_INDEXED, int) \ + X(COLOR_CLEAR_VALUE, float, baregl::data::FixedCount<4>, NOT_INDEXED, std::array) \ + X(DEPTH_CLEAR_VALUE, double, baregl::data::FixedCount<1>, NOT_INDEXED, double) \ + X(STENCIL_CLEAR_VALUE, int, baregl::data::FixedCount<1>, NOT_INDEXED, int) \ + X(DRAW_FRAMEBUFFER_BINDING, int, baregl::data::FixedCount<1>, NOT_INDEXED, uint32_t) \ + X(READ_FRAMEBUFFER_BINDING, int, baregl::data::FixedCount<1>, NOT_INDEXED, uint32_t) \ + X(DRAW_BUFFER, int, baregl::data::FixedCount<1>, NOT_INDEXED, types::EDrawBuffer) \ + X(DRAW_BUFFER0, int, baregl::data::FixedCount<1>, NOT_INDEXED, types::EDrawBuffer) \ + X(DRAW_BUFFER1, int, baregl::data::FixedCount<1>, NOT_INDEXED, types::EDrawBuffer) \ + X(DRAW_BUFFER2, int, baregl::data::FixedCount<1>, NOT_INDEXED, types::EDrawBuffer) \ + X(DRAW_BUFFER3, int, baregl::data::FixedCount<1>, NOT_INDEXED, types::EDrawBuffer) \ + X(DRAW_BUFFER4, int, baregl::data::FixedCount<1>, NOT_INDEXED, types::EDrawBuffer) \ + X(DRAW_BUFFER5, int, baregl::data::FixedCount<1>, NOT_INDEXED, types::EDrawBuffer) \ + X(DRAW_BUFFER6, int, baregl::data::FixedCount<1>, NOT_INDEXED, types::EDrawBuffer) \ + X(DRAW_BUFFER7, int, baregl::data::FixedCount<1>, NOT_INDEXED, types::EDrawBuffer) \ + X(DRAW_BUFFER8, int, baregl::data::FixedCount<1>, NOT_INDEXED, types::EDrawBuffer) \ + X(DRAW_BUFFER9, int, baregl::data::FixedCount<1>, NOT_INDEXED, types::EDrawBuffer) \ + X(DRAW_BUFFER10, int, baregl::data::FixedCount<1>, NOT_INDEXED, types::EDrawBuffer) \ + X(DRAW_BUFFER11, int, baregl::data::FixedCount<1>, NOT_INDEXED, types::EDrawBuffer) \ + X(DRAW_BUFFER12, int, baregl::data::FixedCount<1>, NOT_INDEXED, types::EDrawBuffer) \ + X(DRAW_BUFFER13, int, baregl::data::FixedCount<1>, NOT_INDEXED, types::EDrawBuffer) \ + X(DRAW_BUFFER14, int, baregl::data::FixedCount<1>, NOT_INDEXED, types::EDrawBuffer) \ + X(DRAW_BUFFER15, int, baregl::data::FixedCount<1>, NOT_INDEXED, types::EDrawBuffer) \ + X(READ_BUFFER, int, baregl::data::FixedCount<1>, NOT_INDEXED, types::EDrawBuffer) \ + X(RENDERBUFFER_BINDING, int, baregl::data::FixedCount<1>, NOT_INDEXED, uint32_t) \ + X(UNPACK_SWAP_BYTES, bool, baregl::data::FixedCount<1>, NOT_INDEXED, bool) \ + X(UNPACK_LSB_FIRST, bool, baregl::data::FixedCount<1>, NOT_INDEXED, bool) \ + X(UNPACK_IMAGE_HEIGHT, int, baregl::data::FixedCount<1>, NOT_INDEXED, int) \ + X(UNPACK_SKIP_IMAGES, int, baregl::data::FixedCount<1>, NOT_INDEXED, int) \ + X(UNPACK_ROW_LENGTH, int, baregl::data::FixedCount<1>, NOT_INDEXED, int) \ + X(UNPACK_SKIP_ROWS, int, baregl::data::FixedCount<1>, NOT_INDEXED, int) \ + X(UNPACK_SKIP_PIXELS, int, baregl::data::FixedCount<1>, NOT_INDEXED, int) \ + X(UNPACK_ALIGNMENT, int, baregl::data::FixedCount<1>, NOT_INDEXED, int) \ + X(UNPACK_COMPRESSED_BLOCK_WIDTH, int, baregl::data::FixedCount<1>, NOT_INDEXED, int) \ + X(UNPACK_COMPRESSED_BLOCK_HEIGHT, int, baregl::data::FixedCount<1>, NOT_INDEXED, int) \ + X(UNPACK_COMPRESSED_BLOCK_DEPTH, int, baregl::data::FixedCount<1>, NOT_INDEXED, int) \ + X(UNPACK_COMPRESSED_BLOCK_SIZE, int, baregl::data::FixedCount<1>, NOT_INDEXED, int) \ + X(PIXEL_UNPACK_BUFFER_BINDING, int, baregl::data::FixedCount<1>, NOT_INDEXED, uint32_t) \ + X(PACK_SWAP_BYTES, bool, baregl::data::FixedCount<1>, NOT_INDEXED, bool) \ + X(PACK_LSB_FIRST, bool, baregl::data::FixedCount<1>, NOT_INDEXED, bool) \ + X(PACK_IMAGE_HEIGHT, int, baregl::data::FixedCount<1>, NOT_INDEXED, int) \ + X(PACK_SKIP_IMAGES, int, baregl::data::FixedCount<1>, NOT_INDEXED, int) \ + X(PACK_ROW_LENGTH, int, baregl::data::FixedCount<1>, NOT_INDEXED, int) \ + X(PACK_SKIP_ROWS, int, baregl::data::FixedCount<1>, NOT_INDEXED, int) \ + X(PACK_SKIP_PIXELS, int, baregl::data::FixedCount<1>, NOT_INDEXED, int) \ + X(PACK_ALIGNMENT, int, baregl::data::FixedCount<1>, NOT_INDEXED, int) \ + X(PACK_COMPRESSED_BLOCK_WIDTH, int, baregl::data::FixedCount<1>, NOT_INDEXED, int) \ + X(PACK_COMPRESSED_BLOCK_HEIGHT, int, baregl::data::FixedCount<1>, NOT_INDEXED, int) \ + X(PACK_COMPRESSED_BLOCK_DEPTH, int, baregl::data::FixedCount<1>, NOT_INDEXED, int) \ + X(PACK_COMPRESSED_BLOCK_SIZE, int, baregl::data::FixedCount<1>, NOT_INDEXED, int) \ + X(PIXEL_PACK_BUFFER_BINDING, int, baregl::data::FixedCount<1>, NOT_INDEXED, uint32_t) \ + X(CURRENT_PROGRAM, int, baregl::data::FixedCount<1>, NOT_INDEXED, uint32_t) \ + X(PROGRAM_PIPELINE_BINDING, int, baregl::data::FixedCount<1>, NOT_INDEXED, uint32_t) \ + X(PROGRAM_POINT_SIZE, bool, baregl::data::FixedCount<1>, NOT_INDEXED, bool) \ + X(IMAGE_BINDING_NAME, int, baregl::data::FixedCount<1>, BOTH, int) \ + X(IMAGE_BINDING_LEVEL, int, baregl::data::FixedCount<1>, BOTH, int) \ + X(IMAGE_BINDING_LAYERED, bool, baregl::data::FixedCount<1>, BOTH, bool) \ + X(IMAGE_BINDING_LAYER, int, baregl::data::FixedCount<1>, BOTH, int) \ + X(IMAGE_BINDING_ACCESS, int, baregl::data::FixedCount<1>, BOTH, types::EImageAccessSpecifier) \ + X(IMAGE_BINDING_FORMAT, int, baregl::data::FixedCount<1>, BOTH, types::EInternalFormat) \ + X(ATOMIC_COUNTER_BUFFER_BINDING, int, baregl::data::FixedCount<1>, BOTH, int) \ + X(ATOMIC_COUNTER_BUFFER_START, int64_t, baregl::data::FixedCount<1>, INDEXED, int64_t) \ + X(ATOMIC_COUNTER_BUFFER_SIZE, int64_t, baregl::data::FixedCount<1>, INDEXED, int64_t) \ + X(SHADER_STORAGE_BUFFER_BINDING, int, baregl::data::FixedCount<1>, BOTH, uint32_t) \ + X(SHADER_STORAGE_BUFFER_START, int64_t, baregl::data::FixedCount<1>, INDEXED, int64_t) \ + X(SHADER_STORAGE_BUFFER_SIZE, int64_t, baregl::data::FixedCount<1>, INDEXED, int64_t) \ + X(TRANSFORM_FEEDBACK_BUFFER_BINDING, int, baregl::data::FixedCount<1>, BOTH, uint32_t) \ + X(TRANSFORM_FEEDBACK_BUFFER_START, int64_t, baregl::data::FixedCount<1>, INDEXED, int64_t) \ + X(TRANSFORM_FEEDBACK_BUFFER_SIZE, int64_t, baregl::data::FixedCount<1>, INDEXED, int64_t) \ + X(TRANSFORM_FEEDBACK_PAUSED, bool, baregl::data::FixedCount<1>, NOT_INDEXED, bool) \ + X(TRANSFORM_FEEDBACK_ACTIVE, bool, baregl::data::FixedCount<1>, NOT_INDEXED, bool) \ + X(UNIFORM_BUFFER_BINDING, int, baregl::data::FixedCount<1>, BOTH, uint32_t) \ + X(UNIFORM_BUFFER_START, int64_t, baregl::data::FixedCount<1>, INDEXED, int64_t) \ + X(UNIFORM_BUFFER_SIZE, int64_t, baregl::data::FixedCount<1>, INDEXED, int64_t) \ + X(LINE_SMOOTH_HINT, int, baregl::data::FixedCount<1>, NOT_INDEXED, types::EHint) \ + X(POLYGON_SMOOTH_HINT, int, baregl::data::FixedCount<1>, NOT_INDEXED, types::EHint) \ + X(TEXTURE_COMPRESSION_HINT, int, baregl::data::FixedCount<1>, NOT_INDEXED, types::EHint) \ + X(FRAGMENT_SHADER_DERIVATIVE_HINT, int, baregl::data::FixedCount<1>, NOT_INDEXED, types::EHint) \ + X(DISPATCH_INDIRECT_BUFFER_BINDING, int, baregl::data::FixedCount<1>, NOT_INDEXED, uint32_t) \ + X(CONTEXT_RELEASE_BEHAVIOR, int, baregl::data::FixedCount<1>, NOT_INDEXED, int) \ + X(MAX_CLIP_DISTANCES, int, baregl::data::FixedCount<1>, NOT_INDEXED, int) \ + X(MAX_CULL_DISTANCES, int, baregl::data::FixedCount<1>, NOT_INDEXED, int) \ + X(MAX_COMBINED_CLIP_AND_CULL_DISTANCES, int, baregl::data::FixedCount<1>, NOT_INDEXED, int) \ + X(SUBPIXEL_BITS, int, baregl::data::FixedCount<1>, NOT_INDEXED, int) \ + X(MAX_ELEMENT_INDEX, int64_t, baregl::data::FixedCount<1>, NOT_INDEXED, int64_t) \ + X(PRIMITIVE_RESTART_FOR_PATCHES_SUPPORTED, bool, baregl::data::FixedCount<1>, NOT_INDEXED, bool) \ + X(MAX_3D_TEXTURE_SIZE, int, baregl::data::FixedCount<1>, NOT_INDEXED, int) \ + X(MAX_TEXTURE_SIZE, int, baregl::data::FixedCount<1>, NOT_INDEXED, int) \ + X(MAX_ARRAY_TEXTURE_LAYERS, int, baregl::data::FixedCount<1>, NOT_INDEXED, int) \ + X(MAX_TEXTURE_LOD_BIAS, float, baregl::data::FixedCount<1>, NOT_INDEXED, float) \ + X(MAX_CUBE_MAP_TEXTURE_SIZE, int, baregl::data::FixedCount<1>, NOT_INDEXED, int) \ + X(MAX_RENDERBUFFER_SIZE, int, baregl::data::FixedCount<1>, NOT_INDEXED, int) \ + X(MAX_VIEWPORT_DIMS, int, baregl::data::FixedCount<2>, NOT_INDEXED, std::array) \ + X(MAX_VIEWPORTS, int, baregl::data::FixedCount<1>, NOT_INDEXED, int) \ + X(VIEWPORT_SUBPIXEL_BITS, int, baregl::data::FixedCount<1>, NOT_INDEXED, int) \ + X(VIEWPORT_BOUNDS_RANGE, float, baregl::data::FixedCount<2>, NOT_INDEXED, std::array) \ + X(LAYER_PROVOKING_VERTEX, int, baregl::data::FixedCount<1>, NOT_INDEXED, types::EProvokingVertexConvention) \ + X(VIEWPORT_INDEX_PROVOKING_VERTEX, int, baregl::data::FixedCount<1>, NOT_INDEXED, types::EProvokingVertexConvention) \ + X(POINT_SIZE_RANGE, float, baregl::data::FixedCount<2>, NOT_INDEXED, std::array) \ + X(POINT_SIZE_GRANULARITY, float, baregl::data::FixedCount<1>, NOT_INDEXED, float) \ + X(ALIASED_LINE_WIDTH_RANGE, float, baregl::data::FixedCount<2>, NOT_INDEXED, std::array) \ + X(SMOOTH_LINE_WIDTH_RANGE, float, baregl::data::FixedCount<2>, NOT_INDEXED, std::array) \ + X(SMOOTH_LINE_WIDTH_GRANULARITY, float, baregl::data::FixedCount<1>, NOT_INDEXED, float) \ + X(MAX_ELEMENTS_INDICES, int, baregl::data::FixedCount<1>, NOT_INDEXED, int) \ + X(MAX_ELEMENTS_VERTICES, int, baregl::data::FixedCount<1>, NOT_INDEXED, int) \ + X(MAX_VERTEX_ATTRIB_RELATIVE_OFFSET, int, baregl::data::FixedCount<1>, NOT_INDEXED, int) \ + X(MAX_VERTEX_ATTRIB_BINDINGS, int, baregl::data::FixedCount<1>, NOT_INDEXED, int) \ + X(MAX_VERTEX_ATTRIB_STRIDE, int, baregl::data::FixedCount<1>, NOT_INDEXED, int) \ + X(NUM_COMPRESSED_TEXTURE_FORMATS, int, baregl::data::FixedCount<1>, NOT_INDEXED, int) \ + X(COMPRESSED_TEXTURE_FORMATS, int, baregl::data::DynamicCount, NOT_INDEXED, types::EInternalFormat) \ + X(MAX_TEXTURE_BUFFER_SIZE, int, baregl::data::FixedCount<1>, NOT_INDEXED, int) \ + X(MAX_RECTANGLE_TEXTURE_SIZE, int, baregl::data::FixedCount<1>, NOT_INDEXED, int) \ + X(NUM_PROGRAM_BINARY_FORMATS, int, baregl::data::FixedCount<1>, NOT_INDEXED, int) \ + X(PROGRAM_BINARY_FORMATS, int, baregl::data::DynamicCount, NOT_INDEXED, int) \ + X(NUM_SHADER_BINARY_FORMATS, int, baregl::data::FixedCount<1>, NOT_INDEXED, int) \ + X(SHADER_BINARY_FORMATS, int, baregl::data::DynamicCount, NOT_INDEXED, int) \ + X(SHADER_COMPILER, bool, baregl::data::FixedCount<1>, NOT_INDEXED, bool) \ + X(MIN_MAP_BUFFER_ALIGNMENT, int, baregl::data::FixedCount<1>, NOT_INDEXED, int) \ + X(TEXTURE_BUFFER_OFFSET_ALIGNMENT, int, baregl::data::FixedCount<1>, NOT_INDEXED, int) \ + X(MAJOR_VERSION, int, baregl::data::FixedCount<1>, NOT_INDEXED, int) \ + X(MINOR_VERSION, int, baregl::data::FixedCount<1>, NOT_INDEXED, int) \ + X(CONTEXT_FLAGS, int, baregl::data::FixedCount<1>, NOT_INDEXED, types::EContextFlags) \ + X(CONTEXT_PROFILE_MASK, int, baregl::data::FixedCount<1>, NOT_INDEXED, int) \ + X(EXTENSIONS, std::string, baregl::data::FixedCount<1>, BOTH, std::string) \ + X(NUM_EXTENSIONS, int, baregl::data::FixedCount<1>, NOT_INDEXED, int) \ + X(RENDERER, std::string, baregl::data::FixedCount<1>, NOT_INDEXED, std::string) \ + X(SHADING_LANGUAGE_VERSION, std::string, baregl::data::FixedCount<1>, BOTH, std::string) \ + X(NUM_SHADING_LANGUAGE_VERSIONS, int, baregl::data::FixedCount<1>, NOT_INDEXED, int) \ + X(VENDOR, std::string, baregl::data::FixedCount<1>, NOT_INDEXED, std::string) \ + X(VERSION, std::string, baregl::data::FixedCount<1>, NOT_INDEXED, std::string) \ + X(MAX_VERTEX_ATTRIBS, int, baregl::data::FixedCount<1>, NOT_INDEXED, int) \ + X(MAX_VERTEX_UNIFORM_COMPONENTS, int, baregl::data::FixedCount<1>, NOT_INDEXED, int) \ + X(MAX_VERTEX_UNIFORM_VECTORS, int, baregl::data::FixedCount<1>, NOT_INDEXED, int) \ + X(MAX_VERTEX_UNIFORM_BLOCKS, int, baregl::data::FixedCount<1>, NOT_INDEXED, int) \ + X(MAX_VERTEX_OUTPUT_COMPONENTS, int, baregl::data::FixedCount<1>, NOT_INDEXED, int) \ + X(MAX_VERTEX_TEXTURE_IMAGE_UNITS, int, baregl::data::FixedCount<1>, NOT_INDEXED, int) \ + X(MAX_VERTEX_ATOMIC_COUNTER_BUFFERS, int, baregl::data::FixedCount<1>, NOT_INDEXED, int) \ + X(MAX_VERTEX_ATOMIC_COUNTERS, int, baregl::data::FixedCount<1>, NOT_INDEXED, int) \ + X(MAX_VERTEX_SHADER_STORAGE_BLOCKS, int, baregl::data::FixedCount<1>, NOT_INDEXED, int) \ + X(MAX_TESS_GEN_LEVEL, int, baregl::data::FixedCount<1>, NOT_INDEXED, int) \ + X(MAX_PATCH_VERTICES, int, baregl::data::FixedCount<1>, NOT_INDEXED, int) \ + X(MAX_TESS_CONTROL_UNIFORM_COMPONENTS, int, baregl::data::FixedCount<1>, NOT_INDEXED, int) \ + X(MAX_TESS_CONTROL_TEXTURE_IMAGE_UNITS, int, baregl::data::FixedCount<1>, NOT_INDEXED, int) \ + X(MAX_TESS_CONTROL_OUTPUT_COMPONENTS, int, baregl::data::FixedCount<1>, NOT_INDEXED, int) \ + X(MAX_TESS_PATCH_COMPONENTS, int, baregl::data::FixedCount<1>, NOT_INDEXED, int) \ + X(MAX_TESS_CONTROL_TOTAL_OUTPUT_COMPONENTS, int, baregl::data::FixedCount<1>, NOT_INDEXED, int) \ + X(MAX_TESS_CONTROL_INPUT_COMPONENTS, int, baregl::data::FixedCount<1>, NOT_INDEXED, int) \ + X(MAX_TESS_CONTROL_UNIFORM_BLOCKS, int, baregl::data::FixedCount<1>, NOT_INDEXED, int) \ + X(MAX_TESS_CONTROL_ATOMIC_COUNTER_BUFFERS, int, baregl::data::FixedCount<1>, NOT_INDEXED, int) \ + X(MAX_TESS_CONTROL_ATOMIC_COUNTERS, int, baregl::data::FixedCount<1>, NOT_INDEXED, int) \ + X(MAX_TESS_CONTROL_SHADER_STORAGE_BLOCKS, int, baregl::data::FixedCount<1>, NOT_INDEXED, int) \ + X(MAX_TESS_EVALUATION_UNIFORM_COMPONENTS, int, baregl::data::FixedCount<1>, NOT_INDEXED, int) \ + X(MAX_TESS_EVALUATION_TEXTURE_IMAGE_UNITS, int, baregl::data::FixedCount<1>, NOT_INDEXED, int) \ + X(MAX_TESS_EVALUATION_OUTPUT_COMPONENTS, int, baregl::data::FixedCount<1>, NOT_INDEXED, int) \ + X(MAX_TESS_EVALUATION_INPUT_COMPONENTS, int, baregl::data::FixedCount<1>, NOT_INDEXED, int) \ + X(MAX_TESS_EVALUATION_UNIFORM_BLOCKS, int, baregl::data::FixedCount<1>, NOT_INDEXED, int) \ + X(MAX_TESS_EVALUATION_ATOMIC_COUNTER_BUFFERS, int, baregl::data::FixedCount<1>, NOT_INDEXED, int) \ + X(MAX_TESS_EVALUATION_ATOMIC_COUNTERS, int, baregl::data::FixedCount<1>, NOT_INDEXED, int) \ + X(MAX_TESS_EVALUATION_SHADER_STORAGE_BLOCKS, int, baregl::data::FixedCount<1>, NOT_INDEXED, int) \ + X(MAX_GEOMETRY_UNIFORM_COMPONENTS, int, baregl::data::FixedCount<1>, NOT_INDEXED, int) \ + X(MAX_GEOMETRY_UNIFORM_BLOCKS, int, baregl::data::FixedCount<1>, NOT_INDEXED, int) \ + X(MAX_GEOMETRY_INPUT_COMPONENTS, int, baregl::data::FixedCount<1>, NOT_INDEXED, int) \ + X(MAX_GEOMETRY_OUTPUT_COMPONENTS, int, baregl::data::FixedCount<1>, NOT_INDEXED, int) \ + X(MAX_GEOMETRY_OUTPUT_VERTICES, int, baregl::data::FixedCount<1>, NOT_INDEXED, int) \ + X(MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS, int, baregl::data::FixedCount<1>, NOT_INDEXED, int) \ + X(MAX_GEOMETRY_TEXTURE_IMAGE_UNITS, int, baregl::data::FixedCount<1>, NOT_INDEXED, int) \ + X(MAX_GEOMETRY_SHADER_INVOCATIONS, int, baregl::data::FixedCount<1>, NOT_INDEXED, int) \ + X(MAX_VERTEX_STREAMS, int, baregl::data::FixedCount<1>, NOT_INDEXED, int) \ + X(MAX_GEOMETRY_ATOMIC_COUNTER_BUFFERS, int, baregl::data::FixedCount<1>, NOT_INDEXED, int) \ + X(MAX_GEOMETRY_ATOMIC_COUNTERS, int, baregl::data::FixedCount<1>, NOT_INDEXED, int) \ + X(MAX_GEOMETRY_SHADER_STORAGE_BLOCKS, int, baregl::data::FixedCount<1>, NOT_INDEXED, int) \ + X(MAX_FRAGMENT_UNIFORM_COMPONENTS, int, baregl::data::FixedCount<1>, NOT_INDEXED, int) \ + X(MAX_FRAGMENT_UNIFORM_VECTORS, int, baregl::data::FixedCount<1>, NOT_INDEXED, int) \ + X(MAX_FRAGMENT_UNIFORM_BLOCKS, int, baregl::data::FixedCount<1>, NOT_INDEXED, int) \ + X(MAX_FRAGMENT_INPUT_COMPONENTS, int, baregl::data::FixedCount<1>, NOT_INDEXED, int) \ + X(MAX_TEXTURE_IMAGE_UNITS, int, baregl::data::FixedCount<1>, NOT_INDEXED, int) \ + X(MIN_PROGRAM_TEXTURE_GATHER_OFFSET, int, baregl::data::FixedCount<1>, NOT_INDEXED, int) \ + X(MAX_PROGRAM_TEXTURE_GATHER_OFFSET, int, baregl::data::FixedCount<1>, NOT_INDEXED, int) \ + X(MAX_FRAGMENT_ATOMIC_COUNTER_BUFFERS, int, baregl::data::FixedCount<1>, NOT_INDEXED, int) \ + X(MAX_FRAGMENT_ATOMIC_COUNTERS, int, baregl::data::FixedCount<1>, NOT_INDEXED, int) \ + X(MAX_FRAGMENT_SHADER_STORAGE_BLOCKS, int, baregl::data::FixedCount<1>, NOT_INDEXED, int) \ + X(MAX_COMPUTE_WORK_GROUP_COUNT, int, baregl::data::FixedCount<1>, BOTH, int) \ + X(MAX_COMPUTE_WORK_GROUP_SIZE, int, baregl::data::FixedCount<1>, BOTH, int) \ + X(MAX_COMPUTE_WORK_GROUP_INVOCATIONS, int, baregl::data::FixedCount<1>, NOT_INDEXED, int) \ + X(MAX_COMPUTE_UNIFORM_BLOCKS, int, baregl::data::FixedCount<1>, NOT_INDEXED, int) \ + X(MAX_COMPUTE_TEXTURE_IMAGE_UNITS, int, baregl::data::FixedCount<1>, NOT_INDEXED, int) \ + X(MAX_COMPUTE_ATOMIC_COUNTERS, int, baregl::data::FixedCount<1>, NOT_INDEXED, int) \ + X(MAX_COMPUTE_ATOMIC_COUNTER_BUFFERS, int, baregl::data::FixedCount<1>, NOT_INDEXED, int) \ + X(MAX_COMPUTE_SHARED_MEMORY_SIZE, int, baregl::data::FixedCount<1>, NOT_INDEXED, int) \ + X(MAX_COMPUTE_UNIFORM_COMPONENTS, int, baregl::data::FixedCount<1>, NOT_INDEXED, int) \ + X(MAX_COMPUTE_IMAGE_UNIFORMS, int, baregl::data::FixedCount<1>, NOT_INDEXED, int) \ + X(MAX_COMBINED_COMPUTE_UNIFORM_COMPONENTS, int, baregl::data::FixedCount<1>, NOT_INDEXED, int) \ + X(MAX_COMPUTE_SHADER_STORAGE_BLOCKS, int, baregl::data::FixedCount<1>, NOT_INDEXED, int) \ + X(MIN_PROGRAM_TEXEL_OFFSET, int, baregl::data::FixedCount<1>, NOT_INDEXED, int) \ + X(MAX_PROGRAM_TEXEL_OFFSET, int, baregl::data::FixedCount<1>, NOT_INDEXED, int) \ + X(MAX_UNIFORM_BUFFER_BINDINGS, int, baregl::data::FixedCount<1>, NOT_INDEXED, int) \ + X(MAX_UNIFORM_BLOCK_SIZE, int, baregl::data::FixedCount<1>, NOT_INDEXED, int) \ + X(UNIFORM_BUFFER_OFFSET_ALIGNMENT, int, baregl::data::FixedCount<1>, NOT_INDEXED, int) \ + X(MAX_COMBINED_UNIFORM_BLOCKS, int, baregl::data::FixedCount<1>, NOT_INDEXED, int) \ + X(MAX_VARYING_COMPONENTS, int, baregl::data::FixedCount<1>, NOT_INDEXED, int) \ + X(MAX_VARYING_VECTORS, int, baregl::data::FixedCount<1>, NOT_INDEXED, int) \ + X(MAX_VARYING_FLOATS, int, baregl::data::FixedCount<1>, NOT_INDEXED, int) \ + X(MAX_COMBINED_TEXTURE_IMAGE_UNITS, int, baregl::data::FixedCount<1>, NOT_INDEXED, int) \ + X(MAX_SUBROUTINES, int, baregl::data::FixedCount<1>, NOT_INDEXED, int) \ + X(MAX_SUBROUTINE_UNIFORM_LOCATIONS, int, baregl::data::FixedCount<1>, NOT_INDEXED, int) \ + X(MAX_UNIFORM_LOCATIONS, int, baregl::data::FixedCount<1>, NOT_INDEXED, int) \ + X(MAX_ATOMIC_COUNTER_BUFFER_BINDINGS, int, baregl::data::FixedCount<1>, NOT_INDEXED, int) \ + X(MAX_ATOMIC_COUNTER_BUFFER_SIZE, int, baregl::data::FixedCount<1>, NOT_INDEXED, int) \ + X(MAX_COMBINED_ATOMIC_COUNTER_BUFFERS, int, baregl::data::FixedCount<1>, NOT_INDEXED, int) \ + X(MAX_COMBINED_ATOMIC_COUNTERS, int, baregl::data::FixedCount<1>, NOT_INDEXED, int) \ + X(MAX_SHADER_STORAGE_BUFFER_BINDINGS, int, baregl::data::FixedCount<1>, NOT_INDEXED, int) \ + X(MAX_SHADER_STORAGE_BLOCK_SIZE, int64_t, baregl::data::FixedCount<1>, NOT_INDEXED, int64_t) \ + X(MAX_COMBINED_SHADER_STORAGE_BLOCKS, int, baregl::data::FixedCount<1>, NOT_INDEXED, int) \ + X(SHADER_STORAGE_BUFFER_OFFSET_ALIGNMENT, int, baregl::data::FixedCount<1>, NOT_INDEXED, int) \ + X(MAX_IMAGE_UNITS, int, baregl::data::FixedCount<1>, NOT_INDEXED, int) \ + X(MAX_COMBINED_SHADER_OUTPUT_RESOURCES, int, baregl::data::FixedCount<1>, NOT_INDEXED, int) \ + X(MAX_IMAGE_SAMPLES, int, baregl::data::FixedCount<1>, NOT_INDEXED, int) \ + X(MAX_VERTEX_IMAGE_UNIFORMS, int, baregl::data::FixedCount<1>, NOT_INDEXED, int) \ + X(MAX_TESS_CONTROL_IMAGE_UNIFORMS, int, baregl::data::FixedCount<1>, NOT_INDEXED, int) \ + X(MAX_TESS_EVALUATION_IMAGE_UNIFORMS, int, baregl::data::FixedCount<1>, NOT_INDEXED, int) \ + X(MAX_GEOMETRY_IMAGE_UNIFORMS, int, baregl::data::FixedCount<1>, NOT_INDEXED, int) \ + X(MAX_FRAGMENT_IMAGE_UNIFORMS, int, baregl::data::FixedCount<1>, NOT_INDEXED, int) \ + X(MAX_COMBINED_IMAGE_UNIFORMS, int, baregl::data::FixedCount<1>, NOT_INDEXED, int) \ + X(MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS, int, baregl::data::FixedCount<1>, NOT_INDEXED, int) \ + X(MAX_COMBINED_GEOMETRY_UNIFORM_COMPONENTS, int, baregl::data::FixedCount<1>, NOT_INDEXED, int) \ + X(MAX_COMBINED_TESS_CONTROL_UNIFORM_COMPONENTS, int, baregl::data::FixedCount<1>, NOT_INDEXED, int) \ + X(MAX_COMBINED_TESS_EVALUATION_UNIFORM_COMPONENTS, int, baregl::data::FixedCount<1>, NOT_INDEXED, int) \ + X(MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS, int, baregl::data::FixedCount<1>, NOT_INDEXED, int) \ + X(DEBUG_LOGGED_MESSAGES, int, baregl::data::FixedCount<1>, NOT_INDEXED, int) \ + X(DEBUG_NEXT_LOGGED_MESSAGE_LENGTH, int, baregl::data::FixedCount<1>, NOT_INDEXED, int) \ + X(DEBUG_OUTPUT_SYNCHRONOUS, bool, baregl::data::FixedCount<1>, NOT_INDEXED, bool) \ + X(DEBUG_GROUP_STACK_DEPTH, int, baregl::data::FixedCount<1>, NOT_INDEXED, int) \ + X(DEBUG_OUTPUT, bool, baregl::data::FixedCount<1>, NOT_INDEXED, bool) \ + X(MAX_DEBUG_MESSAGE_LENGTH, int, baregl::data::FixedCount<1>, NOT_INDEXED, int) \ + X(MAX_DEBUG_LOGGED_MESSAGES, int, baregl::data::FixedCount<1>, NOT_INDEXED, int) \ + X(MAX_DEBUG_GROUP_STACK_DEPTH, int, baregl::data::FixedCount<1>, NOT_INDEXED, int) \ + X(MAX_LABEL_LENGTH, int, baregl::data::FixedCount<1>, NOT_INDEXED, int) \ + X(MAX_FRAMEBUFFER_WIDTH, int, baregl::data::FixedCount<1>, NOT_INDEXED, int) \ + X(MAX_FRAMEBUFFER_HEIGHT, int, baregl::data::FixedCount<1>, NOT_INDEXED, int) \ + X(MAX_FRAMEBUFFER_LAYERS, int, baregl::data::FixedCount<1>, NOT_INDEXED, int) \ + X(MAX_FRAMEBUFFER_SAMPLES, int, baregl::data::FixedCount<1>, NOT_INDEXED, int) \ + X(MAX_SAMPLE_MASK_WORDS, int, baregl::data::FixedCount<1>, NOT_INDEXED, int) \ + X(MAX_SAMPLES, int, baregl::data::FixedCount<1>, NOT_INDEXED, int) \ + X(MAX_COLOR_TEXTURE_SAMPLES, int, baregl::data::FixedCount<1>, NOT_INDEXED, int) \ + X(MAX_DEPTH_TEXTURE_SAMPLES, int, baregl::data::FixedCount<1>, NOT_INDEXED, int) \ + X(MAX_INTEGER_SAMPLES, int, baregl::data::FixedCount<1>, NOT_INDEXED, int) \ + X(MAX_SERVER_WAIT_TIMEOUT, int64_t, baregl::data::FixedCount<1>, NOT_INDEXED, int64_t) \ + X(MIN_FRAGMENT_INTERPOLATION_OFFSET, float, baregl::data::FixedCount<1>, NOT_INDEXED, float) \ + X(MAX_FRAGMENT_INTERPOLATION_OFFSET, float, baregl::data::FixedCount<1>, NOT_INDEXED, float) \ + X(FRAGMENT_INTERPOLATION_OFFSET_BITS, int, baregl::data::FixedCount<1>, NOT_INDEXED, int) \ + X(MAX_DRAW_BUFFERS, int, baregl::data::FixedCount<1>, NOT_INDEXED, int) \ + X(MAX_DUAL_SOURCE_DRAW_BUFFERS, int, baregl::data::FixedCount<1>, NOT_INDEXED, int) \ + X(MAX_COLOR_ATTACHMENTS, int, baregl::data::FixedCount<1>, NOT_INDEXED, int) \ + X(MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS, int, baregl::data::FixedCount<1>, NOT_INDEXED, int) \ + X(MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS, int, baregl::data::FixedCount<1>, NOT_INDEXED, int) \ + X(MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS, int, baregl::data::FixedCount<1>, NOT_INDEXED, int) \ + X(MAX_TRANSFORM_FEEDBACK_BUFFERS, int, baregl::data::FixedCount<1>, NOT_INDEXED, int) \ + X(DOUBLEBUFFER, bool, baregl::data::FixedCount<1>, NOT_INDEXED, bool) \ + X(STEREO, bool, baregl::data::FixedCount<1>, NOT_INDEXED, bool) \ + X(SAMPLE_BUFFERS, int, baregl::data::FixedCount<1>, NOT_INDEXED, int) \ + X(SAMPLES, int, baregl::data::FixedCount<1>, NOT_INDEXED, int) \ + X(IMPLEMENTATION_COLOR_READ_FORMAT, int, baregl::data::FixedCount<1>, NOT_INDEXED, types::EPixelDataFormat) \ + X(IMPLEMENTATION_COLOR_READ_TYPE, int, baregl::data::FixedCount<1>, NOT_INDEXED, types::EPixelDataType) \ + X(QUERY_BUFFER_BINDING, int, baregl::data::FixedCount<1>, NOT_INDEXED, int) \ + X(COPY_READ_BUFFER_BINDING, int, baregl::data::FixedCount<1>, NOT_INDEXED, int) \ + X(COPY_WRITE_BUFFER_BINDING, int, baregl::data::FixedCount<1>, NOT_INDEXED, int) \ + X(RESET_NOTIFICATION_STRATEGY, int, baregl::data::FixedCount<1>, NOT_INDEXED, int) \ + X(TEXTURE_BUFFER_BINDING, int, baregl::data::FixedCount<1>, NOT_INDEXED, int) \ + X(TEXTURE_CUBE_MAP_SEAMLESS, bool, baregl::data::FixedCount<1>, NOT_INDEXED, bool) \ + X(TIMESTAMP, int64_t, baregl::data::FixedCount<1>, NOT_INDEXED, int64_t) + diff --git a/Sources/OvRendering/include/OvRendering/Settings/ShaderCompilationResult.h b/Dependencies/baregl/include/baregl/data/ShaderCompilationResult.h similarity index 72% rename from Sources/OvRendering/include/OvRendering/Settings/ShaderCompilationResult.h rename to Dependencies/baregl/include/baregl/data/ShaderCompilationResult.h index c1af60cf0..3f3f5921f 100644 --- a/Sources/OvRendering/include/OvRendering/Settings/ShaderCompilationResult.h +++ b/Dependencies/baregl/include/baregl/data/ShaderCompilationResult.h @@ -1,6 +1,6 @@ /** -* @project: Overload -* @author: Overload Tech. +* @project: baregl +* @author: Adrien Givry * @licence: MIT */ @@ -8,7 +8,7 @@ #include -namespace OvRendering::Settings +namespace baregl::data { /** * Structure that holds the result of a shader compilation diff --git a/Sources/OvRendering/include/OvRendering/Settings/ShaderLinkingResult.h b/Dependencies/baregl/include/baregl/data/ShaderLinkingResult.h similarity index 73% rename from Sources/OvRendering/include/OvRendering/Settings/ShaderLinkingResult.h rename to Dependencies/baregl/include/baregl/data/ShaderLinkingResult.h index 53118d817..89475ce65 100644 --- a/Sources/OvRendering/include/OvRendering/Settings/ShaderLinkingResult.h +++ b/Dependencies/baregl/include/baregl/data/ShaderLinkingResult.h @@ -1,6 +1,6 @@ /** -* @project: Overload -* @author: Overload Tech. +* @project: baregl +* @author: Adrien Givry * @licence: MIT */ @@ -8,7 +8,7 @@ #include -namespace OvRendering::Settings +namespace baregl::data { /** * Structure that contains the result of a shader linking operation diff --git a/Dependencies/baregl/include/baregl/data/TextureDesc.h b/Dependencies/baregl/include/baregl/data/TextureDesc.h new file mode 100644 index 000000000..cdb03b88c --- /dev/null +++ b/Dependencies/baregl/include/baregl/data/TextureDesc.h @@ -0,0 +1,44 @@ +/** +* @project: baregl +* @author: Adrien Givry +* @licence: MIT +*/ + +#pragma once + +#include +#include +#include +#include +#include + +#include + +namespace baregl::data +{ + /** + * Structure that holds additional data for mutable textures + */ + struct MutableTextureDesc + { + types::EFormat format = types::EFormat::RGBA; + types::EPixelDataType type = types::EPixelDataType::UNSIGNED_BYTE; + const void* data = nullptr; + }; + + /** + * Structure that holds the description of a texture + */ + struct TextureDesc + { + uint32_t width = 0; + uint32_t height = 0; + types::ETextureFilteringMode minFilter = types::ETextureFilteringMode::LINEAR_MIPMAP_LINEAR; + types::ETextureFilteringMode magFilter = types::ETextureFilteringMode::LINEAR; + types::ETextureWrapMode horizontalWrap = types::ETextureWrapMode::REPEAT; + types::ETextureWrapMode verticalWrap = types::ETextureWrapMode::REPEAT; + types::EInternalFormat internalFormat = types::EInternalFormat::RGBA; + bool useMipMaps = true; + std::optional mutableDesc = std::nullopt; + }; +} diff --git a/Sources/OvRendering/include/OvRendering/Settings/UniformInfo.h b/Dependencies/baregl/include/baregl/data/UniformInfo.h similarity index 52% rename from Sources/OvRendering/include/OvRendering/Settings/UniformInfo.h rename to Dependencies/baregl/include/baregl/data/UniformInfo.h index 686917a3b..5516f21d9 100644 --- a/Sources/OvRendering/include/OvRendering/Settings/UniformInfo.h +++ b/Dependencies/baregl/include/baregl/data/UniformInfo.h @@ -1,26 +1,27 @@ /** -* @project: Overload -* @author: Overload Tech. +* @project: baregl +* @author: Adrien Givry * @licence: MIT */ #pragma once +#include + #include #include +#include -#include - -namespace OvRendering::Settings +namespace baregl::data { /** * Structure that holds information about a uniform */ struct UniformInfo { - EUniformType type; + types::EUniformType type; std::string name; std::any defaultValue; - uint32_t textureSlot; + std::optional textureIndex; }; } diff --git a/Dependencies/baregl/include/baregl/data/VertexAttribute.h b/Dependencies/baregl/include/baregl/data/VertexAttribute.h new file mode 100644 index 000000000..0506a0163 --- /dev/null +++ b/Dependencies/baregl/include/baregl/data/VertexAttribute.h @@ -0,0 +1,46 @@ +/** +* @project: baregl +* @author: Adrien Givry +* @licence: MIT +*/ + +#pragma once + +#include + +#include +#include + +namespace baregl::data +{ + /** + * Vertex attribute using glVertexAttribPointer (data converted to float). + */ + struct FloatVertexAttribute + { + types::EDataType type = types::EDataType::FLOAT; + uint8_t count = 4; + bool normalized = false; + }; + + /** + * Vertex attribute using glVertexAttribIPointer (integer data kept as-is). + * Valid types: BYTE, UNSIGNED_BYTE, SHORT, UNSIGNED_SHORT, INT, UNSIGNED_INT. + */ + struct IntegerVertexAttribute + { + types::EDataType type = types::EDataType::INT; + uint8_t count = 4; + }; + + /** + * Vertex attribute using glVertexAttribLPointer (double-precision data kept as-is). + */ + struct DoubleVertexAttribute + { + uint8_t count = 4; + }; + + using VertexAttribute = std::variant; + using VertexAttributeLayout = std::initializer_list; +} diff --git a/Dependencies/baregl/include/baregl/debug/Debug.h b/Dependencies/baregl/include/baregl/debug/Debug.h new file mode 100644 index 000000000..65cfac872 --- /dev/null +++ b/Dependencies/baregl/include/baregl/debug/Debug.h @@ -0,0 +1,35 @@ +/** +* @project: baregl +* @author: Adrien Givry +* @licence: MIT +*/ + +#pragma once + +#include +#include +#include + +#include + +namespace baregl::debug +{ + /** + * Provides an assert handler for baregl internal asserts + * @param p_handler + */ + void SetAssertHandler(std::unique_ptr p_handler); + + /** + * Provides a log handler for baregl internal logs + * @param p_handler + */ + void SetLogHandler(std::unique_ptr p_handler); + + /** + * Provides an event handler for baregl notifications + * @param p_handler + */ + void SetEventHandler(std::unique_ptr p_handler); +} + diff --git a/Dependencies/baregl/include/baregl/debug/IAssertHandler.h b/Dependencies/baregl/include/baregl/debug/IAssertHandler.h new file mode 100644 index 000000000..5a263c820 --- /dev/null +++ b/Dependencies/baregl/include/baregl/debug/IAssertHandler.h @@ -0,0 +1,31 @@ +/** +* @project: baregl +* @author: Adrien Givry +* @licence: MIT +*/ + +#pragma once + +#include + +namespace baregl::debug +{ + /** + * Base interface for custom assert handlers + */ + class IAssertHandler + { + public: + /** + * Destructor + */ + virtual ~IAssertHandler() = default; + + /** + * Invoked when an assert fail + * @param p_message + */ + virtual void OnAssert(const std::string_view p_message) = 0; + }; +} + diff --git a/Dependencies/baregl/include/baregl/debug/IEventHandler.h b/Dependencies/baregl/include/baregl/debug/IEventHandler.h new file mode 100644 index 000000000..18f31c3d0 --- /dev/null +++ b/Dependencies/baregl/include/baregl/debug/IEventHandler.h @@ -0,0 +1,118 @@ +/** +* @project: baregl +* @author: Adrien Givry +* @licence: MIT +*/ + +#pragma once + +namespace baregl +{ + class Buffer; + class Framebuffer; + class Renderbuffer; + class ShaderProgram; + class ShaderStage; + class Texture; + class VertexArray; +} + +namespace baregl::debug +{ + /** + * Base interface for custom event handlers + */ + class IEventHandler + { + public: + /** + * Destructor + */ + virtual ~IEventHandler() = default; + + /** + * Invoked when a buffer is created + * @param p_buffer + */ + virtual void OnBufferCreated(const Buffer& p_buffer) = 0; + + /** + * Invoked when a buffer is destroyed + * @param p_buffer + */ + virtual void OnBufferDestroyed(const Buffer& p_buffer) = 0; + + /** + * Invoked when a framebuffer is created + * @param p_framebuffer + */ + virtual void OnFramebufferCreated(const Framebuffer& p_framebuffer) = 0; + + /** + * Invoked when a framebuffer is destroyed + * @param p_framebuffer + */ + virtual void OnFramebufferDestroyed(const Framebuffer& p_framebuffer) = 0; + + /** + * Invoked when a renderbuffer is created + * @param p_renderbuffer + */ + virtual void OnRenderbufferCreated(const Renderbuffer& p_renderbuffer) = 0; + + /** + * Invoked when a renderbuffer is destroyed + * @param p_renderbuffer + */ + virtual void OnRenderbufferDestroyed(const Renderbuffer& p_renderbuffer) = 0; + + /** + * Invoked when a shader program is created + * @param p_shaderProgram + */ + virtual void OnShaderProgramCreated(const ShaderProgram& p_shaderProgram) = 0; + + /** + * Invoked when a shader program is destroyed + * @param p_shaderProgram + */ + virtual void OnShaderProgramDestroyed(const ShaderProgram& p_shaderProgram) = 0; + + /** + * Invoked when a shader stage is created + * @param p_shaderStage + */ + virtual void OnShaderStageCreated(const ShaderStage& p_shaderStage) = 0; + + /** + * Invoked when a shader stage is destroyed + * @param p_shaderStage + */ + virtual void OnShaderStageDestroyed(const ShaderStage& p_shaderStage) = 0; + + /** + * Invoked when a texture is created + * @param p_texture + */ + virtual void OnTextureCreated(const Texture& p_texture) = 0; + + /** + * Invoked when a texture is destroyed + * @param p_texture + */ + virtual void OnTextureDestroyed(const Texture& p_texture) = 0; + + /** + * Invoked when a vertex array is created + * @param p_vertexArray + */ + virtual void OnVertexArrayCreated(const VertexArray& p_vertexArray) = 0; + + /** + * Invoked when a vertex array is destroyed + * @param p_vertexArray + */ + virtual void OnVertexArrayDestroyed(const VertexArray& p_vertexArray) = 0; + }; +} + diff --git a/Dependencies/baregl/include/baregl/debug/ILogHandler.h b/Dependencies/baregl/include/baregl/debug/ILogHandler.h new file mode 100644 index 000000000..ee7d968ef --- /dev/null +++ b/Dependencies/baregl/include/baregl/debug/ILogHandler.h @@ -0,0 +1,43 @@ +/** +* @project: baregl +* @author: Adrien Givry +* @licence: MIT +*/ + +#pragma once + +#include + +namespace baregl::debug +{ + /** + * Base interface for custom log handlers + */ + class ILogHandler + { + public: + /** + * Destructor + */ + virtual ~ILogHandler() = default; + + /** + * Invoked when baregl wants to log an info message + * @param p_message + */ + virtual void LogInfo(const std::string_view p_message) = 0; + + /** + * Invoked when baregl wants to log a warning message + * @param p_message + */ + virtual void LogWarning(const std::string_view p_message) = 0; + + /** + * Invoked when baregl wants to log an error message + * @param p_message + */ + virtual void LogError(const std::string_view p_message) = 0; + }; +} + diff --git a/Dependencies/baregl/include/baregl/detail/NativeObject.h b/Dependencies/baregl/include/baregl/detail/NativeObject.h new file mode 100644 index 000000000..664a06307 --- /dev/null +++ b/Dependencies/baregl/include/baregl/detail/NativeObject.h @@ -0,0 +1,60 @@ +/** +* @project: baregl +* @author: Adrien Givry +* @licence: MIT +*/ + +#pragma once + +#include + +namespace baregl::detail +{ + using NativeID = uint32_t; + + /** + * Wrapper for any OpenGL object + */ + class NativeObject + { + public: + /** + * Creates an instance of native object for the OpenGL object identified by the given native ID + * @param p_id + */ + NativeObject(NativeID p_id = 0U); + + /** + * Destroys the native object (no-op) + */ + virtual ~NativeObject() = default; + + /** + * Deleted copy constructor + */ + NativeObject(const NativeObject&) = delete; + + /** + * Deleted assignment constructor + */ + NativeObject& operator=(const NativeObject&) = delete; + + /** + * Deleted move constructor + */ + NativeObject(NativeObject&&) = delete; + + /** + * Deleted move assignment constructor + */ + NativeObject& operator=(NativeObject&&) = delete; + + /** + * Returns the ID of the underlying object + */ + NativeID GetID() const; + + protected: + NativeID m_id; + }; +} diff --git a/Dependencies/glad/include/glad.h b/Dependencies/baregl/include/baregl/detail/glad/glad.h similarity index 100% rename from Dependencies/glad/include/glad.h rename to Dependencies/baregl/include/baregl/detail/glad/glad.h diff --git a/Dependencies/glad/include/khrplatform.h b/Dependencies/baregl/include/baregl/detail/glad/khrplatform.h similarity index 100% rename from Dependencies/glad/include/khrplatform.h rename to Dependencies/baregl/include/baregl/detail/glad/khrplatform.h diff --git a/Dependencies/baregl/include/baregl/math/Conversions.h b/Dependencies/baregl/include/baregl/math/Conversions.h new file mode 100644 index 000000000..1381fe400 --- /dev/null +++ b/Dependencies/baregl/include/baregl/math/Conversions.h @@ -0,0 +1,27 @@ +/** +* @project: baregl +* @author: Adrien Givry +* @licence: MIT +*/ + +#pragma once + +#include + +namespace baregl::math::conversions +{ + constexpr uint32_t _log2(float n) + { + return ((n < 2) ? 1 : 1 + _log2(n / 2)); + } + + constexpr float Pow2toFloat(uint8_t p_value) + { + return static_cast(1U << p_value); + } + + constexpr uint8_t FloatToPow2(float p_value) + { + return static_cast(_log2(p_value) - 1); + } +} diff --git a/Dependencies/baregl/include/baregl/math/Mat3.h b/Dependencies/baregl/include/baregl/math/Mat3.h new file mode 100644 index 000000000..349f437a6 --- /dev/null +++ b/Dependencies/baregl/include/baregl/math/Mat3.h @@ -0,0 +1,33 @@ +/** +* @project: baregl +* @author: Adrien Givry +* @licence: MIT +*/ + +#pragma once + +#include + +#include + +namespace baregl::math +{ + struct Mat3 + { + std::array data {{ + {0.0f, 0.0f, 0.0f}, + {0.0f, 0.0f, 0.0f}, + {0.0f, 0.0f, 0.0f} + }}; + + Vec3& operator[](int index) + { + return data[index]; + } + + const Vec3& operator[](int index) const + { + return data[index]; + } + }; +} diff --git a/Dependencies/baregl/include/baregl/math/Mat4.h b/Dependencies/baregl/include/baregl/math/Mat4.h new file mode 100644 index 000000000..315d71761 --- /dev/null +++ b/Dependencies/baregl/include/baregl/math/Mat4.h @@ -0,0 +1,34 @@ +/** +* @project: baregl +* @author: Adrien Givry +* @licence: MIT +*/ + +#pragma once + +#include + +#include + +namespace baregl::math +{ + struct Mat4 + { + std::array data {{ + {0.0f, 0.0f, 0.0f, 0.0f}, + {0.0f, 0.0f, 0.0f, 0.0f}, + {0.0f, 0.0f, 0.0f, 0.0f}, + {0.0f, 0.0f, 0.0f, 0.0f} + }}; + + Vec4& operator[](int index) + { + return data[index]; + } + + const Vec4& operator[](int index) const + { + return data[index]; + } + }; +} diff --git a/Dependencies/baregl/include/baregl/math/Vec2.h b/Dependencies/baregl/include/baregl/math/Vec2.h new file mode 100644 index 000000000..ef3c0bcc4 --- /dev/null +++ b/Dependencies/baregl/include/baregl/math/Vec2.h @@ -0,0 +1,26 @@ +/** +* @project: baregl +* @author: Adrien Givry +* @licence: MIT +*/ + +#pragma once + +namespace baregl::math +{ + struct Vec2 + { + float x = 0.0f; + float y = 0.0f; + + float& operator[](int index) + { + return (&x)[index]; + } + + const float& operator[](int index) const + { + return (&x)[index]; + } + }; +} diff --git a/Dependencies/baregl/include/baregl/math/Vec3.h b/Dependencies/baregl/include/baregl/math/Vec3.h new file mode 100644 index 000000000..5fd6da99b --- /dev/null +++ b/Dependencies/baregl/include/baregl/math/Vec3.h @@ -0,0 +1,27 @@ +/** +* @project: baregl +* @author: Adrien Givry +* @licence: MIT +*/ + +#pragma once + +namespace baregl::math +{ + struct Vec3 + { + float x = 0.0f; + float y = 0.0f; + float z = 0.0f; + + float& operator[](int index) + { + return (&x)[index]; + } + + const float& operator[](int index) const + { + return (&x)[index]; + } + }; +} diff --git a/Dependencies/baregl/include/baregl/math/Vec4.h b/Dependencies/baregl/include/baregl/math/Vec4.h new file mode 100644 index 000000000..8e0bb007f --- /dev/null +++ b/Dependencies/baregl/include/baregl/math/Vec4.h @@ -0,0 +1,28 @@ +/** +* @project: baregl +* @author: Adrien Givry +* @licence: MIT +*/ + +#pragma once + +namespace baregl::math +{ + struct Vec4 + { + float x = 0.0f; + float y = 0.0f; + float z = 0.0f; + float w = 0.0f; + + float& operator[](int index) + { + return (&x)[index]; + } + + const float& operator[](int index) const + { + return (&x)[index]; + } + }; +} diff --git a/Sources/OvRendering/include/OvRendering/Settings/EAccessSpecifier.h b/Dependencies/baregl/include/baregl/types/EAccessSpecifier.h similarity index 65% rename from Sources/OvRendering/include/OvRendering/Settings/EAccessSpecifier.h rename to Dependencies/baregl/include/baregl/types/EAccessSpecifier.h index 0103397b4..84f1ec049 100644 --- a/Sources/OvRendering/include/OvRendering/Settings/EAccessSpecifier.h +++ b/Dependencies/baregl/include/baregl/types/EAccessSpecifier.h @@ -1,6 +1,6 @@ /** -* @project: Overload -* @author: Overload Tech. +* @project: baregl +* @author: Adrien Givry * @licence: MIT */ @@ -8,10 +8,10 @@ #include -namespace OvRendering::Settings +namespace baregl::types { /** - * Defines some access hints that buffers can use + * Defines access hints that buffers can use */ enum class EAccessSpecifier : uint8_t { @@ -25,4 +25,4 @@ namespace OvRendering::Settings STATIC_READ, STATIC_COPY }; -} \ No newline at end of file +} diff --git a/Sources/OvRendering/include/OvRendering/Settings/EBlendingEquation.h b/Dependencies/baregl/include/baregl/types/EBlendingEquation.h similarity index 58% rename from Sources/OvRendering/include/OvRendering/Settings/EBlendingEquation.h rename to Dependencies/baregl/include/baregl/types/EBlendingEquation.h index e18221771..6015c9156 100644 --- a/Sources/OvRendering/include/OvRendering/Settings/EBlendingEquation.h +++ b/Dependencies/baregl/include/baregl/types/EBlendingEquation.h @@ -1,6 +1,6 @@ /** -* @project: Overload -* @author: Overload Tech. +* @project: baregl +* @author: Adrien Givry * @licence: MIT */ @@ -8,10 +8,10 @@ #include -namespace OvRendering::Settings +namespace baregl::types { /** - * Blending equations used by the blending operations + * Blending equations used by blending operations */ enum class EBlendingEquation : uint8_t { diff --git a/Sources/OvRendering/include/OvRendering/Settings/EBlendingFactor.h b/Dependencies/baregl/include/baregl/types/EBlendingFactor.h similarity index 78% rename from Sources/OvRendering/include/OvRendering/Settings/EBlendingFactor.h rename to Dependencies/baregl/include/baregl/types/EBlendingFactor.h index 4e5ed8d6f..f5f40fd2c 100644 --- a/Sources/OvRendering/include/OvRendering/Settings/EBlendingFactor.h +++ b/Dependencies/baregl/include/baregl/types/EBlendingFactor.h @@ -1,6 +1,6 @@ /** -* @project: Overload -* @author: Overload Tech. +* @project: baregl +* @author: Adrien Givry * @licence: MIT */ @@ -8,10 +8,10 @@ #include -namespace OvRendering::Settings +namespace baregl::types { /** - * Blending factors used for blending operations + * Blending factors used by blending operations */ enum class EBlendingFactor : uint8_t { diff --git a/Sources/OvRendering/include/OvRendering/Settings/EBufferType.h b/Dependencies/baregl/include/baregl/types/EBufferType.h similarity index 71% rename from Sources/OvRendering/include/OvRendering/Settings/EBufferType.h rename to Dependencies/baregl/include/baregl/types/EBufferType.h index 3f6031d6d..0029d5633 100644 --- a/Sources/OvRendering/include/OvRendering/Settings/EBufferType.h +++ b/Dependencies/baregl/include/baregl/types/EBufferType.h @@ -1,6 +1,6 @@ /** -* @project: Overload -* @author: Overload Tech. +* @project: baregl +* @author: Adrien Givry * @licence: MIT */ @@ -8,7 +8,7 @@ #include -namespace OvRendering::Settings +namespace baregl::types { /** * Enumeration of buffer types diff --git a/Sources/OvRendering/include/OvRendering/Settings/EComparaisonAlgorithm.h b/Dependencies/baregl/include/baregl/types/EComparaisonAlgorithm.h similarity index 77% rename from Sources/OvRendering/include/OvRendering/Settings/EComparaisonAlgorithm.h rename to Dependencies/baregl/include/baregl/types/EComparaisonAlgorithm.h index 74ac73b1f..3105f0319 100644 --- a/Sources/OvRendering/include/OvRendering/Settings/EComparaisonAlgorithm.h +++ b/Dependencies/baregl/include/baregl/types/EComparaisonAlgorithm.h @@ -1,6 +1,6 @@ /** -* @project: Overload -* @author: Overload Tech. +* @project: baregl +* @author: Adrien Givry * @licence: MIT */ @@ -8,7 +8,7 @@ #include -namespace OvRendering::Settings +namespace baregl::types { /** * Comparaison algorithm used by depth/stencil operations diff --git a/Dependencies/baregl/include/baregl/types/EContextFlags.h b/Dependencies/baregl/include/baregl/types/EContextFlags.h new file mode 100644 index 000000000..a60d90983 --- /dev/null +++ b/Dependencies/baregl/include/baregl/types/EContextFlags.h @@ -0,0 +1,28 @@ +/** +* @project: baregl +* @author: Adrien Givry +* @licence: MIT +*/ + +#pragma once + +#include + +#include + +namespace baregl::types +{ + /** + * OpenGL context creation flags. + */ + enum class EContextFlags : uint32_t + { + NONE = 0, + FORWARD_COMPATIBLE = 0x00000001, + DEBUG_BIT = 0x00000002, + ROBUST_ACCESS = 0x00000004, + NO_ERROR = 0x00000008 + }; +} + +ENABLE_BITMASK_OPERATORS(baregl::types::EContextFlags); diff --git a/Sources/OvRendering/include/OvRendering/Settings/ECullFace.h b/Dependencies/baregl/include/baregl/types/ECullFace.h similarity index 68% rename from Sources/OvRendering/include/OvRendering/Settings/ECullFace.h rename to Dependencies/baregl/include/baregl/types/ECullFace.h index 49407d885..e1cd46145 100644 --- a/Sources/OvRendering/include/OvRendering/Settings/ECullFace.h +++ b/Dependencies/baregl/include/baregl/types/ECullFace.h @@ -1,6 +1,6 @@ /** -* @project: Overload -* @author: Overload Tech. +* @project: baregl +* @author: Adrien Givry * @licence: MIT */ @@ -8,7 +8,7 @@ #include -namespace OvRendering::Settings +namespace baregl::types { /** * Enumeration of cullable face @@ -19,4 +19,4 @@ namespace OvRendering::Settings BACK, FRONT_AND_BACK }; -} \ No newline at end of file +} diff --git a/Sources/OvRendering/include/OvRendering/Settings/EDataType.h b/Dependencies/baregl/include/baregl/types/EDataType.h similarity index 74% rename from Sources/OvRendering/include/OvRendering/Settings/EDataType.h rename to Dependencies/baregl/include/baregl/types/EDataType.h index c295172aa..4825b8a2d 100644 --- a/Sources/OvRendering/include/OvRendering/Settings/EDataType.h +++ b/Dependencies/baregl/include/baregl/types/EDataType.h @@ -1,6 +1,6 @@ /** -* @project: Overload -* @author: Overload Tech. +* @project: baregl +* @author: Adrien Givry * @licence: MIT */ @@ -8,7 +8,7 @@ #include -namespace OvRendering::Settings +namespace baregl::types { /** * Enumeration of data types diff --git a/Dependencies/baregl/include/baregl/types/EDrawBuffer.h b/Dependencies/baregl/include/baregl/types/EDrawBuffer.h new file mode 100644 index 000000000..37d969419 --- /dev/null +++ b/Dependencies/baregl/include/baregl/types/EDrawBuffer.h @@ -0,0 +1,44 @@ +/** +* @project: baregl +* @author: Adrien Givry +* @licence: MIT +*/ + +#pragma once + +#include + +namespace baregl::types +{ + /** + * Read/draw buffer selector. + */ + enum class EDrawBuffer : uint32_t + { + NONE, + FRONT_LEFT, + FRONT_RIGHT, + BACK_LEFT, + BACK_RIGHT, + FRONT, + BACK, + LEFT, + RIGHT, + COLOR_ATTACHMENT0, + COLOR_ATTACHMENT1, + COLOR_ATTACHMENT2, + COLOR_ATTACHMENT3, + COLOR_ATTACHMENT4, + COLOR_ATTACHMENT5, + COLOR_ATTACHMENT6, + COLOR_ATTACHMENT7, + COLOR_ATTACHMENT8, + COLOR_ATTACHMENT9, + COLOR_ATTACHMENT10, + COLOR_ATTACHMENT11, + COLOR_ATTACHMENT12, + COLOR_ATTACHMENT13, + COLOR_ATTACHMENT14, + COLOR_ATTACHMENT15 + }; +} diff --git a/Sources/OvRendering/include/OvRendering/Settings/EFormat.h b/Dependencies/baregl/include/baregl/types/EFormat.h similarity index 79% rename from Sources/OvRendering/include/OvRendering/Settings/EFormat.h rename to Dependencies/baregl/include/baregl/types/EFormat.h index 6cb23951f..74ee789dc 100644 --- a/Sources/OvRendering/include/OvRendering/Settings/EFormat.h +++ b/Dependencies/baregl/include/baregl/types/EFormat.h @@ -1,6 +1,6 @@ /** -* @project: Overload -* @author: Overload Tech. +* @project: baregl +* @author: Adrien Givry * @licence: MIT */ @@ -8,7 +8,7 @@ #include -namespace OvRendering::Settings +namespace baregl::types { /** * Enumeration of formats @@ -31,4 +31,4 @@ namespace OvRendering::Settings DEPTH_COMPONENT, DEPTH_STENCIL }; -} \ No newline at end of file +} diff --git a/Sources/OvRendering/include/OvRendering/Settings/EFramebufferAttachment.h b/Dependencies/baregl/include/baregl/types/EFramebufferAttachment.h similarity index 58% rename from Sources/OvRendering/include/OvRendering/Settings/EFramebufferAttachment.h rename to Dependencies/baregl/include/baregl/types/EFramebufferAttachment.h index f6f366ee4..a2762597e 100644 --- a/Sources/OvRendering/include/OvRendering/Settings/EFramebufferAttachment.h +++ b/Dependencies/baregl/include/baregl/types/EFramebufferAttachment.h @@ -1,6 +1,6 @@ /** -* @project: Overload -* @author: Overload Tech. +* @project: baregl +* @author: Adrien Givry * @licence: MIT */ @@ -8,10 +8,10 @@ #include -namespace OvRendering::Settings +namespace baregl::types { /** - * Enumeration of framebuffer attachments + * Enumeration of framebuffer attachment types */ enum class EFramebufferAttachment : uint8_t { diff --git a/Dependencies/baregl/include/baregl/types/EGetParameter.h b/Dependencies/baregl/include/baregl/types/EGetParameter.h new file mode 100644 index 000000000..b44ef9b8e --- /dev/null +++ b/Dependencies/baregl/include/baregl/types/EGetParameter.h @@ -0,0 +1,777 @@ +/** +* @project: baregl +* @author: Adrien Givry +* @licence: MIT +*/ + +#pragma once + +#include + +namespace baregl::types +{ + /** + * Parameter that can be use to retrieve associated values through GetX functions. + */ + enum class EGetParameter : uint16_t + { + // Current Values and Associated Data + PATCH_VERTICES, // 1 int + PATCH_DEFAULT_OUTER_LEVEL, // 4 floats + PATCH_DEFAULT_INNER_LEVEL, // 2 floats + + // Vertex Array Object State + // VERTEX_ATTRIB_ARRAY_ENABLED, // GetVertexAttribiv + // VERTEX_ATTRIB_ARRAY_SIZE, // GetVertexAttribiv + // VERTEX_ATTRIB_ARRAY_STRIDE, // GetVertexAttribiv + // VERTEX_ATTRIB_ARRAY_TYPE, // GetVertexAttribiv + // VERTEX_ATTRIB_ARRAY_NORMALIZED, // GetVertexAttribiv + // VERTEX_ATTRIB_ARRAY_INTEGER, // GetVertexAttribiv + // VERTEX_ATTRIB_ARRAY_LONG, // GetVertexAttribiv + // VERTEX_ATTRIB_ARRAY_DIVISOR, // GetVertexAttribiv + // VERTEX_ATTRIB_ARRAY_POINTER, // GetVertexAttribiv + // GetObjectLabel (string) + ELEMENT_ARRAY_BUFFER_BINDING, // 1 int + // VERTEX_ATTRIB_ARRAY_BUFFER_BINDING, // GetVertexAttribiv + // VERTEX_ATTRIB_BINDING, // GetVertexAttribiv + // VERTEX_ATTRIB_RELATIVE_OFFSET, // GetVertexAttribiv + VERTEX_BINDING_OFFSET, // 1 int64 (indexed) + VERTEX_BINDING_STRIDE, // 1 int (indexed) + VERTEX_BINDING_DIVISOR, // 1 int (indexed) + VERTEX_BINDING_BUFFER, // 1 int (indexed) + + // Vertex Array Data (not in Vertex Array objects) + ARRAY_BUFFER_BINDING, // 1 int + DRAW_INDIRECT_BUFFER_BINDING, // 1 int + VERTEX_ARRAY_BINDING, // 1 int + PRIMITIVE_RESTART, // 1 boolean + PRIMITIVE_RESTART_FIXED_INDEX, // 1 boolean + PRIMITIVE_RESTART_INDEX, // 1 int + + // Buffer Object State + // GetBufferSubData(), + // BUFFER_SIZE, // n int64 (GetBufferParameteri64v) + // BUFFER_USAGE, // n int (GetBufferParameteriv) + // BUFFER_ACCESS, // n int (GetBufferParameteriv) + // BUFFER_ACCESS_FLAGS, // n int (GetBufferParameteriv) + // BUFFER_IMMUTABLE_STORAGE, // n bool (GetBufferParameteriv) + // BUFFER_STORAGE_FLAGS, // n int (GetBufferParameteriv) + // BUFFER_MAPPED, // n bool (GetBufferParameteriv) + // BUFFER_MAP_POINTER, // n pointer (GetBufferPointerv) + // BUFFER_MAP_OFFSET, // n int64 (GetBufferParameteri64v) + // BUFFER_MAP_LENGTH, // n int64 (GetBufferParameteri64v) + // GetObjectLabel (string) + + // Transformation state + VIEWPORT, // 4 float (or indexed) + DEPTH_RANGE, // 2 doubles/floats (or indexed) + CLIP_DISTANCE0, // 1 boolean + CLIP_DISTANCE1, // 1 boolean + CLIP_DISTANCE2, // 1 boolean + CLIP_DISTANCE3, // 1 boolean + CLIP_DISTANCE4, // 1 boolean + CLIP_DISTANCE5, // 1 boolean + CLIP_DISTANCE6, // 1 boolean + CLIP_DISTANCE7, // 1 boolean + CLIP_ORIGIN, // 1 int (GLenum) + CLIP_DEPTH_MODE, // 1 int (GLenum) + DEPTH_CLAMP, // 1 boolean + TRANSFORM_FEEDBACK_BINDING, // 1 int + + // Coloring + CLAMP_READ_COLOR, // 1 int (GLenum) + PROVOKING_VERTEX, // 1 int (GLenum) + + // Rasterization + RASTERIZER_DISCARD, // 1 boolean + POINT_SIZE, // 1 float + POINT_FADE_THRESHOLD_SIZE, // 1 float + POINT_SPRITE_COORD_ORIGIN, // 1 int (GLenum) + LINE_WIDTH, // 1 float + LINE_SMOOTH, // 1 boolean + CULL_FACE, // 1 boolean + CULL_FACE_MODE, // 1 int (GLenum) + FRONT_FACE, // 1 int (GLenum) + POLYGON_SMOOTH, // 1 boolean + POLYGON_MODE, // 1 int (GLenum) + POLYGON_OFFSET_FACTOR, // 1 float + POLYGON_OFFSET_UNITS, // 1 float + POLYGON_OFFSET_POINT, // 1 boolean + POLYGON_OFFSET_LINE, // 1 boolean + POLYGON_OFFSET_FILL, // 1 boolean + + // Multisampling + MULTISAMPLE, // 1 boolean + SAMPLE_ALPHA_TO_COVERAGE, // 1 boolean + SAMPLE_ALPHA_TO_ONE, // 1 boolean + SAMPLE_COVERAGE, // 1 boolean + SAMPLE_COVERAGE_VALUE, // 1 float + SAMPLE_COVERAGE_INVERT, // 1 boolean + SAMPLE_SHADING, // 1 boolean + MIN_SAMPLE_SHADING_VALUE, // 1 float + SAMPLE_MASK, // 1 boolean + SAMPLE_MASK_VALUE, // 1 int (indexed) + + // Textures (state per texture unit) + TEXTURE_BINDING_1D, // 1 int + TEXTURE_BINDING_2D, // 1 int + TEXTURE_BINDING_3D, // 1 int + TEXTURE_BINDING_1D_ARRAY, // 1 int + TEXTURE_BINDING_2D_ARRAY, // 1 int + TEXTURE_BINDING_CUBE_MAP_ARRAY, // 1 int + TEXTURE_BINDING_RECTANGLE, // 1 int + TEXTURE_BINDING_BUFFER, // 1 int + TEXTURE_BINDING_CUBE_MAP, // 1 int + TEXTURE_BINDING_2D_MULTISAMPLE, // 1 int + TEXTURE_BINDING_2D_MULTISAMPLE_ARRAY, // 1 int + SAMPLER_BINDING, // 1 int + // TEXTURE_1D, // image data (GetTexImage) + // TEXTURE_2D, // image data (GetTexImage) + // TEXTURE_3D, // image data (GetTexImage) + // TEXTURE_1D_ARRAY, // image data (GetTexImage) + // TEXTURE_2D_ARRAY, // image data (GetTexImage) + // TEXTURE_CUBE_MAP_ARRAY, // image data (GetTexImage) + // TEXTURE_RECTANGLE, // image data (GetTexImage) + // TEXTURE_CUBE_MAP_POSITIVE_X, // image data (GetTexImage) + // TEXTURE_CUBE_MAP_NEGATIVE_X, // image data (GetTexImage) + // TEXTURE_CUBE_MAP_POSITIVE_Y, // image data (GetTexImage) + // TEXTURE_CUBE_MAP_NEGATIVE_Y, // image data (GetTexImage) + // TEXTURE_CUBE_MAP_POSITIVE_Z, // image data (GetTexImage) + // TEXTURE_CUBE_MAP_NEGATIVE_Z, // image data (GetTexImage) + + // Textures (state per texture object) + // TEXTURE_SWIZZLE_R, // 1 int (GetTexParameteriv / GetSamplerParameteriv) + // TEXTURE_SWIZZLE_G, // 1 int (GetTexParameteriv / GetSamplerParameteriv) + // TEXTURE_SWIZZLE_B, // 1 int (GetTexParameteriv / GetSamplerParameteriv) + // TEXTURE_SWIZZLE_A, // 1 int (GetTexParameteriv / GetSamplerParameteriv) + // TEXTURE_BORDER_COLOR, // 4 floats/ints (GetTexParameter* / GetSamplerParameter*) + // TEXTURE_MIN_FILTER, // 1 int (GetTexParameteriv / GetSamplerParameteriv) + // TEXTURE_MAG_FILTER, // 1 int (GetTexParameteriv / GetSamplerParameteriv) + // TEXTURE_WRAP_S, // 1 int (GetTexParameteriv / GetSamplerParameteriv) + // TEXTURE_WRAP_T, // 1 int (GetTexParameteriv / GetSamplerParameteriv) + // TEXTURE_WRAP_R, // 1 int (GetTexParameteriv / GetSamplerParameteriv) + // TEXTURE_TARGET, // 1 int (GetTextureParameteriv) + // TEXTURE_MIN_LOD, // 1 float (GetTexParameterfv / GetSamplerParameterfv) + // TEXTURE_MAX_LOD, // 1 float (GetTexParameterfv / GetSamplerParameterfv) + // TEXTURE_BASE_LEVEL, // 1 int (GetTexParameteriv) + // TEXTURE_MAX_LEVEL, // 1 int (GetTexParameteriv) + // TEXTURE_LOD_BIAS, // 1 float (GetTexParameterfv / GetSamplerParameterfv) + // DEPTH_STENCIL_TEXTURE_MODE, // 1 int (GetTexParameteriv) + // TEXTURE_COMPARE_MODE, // 1 int (GetTexParameteriv / GetSamplerParameteriv) + // TEXTURE_COMPARE_FUNC, // 1 int (GetTexParameteriv / GetSamplerParameteriv) + // IMAGE_FORMAT_COMPATIBILITY_TYPE, // 1 int (GetTexParameteriv) + // TEXTURE_IMMUTABLE_FORMAT, // 1 bool (GetTexParameteriv) + // TEXTURE_IMMUTABLE_LEVELS, // 1 int (GetTexParameteriv) + // TEXTURE_VIEW_MIN_LEVEL, // 1 int (GetTexParameteriv) + // TEXTURE_VIEW_NUM_LEVELS, // 1 int (GetTexParameteriv) + // TEXTURE_VIEW_MIN_LAYER, // 1 int (GetTexParameteriv) + // TEXTURE_VIEW_NUM_LAYERS, // 1 int (GetTexParameteriv) + // _, (GetObjectLabel) + + // Textures (state per texture image) + // TEXTURE_WIDTH, // 1 int (GetTexLevelParameteriv) + // TEXTURE_HEIGHT, // 1 int (GetTexLevelParameteriv) + // TEXTURE_DEPTH, // 1 int (GetTexLevelParameteriv) + // TEXTURE_SAMPLES, // 1 int (GetTexLevelParameteriv) + // TEXTURE_FIXED_SAMPLE_LOCATIONS, // 1 bool (GetTexLevelParameteriv) + // TEXTURE_INTERNAL_FORMAT, // 1 GLenum (GetTexLevelParameteriv) + // TEXTURE_RED_SIZE, // 1 int (GetTexLevelParameteriv) + // TEXTURE_GREEN_SIZE, // 1 int (GetTexLevelParameteriv) + // TEXTURE_BLUE_SIZE, // 1 int (GetTexLevelParameteriv) + // TEXTURE_ALPHA_SIZE, // 1 int (GetTexLevelParameteriv) + // TEXTURE_DEPTH_SIZE, // 1 int (GetTexLevelParameteriv) + // TEXTURE_STENCIL_SIZE, // 1 int (GetTexLevelParameteriv) + // TEXTURE_SHARED_SIZE, // 1 int (GetTexLevelParameteriv) + // TEXTURE_RED_TYPE, // 1 GLenum (GetTexLevelParameteriv) + // TEXTURE_GREEN_TYPE, // 1 GLenum (GetTexLevelParameteriv) + // TEXTURE_BLUE_TYPE, // 1 GLenum (GetTexLevelParameteriv) + // TEXTURE_ALPHA_TYPE, // 1 GLenum (GetTexLevelParameteriv) + // TEXTURE_DEPTH_TYPE, // 1 GLenum (GetTexLevelParameteriv) + // TEXTURE_STENCIL_TYPE, // 1 GLenum (GetTexLevelParameteriv) + // TEXTURE_COMPRESSED, // 1 bool (GetTexLevelParameteriv) + // TEXTURE_COMPRESSED_IMAGE_SIZE, // 1 int (GetTexLevelParameteriv) + // TEXTURE_BUFFER_DATA_STORE_BINDING, // 1 int (GetTexLevelParameteriv) + // TEXTURE_BUFFER_OFFSET, // 1 int (GetTexLevelParameteriv) + // TEXTURE_BUFFER_SIZE, // 1 int (GetTexLevelParameteriv) + + // Textures (state per sampler object) + // TEXTURE_BORDER_COLOR, // GetSamplerParameterfv + // TEXTURE_COMPARE_FUNC, // GetSamplerParameterfv + // TEXTURE_COMPARE_MODE, // GetSamplerParameterfv + // TEXTURE_LOD_BIAS, // GetSamplerParameterfv + // TEXTURE_MAX_LOD, // GetSamplerParameterfv + // TEXTURE_MAG_FILTER, // GetSamplerParameterfv + // TEXTURE_MIN_FILTER, // GetSamplerParameterfv + // TEXTURE_MIN_LOD, // GetSamplerParameterfv + // TEXTURE_WRAP_S, // GetSamplerParameterfv + // TEXTURE_WRAP_T, // GetSamplerParameterfv + // TEXTURE_WRAP_R, // GetSamplerParameterfv + // _, // GetObjectLabel + + // Texture Environment and Generation + ACTIVE_TEXTURE, // 1 int (GLenum) + + // Pixel Operations + SCISSOR_TEST, // 1 boolean (indexed) + SCISSOR_BOX, // 4 ints (indexed) + STENCIL_TEST, // 1 boolean + STENCIL_FUNC, // 1 int (GLenum) + STENCIL_VALUE_MASK, // 1 int + STENCIL_REF, // 1 int + STENCIL_FAIL, // 1 int (GLenum) + STENCIL_PASS_DEPTH_FAIL, // 1 int (GLenum) + STENCIL_PASS_DEPTH_PASS, // 1 int (GLenum) + STENCIL_BACK_FUNC, // 1 int (GLenum) + STENCIL_BACK_VALUE_MASK, // 1 int + STENCIL_BACK_REF, // 1 int + STENCIL_BACK_FAIL, // 1 int (GLenum) + STENCIL_BACK_PASS_DEPTH_FAIL, // 1 int (GLenum) + STENCIL_BACK_PASS_DEPTH_PASS, // 1 int (GLenum) + DEPTH_TEST, // 1 boolean + DEPTH_FUNC, // 1 int (GLenum) + BLEND, // 1 boolean (indexed) + BLEND_SRC_RGB, // 1 int (GLenum) (indexed) + BLEND_SRC_ALPHA, // 1 int (GLenum) (indexed) + BLEND_DST_RGB, // 1 int (GLenum) (indexed) + BLEND_DST_ALPHA, // 1 int (GLenum) (indexed) + BLEND_EQUATION_RGB, // 1 int (GLenum) (indexed) + BLEND_EQUATION_ALPHA, // 1 int (GLenum) (indexed) + BLEND_COLOR, // 4 floats + FRAMEBUFFER_SRGB, // 1 boolean + DITHER, // 1 boolean + COLOR_LOGIC_OP, // 1 boolean + LOGIC_OP_MODE, // 1 int (GLenum) + + // Framebuffer Control + COLOR_WRITEMASK, // 4 booleans (or indexed) + DEPTH_WRITEMASK, // 1 boolean + STENCIL_WRITEMASK, // 1 int + STENCIL_BACK_WRITEMASK, // 1 int + COLOR_CLEAR_VALUE, // 4 floats + DEPTH_CLEAR_VALUE, // 1 double/float + STENCIL_CLEAR_VALUE, // 1 int + + // Framebuffer (state per target binding point) + DRAW_FRAMEBUFFER_BINDING, // 1 int + READ_FRAMEBUFFER_BINDING, // 1 int + + // Framebuffer (state per framebuffer object) + DRAW_BUFFER, // 1 int (GLenum) + DRAW_BUFFER0, // 1 int (GLenum) + DRAW_BUFFER1, // 1 int (GLenum) + DRAW_BUFFER2, // 1 int (GLenum) + DRAW_BUFFER3, // 1 int (GLenum) + DRAW_BUFFER4, // 1 int (GLenum) + DRAW_BUFFER5, // 1 int (GLenum) + DRAW_BUFFER6, // 1 int (GLenum) + DRAW_BUFFER7, // 1 int (GLenum) + DRAW_BUFFER8, // 1 int (GLenum) + DRAW_BUFFER9, // 1 int (GLenum) + DRAW_BUFFER10, // 1 int (GLenum) + DRAW_BUFFER11, // 1 int (GLenum) + DRAW_BUFFER12, // 1 int (GLenum) + DRAW_BUFFER13, // 1 int (GLenum) + DRAW_BUFFER14, // 1 int (GLenum) + DRAW_BUFFER15, // 1 int (GLenum) + READ_BUFFER, // 1 int (GLenum) + // FRAMEBUFFER_DEFAULT_WIDTH, // 1 int (GetFramebufferParameteriv) + // FRAMEBUFFER_DEFAULT_HEIGHT, // 1 int (GetFramebufferParameteriv) + // FRAMEBUFFER_DEFAULT_LAYERS, // 1 int (GetFramebufferParameteriv) + // FRAMEBUFFER_DEFAULT_SAMPLES, // 1 int (GetFramebufferParameteriv) + // FRAMEBUFFER_DEFAULT_FIXED_SAMPLE_LOCATIONS, // 1 bool (GetFramebufferParameteriv) + // _, // GetObjectLabel + + // Framebuffer (state per framebuffer object) + // FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE, // 1 int (GLenum) (GetFramebufferAttachmentParameteriv) + // FRAMEBUFFER_ATTACHMENT_OBJECT_NAME, // 1 int (GetFramebufferAttachmentParameteriv) + // FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL, // 1 int (GetFramebufferAttachmentParameteriv) + // FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE, // 1 int (GLenum) (GetFramebufferAttachmentParameteriv) + // FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER, // 1 int (GetFramebufferAttachmentParameteriv) + // FRAMEBUFFER_ATTACHMENT_LAYERED, // 1 boolean (GetFramebufferAttachmentParameteriv) + // FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING, // 1 int (GLenum) (GetFramebufferAttachmentParameteriv) + // FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE, // 1 int (GLenum) (GetFramebufferAttachmentParameteriv) + // FRAMEBUFFER_ATTACHMENT_RED_SIZE, // 1 int (GetFramebufferAttachmentParameteriv) + // FRAMEBUFFER_ATTACHMENT_GREEN_SIZE, // 1 int (GetFramebufferAttachmentParameteriv) + // FRAMEBUFFER_ATTACHMENT_BLUE_SIZE, // 1 int (GetFramebufferAttachmentParameteriv) + // FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE, // 1 int (GetFramebufferAttachmentParameteriv) + // FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE, // 1 int (GetFramebufferAttachmentParameteriv) + // FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE, // 1 int (GetFramebufferAttachmentParameteriv) + + // Renderbuffer (state per target and binding point) + RENDERBUFFER_BINDING, // 1 int + + // Renderbuffer (state per renderbuffer object) + // RENDERBUFFER_WIDTH, // 1 int (GetRenderbufferParameteriv) + // RENDERBUFFER_HEIGHT, // 1 int (GetRenderbufferParameteriv) + // RENDERBUFFER_INTERNAL_FORMAT, // 1 GLenum (GetRenderbufferParameteriv) + // RENDERBUFFER_RED_SIZE, // 1 int (GetRenderbufferParameteriv) + // RENDERBUFFER_GREEN_SIZE, // 1 int (GetRenderbufferParameteriv) + // RENDERBUFFER_BLUE_SIZE, // 1 int (GetRenderbufferParameteriv) + // RENDERBUFFER_ALPHA_SIZE, // 1 int (GetRenderbufferParameteriv) + // RENDERBUFFER_DEPTH_SIZE, // 1 int (GetRenderbufferParameteriv) + // RENDERBUFFER_STENCIL_SIZE, // 1 int (GetRenderbufferParameteriv) + // RENDERBUFFER_SAMPLES, // 1 int (GetRenderbufferParameteriv) + // _, // GetObjectLabel + + // Pixels + UNPACK_SWAP_BYTES, // 1 boolean + UNPACK_LSB_FIRST, // 1 boolean + UNPACK_IMAGE_HEIGHT, // 1 int + UNPACK_SKIP_IMAGES, // 1 int + UNPACK_ROW_LENGTH, // 1 int + UNPACK_SKIP_ROWS, // 1 int + UNPACK_SKIP_PIXELS, // 1 int + UNPACK_ALIGNMENT, // 1 int + UNPACK_COMPRESSED_BLOCK_WIDTH, // 1 int + UNPACK_COMPRESSED_BLOCK_HEIGHT, // 1 int + UNPACK_COMPRESSED_BLOCK_DEPTH, // 1 int + UNPACK_COMPRESSED_BLOCK_SIZE, // 1 int + PIXEL_UNPACK_BUFFER_BINDING, // 1 int + PACK_SWAP_BYTES, // 1 boolean + PACK_LSB_FIRST, // 1 boolean + PACK_IMAGE_HEIGHT, // 1 int + PACK_SKIP_IMAGES, // 1 int + PACK_ROW_LENGTH, // 1 int + PACK_SKIP_ROWS, // 1 int + PACK_SKIP_PIXELS, // 1 int + PACK_ALIGNMENT, // 1 int + PACK_COMPRESSED_BLOCK_WIDTH, // 1 int + PACK_COMPRESSED_BLOCK_HEIGHT, // 1 int + PACK_COMPRESSED_BLOCK_DEPTH, // 1 int + PACK_COMPRESSED_BLOCK_SIZE, // 1 int + PIXEL_PACK_BUFFER_BINDING, // 1 int + + // Shader Object State + // SHADER_TYPE, // 1 int (GetShaderiv) + // DELETE_STATUS, // 1 bool (GetShaderiv) + // COMPILE_STATUS, // 1 bool (GetShaderiv) + // _, // GetShaderInfoLog + // INFO_LOG_LENGTH, // 1 int (GetShaderiv) + // SHADER_SOURCE_LENGTH, // 1 int (GetShaderiv) + // _, // GetObjectLabel + + // Program Pipeline Object State + // ACTIVE_PROGRAM, // 1 int (GetProgramPipelineiv) + // VERTEX_SHADER, // 1 int (GetProgramPipelineiv) + // GEOMETRY_SHADER, // 1 int (GetProgramPipelineiv) + // FRAGMENT_SHADER, // 1 int (GetProgramPipelineiv) + // COMPUTE_SHADER, // 1 int (GetProgramPipelineiv) + // TESS_CONTROL_SHADER, // 1 int (GetProgramPipelineiv) + // TESS_EVALUATION_SHADER, // 1 int (GetProgramPipelineiv) + // VALIDATE_STATUS, // 1 bool (GetProgramPipelineiv) + // _, // GetProgramPipelineInfoLog + // INFO_LOG_LENGTH, // 1 int (GetProgramPipelineiv) + // _, // GetObjectLabel + + // Program Object State + CURRENT_PROGRAM, // 1 int + PROGRAM_PIPELINE_BINDING, // 1 int + // PROGRAM_SEPARABLE, // 1 bool (GetProgramiv) + // DELETE_STATUS, // 1 bool (GetProgramiv) + // LINK_STATUS, // 1 bool (GetProgramiv) + // VALIDATE_STATUS, // 1 bool (GetProgramiv) + // ATTACHED_SHADERS, // 1 int (GetProgramiv) + // _, // GetAttachedShaders + // _, // GetProgramInfoLog + // INFO_LOG_LENGTH, // 1 int (GetProgramiv) + // PROGRAM_BINARY_LENGTH, // 1 int (GetProgramiv) + // PROGRAM_BINARY_RETRIEVABLE_HINT, // 1 bool (GetProgramiv) + // _, // GetProgramBinary + // COMPUTE_WORK_GROUP_SIZE, // 3 ints (GetProgramiv) + // _, // GetObjectLabel + // ACTIVE_UNIFORMS, // 1 int (GetProgramiv) + // _, // GetProgramiv + // _, // GetActiveUniform + // _, // GetActiveUniform + // _, // GetActiveUniform + // ACTIVE_UNIFORM_MAX_LENGTH, // 1 int (GetProgramiv) + // _, // GetUniform + // ACTIVE_ATTRIBUTES, // 1 int (GetProgramiv) + // _, // GetAttribLocation + // _, // GetActiveAttrib + // _, // GetActiveAttrib + // _, // GetActiveAttrib + // ACTIVE_ATTRIBUTE_MAX_LENGTH, // 1 int (GetProgramiv) + // GEOMETRY_VERTICES_OUT, // 1 int (GetProgramiv) + // GEOMETRY_INPUT_TYPE, // 1 GLenum (GetProgramiv) + // GEOMETRY_OUTPUT_TYPE, // 1 GLenum (GetProgramiv) + // GEOMETRY_SHADER_INVOCATIONS, // 1 int (GetProgramiv) + // TRANSFORM_FEEDBACK_BUFFER_MODE, // 1 GLenum (GetProgramiv) + // TRANSFORM_FEEDBACK_VARYINS, // 1 int (GetProgramiv) + // TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH, // 1 int (GetProgramiv) + // _, // 1 int (GetTransformFeedbackVarying) + // _, // 1 int (GetTransformFeedbackVarying) + // _, // 1 int (GetTransformFeedbackVarying) + // ACTIVE_UNIFORM_BLOCKS, // 1 int (GetProgramiv) + // ACTIVE_UNIFORM_BLOCKS_MAX_NAME_LENGTH, // 1 int (GetProgramiv) + // UNIFORM_TYPE, // n int (GetActiveUniformsiv) + // UNIFORM_SIZE, // n int (GetActiveUniformsiv) + // UNIFORM_NAME_LENGTH, // n int (GetActiveUniformsiv) + // UNIFORM_BLOCK_INDEX, // n int (GetActiveUniformsiv) + // UNIFORM_OFFSET, // n int (GetActiveUniformsiv) + // UNIFORM_ARRAY_STRIDE, // n int (GetActiveUniformsiv) + // UNIFORM_MATRIX_STRIDE, // n int (GetActiveUniformsiv) + // UNIFORM_IS_ROW_MAJOR, // n booleans (GetActiveUniformsiv) + // UNIFORM_BLOCK_BINDING, // 1 int (GetActiveUniformsiv) + // UNIFORM_BLOCK_DATA_SIZE, // 1 int (GetActiveUniformBlockiv) + // UNIFORM_BLOCK_NAME_LENGTH, // 1 int (GetActiveUniformBlockiv) + // UNIFORM_BLOCK_ACTIVE_UNIFORMS, // 1 int (GetActiveUniformBlockiv) + // UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES, // n int (GetActiveUniformBlockiv) + // UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER, // 1 boolean (GetActiveUniformBlockiv) + // UNIFORM_BLOCK_REFERENCED_BY_TESS_CONTROL_SHADER,// 1 boolean (GetActiveUniformBlockiv) + // UNIFORM_BLOCK_REFERENCED_BY_TESS_EVALUATION_SHADER, // 1 boolean (GetActiveUniformBlockiv) + // UNIFORM_BLOCK_REFERENCED_BY_GEOMETRY_SHADER, // 1 boolean (GetActiveUniformBlockiv) + // UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER, // 1 boolean (GetActiveUniformBlockiv) + // UNIFORM_BLOCK_REFERENCED_BY_COMPUTE_SHADER, // 1 boolean (GetActiveUniformBlockiv) + // TESS_CONTROL_OUTPUT_VERTICES, // 1 int (GetProgramiv) + // TESS_GEN_MODE, // 1 GLenum (GetProgramiv) + // TESS_GEN_SPACING, // 1 GLenum (GetProgramiv) + // TESS_GEN_VERTEX_ORDER, // 1 GLenum (GetProgramiv) + // TESS_GEN_POINT_MODE, // 1 bool (GetProgramiv) + // ACTIVE_SUBROUTINE_UNIFORM_LOCATIONS, // n int (GetProgramStageiv) + // ACTIVE_SUBROUTINE_UNIFORMS, // n int (GetProgramStageiv) + // ACTIVE_SUBROUTINES, // n int (GetProgramStageiv) + // ACTIVE_SUBROUTINE_UNIFORM_MAX_LENGTH, // n int (GetProgramStageiv) + // ACTIVE_SUBROUTINE_MAX_LENGTH, // n int (GetProgramStageiv) + // NUM_COMPATIBLE_SUBROUTINES, // n int (GetActiveSubroutineUniformiv) + // COMPATIBLE_SUBROUTINES, // n int (GetActiveSubroutineUniformiv) + // UNIFORM_SIZE, // n int (GetActiveSubroutineUniformiv) + // UNIFORM_NAME_LENGTH, // n int (GetActiveSubroutineUniformiv) + // _, // n int (GetActiveSubroutineUniformName) + // _, // n int (GetActiveSubroutineName) + // _, // n int (GetActiveSubroutineName) + // ACTIVE_ATOMIC_COUNTER_BUFFERS, // 1 int (GetProgramiv) + // ATOMIC_COUNTER_BUFFER_BINDING, // n int (GetActiveAtomicCounterBufferiv) + // ATOMIC_COUNTER_BUFFER_DATA_SIZE, // n int (GetActiveAtomicCounterBufferiv) + // ATOMIC_COUNTER_BUFFER_ACTIVE_ATOMIC_COUNTERS, // n int (GetActiveAtomicCounterBufferiv) + // ATOMIC_COUNTER_BUFFER_ACTIVE_ATOMIC_COUNTER_INDICES, // n int (GetActiveAtomicCounterBufferiv) + // ATOMIC_COUNTER_BUFFER_REFERENCED_BY_VERTEX_SHADER, // n bool (GetActiveAtomicCounterBufferiv) + // ATOMIC_COUNTER_BUFFER_REFERENCED_BY_TESS_CONTROL_SHADER, // n bool (GetActiveAtomicCounterBufferiv) + // ATOMIC_COUNTER_BUFFER_REFERENCED_BY_TESS_EVALUATION_SHADER, // n bool (GetActiveAtomicCounterBufferiv) + // ATOMIC_COUNTER_BUFFER_REFERENCED_BY_GEOMETRY_SHADER, // n bool (GetActiveAtomicCounterBufferiv) + // ATOMIC_COUNTER_BUFFER_REFERENCED_BY_FRAGMENT_SHADER, // n bool (GetActiveAtomicCounterBufferiv) + // ATOMIC_COUNTER_BUFFER_REFERENCED_BY_COMPUTE_SHADER, // n bool (GetActiveAtomicCounterBufferiv) + // UNIFORM_ATOMIC_COUNTER_BUFFER_INDEX, // n int (GetActiveUniformsiv) + + // Program Interface State + // ACTIVE_RESOURCES, // n int (GetProgramInterfaceiv) + // MAX_NAME_LENGTH, // n int (GetProgramInterfaceiv) + // MAX_NUM_ACTIVE_VARIABLES, // n int (GetProgramInterfaceiv) + // MAX_NUM_COMPATIBLE_SUBROUTINES, // n int (GetProgramInterfaceiv) + + // Program Object Resource State + // ACTIVE_VARIABLES, // 1 int (GetProgramResourceiv) + // ARRAY_SIZE, // 1 int (GetProgramResourceiv) + // ARRAY_STRIDE, // 1 int (GetProgramResourceiv) + // ATOMIC_COUNTER_BUFFER_INDEX, // 1 int (GetProgramResourceiv) + // BLOCK_INDEX, // 1 int (GetProgramResourceiv) + // BUFFER_BINDING, // 1 int (GetProgramResourceiv) + // BUFFER_DATA_SIZE, // 1 int (GetProgramResourceiv) + // COMPATIBLE_SUBROUTINES, // 1 int (GetProgramResourceiv) + // IS_PER_PATCH, // 1 int (GetProgramResourceiv) + // IS_ROW_MAJOR, // 1 int (GetProgramResourceiv) + // LOCATION, // 1 int (GetProgramResourceiv) + // LOCATION_COMPONENT, // 1 int (GetProgramResourceiv) + // LOCATION_INDEX, // 1 int (GetProgramResourceiv) + // MATRIX_STRIDE, // 1 int (GetProgramResourceiv) + // NAME_LENGTH, // 1 int (GetProgramResourceiv) + // NUM_ACTIVE_VARIABLES, // 1 int (GetProgramResourceiv) + // NUM_COMPATIBLE_SUBROUTINES, // 1 int (GetProgramResourceiv) + // OFFSET, // 1 int (GetProgramResourceiv) + // REFERENCED_BY_VERTEX_SHADER, // 1 int (GetProgramResourceiv) + // REFERENCED_BY_TESS_CONTROL_SHADER, // 1 int (GetProgramResourceiv) + // REFERENCED_BY_TESS_EVALUATION_SHADER, // 1 int (GetProgramResourceiv) + // REFERENCED_BY_GEOMETRY_SHADER, // 1 int (GetProgramResourceiv) + // REFERENCED_BY_FRAGMENT_SHADER, // 1 int (GetProgramResourceiv) + // REFERENCED_BY_COMPUTE_SHADER, // 1 int (GetProgramResourceiv) + // TOP_LEVEL_ARRAY_SIZE, // 1 int (GetProgramResourceiv) + // TOP_LEVEL_ARRAY_STRIDE, // 1 int (GetProgramResourceiv) + // TYPE, // 1 int (GetProgramResourceiv) + + + // Vertex and Geometry Shader State (not part of program objects) + // CURRENT_VERTEX_ATTRIB, // ? floats (GetVertexAttribfv) + PROGRAM_POINT_SIZE, // 1 boolean + + // Query Object State + // QUERY_RESULT, // 1 int (GetQueryObjectuiv) + // QUERY_RESULT_AVAILABLE, // 1 int (GetQueryObjectiv) + // GetObjectLabel, + // QUERY_TARGET, // 1 int (GLenum) (GetQueryObjectiv) + + // Image State (state per image unit) + IMAGE_BINDING_NAME, // 1 int (indexed) + IMAGE_BINDING_LEVEL, // 1 int (indexed) + IMAGE_BINDING_LAYERED, // 1 boolean (indexed) + IMAGE_BINDING_LAYER, // 1 int (indexed) + IMAGE_BINDING_ACCESS, // 1 int (GLenum)(indexed) + IMAGE_BINDING_FORMAT, // 1 int (GLenum)(indexed) + + // Atomic Counter Buffer Binding State + ATOMIC_COUNTER_BUFFER_BINDING, // 1 int (or indexed) + ATOMIC_COUNTER_BUFFER_START, // 1 int64 (indexed) + ATOMIC_COUNTER_BUFFER_SIZE, // 1 int64 (indexed) + + // Shader Storage Buffer Binding State + SHADER_STORAGE_BUFFER_BINDING, // 1 int (or indexed) + SHADER_STORAGE_BUFFER_START, // 1 int64 (indexed) + SHADER_STORAGE_BUFFER_SIZE, // 1 int64 (indexed) + + // Transform Feedback State + TRANSFORM_FEEDBACK_BUFFER_BINDING, // 1 int (or indexed) + TRANSFORM_FEEDBACK_BUFFER_START, // 1 int64 (indexed) + TRANSFORM_FEEDBACK_BUFFER_SIZE, // 1 int64 (indexed) + TRANSFORM_FEEDBACK_PAUSED, // 1 boolean + TRANSFORM_FEEDBACK_ACTIVE, // 1 boolean + // GetObjectLabel, + + // Uniform Buffer Binding State + UNIFORM_BUFFER_BINDING, // 1 int (or indexed) + UNIFORM_BUFFER_START, // 1 int64 (indexed) + UNIFORM_BUFFER_SIZE, // 1 int64 (indexed) + + // Sync Object State + // OBJECT_TYPE, // 1 int (GLenum) (GetSynciv) + // SYNC_STATUS, // 1 int (GLenum) (GetSynciv) + // SYNC_CONDITION, // 1 int (GLenum) (GetSynciv) + // SYNC_FLAGS, // 1 int (GetSynciv) + // GetObjectPtrLabel, + + // Hints + LINE_SMOOTH_HINT, // 1 int (GLenum) + POLYGON_SMOOTH_HINT, // 1 int (GLenum) + TEXTURE_COMPRESSION_HINT, // 1 int (GLenum) + FRAGMENT_SHADER_DERIVATIVE_HINT, // 1 int (GLenum) + + // Compute Dispatch State + DISPATCH_INDIRECT_BUFFER_BINDING, // 1 int + + // Implementation Dependent Values + CONTEXT_RELEASE_BEHAVIOR, // 1 GLenum + MAX_CLIP_DISTANCES, // 1 int + MAX_CULL_DISTANCES, // 1 int + MAX_COMBINED_CLIP_AND_CULL_DISTANCES, // 1 int + SUBPIXEL_BITS, // 1 int + MAX_ELEMENT_INDEX, // 1 int64 + PRIMITIVE_RESTART_FOR_PATCHES_SUPPORTED, // 1 bool + MAX_3D_TEXTURE_SIZE, // 1 int + MAX_TEXTURE_SIZE, // 1 int + MAX_ARRAY_TEXTURE_LAYERS, // 1 int + MAX_TEXTURE_LOD_BIAS, // 1 float + MAX_CUBE_MAP_TEXTURE_SIZE, // 1 int + MAX_RENDERBUFFER_SIZE, // 1 int + MAX_VIEWPORT_DIMS, // 2 ints + MAX_VIEWPORTS, // 1 int + VIEWPORT_SUBPIXEL_BITS, // 1 int + VIEWPORT_BOUNDS_RANGE, // 2 ints + LAYER_PROVOKING_VERTEX, // 1 int (GLenum) + VIEWPORT_INDEX_PROVOKING_VERTEX, // 1 int (GLenum) + POINT_SIZE_RANGE, // 2 floats + POINT_SIZE_GRANULARITY, // 1 float + ALIASED_LINE_WIDTH_RANGE, // 2 floats + SMOOTH_LINE_WIDTH_RANGE, // 2 floats + SMOOTH_LINE_WIDTH_GRANULARITY, // 1 float + MAX_ELEMENTS_INDICES, // 1 int + MAX_ELEMENTS_VERTICES, // 1 int + MAX_VERTEX_ATTRIB_RELATIVE_OFFSET, // 1 int + MAX_VERTEX_ATTRIB_BINDINGS, // 1 int + MAX_VERTEX_ATTRIB_STRIDE, // 1 int + NUM_COMPRESSED_TEXTURE_FORMATS, // 1 int + COMPRESSED_TEXTURE_FORMATS, // n ints (GL_NUM_COMPRESSED_TEXTURE_FORMATS) + MAX_TEXTURE_BUFFER_SIZE, // 1 int + MAX_RECTANGLE_TEXTURE_SIZE, // 1 int + NUM_PROGRAM_BINARY_FORMATS, // 1 int + PROGRAM_BINARY_FORMATS, // n ints (GL_NUM_PROGRAM_BINARY_FORMATS) + NUM_SHADER_BINARY_FORMATS, // 1 int + SHADER_BINARY_FORMATS, // n ints (GL_NUM_SHADER_BINARY_FORMATS) + SHADER_COMPILER, // 1 boolean + MIN_MAP_BUFFER_ALIGNMENT, // 1 int + TEXTURE_BUFFER_OFFSET_ALIGNMENT, // 1 int + + // Implementation Dependent Version and Extension Support + MAJOR_VERSION, // 1 int + MINOR_VERSION, // 1 int + CONTEXT_FLAGS, // 1 int + CONTEXT_PROFILE_MASK, // 1 int + EXTENSIONS, // 1 int (indexed) + NUM_EXTENSIONS, // 1 int + RENDERER, // 1 string + SHADING_LANGUAGE_VERSION, // 1 string (indexed) + NUM_SHADING_LANGUAGE_VERSIONS, // 1 int + VENDOR, // 1 string + VERSION, // 1 string + + // Implementation Dependent Vertex Shader Limits + MAX_VERTEX_ATTRIBS, // 1 int + MAX_VERTEX_UNIFORM_COMPONENTS, // 1 int + MAX_VERTEX_UNIFORM_VECTORS, // 1 int + MAX_VERTEX_UNIFORM_BLOCKS, // 1 int + MAX_VERTEX_OUTPUT_COMPONENTS, // 1 int + MAX_VERTEX_TEXTURE_IMAGE_UNITS, // 1 int + MAX_VERTEX_ATOMIC_COUNTER_BUFFERS, // 1 int + MAX_VERTEX_ATOMIC_COUNTERS, // 1 int + MAX_VERTEX_SHADER_STORAGE_BLOCKS, // 1 int + + // Implementation Dependent Tessellation Shader Limits + MAX_TESS_GEN_LEVEL, // 1 int + MAX_PATCH_VERTICES, // 1 int + MAX_TESS_CONTROL_UNIFORM_COMPONENTS, // 1 int + MAX_TESS_CONTROL_TEXTURE_IMAGE_UNITS, // 1 int + MAX_TESS_CONTROL_OUTPUT_COMPONENTS, // 1 int + MAX_TESS_PATCH_COMPONENTS, // 1 int + MAX_TESS_CONTROL_TOTAL_OUTPUT_COMPONENTS, // 1 int + MAX_TESS_CONTROL_INPUT_COMPONENTS, // 1 int + MAX_TESS_CONTROL_UNIFORM_BLOCKS, // 1 int + MAX_TESS_CONTROL_ATOMIC_COUNTER_BUFFERS, // 1 int + MAX_TESS_CONTROL_ATOMIC_COUNTERS, // 1 int + MAX_TESS_CONTROL_SHADER_STORAGE_BLOCKS, // 1 int + MAX_TESS_EVALUATION_UNIFORM_COMPONENTS, // 1 int + MAX_TESS_EVALUATION_TEXTURE_IMAGE_UNITS, // 1 int + MAX_TESS_EVALUATION_OUTPUT_COMPONENTS, // 1 int + MAX_TESS_EVALUATION_INPUT_COMPONENTS, // 1 int + MAX_TESS_EVALUATION_UNIFORM_BLOCKS, // 1 int + MAX_TESS_EVALUATION_ATOMIC_COUNTER_BUFFERS, // 1 int + MAX_TESS_EVALUATION_ATOMIC_COUNTERS, // 1 int + MAX_TESS_EVALUATION_SHADER_STORAGE_BLOCKS, // 1 int + + // Implementation Dependent Geometry Shader Limits + MAX_GEOMETRY_UNIFORM_COMPONENTS, // 1 int + MAX_GEOMETRY_UNIFORM_BLOCKS, // 1 int + MAX_GEOMETRY_INPUT_COMPONENTS, // 1 int + MAX_GEOMETRY_OUTPUT_COMPONENTS, // 1 int + MAX_GEOMETRY_OUTPUT_VERTICES, // 1 int + MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS, // 1 int + MAX_GEOMETRY_TEXTURE_IMAGE_UNITS, // 1 int + MAX_GEOMETRY_SHADER_INVOCATIONS, // 1 int + MAX_VERTEX_STREAMS, // 1 int + MAX_GEOMETRY_ATOMIC_COUNTER_BUFFERS, // 1 int + MAX_GEOMETRY_ATOMIC_COUNTERS, // 1 int + MAX_GEOMETRY_SHADER_STORAGE_BLOCKS, // 1 int + + // Implementation Dependent Fragment Shader Limits + MAX_FRAGMENT_UNIFORM_COMPONENTS, // 1 int + MAX_FRAGMENT_UNIFORM_VECTORS, // 1 int + MAX_FRAGMENT_UNIFORM_BLOCKS, // 1 int + MAX_FRAGMENT_INPUT_COMPONENTS, // 1 int + MAX_TEXTURE_IMAGE_UNITS, // 1 int + MIN_PROGRAM_TEXTURE_GATHER_OFFSET, // 1 int + MAX_PROGRAM_TEXTURE_GATHER_OFFSET, // 1 int + MAX_FRAGMENT_ATOMIC_COUNTER_BUFFERS, // 1 int + MAX_FRAGMENT_ATOMIC_COUNTERS, // 1 int + MAX_FRAGMENT_SHADER_STORAGE_BLOCKS, // 1 int + + // Implementation Dependent Compute Shader Limits + MAX_COMPUTE_WORK_GROUP_COUNT, // 3 int (indexed) + MAX_COMPUTE_WORK_GROUP_SIZE, // 3 int (indexed) + MAX_COMPUTE_WORK_GROUP_INVOCATIONS, // 1 int + MAX_COMPUTE_UNIFORM_BLOCKS, // 1 int + MAX_COMPUTE_TEXTURE_IMAGE_UNITS, // 1 int + MAX_COMPUTE_ATOMIC_COUNTERS, // 1 int + MAX_COMPUTE_ATOMIC_COUNTER_BUFFERS, // 1 int + MAX_COMPUTE_SHARED_MEMORY_SIZE, // 1 int + MAX_COMPUTE_UNIFORM_COMPONENTS, // 1 int + MAX_COMPUTE_IMAGE_UNIFORMS, // 1 int + MAX_COMBINED_COMPUTE_UNIFORM_COMPONENTS, // 1 int + MAX_COMPUTE_SHADER_STORAGE_BLOCKS, // 1 int + + // Implementation Dependent Aggregate Shader Limits + MIN_PROGRAM_TEXEL_OFFSET, // 1 int + MAX_PROGRAM_TEXEL_OFFSET, // 1 int + MAX_UNIFORM_BUFFER_BINDINGS, // 1 int + MAX_UNIFORM_BLOCK_SIZE, // 1 int + UNIFORM_BUFFER_OFFSET_ALIGNMENT, // 1 int + MAX_COMBINED_UNIFORM_BLOCKS, // 1 int + MAX_VARYING_COMPONENTS, // 1 int + MAX_VARYING_VECTORS, // 1 int + MAX_VARYING_FLOATS, // 1 int + MAX_COMBINED_TEXTURE_IMAGE_UNITS, // 1 int + MAX_SUBROUTINES, // 1 int + MAX_SUBROUTINE_UNIFORM_LOCATIONS, // 1 int + MAX_UNIFORM_LOCATIONS, // 1 int + MAX_ATOMIC_COUNTER_BUFFER_BINDINGS, // 1 int + MAX_ATOMIC_COUNTER_BUFFER_SIZE, // 1 int + MAX_COMBINED_ATOMIC_COUNTER_BUFFERS, // 1 int + MAX_COMBINED_ATOMIC_COUNTERS, // 1 int + MAX_SHADER_STORAGE_BUFFER_BINDINGS, // 1 int + MAX_SHADER_STORAGE_BLOCK_SIZE, // 1 int64 + MAX_COMBINED_SHADER_STORAGE_BLOCKS, // 1 int + SHADER_STORAGE_BUFFER_OFFSET_ALIGNMENT, // 1 int + MAX_IMAGE_UNITS, // 1 int + MAX_COMBINED_SHADER_OUTPUT_RESOURCES, // 1 int + MAX_IMAGE_SAMPLES, // 1 int + MAX_VERTEX_IMAGE_UNIFORMS, // 1 int + MAX_TESS_CONTROL_IMAGE_UNIFORMS, // 1 int + MAX_TESS_EVALUATION_IMAGE_UNIFORMS, // 1 int + MAX_GEOMETRY_IMAGE_UNIFORMS, // 1 int + MAX_FRAGMENT_IMAGE_UNIFORMS, // 1 int + MAX_COMBINED_IMAGE_UNIFORMS, // 1 int + MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS, // 1 int + MAX_COMBINED_GEOMETRY_UNIFORM_COMPONENTS, // 1 int + MAX_COMBINED_TESS_CONTROL_UNIFORM_COMPONENTS, // 1 int + MAX_COMBINED_TESS_EVALUATION_UNIFORM_COMPONENTS,// 1 int + MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS, // 1 int + + // Debug Output State + // DEBUG_CALLBACK_FUNCTION, // 1 pointer (GetPointerv) + // DEBUG_CALLBACK_USER_PARAM, // 1 pointer (GetPointerv) + DEBUG_LOGGED_MESSAGES, // 1 int + DEBUG_NEXT_LOGGED_MESSAGE_LENGTH, // 1 int + DEBUG_OUTPUT_SYNCHRONOUS, // 1 boolean + DEBUG_GROUP_STACK_DEPTH, // 1 int + DEBUG_OUTPUT, // 1 boolean + + // Implementation Dependent Debug Output State + MAX_DEBUG_MESSAGE_LENGTH, // 1 int + MAX_DEBUG_LOGGED_MESSAGES, // 1 int + MAX_DEBUG_GROUP_STACK_DEPTH, // 1 int + MAX_LABEL_LENGTH, // 1 int + + // Implementation Dependent Values (cont.) + MAX_FRAMEBUFFER_WIDTH, // 1 int + MAX_FRAMEBUFFER_HEIGHT, // 1 int + MAX_FRAMEBUFFER_LAYERS, // 1 int + MAX_FRAMEBUFFER_SAMPLES, // 1 int + MAX_SAMPLE_MASK_WORDS, // 1 int + MAX_SAMPLES, // 1 int + MAX_COLOR_TEXTURE_SAMPLES, // 1 int + MAX_DEPTH_TEXTURE_SAMPLES, // 1 int + MAX_INTEGER_SAMPLES, // 1 int + // QUERY_COUNTER_BITS, // 5 int (GetQueryiv) + MAX_SERVER_WAIT_TIMEOUT, // 1 int64 + MIN_FRAGMENT_INTERPOLATION_OFFSET, // 1 float + MAX_FRAGMENT_INTERPOLATION_OFFSET, // 1 float + FRAGMENT_INTERPOLATION_OFFSET_BITS, // 1 int + MAX_DRAW_BUFFERS, // 1 int + MAX_DUAL_SOURCE_DRAW_BUFFERS, // 1 int + MAX_COLOR_ATTACHMENTS, // 1 int + + // Internal Format Dependent Values + // SAMPLES, // 1 int (GetInternalformativ) + // NUM_SAMPLE_COUNTS, // 1 int (GetInternalformativ) + + // Implementation Dependent Transform Feedback Limits + MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS, // 1 int + MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS, // 1 int + MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS, // 1 int + MAX_TRANSFORM_FEEDBACK_BUFFERS, // 1 int + + // Framebuffer Dependent Values + DOUBLEBUFFER, // 1 boolean + STEREO, // 1 boolean + SAMPLE_BUFFERS, // 1 int + SAMPLES, // 1 int + // SAMPLE_POSITION, // ??? (GetMultisamplefv) + IMPLEMENTATION_COLOR_READ_FORMAT, // 1 int (GLenum) + IMPLEMENTATION_COLOR_READ_TYPE, // 1 int (GLenum) + + // Miscellaneous + // CURRENT_QUERY, // 1 int (GetQueryiv) + QUERY_BUFFER_BINDING, // 1 int + COPY_READ_BUFFER_BINDING, // 1 int + COPY_WRITE_BUFFER_BINDING, // 1 int + RESET_NOTIFICATION_STRATEGY, // 1 int + TEXTURE_BUFFER_BINDING, // 1 int + TEXTURE_CUBE_MAP_SEAMLESS, // 1 boolean + TIMESTAMP, // 1 int64 + }; +} diff --git a/Dependencies/baregl/include/baregl/types/EHint.h b/Dependencies/baregl/include/baregl/types/EHint.h new file mode 100644 index 000000000..c157ef6ab --- /dev/null +++ b/Dependencies/baregl/include/baregl/types/EHint.h @@ -0,0 +1,22 @@ +/** +* @project: baregl +* @author: Adrien Givry +* @licence: MIT +*/ + +#pragma once + +#include + +namespace baregl::types +{ + /** + * Hint behavior. + */ + enum class EHint : uint8_t + { + DONT_CARE, + FASTEST, + NICEST + }; +} diff --git a/Dependencies/baregl/include/baregl/types/EImageAccessSpecifier.h b/Dependencies/baregl/include/baregl/types/EImageAccessSpecifier.h new file mode 100644 index 000000000..46750efbc --- /dev/null +++ b/Dependencies/baregl/include/baregl/types/EImageAccessSpecifier.h @@ -0,0 +1,22 @@ +/** +* @project: baregl +* @author: Vaani +* @licence: MIT +*/ + +#pragma once + +#include + +namespace baregl::types +{ + /** + * Defines access hints that images can use + */ + enum class EImageAccessSpecifier : uint8_t + { + READ_ONLY, + WRITE_ONLY, + READ_WRITE + }; +} diff --git a/Sources/OvRendering/include/OvRendering/Settings/EInternalFormat.h b/Dependencies/baregl/include/baregl/types/EInternalFormat.h similarity index 72% rename from Sources/OvRendering/include/OvRendering/Settings/EInternalFormat.h rename to Dependencies/baregl/include/baregl/types/EInternalFormat.h index 40e691656..eb90f895d 100644 --- a/Sources/OvRendering/include/OvRendering/Settings/EInternalFormat.h +++ b/Dependencies/baregl/include/baregl/types/EInternalFormat.h @@ -1,6 +1,6 @@ /** -* @project: Overload -* @author: Overload Tech. +* @project: baregl +* @author: Adrien Givry * @licence: MIT */ @@ -8,13 +8,16 @@ #include -namespace OvRendering::Settings +namespace baregl::types { /** * Enumeration of internal formats */ enum class EInternalFormat : uint8_t { + // Unsupported extension-specific formats + UNKNOWN, + // Base Internal Formats DEPTH_COMPONENT, DEPTH_STENCIL, @@ -100,6 +103,16 @@ namespace OvRendering::Settings COMPRESSED_RGBA_BPTC_UNORM, COMPRESSED_SRGB_ALPHA_BPTC_UNORM, COMPRESSED_RGB_BPTC_SIGNED_FLOAT, - COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT + COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT, + COMPRESSED_RGB8_ETC2, + COMPRESSED_SRGB8_ETC2, + COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2, + COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2, + COMPRESSED_RGBA8_ETC2_EAC, + COMPRESSED_SRGB8_ALPHA8_ETC2_EAC, + COMPRESSED_R11_EAC, + COMPRESSED_SIGNED_R11_EAC, + COMPRESSED_RG11_EAC, + COMPRESSED_SIGNED_RG11_EAC }; -} \ No newline at end of file +} diff --git a/Dependencies/baregl/include/baregl/types/ELogicOperation.h b/Dependencies/baregl/include/baregl/types/ELogicOperation.h new file mode 100644 index 000000000..b7d4067a5 --- /dev/null +++ b/Dependencies/baregl/include/baregl/types/ELogicOperation.h @@ -0,0 +1,35 @@ +/** +* @project: baregl +* @author: Adrien Givry +* @licence: MIT +*/ + +#pragma once + +#include + +namespace baregl::types +{ + /** + * Logical pixel operation. + */ + enum class ELogicOperation : uint8_t + { + CLEAR, + SET, + COPY, + COPY_INVERTED, + NOOP, + INVERT, + AND, + NAND, + OR, + NOR, + XOR, + EQUIV, + AND_REVERSE, + AND_INVERTED, + OR_REVERSE, + OR_INVERTED + }; +} diff --git a/Dependencies/baregl/include/baregl/types/EMemoryBarrierFlags.h b/Dependencies/baregl/include/baregl/types/EMemoryBarrierFlags.h new file mode 100644 index 000000000..2eca5ca53 --- /dev/null +++ b/Dependencies/baregl/include/baregl/types/EMemoryBarrierFlags.h @@ -0,0 +1,40 @@ +/** +* @project: baregl +* @author: Adrien Givry +* @licence: MIT +*/ + +#pragma once + +#include + +#include +#include + +namespace baregl::types +{ + /** + * Enumeration of memory barrier flags + */ + enum class EMemoryBarrierFlags : uint16_t + { + VERTEX_ATTRIB_ARRAY = 0x1, + ELEMENT_ARRAY = 0x2, + UNIFORM = 0x4, + TEXTURE_FETCH = 0x8, + SHADER_IMAGE_ACCESS = 0x10, + COMMAND = 0x20, + PIXEL_BUFFER = 0x40, + TEXTURE_UPDATE = 0x80, + BUFFER_UPDATE = 0x100, + CLIENT_MAPPED_BUFFER = 0x200, + FRAMEBUFFER = 0x400, + TRANSFORM_FEEDBACK = 0x800, + ATOMIC_COUNTER = 0x1000, + SHADER_STORAGE = 0x2000, + QUERY_BUFFER = 0x4000, + ALL = std::numeric_limits::max() + }; +} + +ENABLE_BITMASK_OPERATORS(baregl::types::EMemoryBarrierFlags); diff --git a/Sources/OvRendering/include/OvRendering/Settings/EOperation.h b/Dependencies/baregl/include/baregl/types/EOperation.h similarity index 61% rename from Sources/OvRendering/include/OvRendering/Settings/EOperation.h rename to Dependencies/baregl/include/baregl/types/EOperation.h index 7664be2c1..5017ad766 100644 --- a/Sources/OvRendering/include/OvRendering/Settings/EOperation.h +++ b/Dependencies/baregl/include/baregl/types/EOperation.h @@ -1,6 +1,6 @@ /** -* @project: Overload -* @author: Overload Tech. +* @project: baregl +* @author: Adrien Givry * @licence: MIT */ @@ -8,10 +8,10 @@ #include -namespace OvRendering::Settings +namespace baregl::types { /** - * Graphics operations (for stencil/depth buffers) + * Graphics operation types for stencil/depth operations */ enum class EOperation : uint8_t { @@ -24,4 +24,4 @@ namespace OvRendering::Settings DECREMENT_WRAP, INVERT }; -} \ No newline at end of file +} diff --git a/Sources/OvRendering/include/OvRendering/Settings/EPixelDataFormat.h b/Dependencies/baregl/include/baregl/types/EPixelDataFormat.h similarity index 78% rename from Sources/OvRendering/include/OvRendering/Settings/EPixelDataFormat.h rename to Dependencies/baregl/include/baregl/types/EPixelDataFormat.h index 208e85537..5b5b39665 100644 --- a/Sources/OvRendering/include/OvRendering/Settings/EPixelDataFormat.h +++ b/Dependencies/baregl/include/baregl/types/EPixelDataFormat.h @@ -1,6 +1,6 @@ /** -* @project: Overload -* @author: Overload Tech. +* @project: baregl +* @author: Adrien Givry * @licence: MIT */ @@ -8,7 +8,7 @@ #include -namespace OvRendering::Settings +namespace baregl::types { /** * Enumeration of pixel data formats @@ -29,4 +29,4 @@ namespace OvRendering::Settings LUMINANCE, LUMINANCE_ALPHA, }; -} \ No newline at end of file +} diff --git a/Sources/OvRendering/include/OvRendering/Settings/EPixelDataType.h b/Dependencies/baregl/include/baregl/types/EPixelDataType.h similarity index 87% rename from Sources/OvRendering/include/OvRendering/Settings/EPixelDataType.h rename to Dependencies/baregl/include/baregl/types/EPixelDataType.h index 1cb0ebbcd..666ef4364 100644 --- a/Sources/OvRendering/include/OvRendering/Settings/EPixelDataType.h +++ b/Dependencies/baregl/include/baregl/types/EPixelDataType.h @@ -1,6 +1,6 @@ /** -* @project: Overload -* @author: Overload Tech. +* @project: baregl +* @author: Adrien Givry * @licence: MIT */ @@ -8,7 +8,7 @@ #include -namespace OvRendering::Settings +namespace baregl::types { /** * Enumeration of pixel data types @@ -36,4 +36,4 @@ namespace OvRendering::Settings UNSIGNED_INT_10_10_10_2, UNSIGNED_INT_2_10_10_10_REV }; -} \ No newline at end of file +} diff --git a/Sources/OvRendering/include/OvRendering/Settings/EPrimitiveMode.h b/Dependencies/baregl/include/baregl/types/EPrimitiveMode.h similarity index 81% rename from Sources/OvRendering/include/OvRendering/Settings/EPrimitiveMode.h rename to Dependencies/baregl/include/baregl/types/EPrimitiveMode.h index 6b76a4794..c71d6b0e7 100644 --- a/Sources/OvRendering/include/OvRendering/Settings/EPrimitiveMode.h +++ b/Dependencies/baregl/include/baregl/types/EPrimitiveMode.h @@ -1,6 +1,6 @@ /** -* @project: Overload -* @author: Overload Tech. +* @project: baregl +* @author: Adrien Givry * @licence: MIT */ @@ -8,7 +8,7 @@ #include -namespace OvRendering::Settings +namespace baregl::types { /** * Enumeration of primitive modes @@ -28,4 +28,4 @@ namespace OvRendering::Settings TRIANGLE_STRIP_ADJACENCY, PATCHES }; -} \ No newline at end of file +} diff --git a/Dependencies/baregl/include/baregl/types/EProvokingVertexConvention.h b/Dependencies/baregl/include/baregl/types/EProvokingVertexConvention.h new file mode 100644 index 000000000..c1cd9b5be --- /dev/null +++ b/Dependencies/baregl/include/baregl/types/EProvokingVertexConvention.h @@ -0,0 +1,23 @@ +/** +* @project: baregl +* @author: Adrien Givry +* @licence: MIT +*/ + +#pragma once + +#include + +namespace baregl::types +{ + /** + * Provoking vertex convention. + */ + enum class EProvokingVertexConvention : uint8_t + { + PROVOKING_VERTEX, + FIRST_VERTEX_CONVENTION, + LAST_VERTEX_CONVENTION, + UNDEFINED_VERTEX + }; +} diff --git a/Dependencies/baregl/include/baregl/types/ERasterizationMode.h b/Dependencies/baregl/include/baregl/types/ERasterizationMode.h new file mode 100644 index 000000000..2ae878292 --- /dev/null +++ b/Dependencies/baregl/include/baregl/types/ERasterizationMode.h @@ -0,0 +1,22 @@ +/** +* @project: baregl +* @author: Adrien Givry +* @licence: MIT +*/ + +#pragma once + +#include + +namespace baregl::types +{ + /** + * Enumeration of rasterization modes + */ + enum class ERasterizationMode : uint8_t + { + POINT, + LINE, + FILL + }; +} diff --git a/Dependencies/baregl/include/baregl/types/ERenderingCapability.h b/Dependencies/baregl/include/baregl/types/ERenderingCapability.h new file mode 100644 index 000000000..c38126ddf --- /dev/null +++ b/Dependencies/baregl/include/baregl/types/ERenderingCapability.h @@ -0,0 +1,30 @@ +/** +* @project: baregl +* @author: Adrien Givry +* @licence: MIT +*/ + +#pragma once + +#include + +namespace baregl::types +{ + /** + * Enumeration of rendering capabilities + */ + enum class ERenderingCapability : uint8_t + { + BLEND, + CULL_FACE, + DEPTH_TEST, + DITHER, + POLYGON_OFFSET_FILL, + SAMPLE_ALPHA_TO_COVERAGE, + SAMPLE_COVERAGE, + SCISSOR_TEST, + STENCIL_TEST, + MULTISAMPLE, + LINE_SMOOTH + }; +} diff --git a/Dependencies/baregl/include/baregl/types/EShaderType.h b/Dependencies/baregl/include/baregl/types/EShaderType.h new file mode 100644 index 000000000..1a9f46f1c --- /dev/null +++ b/Dependencies/baregl/include/baregl/types/EShaderType.h @@ -0,0 +1,26 @@ +/** +* @project: baregl +* @author: Adrien Givry +* @licence: MIT +*/ + +#pragma once + +#include + +namespace baregl::types +{ + /** + * Enumeration of shader types + */ + enum class EShaderType : uint8_t + { + NONE, + VERTEX, + FRAGMENT, + GEOMETRY, + COMPUTE, + TESSELLATION_CONTROL, + TESSELLATION_EVALUATION + }; +} diff --git a/Sources/OvRendering/include/OvRendering/Settings/ETextureFilteringMode.h b/Dependencies/baregl/include/baregl/types/ETextureFilteringMode.h similarity index 74% rename from Sources/OvRendering/include/OvRendering/Settings/ETextureFilteringMode.h rename to Dependencies/baregl/include/baregl/types/ETextureFilteringMode.h index b19dab669..58923784d 100644 --- a/Sources/OvRendering/include/OvRendering/Settings/ETextureFilteringMode.h +++ b/Dependencies/baregl/include/baregl/types/ETextureFilteringMode.h @@ -1,12 +1,14 @@ /** -* @project: Overload -* @author: Overload Tech. +* @project: baregl +* @author: Adrien Givry * @licence: MIT */ #pragma once -namespace OvRendering::Settings +#include + +namespace baregl::types { /** * Enumeration of texture filtering modes @@ -20,4 +22,4 @@ namespace OvRendering::Settings LINEAR_MIPMAP_NEAREST, NEAREST_MIPMAP_LINEAR }; -} \ No newline at end of file +} diff --git a/Sources/OvRendering/include/OvRendering/Settings/ETextureType.h b/Dependencies/baregl/include/baregl/types/ETextureType.h similarity index 58% rename from Sources/OvRendering/include/OvRendering/Settings/ETextureType.h rename to Dependencies/baregl/include/baregl/types/ETextureType.h index 3923c44ec..5ec1160c7 100644 --- a/Sources/OvRendering/include/OvRendering/Settings/ETextureType.h +++ b/Dependencies/baregl/include/baregl/types/ETextureType.h @@ -1,6 +1,6 @@ /** -* @project: Overload -* @author: Overload Tech. +* @project: baregl +* @author: Adrien Givry * @licence: MIT */ @@ -8,10 +8,10 @@ #include -namespace OvRendering::Settings +namespace baregl::types { /** - * Texture types + * Enumeration of texture types */ enum class ETextureType : uint8_t { diff --git a/Dependencies/baregl/include/baregl/types/ETextureUnit.h b/Dependencies/baregl/include/baregl/types/ETextureUnit.h new file mode 100644 index 000000000..1f42e66a1 --- /dev/null +++ b/Dependencies/baregl/include/baregl/types/ETextureUnit.h @@ -0,0 +1,52 @@ +/** +* @project: baregl +* @author: Adrien Givry +* @licence: MIT +*/ + +#pragma once + +#include + +namespace baregl::types +{ + /** + * Enumeration of texture units + */ + enum class ETextureUnit : uint8_t + { + TEXTURE0 = 0, + TEXTURE1, + TEXTURE2, + TEXTURE3, + TEXTURE4, + TEXTURE5, + TEXTURE6, + TEXTURE7, + TEXTURE8, + TEXTURE9, + TEXTURE10, + TEXTURE11, + TEXTURE12, + TEXTURE13, + TEXTURE14, + TEXTURE15, + TEXTURE16, + TEXTURE17, + TEXTURE18, + TEXTURE19, + TEXTURE20, + TEXTURE21, + TEXTURE22, + TEXTURE23, + TEXTURE24, + TEXTURE25, + TEXTURE26, + TEXTURE27, + TEXTURE28, + TEXTURE29, + TEXTURE30, + TEXTURE31 + }; +} + diff --git a/Sources/OvRendering/include/OvRendering/Settings/ETextureWrapMode.h b/Dependencies/baregl/include/baregl/types/ETextureWrapMode.h similarity index 75% rename from Sources/OvRendering/include/OvRendering/Settings/ETextureWrapMode.h rename to Dependencies/baregl/include/baregl/types/ETextureWrapMode.h index d718aede2..89001de1c 100644 --- a/Sources/OvRendering/include/OvRendering/Settings/ETextureWrapMode.h +++ b/Dependencies/baregl/include/baregl/types/ETextureWrapMode.h @@ -1,6 +1,6 @@ /** -* @project: Overload -* @author: Overload Tech. +* @project: baregl +* @author: Adrien Givry * @licence: MIT */ @@ -8,7 +8,7 @@ #include -namespace OvRendering::Settings +namespace baregl::types { /** * Enumeration of texture wrap modes @@ -21,4 +21,4 @@ namespace OvRendering::Settings MIRRORED_REPEAT, MIRROR_CLAMP_TO_EDGE }; -} \ No newline at end of file +} diff --git a/Sources/OvRendering/include/OvRendering/Settings/EUniformType.h b/Dependencies/baregl/include/baregl/types/EUniformType.h similarity index 68% rename from Sources/OvRendering/include/OvRendering/Settings/EUniformType.h rename to Dependencies/baregl/include/baregl/types/EUniformType.h index 48b945f80..38c1b8da3 100644 --- a/Sources/OvRendering/include/OvRendering/Settings/EUniformType.h +++ b/Dependencies/baregl/include/baregl/types/EUniformType.h @@ -1,6 +1,6 @@ /** -* @project: Overload -* @author: Overload Tech. +* @project: baregl +* @author: Adrien Givry * @licence: MIT */ @@ -8,7 +8,7 @@ #include -namespace OvRendering::Settings +namespace baregl::types { /** * Enumeration of uniform types @@ -17,6 +17,7 @@ namespace OvRendering::Settings { BOOL, INT, + UNSIGNED_INT, FLOAT, FLOAT_VEC2, FLOAT_VEC3, @@ -25,6 +26,8 @@ namespace OvRendering::Settings FLOAT_MAT4, DOUBLE_MAT4, SAMPLER_2D, - SAMPLER_CUBE + SAMPLER_CUBE, + IMAGE_2D, + IMAGE_CUBE }; } diff --git a/Dependencies/baregl/include/baregl/utils/BitmaskOperators.h b/Dependencies/baregl/include/baregl/utils/BitmaskOperators.h new file mode 100644 index 000000000..f2ff9c1ab --- /dev/null +++ b/Dependencies/baregl/include/baregl/utils/BitmaskOperators.h @@ -0,0 +1,116 @@ +/** +* @project: baregl +* @author: Adrien Givry +* @licence: MIT +*/ +#pragma once + +#include + +namespace baregl::utils +{ + // Primary template - disabled by default + template + struct enable_bitmask_operators + { + static constexpr bool enable = false; + }; + + // SFINAE helper to check if bitmask operators are enabled for a type + template + constexpr bool is_bitmask_enum_v = enable_bitmask_operators::enable && std::is_enum_v; +} + +// Bitwise OR operator | +template +constexpr std::enable_if_t, T> +operator|(T lhs, T rhs) noexcept +{ + using underlying = std::underlying_type_t; + return static_cast(static_cast(lhs) | static_cast(rhs)); +} + +// Bitwise AND operator & +template +constexpr std::enable_if_t, T> +operator&(T lhs, T rhs) noexcept +{ + using underlying = std::underlying_type_t; + return static_cast(static_cast(lhs) & static_cast(rhs)); +} + +// Bitwise XOR operator ^ +template +constexpr std::enable_if_t, T> +operator^(T lhs, T rhs) noexcept +{ + using underlying = std::underlying_type_t; + return static_cast(static_cast(lhs) ^ static_cast(rhs)); +} + +// Bitwise NOT operator ~ +template +constexpr std::enable_if_t, T> +operator~(T rhs) noexcept +{ + using underlying = std::underlying_type_t; + return static_cast(~static_cast(rhs)); +} + +// Compound assignment OR operator |= +template +constexpr std::enable_if_t, T&> +operator|=(T& lhs, T rhs) noexcept +{ + return lhs = lhs | rhs; +} + +// Compound assignment AND operator &= +template +constexpr std::enable_if_t, T&> +inline operator&=(T& lhs, T rhs) noexcept +{ + return lhs = lhs & rhs; +} + +// Compound assignment XOR operator ^= +template +constexpr std::enable_if_t, T&> +inline operator^=(T& lhs, T rhs) noexcept +{ + return lhs = lhs ^ rhs; +} + +// Utility function to check if a flag is set +template +constexpr std::enable_if_t, bool> +inline IsFlagSet(T flags, T mask) noexcept +{ + using underlying = std::underlying_type_t; + return (static_cast(flags) & static_cast(mask)) != 0; +} + +// Utility function to check if any flags are set +template +constexpr std::enable_if_t, bool> +inline HasAnyFlag(T flags) noexcept +{ + using underlying = std::underlying_type_t; + return static_cast(flags) != 0; +} + +// Utility function to check if all flags in mask are set +template +constexpr std::enable_if_t, bool> +inline HasAllFlags(T flags, T mask) noexcept +{ + return (flags & mask) == mask; +} + +// Macro to enable bitmask operators for an enum type +#define ENABLE_BITMASK_OPERATORS(x) \ +template<> \ +struct baregl::utils::enable_bitmask_operators \ +{ \ + static constexpr bool enable = true; \ +}; diff --git a/Dependencies/glad/premake5.lua b/Dependencies/baregl/premake5.lua similarity index 63% rename from Dependencies/glad/premake5.lua rename to Dependencies/baregl/premake5.lua index 3d2879fa0..2853331b1 100644 --- a/Dependencies/glad/premake5.lua +++ b/Dependencies/baregl/premake5.lua @@ -1,24 +1,25 @@ -project "glad" +project "baregl" kind "StaticLib" - language "C" - cdialect "C17" + language "C++" + cppdialect "C++20" targetdir (outputdir .. "%{cfg.buildcfg}/%{prj.name}") objdir (objoutdir .. "%{cfg.buildcfg}/%{prj.name}") - warnings "Off" files { - "**.h", - "**.c", - "**.lua" + "include/**.h", -- public headers + "src/**.h", -- private headers + "src/**.cpp", + "src/**.c", } includedirs { - "include" + "include", + "src" } filter { "configurations:Debug" } defines { "DEBUG", "_DEBUG" } - optimize "On" + symbols "On" filter { "configurations:Release or configurations:Publish" } defines { "NDEBUG" } diff --git a/Dependencies/baregl/src/baregl/Buffer.cpp b/Dependencies/baregl/src/baregl/Buffer.cpp new file mode 100644 index 000000000..8a507af8d --- /dev/null +++ b/Dependencies/baregl/src/baregl/Buffer.cpp @@ -0,0 +1,100 @@ +/** +* @project: baregl +* @author: Adrien Givry +* @licence: MIT +*/ + +#include + +#include +#include +#include +#include + +namespace baregl +{ + Buffer::Buffer() + { + glCreateBuffers(1, &m_id); + NOTIFY_BUFFER_CREATED; + } + + Buffer::~Buffer() + { + glDeleteBuffers(1, &m_id); + NOTIFY_BUFFER_DESTROYED; + } + + uint64_t Buffer::Allocate(uint64_t p_size, types::EAccessSpecifier p_usage) + { + BAREGL_ASSERT(IsValid(), "Cannot allocate memory for an invalid buffer"); + glNamedBufferData(m_id, p_size, nullptr, utils::EnumToValue(p_usage)); + return m_allocatedBytes = p_size; + } + + void Buffer::Upload(const void* p_data, std::optional p_range) + { + BAREGL_ASSERT(IsValid(), "Trying to upload data to an invalid buffer"); + BAREGL_ASSERT(!IsEmpty(), "Trying to upload data to an empty buffer"); + + glNamedBufferSubData( + m_id, + p_range ? p_range->offset : 0, + p_range ? p_range->size : m_allocatedBytes, + p_data + ); + } + + void Buffer::Bind( + types::EBufferType p_type, + std::optional p_index + ) + { + BAREGL_ASSERT(IsValid(), "Cannot bind an invalid buffer"); + + if (p_index.has_value()) + { + glBindBufferBase(utils::EnumToValue(p_type), p_index.value(), m_id); + } + else + { + glBindBuffer(utils::EnumToValue(p_type), m_id); + } + + m_boundAs = p_type; + m_bindIndex = p_index; + } + + void Buffer::Unbind() + { + BAREGL_ASSERT(IsValid(), "Cannot unbind an invalid buffer"); + BAREGL_ASSERT(m_boundAs.has_value(), "Cannot unbind a buffer that is not bound"); + + if (m_bindIndex.has_value()) + { + glBindBufferBase(utils::EnumToValue(m_boundAs.value()), m_bindIndex.value(), m_id); + } + else + { + glBindBuffer(utils::EnumToValue(m_boundAs.value()), 0); + } + + m_boundAs.reset(); + } + + bool Buffer::IsValid() const + { + return m_id != 0; + } + + bool Buffer::IsEmpty() const + { + return GetSize() == 0; + } + + uint64_t Buffer::GetSize() const + { + BAREGL_ASSERT(IsValid(), "Cannot get size of an invalid buffer"); + return m_allocatedBytes; + } +} diff --git a/Dependencies/baregl/src/baregl/Context.cpp b/Dependencies/baregl/src/baregl/Context.cpp new file mode 100644 index 000000000..4892d62b1 --- /dev/null +++ b/Dependencies/baregl/src/baregl/Context.cpp @@ -0,0 +1,644 @@ +/** +* @project: baregl +* @author: Adrien Givry +* @licence: MIT +*/ + +#include + +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace +{ + uint32_t g_contextCount = 0u; + + void GLDebugMessageCallback(uint32_t p_source, uint32_t p_type, uint32_t p_id, uint32_t p_severity, int32_t p_length, const char* p_message, const void* p_userParam) + { + // Ignore non-significant error/warning codes + if (p_id == 131169 || p_id == 131185 || p_id == 131218 || p_id == 131204) + { + return; + } + + std::string output = "OpenGL Debug Message:\n"; + output += "Debug message (" + std::to_string(p_id) + "): " + p_message + "\n"; + + switch (p_source) + { + case GL_DEBUG_SOURCE_API: output += "Source: API"; break; + case GL_DEBUG_SOURCE_WINDOW_SYSTEM: output += "Source: Window System"; break; + case GL_DEBUG_SOURCE_SHADER_COMPILER: output += "Source: Shader Compiler"; break; + case GL_DEBUG_SOURCE_THIRD_PARTY: output += "Source: Third Party"; break; + case GL_DEBUG_SOURCE_APPLICATION: output += "Source: Application"; break; + case GL_DEBUG_SOURCE_OTHER: output += "Source: Other"; break; + } + + output += "\n"; + + switch (p_type) + { + case GL_DEBUG_TYPE_ERROR: output += "Type: Error"; break; + case GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR: output += "Type: Deprecated Behaviour"; break; + case GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR: output += "Type: Undefined Behaviour"; break; + case GL_DEBUG_TYPE_PORTABILITY: output += "Type: Portability"; break; + case GL_DEBUG_TYPE_PERFORMANCE: output += "Type: Performance"; break; + case GL_DEBUG_TYPE_MARKER: output += "Type: Marker"; break; + case GL_DEBUG_TYPE_PUSH_GROUP: output += "Type: Push Group"; break; + case GL_DEBUG_TYPE_POP_GROUP: output += "Type: Pop Group"; break; + case GL_DEBUG_TYPE_OTHER: output += "Type: Other"; break; + } + + output += "\n"; + + switch (p_severity) + { + case GL_DEBUG_SEVERITY_HIGH: output += "Severity: High"; BAREGL_LOG_ERROR(output); break; + case GL_DEBUG_SEVERITY_MEDIUM: output += "Severity: Medium"; BAREGL_LOG_WARNING(output); break; + case GL_DEBUG_SEVERITY_LOW: output += "Severity: Low"; BAREGL_LOG_INFO(output); break; + case GL_DEBUG_SEVERITY_NOTIFICATION: output += "Severity: Notification"; BAREGL_LOG_INFO(output); break; + } + } + + template + concept SupportedGetType = + std::same_as || + std::same_as || + std::same_as || + std::same_as || + std::same_as || + std::same_as; + + template + struct StdVectorTraits; + + template + struct StdVectorTraits> + { + using value_type = T; + }; + + template + void GetValue( + baregl::types::EGetParameter p_param, + std::span p_out + ); + + template + void GetValueIndexed( + baregl::types::EGetParameter p_param, + std::span p_out, + uint32_t p_index + ); + + template<> + void GetValue( + baregl::types::EGetParameter p_param, + std::span p_out + ) + { + glGetIntegerv( + baregl::utils::EnumToValue(p_param), + p_out.data() + ); + } + + template<> + void GetValueIndexed( + baregl::types::EGetParameter p_param, + std::span p_out, + uint32_t p_index + ) + { + glGetIntegeri_v( + baregl::utils::EnumToValue(p_param), + p_index, + p_out.data() + ); + } + + template<> + void GetValue( + baregl::types::EGetParameter p_param, + std::span p_out + ) + { + glGetInteger64v( + baregl::utils::EnumToValue(p_param), + p_out.data() + ); + } + + template<> + void GetValueIndexed( + baregl::types::EGetParameter p_param, + std::span p_out, + uint32_t p_index + ) + { + glGetInteger64i_v( + baregl::utils::EnumToValue(p_param), + p_index, + p_out.data() + ); + } + + template<> + void GetValue( + baregl::types::EGetParameter p_param, + std::span p_out + ) + { + std::vector values(p_out.size()); + glGetBooleanv( + baregl::utils::EnumToValue(p_param), + values.data() + ); + + for (size_t i = 0; i < p_out.size(); ++i) + { + p_out[i] = values[i] != GL_FALSE; + } + } + + template<> + void GetValueIndexed( + baregl::types::EGetParameter p_param, + std::span p_out, + uint32_t p_index + ) + { + std::vector values(p_out.size()); + glGetBooleani_v( + baregl::utils::EnumToValue(p_param), + p_index, + values.data() + ); + + for (size_t i = 0; i < p_out.size(); ++i) + { + p_out[i] = values[i] != GL_FALSE; + } + } + + template<> + void GetValue( + baregl::types::EGetParameter p_param, + std::span p_out + ) + { + glGetFloatv( + baregl::utils::EnumToValue(p_param), + p_out.data() + ); + } + + template<> + void GetValueIndexed( + baregl::types::EGetParameter p_param, + std::span p_out, + uint32_t p_index + ) + { + glGetFloati_v( + baregl::utils::EnumToValue(p_param), + p_index, + p_out.data() + ); + } + + template<> + void GetValue( + baregl::types::EGetParameter p_param, + std::span p_out + ) + { + glGetDoublev( + baregl::utils::EnumToValue(p_param), + p_out.data() + ); + } + + template<> + void GetValueIndexed( + baregl::types::EGetParameter p_param, + std::span p_out, + uint32_t p_index + ) + { + glGetDoublei_v( + baregl::utils::EnumToValue(p_param), + p_index, + p_out.data() + ); + } + + template<> + void GetValue( + baregl::types::EGetParameter p_param, + std::span p_out + ) + { + const GLubyte* result = glGetString( + baregl::utils::EnumToValue(p_param) + ); + + p_out[0] = + result ? + reinterpret_cast(result) : + std::string(); + } + + template<> + void GetValueIndexed( + baregl::types::EGetParameter p_param, + std::span p_out, + uint32_t p_index + ) + { + const GLubyte* result = glGetStringi( + baregl::utils::EnumToValue(p_param), + p_index + ); + + p_out[0] = + result ? + reinterpret_cast(result) : + std::string(); + } +} + +namespace baregl +{ + Context::Context(const baregl::data::ContextDesc& p_desc) + { + BAREGL_ASSERT(g_contextCount == 0, "A context already exists. BareGL currently only supports a single context."); + + ++g_contextCount; + + const int error = gladLoadGL(); + + if (error == 0) + { + BAREGL_LOG_ERROR("GLAD failed to initialize"); + return; + } + + BAREGL_LOG_INFO("OpenGL context initialized."); + + if (p_desc.debug) + { + glEnable(GL_DEBUG_OUTPUT); + glEnable(GL_DEBUG_OUTPUT_SYNCHRONOUS); + glDebugMessageCallback(GLDebugMessageCallback, nullptr); + } + + // Seamless cubemap (always on) + glEnable(GL_TEXTURE_CUBE_MAP_SEAMLESS); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + } + + Context::~Context() + { + BAREGL_ASSERT(g_contextCount > 0, "No context to destroy, did you modify g_contextCount manually?"); + + --g_contextCount; + } + + void Context::Clear(bool p_colorBuffer, bool p_depthBuffer, bool p_stencilBuffer) + { + GLbitfield clearMask = 0; + if (p_colorBuffer) clearMask |= GL_COLOR_BUFFER_BIT; + if (p_depthBuffer) clearMask |= GL_DEPTH_BUFFER_BIT; + if (p_stencilBuffer) clearMask |= GL_STENCIL_BUFFER_BIT; + + if (clearMask != 0) + { + glClear(clearMask); + } + } + + void Context::DrawElements(types::EPrimitiveMode p_primitiveMode, uint32_t p_indexCount) + { + glDrawElements(utils::EnumToValue(p_primitiveMode), p_indexCount, GL_UNSIGNED_INT, nullptr); + } + + void Context::DrawElementsInstanced(types::EPrimitiveMode p_primitiveMode, uint32_t p_indexCount, uint32_t p_instances) + { + glDrawElementsInstanced(utils::EnumToValue(p_primitiveMode), p_indexCount, GL_UNSIGNED_INT, nullptr, p_instances); + } + + void Context::DrawArrays(types::EPrimitiveMode p_primitiveMode, uint32_t p_vertexCount) + { + glDrawArrays(utils::EnumToValue(p_primitiveMode), 0, p_vertexCount); + } + + void Context::DrawArraysInstanced(types::EPrimitiveMode p_primitiveMode, uint32_t p_vertexCount, uint32_t p_instances) + { + glDrawArraysInstanced(utils::EnumToValue(p_primitiveMode), 0, p_vertexCount, p_instances); + } + + void Context::DispatchCompute(uint32_t p_x, uint32_t p_y, uint32_t p_z) const + { + BAREGL_ASSERT( + p_x > 0 && p_y > 0 && p_z > 0, + "Dispatch work group count cannot be zero" + ); + + glDispatchCompute(p_x, p_y, p_z); + } + + void Context::MemoryBarrier(types::EMemoryBarrierFlags p_barriers) const + { + glMemoryBarrier( + utils::EnumToValue(p_barriers) + ); + } + + void Context::SetClearColor(float p_red, float p_green, float p_blue, float p_alpha) + { + glClearColor(p_red, p_green, p_blue, p_alpha); + } + + void Context::SetRasterizationLinesWidth(float p_width) + { + glLineWidth(p_width); + } + + void Context::SetRasterizationMode(types::ERasterizationMode p_rasterizationMode) + { + glPolygonMode(GL_FRONT_AND_BACK, utils::EnumToValue(p_rasterizationMode)); + } + + void Context::SetCapability(types::ERenderingCapability p_capability, bool p_value) + { + (p_value ? glEnable : glDisable)(utils::EnumToValue(p_capability)); + } + + bool Context::GetCapability(types::ERenderingCapability p_capability) + { + return glIsEnabled(utils::EnumToValue(p_capability)); + } + + void Context::SetStencilAlgorithm(types::EComparaisonAlgorithm p_algorithm, int32_t p_reference, uint32_t p_mask) + { + glStencilFunc(utils::EnumToValue(p_algorithm), p_reference, p_mask); + } + + void Context::SetDepthAlgorithm(types::EComparaisonAlgorithm p_algorithm) + { + glDepthFunc(utils::EnumToValue(p_algorithm)); + } + + void Context::SetStencilMask(uint32_t p_mask) + { + glStencilMask(p_mask); + } + + void Context::SetStencilOperations(types::EOperation p_stencilFail, types::EOperation p_depthFail, types::EOperation p_bothPass) + { + glStencilOp( + utils::EnumToValue(p_stencilFail), + utils::EnumToValue(p_depthFail), + utils::EnumToValue(p_bothPass) + ); + } + + void Context::SetBlendingFunction(types::EBlendingFactor p_sourceFactor, types::EBlendingFactor p_destinationFactor) + { + glBlendFunc( + utils::EnumToValue(p_sourceFactor), + utils::EnumToValue(p_destinationFactor) + ); + } + + void Context::SetBlendingEquation(types::EBlendingEquation p_equation) + { + glBlendEquation(utils::EnumToValue(p_equation)); + } + + void Context::SetCullFace(types::ECullFace p_cullFace) + { + glCullFace(utils::EnumToValue(p_cullFace)); + } + + void Context::SetDepthWriting(bool p_enable) + { + glDepthMask(p_enable); + } + + void Context::SetColorWriting(bool p_enableRed, bool p_enableGreen, bool p_enableBlue, bool p_enableAlpha) + { + glColorMask(p_enableRed, p_enableGreen, p_enableBlue, p_enableAlpha); + } + + void Context::SetViewport(uint32_t x, uint32_t y, uint32_t width, uint32_t height) + { + glViewport(x, y, width, height); + } + + template + requires (data::GetResult::non_indexed) + data::GetResultType Context::Get() + { + using R = data::GetResult; + using Elem = typename R::get_type; + + if constexpr (R::dynamic_count) + { + using CountGet = data::GetResult; + using CountElem = typename CountGet::get_type; + using ResultElem = typename StdVectorTraits::value_type; + std::array countRaw; + GetValue(R::dynamic_count_parameter, countRaw); + + const auto elementCount = static_cast(countRaw[0] > 0 ? countRaw[0] : 0); + std::vector raw(elementCount); + if constexpr (std::same_as) + { + for (size_t i = 0; i < elementCount; ++i) + { + std::array value; + GetValueIndexed(PName, value, static_cast(i)); + raw[i] = value[0]; + } + } + else + { + GetValue(PName, raw); + } + + if constexpr (std::same_as) + return raw; + else if constexpr (std::is_enum_v && std::integral) + { + std::vector converted(raw.size()); + for (size_t i = 0; i < raw.size(); ++i) + converted[i] = utils::ValueToEnum(static_cast(raw[i])); + return converted; + } + else if constexpr (std::integral && std::integral) + { + std::vector converted(raw.size()); + for (size_t i = 0; i < raw.size(); ++i) + converted[i] = static_cast(raw[i]); + return converted; + } + else + { + static_assert( + std::same_as || + (std::is_enum_v && std::integral) || + (std::integral && std::integral), + "Unsupported dynamic get result type" + ); + } + + } + else + { + constexpr size_t N = R::count; + std::array raw; + GetValue(PName, raw); + + if constexpr (std::same_as) + return raw[0]; + else if constexpr (std::same_as>) + return raw; + else if constexpr (std::integral && std::integral) + return static_cast(raw[0]); + else if constexpr (std::is_enum_v) + return utils::ValueToEnum(static_cast(raw[0])); + + static_assert( + std::same_as || + std::same_as> || + (std::integral && std::integral) || + std::is_enum_v, + "Unsupported get result type" + ); + } + } + + template + requires (data::GetResult::indexed) + data::GetResultType Context::Get(uint32_t p_index) + { + using R = data::GetResult; + using Elem = typename R::get_type; + + if constexpr (R::dynamic_count) + { + using CountGet = data::GetResult; + using CountElem = typename CountGet::get_type; + using ResultElem = typename StdVectorTraits::value_type; + + std::array countRaw; + GetValue(R::dynamic_count_parameter, countRaw); + + const auto elementCount = static_cast(countRaw[0] > 0 ? countRaw[0] : 0); + std::vector raw(elementCount); + GetValueIndexed(PName, raw, p_index); + + if constexpr (std::same_as) + { + return raw; + } + else if constexpr (std::is_enum_v && std::integral) + { + std::vector converted(raw.size()); + for (size_t i = 0; i < raw.size(); ++i) + converted[i] = utils::ValueToEnum(static_cast(raw[i])); + return converted; + } + else if constexpr (std::integral && std::integral) + { + std::vector converted(raw.size()); + for (size_t i = 0; i < raw.size(); ++i) + converted[i] = static_cast(raw[i]); + return converted; + } + else + { + static_assert( + std::same_as || + (std::is_enum_v && std::integral) || + (std::integral && std::integral), + "Unsupported dynamic indexed get result type" + ); + } + } + else + { + constexpr size_t N = R::count; + std::array raw; + GetValueIndexed(PName, raw, p_index); + + if constexpr (std::same_as) + return raw[0]; + else if constexpr (std::same_as>) + return raw; + else if constexpr (std::integral && std::integral) + return static_cast(raw[0]); + else if constexpr (std::is_enum_v) + return utils::ValueToEnum(static_cast(raw[0])); + + static_assert( + std::same_as || + std::same_as> || + (std::integral && std::integral) || + std::is_enum_v, + "Unsupported indexed get result type" + ); + } + } + +#define INSTANTIATE_GET(PARAM, GET_TYPE, COUNT_SPEC, INDEXING, ...) \ + INSTANTIATE_GET_##INDEXING(PARAM) + +#define INSTANTIATE_GET_NOT_INDEXED(PARAM) \ + template data::GetResultType \ + Context::Get(); + +#define INSTANTIATE_GET_INDEXED(PARAM) + +#define INSTANTIATE_GET_BOTH(PARAM) \ + template data::GetResultType \ + Context::Get(); + +#define INSTANTIATE_INDEXED_GET(PARAM, GET_TYPE, COUNT_SPEC, INDEXING, ...) \ + INSTANTIATE_INDEXED_GET_##INDEXING(PARAM) + +#define INSTANTIATE_INDEXED_GET_NOT_INDEXED(PARAM) + +#define INSTANTIATE_INDEXED_GET_INDEXED(PARAM) \ + template data::GetResultType \ + Context::Get(uint32_t); + +#define INSTANTIATE_INDEXED_GET_BOTH(PARAM) \ + template data::GetResultType \ + Context::Get(uint32_t); + +BAREGL_GET_RESULTS(INSTANTIATE_GET) +BAREGL_GET_RESULTS(INSTANTIATE_INDEXED_GET) + +#undef INSTANTIATE_INDEXED_GET_BOTH +#undef INSTANTIATE_INDEXED_GET_INDEXED +#undef INSTANTIATE_INDEXED_GET_NOT_INDEXED +#undef INSTANTIATE_INDEXED_GET +#undef INSTANTIATE_GET_BOTH +#undef INSTANTIATE_GET_INDEXED +#undef INSTANTIATE_GET_NOT_INDEXED +#undef INSTANTIATE_GET + +} diff --git a/Dependencies/baregl/src/baregl/Framebuffer.cpp b/Dependencies/baregl/src/baregl/Framebuffer.cpp new file mode 100644 index 000000000..bd38458ac --- /dev/null +++ b/Dependencies/baregl/src/baregl/Framebuffer.cpp @@ -0,0 +1,267 @@ +/** +* @project: baregl +* @author: Adrien Givry +* @licence: MIT +*/ + +#include + +#include +#include +#include +#include +#include +#include + +namespace +{ + constexpr uint32_t k_maxColorAttachmentCount = 32; +} + +namespace baregl +{ + template<> + void Framebuffer::Attach( + std::shared_ptr p_toAttach, + types::EFramebufferAttachment p_attachment, + uint32_t p_index, + std::optional p_layer + ) + { + BAREGL_ASSERT(p_toAttach != nullptr, "Cannot attach a null renderbuffer"); + BAREGL_ASSERT(!p_layer.has_value(), "Renderbuffer cannot use layers"); + BAREGL_ASSERT(p_index == 0 || p_attachment == types::EFramebufferAttachment::COLOR, "Only color attachments support indexing"); + BAREGL_ASSERT(p_index < k_maxColorAttachmentCount, "Color attachment index must be in range [0, 31]"); + + const auto attachmentIndex = utils::EnumToValue(p_attachment) + static_cast(p_index); + glNamedFramebufferRenderbuffer(m_id, attachmentIndex, GL_RENDERBUFFER, p_toAttach->GetID()); + m_attachments[attachmentIndex] = p_toAttach; + } + + template<> + void Framebuffer::Attach( + std::shared_ptr p_toAttach, + types::EFramebufferAttachment p_attachment, + uint32_t p_index, + std::optional p_layer + ) + { + BAREGL_ASSERT(p_toAttach != nullptr, "Cannot attach a null texture"); + BAREGL_ASSERT(p_index == 0 || p_attachment == types::EFramebufferAttachment::COLOR, "Only color attachments support indexing"); + BAREGL_ASSERT(p_index < k_maxColorAttachmentCount, "Color attachment index must be in range [0, 31]"); + + const auto attachmentIndex = utils::EnumToValue(p_attachment) + static_cast(p_index); + constexpr uint32_t k_mipMapLevel = 0; + + if (p_layer.has_value()) + { + glNamedFramebufferTextureLayer(m_id, attachmentIndex, p_toAttach->GetID(), k_mipMapLevel, p_layer.value()); + } + else + { + glNamedFramebufferTexture(m_id, attachmentIndex, p_toAttach->GetID(), k_mipMapLevel); + } + + m_attachments[attachmentIndex] = p_toAttach; + } + + Framebuffer::Framebuffer(std::string_view p_debugName) : + m_debugName{ p_debugName } + { + glCreateFramebuffers(1, &m_id); + NOTIFY_FRAMEBUFFER_CREATED; + } + + Framebuffer::~Framebuffer() + { + glDeleteFramebuffers(1, &m_id); + NOTIFY_FRAMEBUFFER_DESTROYED; + } + + void Framebuffer::Bind() const + { + glBindFramebuffer(GL_FRAMEBUFFER, m_id); + } + + void Framebuffer::Unbind() const + { + glBindFramebuffer(GL_FRAMEBUFFER, 0); + } + + bool Framebuffer::Validate() + { + const GLenum status = glCheckNamedFramebufferStatus(m_id, GL_FRAMEBUFFER); + + if (status != GL_FRAMEBUFFER_COMPLETE) + { + BAREGL_LOG_ERROR("Framebuffer validation failed with status: " + std::to_string(status)); + return m_valid = false; + } + + return m_valid = true; + } + + bool Framebuffer::IsValid() const + { + return m_valid; + } + + template<> + std::optional> Framebuffer::GetAttachment( + baregl::types::EFramebufferAttachment p_attachment, + uint32_t p_index + ) const + { + const auto attachmentIndex = utils::EnumToValue(p_attachment) + static_cast(p_index); + + if (m_attachments.contains(attachmentIndex)) + { + auto attachment = m_attachments.at(attachmentIndex); + + if (auto pval = std::get_if>(&attachment); pval && *pval) + { + return **pval; + } + } + + return std::nullopt; + } + + template<> + std::optional> Framebuffer::GetAttachment( + baregl::types::EFramebufferAttachment p_attachment, + uint32_t p_index + ) const + { + const auto attachmentIndex = utils::EnumToValue(p_attachment) + static_cast(p_index); + + if (m_attachments.contains(attachmentIndex)) + { + auto attachment = m_attachments.at(attachmentIndex); + + if (auto pval = std::get_if>(&attachment); pval && *pval) + { + return **pval; + } + } + + return std::nullopt; + } + + void Framebuffer::Resize(uint16_t p_width, uint16_t p_height) + { + BAREGL_ASSERT(IsValid(), "Cannot resize an invalid framebuffer"); + + for (auto& attachment : m_attachments) + { + if (const auto pval = std::get_if>(&attachment.second); pval && *pval) + { + (*pval)->Resize(p_width, p_height); + } + else if (const auto* pval = std::get_if>(&attachment.second); pval && *pval) + { + (*pval)->Resize(p_width, p_height); + } + } + } + + void Framebuffer::SetTargetDrawBuffer(std::optional p_index) + { + BAREGL_ASSERT(IsValid(), "Invalid framebuffer"); + BAREGL_ASSERT(!p_index.has_value() || p_index < k_maxColorAttachmentCount, "Color attachment index must be in range [0, 31]"); + + if (p_index.has_value()) + { + glNamedFramebufferDrawBuffer(m_id, GL_COLOR_ATTACHMENT0 + p_index.value()); + } + else + { + glNamedFramebufferDrawBuffer(m_id, GL_NONE); + } + } + + void Framebuffer::SetTargetReadBuffer(std::optional p_index) + { + BAREGL_ASSERT(IsValid(), "Invalid framebuffer"); + BAREGL_ASSERT(!p_index.has_value() || p_index < k_maxColorAttachmentCount, "Color attachment index must be in range [0, 31]"); + + if (p_index.has_value()) + { + glNamedFramebufferReadBuffer(m_id, GL_COLOR_ATTACHMENT0 + p_index.value()); + } + else + { + glNamedFramebufferReadBuffer(m_id, GL_NONE); + } + } + + std::pair Framebuffer::GetSize() const + { + BAREGL_ASSERT(IsValid(), "Cannot get width of an invalid framebuffer"); + + // Attachments are expected to be of the same size, other Validate() would fail. + // We only need to return the size of the first attachment found, whether it's a texture of render buffer. + for (auto& attachment : m_attachments) + { + if (const auto pval = std::get_if>(&attachment.second); pval && *pval) + { + return { + (*pval)->GetDesc().width, + (*pval)->GetDesc().height + }; + } + else if (const auto* pval = std::get_if>(&attachment.second); pval && *pval) + { + return { + (*pval)->GetWidth(), + (*pval)->GetHeight() + }; + } + } + + return { {}, {} }; // <-- not an emoji + } + + void Framebuffer::BlitToBackBuffer(uint16_t p_backBufferWidth, uint16_t p_backBufferHeight) const + { + BAREGL_ASSERT(IsValid(), "Cannot blit an invalid framebuffer"); + + auto [width, height] = GetSize(); + + glBlitNamedFramebuffer( + m_id, 0, + 0, 0, width, height, + 0, 0, p_backBufferWidth, p_backBufferHeight, + GL_COLOR_BUFFER_BIT, GL_LINEAR + ); + } + + void Framebuffer::ReadPixels( + uint32_t p_x, + uint32_t p_y, + uint32_t p_width, + uint32_t p_height, + types::EPixelDataFormat p_format, + types::EPixelDataType p_type, + void* p_data) const + { + BAREGL_ASSERT(IsValid(), "Cannot read pixels from an invalid framebuffer"); + BAREGL_ASSERT(p_width > 0 && p_height > 0, "Invalid read size"); + + Bind(); + glReadPixels( + p_x, p_y, + p_width, + p_height, + utils::EnumToValue(p_format), + utils::EnumToValue(p_type), + p_data + ); + Unbind(); + } + + const std::string& Framebuffer::GetDebugName() const + { + return m_debugName; + } +} diff --git a/Dependencies/baregl/src/baregl/Renderbuffer.cpp b/Dependencies/baregl/src/baregl/Renderbuffer.cpp new file mode 100644 index 000000000..a742afc70 --- /dev/null +++ b/Dependencies/baregl/src/baregl/Renderbuffer.cpp @@ -0,0 +1,78 @@ +/** +* @project: baregl +* @author: Adrien Givry +* @licence: MIT +*/ + +#include + +#include +#include +#include +#include + +namespace baregl +{ + Renderbuffer::Renderbuffer() + { + glCreateRenderbuffers(1, &m_id); + NOTIFY_RENDERBUFFER_CREATED; + } + + Renderbuffer::~Renderbuffer() + { + glDeleteRenderbuffers(1, &m_id); + NOTIFY_RENDERBUFFER_DESTROYED; + } + + void Renderbuffer::Bind() const + { + glBindRenderbuffer(GL_RENDERBUFFER, m_id); + } + + void Renderbuffer::Unbind() const + { + glBindRenderbuffer(GL_RENDERBUFFER, 0); + } + + void Renderbuffer::Allocate(uint16_t p_width, uint16_t p_height, types::EInternalFormat p_format) + { + m_width = p_width; + m_height = p_height; + m_format = p_format; + + glNamedRenderbufferStorage(m_id, utils::EnumToValue(m_format), m_width, m_height); + + m_allocated = true; + } + + bool Renderbuffer::IsValid() const + { + return m_allocated; + } + + void Renderbuffer::Resize(uint16_t p_width, uint16_t p_height) + { + BAREGL_ASSERT(IsValid(), "Cannot resize a renderbuffer that has not been allocated"); + + if (m_width == p_width && m_height == p_height) + { + return; + } + + Allocate(p_width, p_height, m_format); + } + + + uint16_t Renderbuffer::GetWidth() const + { + BAREGL_ASSERT(IsValid(), "Cannot get width of an invalid renderbuffer"); + return m_width; + } + + uint16_t Renderbuffer::GetHeight() const + { + BAREGL_ASSERT(IsValid(), "Cannot get height of an invalid renderbuffer"); + return m_height; + } +} diff --git a/Dependencies/baregl/src/baregl/ShaderProgram.cpp b/Dependencies/baregl/src/baregl/ShaderProgram.cpp new file mode 100644 index 000000000..fe24ebc46 --- /dev/null +++ b/Dependencies/baregl/src/baregl/ShaderProgram.cpp @@ -0,0 +1,224 @@ +/** +* @project: baregl +* @author: Adrien Givry +* @licence: MIT +*/ + +#include + +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +namespace baregl +{ + ShaderProgram::ShaderProgram() : + detail::NativeObject(glCreateProgram()) + { + NOTIFY_SHADER_PROGRAM_CREATED; + } + + ShaderProgram::~ShaderProgram() + { + glDeleteProgram(m_id); + NOTIFY_SHADER_PROGRAM_DESTROYED; + } + + void ShaderProgram::Bind() const + { + glUseProgram(m_id); + } + + void ShaderProgram::Unbind() const + { + glUseProgram(0); + } + + void ShaderProgram::Attach(const ShaderStage& p_shader) + { + glAttachShader(m_id, p_shader.GetID()); + m_attachedShaders.push_back(std::ref(p_shader)); + } + + void ShaderProgram::Detach(const ShaderStage& p_shader) + { + glDetachShader(m_id, p_shader.GetID()); + m_attachedShaders.erase(std::remove_if( + m_attachedShaders.begin(), + m_attachedShaders.end(), + [&p_shader](const std::reference_wrapper shader) { + return shader.get().GetID() == p_shader.GetID(); + } + )); + } + + void ShaderProgram::DetachAll() + { + for (auto& shader : m_attachedShaders) + { + glDetachShader(m_id, shader.get().GetID()); + } + + m_attachedShaders.clear(); + } + + baregl::data::ShaderLinkingResult ShaderProgram::Link() + { + glLinkProgram(m_id); + + GLint linkStatus; + glGetProgramiv(m_id, GL_LINK_STATUS, &linkStatus); + + if (linkStatus == GL_FALSE) + { + GLint maxLength; + glGetProgramiv(m_id, GL_INFO_LOG_LENGTH, &maxLength); + + std::string errorLog(maxLength, ' '); + glGetProgramInfoLog(m_id, maxLength, &maxLength, errorLog.data()); + + return { + .success = false, + .message = errorLog + }; + } + + QueryUniforms(); + + return { + .success = true + }; + } + +#define DECLARE_GET_UNIFORM_FUNCTION(type, glType, func) \ +template<> \ +type ShaderProgram::GetUniform(const std::string& p_name) \ +{ \ + type result{}; \ + if (auto it = m_uniformsLocationCache.find(p_name); it != m_uniformsLocationCache.end()) \ + { \ + func(m_id, it->second, reinterpret_cast(&result)); \ + } \ + return result; \ +} + + DECLARE_GET_UNIFORM_FUNCTION(int, GLint, glGetUniformiv); + DECLARE_GET_UNIFORM_FUNCTION(unsigned int, GLuint, glGetUniformuiv); + DECLARE_GET_UNIFORM_FUNCTION(float, GLfloat, glGetUniformfv); + DECLARE_GET_UNIFORM_FUNCTION(math::Vec2, GLfloat, glGetUniformfv); + DECLARE_GET_UNIFORM_FUNCTION(math::Vec3, GLfloat, glGetUniformfv); + DECLARE_GET_UNIFORM_FUNCTION(math::Vec4, GLfloat, glGetUniformfv); + DECLARE_GET_UNIFORM_FUNCTION(math::Mat3, GLfloat, glGetUniformfv); + DECLARE_GET_UNIFORM_FUNCTION(math::Mat4, GLfloat, glGetUniformfv); + +#define DECLARE_SET_UNIFORM_FUNCTION(type, func, ...) \ +template<> \ +void ShaderProgram::SetUniform(const std::string& p_name, const type& value) \ +{ \ + if (auto it = m_uniformsLocationCache.find(p_name); it != m_uniformsLocationCache.end()) \ + { \ + func(it->second, __VA_ARGS__); \ + } \ +} + + DECLARE_SET_UNIFORM_FUNCTION(int, glUniform1i, value); + DECLARE_SET_UNIFORM_FUNCTION(unsigned int, glUniform1ui, value); + DECLARE_SET_UNIFORM_FUNCTION(float, glUniform1f, value); + DECLARE_SET_UNIFORM_FUNCTION(math::Vec2, glUniform2f, value.x, value.y); + DECLARE_SET_UNIFORM_FUNCTION(math::Vec3, glUniform3f, value.x, value.y, value.z); + DECLARE_SET_UNIFORM_FUNCTION(math::Vec4, glUniform4f, value.x, value.y, value.z, value.w); + DECLARE_SET_UNIFORM_FUNCTION(math::Mat3, glUniformMatrix3fv, 1, GL_FALSE, &value[0][0]); + DECLARE_SET_UNIFORM_FUNCTION(math::Mat4, glUniformMatrix4fv, 1, GL_FALSE, &value[0][0]); + + std::optional> ShaderProgram::GetUniformInfo(const std::string& p_name) const + { + if (m_uniforms.contains(p_name)) + { + return m_uniforms.at(p_name); + } + + return std::nullopt; + } + + const std::unordered_map& ShaderProgram::GetUniforms() const + { + return m_uniforms; + } + + void ShaderProgram::QueryUniforms() + { + m_uniforms.clear(); + + std::array nameBuffer; + + GLint activeUniformCount = 0; + glGetProgramiv(m_id, GL_ACTIVE_UNIFORMS, &activeUniformCount); + + uint32_t textureIndex = 0U; + + for (GLint i = 0; i < activeUniformCount; ++i) + { + GLint arraySize = 0; + GLenum type = 0; + GLsizei actualLength = 0; + + glGetActiveUniform(m_id, i, static_cast(nameBuffer.size()), &actualLength, &arraySize, &type, nameBuffer.data()); + + const auto name = std::string{ nameBuffer.data(), static_cast(actualLength) }; + const auto uniformType = utils::ValueToEnum(type); + const auto location = glGetUniformLocation(m_id, name.c_str()); + + if (location == -1) + { + continue; // Skip uniforms that don't have a valid location (e.g. uniform buffer members) + } + + m_uniformsLocationCache.emplace(name, static_cast(location)); + + const std::any uniformValue = [&]() -> std::any { + switch (uniformType) + { + using enum types::EUniformType; + case BOOL: return static_cast(GetUniform(name)); + case INT: return GetUniform(name); + case UNSIGNED_INT: return GetUniform(name); + case FLOAT: return GetUniform(name); + case FLOAT_VEC2: return GetUniform(name); + case FLOAT_VEC3: return GetUniform(name); + case FLOAT_VEC4: return GetUniform(name); + case FLOAT_MAT3: return GetUniform(name); + case FLOAT_MAT4: return GetUniform(name); + case SAMPLER_2D: return std::make_any(nullptr); + case SAMPLER_CUBE: return std::make_any(nullptr); + case IMAGE_2D: return std::make_any(nullptr); + case IMAGE_CUBE: return std::make_any(nullptr); + default: return std::nullopt; + } + }(); + + const bool isTexture = + uniformType == types::EUniformType::SAMPLER_2D || + uniformType == types::EUniformType::SAMPLER_CUBE || + uniformType == types::EUniformType::IMAGE_2D || + uniformType == types::EUniformType::IMAGE_CUBE; + + // Only add the uniform if it has a value (unsupported uniform types will be ignored) + if (uniformValue.has_value()) + { + m_uniforms.emplace(name, data::UniformInfo{ + .type = uniformType, + .name = name, + .defaultValue = uniformValue, + .textureIndex = isTexture ? std::make_optional(textureIndex++) : std::nullopt + }); + } + } + } +} diff --git a/Dependencies/baregl/src/baregl/ShaderStage.cpp b/Dependencies/baregl/src/baregl/ShaderStage.cpp new file mode 100644 index 000000000..4970c7c3c --- /dev/null +++ b/Dependencies/baregl/src/baregl/ShaderStage.cpp @@ -0,0 +1,67 @@ +/** +* @project: baregl +* @author: Adrien Givry +* @licence: MIT +*/ + +#include + +#include +#include +#include +#include + +#include + +namespace baregl +{ + ShaderStage::ShaderStage(types::EShaderType p_type) : + detail::NativeObject(glCreateShader(utils::EnumToValue(p_type))), + m_type{ p_type } + { + NOTIFY_SHADER_STAGE_CREATED; + } + + ShaderStage::~ShaderStage() + { + glDeleteShader(m_id); + NOTIFY_SHADER_STAGE_DESTROYED; + } + + void ShaderStage::Upload(const std::string& p_source) const + { + const char* source = p_source.c_str(); + glShaderSource(m_id, 1, &source, nullptr); + } + + baregl::data::ShaderCompilationResult ShaderStage::Compile() const + { + glCompileShader(m_id); + + GLint compileStatus; + glGetShaderiv(m_id, GL_COMPILE_STATUS, &compileStatus); + + if (compileStatus == GL_FALSE) + { + GLint maxLength; + glGetShaderiv(m_id, GL_INFO_LOG_LENGTH, &maxLength); + + std::string errorLog(maxLength, ' '); + glGetShaderInfoLog(m_id, maxLength, &maxLength, errorLog.data()); + + return { + .success = false, + .message = errorLog + }; + } + + return { + .success = true + }; + } + + types::EShaderType ShaderStage::GetType() const + { + return m_type; + } +} diff --git a/Dependencies/baregl/src/baregl/Texture.cpp b/Dependencies/baregl/src/baregl/Texture.cpp new file mode 100644 index 000000000..04f21060a --- /dev/null +++ b/Dependencies/baregl/src/baregl/Texture.cpp @@ -0,0 +1,249 @@ +/** +* @project: baregl +* @author: Adrien Givry +* @licence: MIT +*/ + +#include + +#include +#include +#include +#include +#include + +namespace +{ + constexpr uint32_t CalculateMipMapLevels(uint32_t p_width, uint32_t p_height) + { + uint32_t maxDim = p_width > p_height ? p_width : p_height; + uint32_t levels = 0; + + while (maxDim > 1) + { + maxDim >>= 1; + ++levels; + } + + return levels ? levels + 1 : 1u; + } + + constexpr bool IsValidMipMapFilter(baregl::types::ETextureFilteringMode p_mode) + { + return + p_mode == baregl::types::ETextureFilteringMode::NEAREST_MIPMAP_NEAREST || + p_mode == baregl::types::ETextureFilteringMode::NEAREST_MIPMAP_LINEAR || + p_mode == baregl::types::ETextureFilteringMode::LINEAR_MIPMAP_NEAREST || + p_mode == baregl::types::ETextureFilteringMode::LINEAR_MIPMAP_LINEAR; + } +} + +namespace baregl +{ + Texture::Texture(types::ETextureType p_type, std::string_view p_debugName) : + m_type{ utils::EnumToValue(p_type) } + { + glCreateTextures(m_type, 1, &m_id); + m_debugName = p_debugName; + NOTIFY_TEXTURE_CREATED; + } + + void Texture::Bind(std::optional p_slot) const + { + if (p_slot.has_value()) + { + glBindTextureUnit(p_slot.value(), m_id); + } + else + { + glBindTexture(m_type, m_id); + } + } + + void Texture::Bind(uint32_t p_slot, types::EImageAccessSpecifier p_access, types::EInternalFormat p_format, uint32_t p_level, std::optional p_layer) const + { + const bool layered = !p_layer.has_value(); + const uint32_t layer = layered ? 0 : p_layer.value(); + + glBindImageTexture(p_slot, m_id, p_level, layered, layer, utils::EnumToValue(p_access), utils::EnumToValue(p_format)); + } + + void Texture::Unbind() const + { + glBindTexture(m_type, 0); + } + + types::ETextureType Texture::GetType() const + { + return utils::ValueToEnum(m_type); + } + + Texture::~Texture() + { + glDeleteTextures(1, &m_id); + NOTIFY_TEXTURE_DESTROYED; + } + + void Texture::Allocate(const data::TextureDesc& p_desc) + { + auto& desc = m_desc; + + desc = p_desc; + desc.width = std::max(1u, desc.width); + desc.height = std::max(1u, desc.height); + + if (desc.mutableDesc.has_value()) + { + const auto& mutableDesc = desc.mutableDesc.value(); + + BAREGL_ASSERT(m_type == GL_TEXTURE_2D, "Mutable textures are only supported for 2D textures"); + + // No DSA version for glTexImage2D (mutable texture), + // so we need to Bind/Unbind the texture. + Bind(); + glTexImage2D( + m_type, + 0, + utils::EnumToValue(desc.internalFormat), + desc.width, + desc.height, + 0, + utils::EnumToValue(mutableDesc.format), + utils::EnumToValue(mutableDesc.type), + mutableDesc.data + ); + Unbind(); + } + else + { + // If the underlying texture is a cube map, this will allocate all 6 sides. + // No need to iterate over each side. + glTextureStorage2D( + m_id, + desc.useMipMaps ? CalculateMipMapLevels(desc.width, desc.height) : 1, + utils::EnumToValue(desc.internalFormat), + desc.width, + desc.height + ); + } + + // Once the texture is allocated, we don't need to set the parameters again + if (!m_allocated) + { + glTextureParameteri(m_id, GL_TEXTURE_WRAP_S, utils::EnumToValue(p_desc.horizontalWrap)); + glTextureParameteri(m_id, GL_TEXTURE_WRAP_T, utils::EnumToValue(p_desc.verticalWrap)); + glTextureParameteri(m_id, GL_TEXTURE_MIN_FILTER, utils::EnumToValue(p_desc.minFilter)); + glTextureParameteri(m_id, GL_TEXTURE_MAG_FILTER, utils::EnumToValue(p_desc.magFilter)); + } + + m_allocated = true; + } + + bool Texture::IsValid() const + { + return m_allocated; + } + + bool Texture::IsMutable() const + { + BAREGL_ASSERT(IsValid(), "Cannot check if a texture is mutable before it has been allocated"); + return m_desc.mutableDesc.has_value(); + } + + void Texture::Upload(const void* p_data, types::EFormat p_format, types::EPixelDataType p_type) + { + BAREGL_ASSERT(IsValid(), "Cannot upload data to a texture before it has been allocated"); + BAREGL_ASSERT(p_data, "Cannot upload texture data from a null pointer"); + + if (IsMutable()) + { + m_desc.mutableDesc.value().data = p_data; + Allocate(m_desc); + } + else + { + if (m_type == GL_TEXTURE_CUBE_MAP) + { + for (uint32_t i = 0; i < 6; ++i) + { + glTextureSubImage3D( + m_id, + 0, + 0, + 0, + i, + m_desc.width, + m_desc.height, + 1, + utils::EnumToValue(p_format), + utils::EnumToValue(p_type), + p_data + ); + } + } + else + { + glTextureSubImage2D( + m_id, + 0, + 0, + 0, + m_desc.width, + m_desc.height, + utils::EnumToValue(p_format), + utils::EnumToValue(p_type), + p_data + ); + } + } + } + + void Texture::Resize(uint32_t p_width, uint32_t p_height) + { + BAREGL_ASSERT(IsValid(), "Cannot resize a texture before it has been allocated"); + BAREGL_ASSERT(IsMutable(), "Cannot resize an immutable texture"); + + auto& desc = m_desc; + + if (p_width != desc.width || p_height != desc.height) + { + desc.width = p_width; + desc.height = p_height; + + Allocate(desc); + } + } + + const baregl::data::TextureDesc& Texture::GetDesc() const + { + BAREGL_ASSERT(IsValid(), "Cannot get the descriptor of a texture before it has been allocated"); + return m_desc; + } + + void Texture::GenerateMipmaps() const + { + BAREGL_ASSERT(IsValid(), "Cannot generate mipmaps for a texture before it has been allocated"); + BAREGL_ASSERT(m_desc.useMipMaps, "Cannot generate mipmaps for a texture that doesn't use them"); + + if (IsValidMipMapFilter(m_desc.minFilter)) + { + glGenerateTextureMipmap(m_id); + } + else + { + // In the event a user tries to generate mipmaps for a texture that doesn't use a valid mipmap filter + BAREGL_LOG_ERROR("Cannot generate mipmaps for a texture that doesn't use a valid mipmap filter"); + } + } + + void Texture::SetBorderColor(const math::Vec4& p_color) + { + BAREGL_ASSERT(IsValid(), "Cannot set border color for a texture before it has been allocated"); + glTextureParameterfv(m_id, GL_TEXTURE_BORDER_COLOR, &p_color.x); + } + + const std::string& Texture::GetDebugName() const + { + return m_debugName; + } +} diff --git a/Dependencies/baregl/src/baregl/VertexArray.cpp b/Dependencies/baregl/src/baregl/VertexArray.cpp new file mode 100644 index 000000000..3b9ad86a1 --- /dev/null +++ b/Dependencies/baregl/src/baregl/VertexArray.cpp @@ -0,0 +1,191 @@ +/** +* @project: baregl +* @author: Adrien Givry +* @licence: MIT +*/ + +#include + +#include +#include +#include +#include + +namespace +{ + uint32_t GetDataTypeSizeInBytes(baregl::types::EDataType p_type) + { + switch (p_type) + { + case baregl::types::EDataType::BYTE: return sizeof(GLbyte); + case baregl::types::EDataType::UNSIGNED_BYTE: return sizeof(GLubyte); + case baregl::types::EDataType::SHORT: return sizeof(GLshort); + case baregl::types::EDataType::UNSIGNED_SHORT: return sizeof(GLushort); + case baregl::types::EDataType::INT: return sizeof(GLint); + case baregl::types::EDataType::UNSIGNED_INT: return sizeof(GLuint); + case baregl::types::EDataType::FLOAT: return sizeof(GLfloat); + case baregl::types::EDataType::DOUBLE: return sizeof(GLdouble); + default: return 0; + } + } + + uint32_t GetAttributeSizeInBytes(const baregl::data::VertexAttribute& p_attribute) + { + return std::visit([](const auto& attr) -> uint32_t { + using T = std::decay_t; + if constexpr (std::is_same_v) + { + return sizeof(GLdouble) * attr.count; + } + else + { + return GetDataTypeSizeInBytes(attr.type) * attr.count; + } + }, p_attribute); + } + + uint32_t CalculateTotalVertexSize(baregl::data::VertexAttributeLayout p_attributes) + { + uint32_t result = 0; + + for (const auto& attribute : p_attributes) + { + result += GetAttributeSizeInBytes(attribute); + } + + return result; + } + + struct VertexAttribSetter + { + GLuint index; + GLsizei stride; + const GLvoid* offset; + + void operator()(const baregl::data::FloatVertexAttribute& attr) const + { + BAREGL_ASSERT(attr.count >= 1 && attr.count <= 4, "Attribute count must be between 1 and 4"); + glVertexAttribPointer( + index, + static_cast(attr.count), + baregl::utils::EnumToValue(attr.type), + static_cast(attr.normalized), + stride, + offset + ); + } + + void operator()(const baregl::data::IntegerVertexAttribute& attr) const + { + BAREGL_ASSERT(attr.count >= 1 && attr.count <= 4, "Attribute count must be between 1 and 4"); + BAREGL_ASSERT( + attr.type == baregl::types::EDataType::BYTE || + attr.type == baregl::types::EDataType::UNSIGNED_BYTE || + attr.type == baregl::types::EDataType::SHORT || + attr.type == baregl::types::EDataType::UNSIGNED_SHORT || + attr.type == baregl::types::EDataType::INT || + attr.type == baregl::types::EDataType::UNSIGNED_INT, + "glVertexAttribIPointer requires an integer data type" + ); + glVertexAttribIPointer( + index, + static_cast(attr.count), + baregl::utils::EnumToValue(attr.type), + stride, + offset + ); + } + + void operator()(const baregl::data::DoubleVertexAttribute& attr) const + { + BAREGL_ASSERT(attr.count >= 1 && attr.count <= 4, "Attribute count must be between 1 and 4"); + glVertexAttribLPointer( + index, + static_cast(attr.count), + GL_DOUBLE, + stride, + offset + ); + } + }; +} + +namespace baregl +{ + VertexArray::VertexArray() + { + glCreateVertexArrays(1, &m_id); + NOTIFY_VERTEX_ARRAY_CREATED; + } + + VertexArray::~VertexArray() + { + glDeleteVertexArrays(1, &m_id); + NOTIFY_VERTEX_ARRAY_DESTROYED; + } + + bool VertexArray::IsValid() const + { + return m_attributeCount > 0; + } + + void VertexArray::SetLayout( + data::VertexAttributeLayout p_attributes, + Buffer& p_vertexBuffer, + Buffer& p_indexBuffer + ) + { + BAREGL_ASSERT(!IsValid(), "Vertex array layout already set"); + + Bind(); + p_indexBuffer.Bind(types::EBufferType::INDEX); + p_vertexBuffer.Bind(types::EBufferType::VERTEX); + + uint32_t attributeIndex = 0; + + const GLsizei totalSize = static_cast(CalculateTotalVertexSize(p_attributes)); + intptr_t currentOffset = 0; + + for (const auto& attribute : p_attributes) + { + glEnableVertexAttribArray(attributeIndex); + + std::visit(VertexAttribSetter{ + static_cast(attributeIndex), + totalSize, + reinterpret_cast(currentOffset) + }, attribute); + + currentOffset += GetAttributeSizeInBytes(attribute); + ++attributeIndex; + ++m_attributeCount; + } + + Unbind(); + p_indexBuffer.Unbind(); + p_vertexBuffer.Unbind(); + } + + void VertexArray::ResetLayout() + { + BAREGL_ASSERT(IsValid(), "Vertex array layout not already set"); + + Bind(); + for (uint32_t i = 0; i < m_attributeCount; ++i) + { + glDisableVertexAttribArray(i); + } + m_attributeCount = 0; + Unbind(); + } + + void VertexArray::Bind() const + { + glBindVertexArray(m_id); + } + + void VertexArray::Unbind() const + { + glBindVertexArray(0); + } +} diff --git a/Dependencies/baregl/src/baregl/debug/Assert.cpp b/Dependencies/baregl/src/baregl/debug/Assert.cpp new file mode 100644 index 000000000..6e859ffc2 --- /dev/null +++ b/Dependencies/baregl/src/baregl/debug/Assert.cpp @@ -0,0 +1,53 @@ +/** +* @project: baregl +* @author: Adrien Givry +* @licence: MIT +*/ + +#include + +#include + +#include +#include + +namespace +{ + class DefaultAssertHandler final : public baregl::debug::IAssertHandler + { + public: + virtual void OnAssert(const std::string_view p_message) override + { + fprintf( + stdout, + "[baregl] %s\n", + p_message.data() + ); + std::abort(); + } + }; + + std::unique_ptr g_assertHandler = std::make_unique(); +} + +namespace baregl::debug +{ + void SetAssertHandler(std::unique_ptr p_handler) + { + g_assertHandler = std::move(p_handler); + } + + void ResetAssertHandler() + { + g_assertHandler = std::make_unique(); + } + + void Assert(bool condition, const std::string_view p_message) + { + if (!condition) + { + g_assertHandler->OnAssert(p_message); + } + } +} + diff --git a/Dependencies/baregl/src/baregl/debug/Assert.h b/Dependencies/baregl/src/baregl/debug/Assert.h new file mode 100644 index 000000000..77194ca95 --- /dev/null +++ b/Dependencies/baregl/src/baregl/debug/Assert.h @@ -0,0 +1,20 @@ +/** +* @project: baregl +* @author: Adrien Givry +* @licence: MIT +*/ + +#pragma once + +#include + +#if defined(DEBUG) || defined(_DEBUG) + #define BAREGL_ASSERT(condition, message) baregl::debug::Assert(condition, message) +#else + #define BAREGL_ASSERT(condition, message) ((void)(condition), (void)(message)) +#endif + +namespace baregl::debug +{ + void Assert(bool condition, const std::string_view p_message = {}); +} diff --git a/Dependencies/baregl/src/baregl/debug/Event.cpp b/Dependencies/baregl/src/baregl/debug/Event.cpp new file mode 100644 index 000000000..8db16bc9a --- /dev/null +++ b/Dependencies/baregl/src/baregl/debug/Event.cpp @@ -0,0 +1,64 @@ +/** +* @project: baregl +* @author: Adrien Givry +* @licence: MIT +*/ + +#include + +#include + +#include + +namespace +{ + class DefaultEventHandler final : public baregl::debug::IEventHandler + { + public: + virtual void OnBufferCreated([[maybe_unused]] const baregl::Buffer&) override {} + virtual void OnBufferDestroyed([[maybe_unused]] const baregl::Buffer&) override {} + virtual void OnFramebufferCreated([[maybe_unused]] const baregl::Framebuffer&) override {} + virtual void OnFramebufferDestroyed([[maybe_unused]] const baregl::Framebuffer&) override {} + virtual void OnRenderbufferCreated([[maybe_unused]] const baregl::Renderbuffer&) override {} + virtual void OnRenderbufferDestroyed([[maybe_unused]] const baregl::Renderbuffer&) override {} + virtual void OnShaderProgramCreated([[maybe_unused]] const baregl::ShaderProgram&) override {} + virtual void OnShaderProgramDestroyed([[maybe_unused]] const baregl::ShaderProgram&) override {} + virtual void OnShaderStageCreated([[maybe_unused]] const baregl::ShaderStage&) override {} + virtual void OnShaderStageDestroyed([[maybe_unused]] const baregl::ShaderStage&) override {} + virtual void OnTextureCreated([[maybe_unused]] const baregl::Texture&) override {} + virtual void OnTextureDestroyed([[maybe_unused]] const baregl::Texture&) override {} + virtual void OnVertexArrayCreated([[maybe_unused]] const baregl::VertexArray&) override {} + virtual void OnVertexArrayDestroyed([[maybe_unused]] const baregl::VertexArray&) override {} + }; + + std::unique_ptr g_eventHandler = std::make_unique(); +} + +namespace baregl::debug +{ + void SetEventHandler(std::unique_ptr p_handler) + { + g_eventHandler = std::move(p_handler); + } + + void ResetEventHandler() + { + g_eventHandler = std::make_unique(); + } + + void OnBufferCreated(const Buffer& p_buffer) { g_eventHandler->OnBufferCreated(p_buffer); } + void OnBufferDestroyed(const Buffer& p_buffer) { g_eventHandler->OnBufferDestroyed(p_buffer); } + void OnFramebufferCreated(const Framebuffer& p_framebuffer) { g_eventHandler->OnFramebufferCreated(p_framebuffer); } + void OnFramebufferDestroyed(const Framebuffer& p_framebuffer) { g_eventHandler->OnFramebufferDestroyed(p_framebuffer); } + void OnRenderbufferCreated(const Renderbuffer& p_renderbuffer) { g_eventHandler->OnRenderbufferCreated(p_renderbuffer); } + void OnRenderbufferDestroyed(const Renderbuffer& p_renderbuffer) { g_eventHandler->OnRenderbufferDestroyed(p_renderbuffer); } + void OnShaderProgramCreated(const ShaderProgram& p_shaderProgram) { g_eventHandler->OnShaderProgramCreated(p_shaderProgram); } + void OnShaderProgramDestroyed(const ShaderProgram& p_shaderProgram) { g_eventHandler->OnShaderProgramDestroyed(p_shaderProgram); } + void OnShaderStageCreated(const ShaderStage& p_shaderStage) { g_eventHandler->OnShaderStageCreated(p_shaderStage); } + void OnShaderStageDestroyed(const ShaderStage& p_shaderStage) { g_eventHandler->OnShaderStageDestroyed(p_shaderStage); } + void OnTextureCreated(const Texture& p_texture) { g_eventHandler->OnTextureCreated(p_texture); } + void OnTextureDestroyed(const Texture& p_texture) { g_eventHandler->OnTextureDestroyed(p_texture); } + void OnVertexArrayCreated(const VertexArray& p_vertexArray) { g_eventHandler->OnVertexArrayCreated(p_vertexArray); } + void OnVertexArrayDestroyed(const VertexArray& p_vertexArray) { g_eventHandler->OnVertexArrayDestroyed(p_vertexArray); } +} + diff --git a/Dependencies/baregl/src/baregl/debug/Event.h b/Dependencies/baregl/src/baregl/debug/Event.h new file mode 100644 index 000000000..e0884aa05 --- /dev/null +++ b/Dependencies/baregl/src/baregl/debug/Event.h @@ -0,0 +1,52 @@ +/** +* @project: baregl +* @author: Adrien Givry +* @licence: MIT +*/ + +#pragma once + +#define NOTIFY_BUFFER_CREATED baregl::debug::OnBufferCreated(*this) +#define NOTIFY_BUFFER_DESTROYED baregl::debug::OnBufferDestroyed(*this) +#define NOTIFY_FRAMEBUFFER_CREATED baregl::debug::OnFramebufferCreated(*this) +#define NOTIFY_FRAMEBUFFER_DESTROYED baregl::debug::OnFramebufferDestroyed(*this) +#define NOTIFY_RENDERBUFFER_CREATED baregl::debug::OnRenderbufferCreated(*this) +#define NOTIFY_RENDERBUFFER_DESTROYED baregl::debug::OnRenderbufferDestroyed(*this) +#define NOTIFY_SHADER_PROGRAM_CREATED baregl::debug::OnShaderProgramCreated(*this) +#define NOTIFY_SHADER_PROGRAM_DESTROYED baregl::debug::OnShaderProgramDestroyed(*this) +#define NOTIFY_SHADER_STAGE_CREATED baregl::debug::OnShaderStageCreated(*this) +#define NOTIFY_SHADER_STAGE_DESTROYED baregl::debug::OnShaderStageDestroyed(*this) +#define NOTIFY_TEXTURE_CREATED baregl::debug::OnTextureCreated(*this) +#define NOTIFY_TEXTURE_DESTROYED baregl::debug::OnTextureDestroyed(*this) +#define NOTIFY_VERTEX_ARRAY_CREATED baregl::debug::OnVertexArrayCreated(*this) +#define NOTIFY_VERTEX_ARRAY_DESTROYED baregl::debug::OnVertexArrayDestroyed(*this) + +namespace baregl +{ + class Buffer; + class Framebuffer; + class Renderbuffer; + class ShaderProgram; + class ShaderStage; + class Texture; + class VertexArray; +} + +namespace baregl::debug +{ + void OnBufferCreated(const Buffer& p_buffer); + void OnBufferDestroyed(const Buffer& p_buffer); + void OnFramebufferCreated(const Framebuffer& p_framebuffer); + void OnFramebufferDestroyed(const Framebuffer& p_framebuffer); + void OnRenderbufferCreated(const Renderbuffer& p_renderbuffer); + void OnRenderbufferDestroyed(const Renderbuffer& p_renderbuffer); + void OnShaderProgramCreated(const ShaderProgram& p_shaderProgram); + void OnShaderProgramDestroyed(const ShaderProgram& p_shaderProgram); + void OnShaderStageCreated(const ShaderStage& p_shaderStage); + void OnShaderStageDestroyed(const ShaderStage& p_shaderStage); + void OnTextureCreated(const Texture& p_texture); + void OnTextureDestroyed(const Texture& p_texture); + void OnVertexArrayCreated(const VertexArray& p_vertexArray); + void OnVertexArrayDestroyed(const VertexArray& p_vertexArray); +} + diff --git a/Dependencies/baregl/src/baregl/debug/Log.cpp b/Dependencies/baregl/src/baregl/debug/Log.cpp new file mode 100644 index 000000000..3dd1e32d4 --- /dev/null +++ b/Dependencies/baregl/src/baregl/debug/Log.cpp @@ -0,0 +1,79 @@ +/** +* @project: baregl +* @author: Adrien Givry +* @licence: MIT +*/ + +#include + +#include + +#include +#include + +namespace +{ + class DefaultLogHandler final : public baregl::debug::ILogHandler + { + public: + virtual void LogInfo(const std::string_view p_message) override + { + fprintf( + stdout, + "[baregl] %s\n", + p_message.data() + ); + } + + virtual void LogWarning(const std::string_view p_message) override + { + fprintf( + stdout, + "[baregl] %s\n", + p_message.data() + ); + } + + virtual void LogError(const std::string_view p_message) override + { + fprintf( + stderr, + "[baregl] %s\n", + p_message.data() + ); + } + }; + + std::unique_ptr g_logHandler = std::make_unique(); +} + +namespace baregl::debug +{ + void SetLogHandler(std::unique_ptr p_handler) + { + g_logHandler = std::move(p_handler); + } + + void ResetLogHandler() + { + g_logHandler = std::make_unique(); + } + + template<> + void Log(const std::string_view p_message) + { + g_logHandler->LogInfo(p_message); + } + + template<> + void Log(const std::string_view p_message) + { + g_logHandler->LogWarning(p_message); + } + + template<> + void Log(const std::string_view p_message) + { + g_logHandler->LogError(p_message); + } +} diff --git a/Dependencies/baregl/src/baregl/debug/Log.h b/Dependencies/baregl/src/baregl/debug/Log.h new file mode 100644 index 000000000..b00d04093 --- /dev/null +++ b/Dependencies/baregl/src/baregl/debug/Log.h @@ -0,0 +1,26 @@ +/** +* @project: baregl +* @author: Adrien Givry +* @licence: MIT +*/ + +#pragma once + +#include + +#define BAREGL_LOG_INFO(message) baregl::debug::Log(message) +#define BAREGL_LOG_WARNING(message) baregl::debug::Log(message) +#define BAREGL_LOG_ERROR(message) baregl::debug::Log(message) + +namespace baregl::debug +{ + enum class ELogLevel + { + INFO, + WARNING, + ERROR + }; + + template + void Log(const std::string_view p_message); +} diff --git a/Dependencies/baregl/src/baregl/detail/NativeObject.cpp b/Dependencies/baregl/src/baregl/detail/NativeObject.cpp new file mode 100644 index 000000000..3fe6fc8e0 --- /dev/null +++ b/Dependencies/baregl/src/baregl/detail/NativeObject.cpp @@ -0,0 +1,25 @@ +/** +* @project: baregl +* @author: Adrien Givry +* @licence: MIT +*/ + +#include + +#include +#include +#include +#include + +namespace baregl::detail +{ + NativeObject::NativeObject(NativeID p_id) : + m_id{p_id} + { + } + + NativeID NativeObject::GetID() const + { + return m_id; + } +} diff --git a/Dependencies/baregl/src/baregl/detail/Types.h b/Dependencies/baregl/src/baregl/detail/Types.h new file mode 100644 index 000000000..e271f3897 --- /dev/null +++ b/Dependencies/baregl/src/baregl/detail/Types.h @@ -0,0 +1,1016 @@ +/** +* @project: baregl +* @author: Adrien Givry +* @licence: MIT +*/ + +#pragma once + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +template <> +struct baregl::utils::MappingFor +{ + using EnumType = baregl::types::EComparaisonAlgorithm; + using type = std::tuple< + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair + >; +}; + +template <> +struct baregl::utils::MappingFor +{ + using EnumType = baregl::types::EBlendingEquation; + using type = std::tuple< + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair + >; +}; + +template <> +struct baregl::utils::MappingFor +{ + using EnumType = baregl::types::EBlendingFactor; + using type = std::tuple< + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair + >; +}; + +template <> +struct baregl::utils::MappingFor +{ + using EnumType = baregl::types::ERasterizationMode; + using type = std::tuple< + EnumValuePair, + EnumValuePair, + EnumValuePair + >; +}; + +template <> +struct baregl::utils::MappingFor +{ + using EnumType = baregl::types::ECullFace; + using type = std::tuple< + EnumValuePair, + EnumValuePair, + EnumValuePair + >; +}; + +template <> +struct baregl::utils::MappingFor +{ + using EnumType = baregl::types::EHint; + using type = std::tuple< + EnumValuePair, + EnumValuePair, + EnumValuePair + >; +}; + +template <> +struct baregl::utils::MappingFor +{ + using EnumType = baregl::types::ELogicOperation; + using type = std::tuple< + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair + >; +}; + +template <> +struct baregl::utils::MappingFor +{ + using EnumType = baregl::types::EProvokingVertexConvention; + using type = std::tuple< + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair + >; +}; + +template <> +struct baregl::utils::MappingFor +{ + using EnumType = baregl::types::EDrawBuffer; + using type = std::tuple< + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair + >; +}; + +template <> +struct baregl::utils::MappingFor +{ + using EnumType = baregl::types::EOperation; + using type = std::tuple< + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair + >; +}; + +template <> +struct baregl::utils::MappingFor +{ + using EnumType = baregl::types::ERenderingCapability; + using type = std::tuple< + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair + >; +}; + +template <> +struct baregl::utils::MappingFor +{ + using EnumType = baregl::types::EPrimitiveMode; + using type = std::tuple< + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair + >; +}; + +template <> +struct baregl::utils::MappingFor +{ + using EnumType = baregl::types::EFormat; + using type = std::tuple< + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair + >; +}; + +template <> +struct baregl::utils::MappingFor +{ + using EnumType = baregl::types::ETextureFilteringMode; + using type = std::tuple< + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair + >; +}; + +template <> +struct baregl::utils::MappingFor +{ + using EnumType = baregl::types::ETextureWrapMode; + using type = std::tuple< + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair + >; +}; + +template <> +struct baregl::utils::MappingFor +{ + using EnumType = baregl::types::EPixelDataFormat; + using type = std::tuple< + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair + >; +}; + +template <> +struct baregl::utils::MappingFor +{ + using EnumType = baregl::types::EPixelDataType; + using type = std::tuple< + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair + >; +}; + +template <> +struct baregl::utils::MappingFor +{ + using EnumType = baregl::types::EDataType; + using type = std::tuple< + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair + >; +}; + +template <> +struct baregl::utils::MappingFor +{ + using EnumType = baregl::types::EAccessSpecifier; + using type = std::tuple< + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair + >; +}; + +template <> +struct baregl::utils::MappingFor +{ + using EnumType = baregl::types::EImageAccessSpecifier; + using type = std::tuple< + EnumValuePair, + EnumValuePair, + EnumValuePair + >; +}; + +template <> +struct baregl::utils::MappingFor +{ + using EnumType = baregl::types::EUniformType; + using type = std::tuple< + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair + >; +}; + +template <> +struct baregl::utils::MappingFor +{ + using EnumType = baregl::types::EInternalFormat; + using type = std::tuple < + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair + >; +}; + +template <> +struct baregl::utils::MappingFor +{ + using EnumType = baregl::types::EShaderType; + using type = std::tuple< + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair + >; +}; + +template <> +struct baregl::utils::MappingFor +{ + using EnumType = baregl::types::EFramebufferAttachment; + using type = std::tuple< + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair + >; +}; + +template <> +struct baregl::utils::MappingFor +{ + using EnumType = baregl::types::EBufferType; + using type = std::tuple< + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair + >; +}; + +template <> +struct baregl::utils::MappingFor +{ + using EnumType = baregl::types::ETextureType; + using type = std::tuple< + EnumValuePair, + EnumValuePair + >; +}; + +template <> +struct baregl::utils::MappingFor +{ + using EnumType = baregl::types::ETextureUnit; + using type = std::tuple< + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair + >; +}; + +template <> +struct baregl::utils::MappingFor +{ + using EnumType = baregl::types::EMemoryBarrierFlags; + using type = std::tuple< + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair + >; +}; + +template <> +struct baregl::utils::MappingFor +{ + using EnumType = baregl::types::EContextFlags; + using type = std::tuple< + EnumValuePair(0)>, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair(0x00000008)> + >; +}; + +template <> +struct baregl::utils::MappingFor +{ + using EnumType = baregl::types::EGetParameter; + using type = std::tuple< + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair, + EnumValuePair + + >; +}; diff --git a/Dependencies/glad/src/glad.c b/Dependencies/baregl/src/baregl/detail/glad/glad.c similarity index 99% rename from Dependencies/glad/src/glad.c rename to Dependencies/baregl/src/baregl/detail/glad/glad.c index c6bf132ef..cf09e4448 100644 --- a/Dependencies/glad/src/glad.c +++ b/Dependencies/baregl/src/baregl/detail/glad/glad.c @@ -22,7 +22,7 @@ #include #include #include -#include "glad.h" +#include static void* get_proc(const char *namez); diff --git a/Dependencies/baregl/src/baregl/utils/EnumMapper.h b/Dependencies/baregl/src/baregl/utils/EnumMapper.h new file mode 100644 index 000000000..210602772 --- /dev/null +++ b/Dependencies/baregl/src/baregl/utils/EnumMapper.h @@ -0,0 +1,163 @@ +/** +* @project: baregl +* @author: Adrien Givry +* @licence: MIT +*/ + +#pragma once + +#include + +#include +#include + +namespace baregl::utils +{ + template + struct EnumValuePair + { + static constexpr auto enumValue = EnumValue; + static constexpr auto value = Value; + using ValueType = decltype(Value); + using EnumType = decltype(EnumValue); + }; + + template + constexpr std::size_t tuple_size_v = std::tuple_size::value; + + template + struct MappingFor; + + template ::type, std::size_t I = 0> + constexpr ValueType ToValueImpl(EnumType enumValue) + { + if constexpr (I == tuple_size_v) + { + return ValueType{}; + } + else + { + using CurrentPair = typename std::tuple_element::type; + if (enumValue == CurrentPair::enumValue) + { + return CurrentPair::value; + } + else + { + return ToValueImpl(enumValue); + } + } + } + + template ::type, std::size_t I = 0> + constexpr EnumType FromValueImpl(ValueType value) + { + if constexpr (I == tuple_size_v) + { + if constexpr (requires { EnumType::UNKNOWN; }) + { + return EnumType::UNKNOWN; + } + else + { + throw std::runtime_error(std::format("Value '{}' not found in mapping", value)); + } + } + else + { + using CurrentPair = typename std::tuple_element::type; + if (value == CurrentPair::value) + { + return CurrentPair::enumValue; + } + else + { + return FromValueImpl(value); + } + } + } + + // New flag conversion functions + template ::type, std::size_t I = 0> + constexpr ValueType ToFlagsImpl(EnumType enumFlags) + { + if constexpr (I == tuple_size_v) + { + return ValueType{}; + } + else + { + using CurrentPair = typename std::tuple_element::type; + ValueType result{}; + + // Check if this flag is set in the input + if ((enumFlags & CurrentPair::enumValue) == CurrentPair::enumValue) + { + result = CurrentPair::value; + } + + // Recursively check remaining flags + if constexpr (I + 1 < tuple_size_v) + { + result = result | ToFlagsImpl(enumFlags); + } + + return result; + } + } + + template ::type, std::size_t I = 0> + constexpr EnumType FromFlagsImpl(ValueType valueFlags) + { + if constexpr (I == tuple_size_v) + { + return EnumType{}; + } + else + { + using CurrentPair = typename std::tuple_element::type; + EnumType result{}; + + // Check if this flag is set in the input + if ((valueFlags & CurrentPair::value) == CurrentPair::value) + { + result = CurrentPair::enumValue; + } + + // Recursively check remaining flags + if constexpr (I + 1 < tuple_size_v) + { + result = result | FromFlagsImpl(valueFlags); + } + + return result; + } + } + + // Public interface functions + template + constexpr ValueType EnumToValue(EnumType enumValue) + { + if constexpr (baregl::utils::is_bitmask_enum_v) + { + return baregl::utils::ToFlagsImpl(enumValue); + } + else + { + return baregl::utils::ToValueImpl(enumValue); + } + } + + template + constexpr EnumType ValueToEnum(ValueType value) + { + if constexpr (baregl::utils::is_bitmask_enum_v) + { + return baregl::utils::FromFlagsImpl(value); + } + else + { + return baregl::utils::FromValueImpl(value); + } + } +} diff --git a/Scripts/Windows/Build.bat b/Scripts/Windows/Build.bat index 3b9eff5f8..5edec924f 100644 --- a/Scripts/Windows/Build.bat +++ b/Scripts/Windows/Build.bat @@ -56,10 +56,16 @@ exit /b 1 echo vswhere.exe found at: "!VSWHERE_PATH!" echo. -:: Get the msbuild path using vswhere -echo Searching for msbuild.exe... +:: Get the msbuild path using vswhere. +:: Prefer 64-bit MSBuild to avoid compiler heap exhaustion on template-heavy translation units. +echo Searching for 64-bit msbuild.exe... -for /f "tokens=*" %%i in ('"!VSWHERE_PATH!" -latest -products * -requires Microsoft.Component.MSBuild -find MSBuild\**\Bin\MSBuild.exe') do set "MSBUILD_PATH=%%i" +for /f "tokens=*" %%i in ('"!VSWHERE_PATH!" -latest -products * -requires Microsoft.Component.MSBuild -find MSBuild\**\Bin\amd64\MSBuild.exe') do set "MSBUILD_PATH=%%i" + +if not defined MSBUILD_PATH ( + echo 64-bit msbuild.exe not found, searching for any msbuild.exe... + for /f "tokens=*" %%i in ('"!VSWHERE_PATH!" -latest -products * -requires Microsoft.Component.MSBuild -find MSBuild\**\Bin\MSBuild.exe') do set "MSBUILD_PATH=%%i" +) if not defined MSBUILD_PATH ( echo msbuild.exe was not found using vswhere. @@ -76,10 +82,10 @@ echo. pushd "%~dp0..\..\" if "%CONFIGURATION%"=="" ( echo Building with default configuration configuration... - "!MSBUILD_PATH!" Overload.sln -m -verbosity:minimal + "!MSBUILD_PATH!" Overload.sln -m -verbosity:minimal /p:PreferredToolArchitecture=x64 ) else ( echo Building with configuration: %CONFIGURATION%... - "!MSBUILD_PATH!" Overload.sln -m -verbosity:minimal /p:Configuration=%CONFIGURATION% + "!MSBUILD_PATH!" Overload.sln -m -verbosity:minimal /p:Configuration=%CONFIGURATION% /p:PreferredToolArchitecture=x64 ) popd diff --git a/Sources/OvCore/include/OvCore/ECS/Components/CReflectionProbe.h b/Sources/OvCore/include/OvCore/ECS/Components/CReflectionProbe.h index 7bbab2439..94ea1dbd1 100644 --- a/Sources/OvCore/include/OvCore/ECS/Components/CReflectionProbe.h +++ b/Sources/OvCore/include/OvCore/ECS/Components/CReflectionProbe.h @@ -6,11 +6,12 @@ #pragma once +#include +#include +#include + #include #include -#include -#include -#include namespace OvCore::ECS { class Actor; } @@ -162,7 +163,7 @@ namespace OvCore::ECS::Components /** * Returns the last complete cubemap captured by the reflection probe */ - std::shared_ptr GetCubemap() const; + std::shared_ptr GetCubemap() const; /** * Serialize the component @@ -189,8 +190,8 @@ namespace OvCore::ECS::Components void _AllocateResources(); void _PrepareUBO(); std::vector _GetCaptureFaceIndices(); - OvRendering::HAL::Framebuffer& _GetTargetFramebuffer() const; - OvRendering::HAL::UniformBuffer& _GetUniformBuffer() const; + baregl::Framebuffer& _GetTargetFramebuffer() const; + baregl::Buffer& _GetUniformBuffer() const; bool _IsDoubleBuffered() const; friend class OvCore::Rendering::ReflectionRenderPass; @@ -205,9 +206,9 @@ namespace OvCore::ECS::Components private: // Double buffering so we can render to progressively one while reading from the other Rendering::PingPongFramebuffer m_framebuffers; - std::array, 2> m_cubemaps; - OvTools::Utils::CircularIterator, 2> m_cubemapIterator; - std::unique_ptr m_uniformBuffer; + std::array, 2> m_cubemaps; + OvTools::Utils::CircularIterator, 2> m_cubemapIterator; + std::unique_ptr m_uniformBuffer; uint32_t m_captureFaceIndex = 0; // Current frame index in the capture process std::optional m_captureRequest = std::nullopt; bool m_isAnyCubemapComplete = false; diff --git a/Sources/OvCore/include/OvCore/Rendering/EngineBufferRenderFeature.h b/Sources/OvCore/include/OvCore/Rendering/EngineBufferRenderFeature.h index f432cfbd0..6a9c1ce6f 100644 --- a/Sources/OvCore/include/OvCore/Rendering/EngineBufferRenderFeature.h +++ b/Sources/OvCore/include/OvCore/Rendering/EngineBufferRenderFeature.h @@ -10,8 +10,9 @@ #include #include +#include + #include -#include #include namespace OvCore::Rendering @@ -45,6 +46,6 @@ namespace OvCore::Rendering protected: std::chrono::high_resolution_clock::time_point m_startTime; - std::unique_ptr m_engineBuffer; + std::unique_ptr m_engineBuffer; }; } diff --git a/Sources/OvCore/include/OvCore/Rendering/FramebufferUtil.h b/Sources/OvCore/include/OvCore/Rendering/FramebufferUtil.h index ce46eca08..3c2388177 100644 --- a/Sources/OvCore/include/OvCore/Rendering/FramebufferUtil.h +++ b/Sources/OvCore/include/OvCore/Rendering/FramebufferUtil.h @@ -8,7 +8,7 @@ #include -#include +#include namespace OvCore::Rendering::FramebufferUtil { @@ -22,8 +22,8 @@ namespace OvCore::Rendering::FramebufferUtil * @param p_useStencil */ void SetupFramebuffer( - OvRendering::HAL::Framebuffer& p_framebuffer, - const OvRendering::Settings::TextureDesc& p_textureDesc, + baregl::Framebuffer& p_framebuffer, + const baregl::data::TextureDesc& p_textureDesc, bool p_useDepth = true, bool p_useStencil = false ); @@ -39,7 +39,7 @@ namespace OvCore::Rendering::FramebufferUtil * @param p_useMipMaps */ void SetupFramebuffer( - OvRendering::HAL::Framebuffer& p_framebuffer, + baregl::Framebuffer& p_framebuffer, uint32_t p_width = 0, uint32_t p_height = 0, bool p_useDepth = true, diff --git a/Sources/OvCore/include/OvCore/Rendering/PingPongFramebuffer.h b/Sources/OvCore/include/OvCore/Rendering/PingPongFramebuffer.h index f1dfa4dbf..e79935635 100644 --- a/Sources/OvCore/include/OvCore/Rendering/PingPongFramebuffer.h +++ b/Sources/OvCore/include/OvCore/Rendering/PingPongFramebuffer.h @@ -8,7 +8,7 @@ #include -#include +#include #include namespace OvCore::Rendering @@ -16,7 +16,7 @@ namespace OvCore::Rendering /** * Convenient ping-pong buffer holding two framebuffers */ - class PingPongFramebuffer : public OvTools::Utils::CircularIterator + class PingPongFramebuffer : public OvTools::Utils::CircularIterator { public: /** @@ -28,9 +28,9 @@ namespace OvCore::Rendering /** * Return the two framebuffers */ - std::array& GetFramebuffers(); + std::array& GetFramebuffers(); private: - std::array m_framebuffers; + std::array m_framebuffers; }; } diff --git a/Sources/OvCore/include/OvCore/Rendering/PostProcess/AEffect.h b/Sources/OvCore/include/OvCore/Rendering/PostProcess/AEffect.h index 0377647ac..1bca8b4b0 100644 --- a/Sources/OvCore/include/OvCore/Rendering/PostProcess/AEffect.h +++ b/Sources/OvCore/include/OvCore/Rendering/PostProcess/AEffect.h @@ -54,8 +54,8 @@ namespace OvCore::Rendering::PostProcess */ virtual void Draw( OvRendering::Data::PipelineState p_pso, - OvRendering::HAL::Framebuffer& p_src, - OvRendering::HAL::Framebuffer& p_dst, + baregl::Framebuffer& p_src, + baregl::Framebuffer& p_dst, const EffectSettings& p_settings ) = 0; diff --git a/Sources/OvCore/include/OvCore/Rendering/PostProcess/AutoExposureEffect.h b/Sources/OvCore/include/OvCore/Rendering/PostProcess/AutoExposureEffect.h index daff7056f..0f0c7e073 100644 --- a/Sources/OvCore/include/OvCore/Rendering/PostProcess/AutoExposureEffect.h +++ b/Sources/OvCore/include/OvCore/Rendering/PostProcess/AutoExposureEffect.h @@ -50,14 +50,14 @@ namespace OvCore::Rendering::PostProcess */ virtual void Draw( OvRendering::Data::PipelineState p_pso, - OvRendering::HAL::Framebuffer& p_src, - OvRendering::HAL::Framebuffer& p_dst, + baregl::Framebuffer& p_src, + baregl::Framebuffer& p_dst, const EffectSettings& p_settings ) override; private: std::optional m_previousTime; - OvRendering::HAL::Framebuffer m_luminanceBuffer; + baregl::Framebuffer m_luminanceBuffer; PingPongFramebuffer m_exposurePingPongBuffer; OvRendering::Data::Material m_luminanceMaterial; OvRendering::Data::Material m_exposureMaterial; @@ -66,4 +66,4 @@ namespace OvCore::Rendering::PostProcess // Used to skip the first frame of the exposure adaptation bool m_firstFrame = true; }; -} \ No newline at end of file +} diff --git a/Sources/OvCore/include/OvCore/Rendering/PostProcess/BloomEffect.h b/Sources/OvCore/include/OvCore/Rendering/PostProcess/BloomEffect.h index 48fa0e68d..fb5e0d6a4 100644 --- a/Sources/OvCore/include/OvCore/Rendering/PostProcess/BloomEffect.h +++ b/Sources/OvCore/include/OvCore/Rendering/PostProcess/BloomEffect.h @@ -8,7 +8,7 @@ #include #include -#include +#include namespace OvCore::Rendering::PostProcess { @@ -58,17 +58,17 @@ namespace OvCore::Rendering::PostProcess */ virtual void Draw( OvRendering::Data::PipelineState p_pso, - OvRendering::HAL::Framebuffer& p_src, - OvRendering::HAL::Framebuffer& p_dst, + baregl::Framebuffer& p_src, + baregl::Framebuffer& p_dst, const EffectSettings& p_settings ) override; private: - std::array m_bloomSamplingBuffers; - OvRendering::HAL::Framebuffer m_bloomOutputBuffer; + std::array m_bloomSamplingBuffers; + baregl::Framebuffer m_bloomOutputBuffer; OvRendering::Data::Material m_downsamplingMaterial; OvRendering::Data::Material m_upsamplingMaterial; OvRendering::Data::Material m_bloomMaterial; OvRendering::Data::Material m_blitMaterial; }; -} \ No newline at end of file +} diff --git a/Sources/OvCore/include/OvCore/Rendering/PostProcess/FXAAEffect.h b/Sources/OvCore/include/OvCore/Rendering/PostProcess/FXAAEffect.h index 579861005..38cd69e35 100644 --- a/Sources/OvCore/include/OvCore/Rendering/PostProcess/FXAAEffect.h +++ b/Sources/OvCore/include/OvCore/Rendering/PostProcess/FXAAEffect.h @@ -38,8 +38,8 @@ namespace OvCore::Rendering::PostProcess */ virtual void Draw( OvRendering::Data::PipelineState p_pso, - OvRendering::HAL::Framebuffer& p_src, - OvRendering::HAL::Framebuffer& p_dst, + baregl::Framebuffer& p_src, + baregl::Framebuffer& p_dst, const EffectSettings& p_settings ) override; diff --git a/Sources/OvCore/include/OvCore/Rendering/PostProcess/TonemappingEffect.h b/Sources/OvCore/include/OvCore/Rendering/PostProcess/TonemappingEffect.h index d0254e659..36190d051 100644 --- a/Sources/OvCore/include/OvCore/Rendering/PostProcess/TonemappingEffect.h +++ b/Sources/OvCore/include/OvCore/Rendering/PostProcess/TonemappingEffect.h @@ -59,12 +59,12 @@ namespace OvCore::Rendering::PostProcess */ virtual void Draw( OvRendering::Data::PipelineState p_pso, - OvRendering::HAL::Framebuffer& p_src, - OvRendering::HAL::Framebuffer& p_dst, + baregl::Framebuffer& p_src, + baregl::Framebuffer& p_dst, const EffectSettings& p_settings ) override; private: OvRendering::Data::Material m_tonemappingMaterial; }; -} \ No newline at end of file +} diff --git a/Sources/OvCore/include/OvCore/Rendering/PostProcessRenderPass.h b/Sources/OvCore/include/OvCore/Rendering/PostProcessRenderPass.h index 481457e2f..5722f33bf 100644 --- a/Sources/OvCore/include/OvCore/Rendering/PostProcessRenderPass.h +++ b/Sources/OvCore/include/OvCore/Rendering/PostProcessRenderPass.h @@ -7,7 +7,7 @@ #pragma once #include -#include +#include #include #include diff --git a/Sources/OvCore/include/OvCore/Rendering/ReflectionRenderPass.h b/Sources/OvCore/include/OvCore/Rendering/ReflectionRenderPass.h index c417f30b6..5ef8b7436 100644 --- a/Sources/OvCore/include/OvCore/Rendering/ReflectionRenderPass.h +++ b/Sources/OvCore/include/OvCore/Rendering/ReflectionRenderPass.h @@ -7,7 +7,7 @@ #pragma once #include -#include +#include #include #include diff --git a/Sources/OvCore/include/OvCore/Rendering/SceneRenderer.h b/Sources/OvCore/include/OvCore/Rendering/SceneRenderer.h index 97f3e1066..020d2fec8 100644 --- a/Sources/OvCore/include/OvCore/Rendering/SceneRenderer.h +++ b/Sources/OvCore/include/OvCore/Rendering/SceneRenderer.h @@ -8,11 +8,11 @@ #include +#include + #include #include #include -#include -#include #include #include diff --git a/Sources/OvCore/include/OvCore/Rendering/SkinningRenderFeature.h b/Sources/OvCore/include/OvCore/Rendering/SkinningRenderFeature.h index f7464af18..68a0ca01a 100644 --- a/Sources/OvCore/include/OvCore/Rendering/SkinningRenderFeature.h +++ b/Sources/OvCore/include/OvCore/Rendering/SkinningRenderFeature.h @@ -12,7 +12,7 @@ #include #include -#include +#include namespace OvCore::Rendering { @@ -48,7 +48,7 @@ namespace OvCore::Rendering private: void BindIdentityPalette() const; - OvRendering::HAL::ShaderStorageBuffer& GetCurrentSkinningBuffer() const; + baregl::Buffer& GetCurrentSkinningBuffer() const; private: static constexpr uint32_t kSkinningBufferRingSize = 3; @@ -77,8 +77,8 @@ namespace OvCore::Rendering uint32_t m_bufferBindingPoint; mutable uint32_t m_skinningBufferIndex = kSkinningBufferRingSize - 1; - std::array, kSkinningBufferRingSize> m_skinningBuffers; - std::unique_ptr m_identityBuffer; + std::array, kSkinningBufferRingSize> m_skinningBuffers; + std::unique_ptr m_identityBuffer; UploadedPaletteState m_lastUploaded; mutable BoundPaletteState m_bound; diff --git a/Sources/OvCore/include/OvCore/Resources/Material.h b/Sources/OvCore/include/OvCore/Resources/Material.h index 3e654f4eb..0baafb577 100644 --- a/Sources/OvCore/include/OvCore/Resources/Material.h +++ b/Sources/OvCore/include/OvCore/Resources/Material.h @@ -9,10 +9,9 @@ #include #include +#include #include -#include "OvCore/API/ISerializable.h" - namespace OvCore::Resources { /** diff --git a/Sources/OvCore/premake5.lua b/Sources/OvCore/premake5.lua index 5e9b8f592..09867fe48 100644 --- a/Sources/OvCore/premake5.lua +++ b/Sources/OvCore/premake5.lua @@ -21,7 +21,7 @@ project "OvCore" includedirs { -- Dependencies - dependdir .. "glad/include", + dependdir .. "baregl/include", dependdir .. "ImGui/include", dependdir .. "lua/include", dependdir .. "sol/include", diff --git a/Sources/OvCore/src/OvCore/ECS/Components/CReflectionProbe.cpp b/Sources/OvCore/src/OvCore/ECS/Components/CReflectionProbe.cpp index 83f797274..a2f68e450 100644 --- a/Sources/OvCore/src/OvCore/ECS/Components/CReflectionProbe.cpp +++ b/Sources/OvCore/src/OvCore/ECS/Components/CReflectionProbe.cpp @@ -12,7 +12,7 @@ #include -#include +#include #include #include @@ -44,8 +44,8 @@ OvCore::ECS::Components::CReflectionProbe::CReflectionProbe(ECS::Actor& p_owner) m_framebuffers{ "ReflectionProbeFramebuffer" }, m_cubemapIterator{ m_cubemaps } { - m_uniformBuffer = std::make_unique(); - m_uniformBuffer->Allocate(kUBOSize, OvRendering::Settings::EAccessSpecifier::STREAM_DRAW); + m_uniformBuffer = std::make_unique(); + m_uniformBuffer->Allocate(kUBOSize, baregl::types::EAccessSpecifier::STREAM_DRAW); _AllocateResources(); } @@ -178,7 +178,7 @@ void OvCore::ECS::Components::CReflectionProbe::RequestCapture(bool p_forceImmed }; } -std::shared_ptr OvCore::ECS::Components::CReflectionProbe::GetCubemap() const +std::shared_ptr OvCore::ECS::Components::CReflectionProbe::GetCubemap() const { const auto& target = _IsDoubleBuffered() ? @@ -384,39 +384,39 @@ void OvCore::ECS::Components::CReflectionProbe::_AllocateResources() for (uint8_t i = 0; i < cubemapCount; ++i) { auto& cubemap = m_cubemaps[i]; - cubemap = std::make_shared( - OvRendering::Settings::ETextureType::TEXTURE_CUBE, + cubemap = std::make_shared( + baregl::types::ETextureType::TEXTURE_CUBE, "ReflectionProbeCubemap" ); cubemap->Allocate( - OvRendering::Settings::TextureDesc{ + baregl::data::TextureDesc{ .width = m_resolution, .height = m_resolution, - .minFilter = OvRendering::Settings::ETextureFilteringMode::LINEAR_MIPMAP_LINEAR, - .magFilter = OvRendering::Settings::ETextureFilteringMode::LINEAR, - .horizontalWrap = OvRendering::Settings::ETextureWrapMode::CLAMP_TO_EDGE, - .verticalWrap = OvRendering::Settings::ETextureWrapMode::CLAMP_TO_EDGE, - .internalFormat = OvRendering::Settings::EInternalFormat::RGBA32F, + .minFilter = baregl::types::ETextureFilteringMode::LINEAR_MIPMAP_LINEAR, + .magFilter = baregl::types::ETextureFilteringMode::LINEAR, + .horizontalWrap = baregl::types::ETextureWrapMode::CLAMP_TO_EDGE, + .verticalWrap = baregl::types::ETextureWrapMode::CLAMP_TO_EDGE, + .internalFormat = baregl::types::EInternalFormat::RGBA32F, .useMipMaps = true } ); for (uint32_t faceIndex = 0; faceIndex < 6; ++faceIndex) { - m_framebuffers[i].Attach( + m_framebuffers[i].Attach( cubemap, - OvRendering::Settings::EFramebufferAttachment::COLOR, + baregl::types::EFramebufferAttachment::COLOR, faceIndex, // Each color attachment is a face of the cubemap faceIndex // Each face of the cubemap is accessed by its layer index ); } // Depth buffer - const auto renderbuffer = std::make_shared(); - const auto internalFormat = OvRendering::Settings::EInternalFormat::DEPTH_COMPONENT; + const auto renderbuffer = std::make_shared(); + const auto internalFormat = baregl::types::EInternalFormat::DEPTH_COMPONENT; renderbuffer->Allocate(m_resolution, m_resolution, internalFormat); - m_framebuffers[i].Attach(renderbuffer, OvRendering::Settings::EFramebufferAttachment::DEPTH); + m_framebuffers[i].Attach(renderbuffer, baregl::types::EFramebufferAttachment::DEPTH); // Validation m_framebuffers[i].Validate(); @@ -513,7 +513,7 @@ std::vector OvCore::ECS::Components::CReflectionProbe::_GetCaptureFace return faceIndices; } -OvRendering::HAL::Framebuffer& OvCore::ECS::Components::CReflectionProbe::_GetTargetFramebuffer() const +baregl::Framebuffer& OvCore::ECS::Components::CReflectionProbe::_GetTargetFramebuffer() const { auto& framebuffer = _IsDoubleBuffered() ? @@ -524,7 +524,7 @@ OvRendering::HAL::Framebuffer& OvCore::ECS::Components::CReflectionProbe::_GetTa return framebuffer; } -OvRendering::HAL::UniformBuffer& OvCore::ECS::Components::CReflectionProbe::_GetUniformBuffer() const +baregl::Buffer& OvCore::ECS::Components::CReflectionProbe::_GetUniformBuffer() const { OVASSERT(m_uniformBuffer != nullptr, "Uniform buffer is not initialized"); return *m_uniformBuffer; diff --git a/Sources/OvCore/src/OvCore/Rendering/EngineBufferRenderFeature.cpp b/Sources/OvCore/src/OvCore/Rendering/EngineBufferRenderFeature.cpp index 909bd025e..0d815d8e3 100644 --- a/Sources/OvCore/src/OvCore/Rendering/EngineBufferRenderFeature.cpp +++ b/Sources/OvCore/src/OvCore/Rendering/EngineBufferRenderFeature.cpp @@ -27,8 +27,8 @@ OvCore::Rendering::EngineBufferRenderFeature::EngineBufferRenderFeature( ) : ARenderFeature(p_renderer, p_executionPolicy) { - m_engineBuffer = std::make_unique(); - m_engineBuffer->Allocate(kUBOSize, OvRendering::Settings::EAccessSpecifier::STREAM_DRAW); + m_engineBuffer = std::make_unique(); + m_engineBuffer->Allocate(kUBOSize, baregl::types::EAccessSpecifier::STREAM_DRAW); m_startTime = std::chrono::high_resolution_clock::now(); } @@ -45,7 +45,7 @@ void OvCore::Rendering::EngineBufferRenderFeature::SetCamera(const OvRendering:: .cameraPosition = p_camera.GetPosition() }; - m_engineBuffer->Upload(&uboDataPage, OvRendering::HAL::BufferMemoryRange{ + m_engineBuffer->Upload(&uboDataPage, baregl::data::BufferMemoryRange{ .offset = sizeof(OvMaths::FMatrix4), // Skip uploading the first matrix (Model matrix) .size = sizeof(uboDataPage) }); @@ -71,12 +71,12 @@ void OvCore::Rendering::EngineBufferRenderFeature::OnBeginFrame(const OvRenderin .elapsedTime = elapsedTime.count() }; - m_engineBuffer->Upload(&uboDataPage, OvRendering::HAL::BufferMemoryRange{ + m_engineBuffer->Upload(&uboDataPage, baregl::data::BufferMemoryRange{ .offset = sizeof(OvMaths::FMatrix4), // Skip uploading the first matrix (Model matrix) .size = sizeof(uboDataPage) }); - m_engineBuffer->Bind(0); + m_engineBuffer->Bind(baregl::types::EBufferType::UNIFORM, 0); } void OvCore::Rendering::EngineBufferRenderFeature::OnEndFrame() @@ -95,13 +95,13 @@ void OvCore::Rendering::EngineBufferRenderFeature::OnBeforeDraw(OvRendering::Dat const auto modelMatrix = OvMaths::FMatrix4::Transpose(descriptor->modelMatrix); // Upload model matrix (First matrix in the UBO) - m_engineBuffer->Upload(&modelMatrix, OvRendering::HAL::BufferMemoryRange{ + m_engineBuffer->Upload(&modelMatrix, baregl::data::BufferMemoryRange{ .offset = 0, .size = sizeof(modelMatrix) }); // Upload user matrix (Last matrix in the UBO) - m_engineBuffer->Upload(&descriptor->userMatrix, OvRendering::HAL::BufferMemoryRange{ + m_engineBuffer->Upload(&descriptor->userMatrix, baregl::data::BufferMemoryRange{ .offset = kUBOSize - sizeof(modelMatrix), .size = sizeof(modelMatrix) }); diff --git a/Sources/OvCore/src/OvCore/Rendering/FramebufferUtil.cpp b/Sources/OvCore/src/OvCore/Rendering/FramebufferUtil.cpp index 5f51bc14c..ce8d98094 100644 --- a/Sources/OvCore/src/OvCore/Rendering/FramebufferUtil.cpp +++ b/Sources/OvCore/src/OvCore/Rendering/FramebufferUtil.cpp @@ -7,23 +7,22 @@ #include #include -#include -#include -#include +#include +#include +#include namespace OvCore::Rendering::FramebufferUtil { void SetupFramebuffer( - OvRendering::HAL::Framebuffer& p_framebuffer, - const OvRendering::Settings::TextureDesc& p_textureDesc, + baregl::Framebuffer& p_framebuffer, + const baregl::data::TextureDesc& p_textureDesc, bool p_useDepth, bool p_useStencil ) { - using namespace OvRendering::HAL; - using namespace OvRendering::Settings; + using namespace baregl::types; - const auto renderTexture = std::make_shared( + const auto renderTexture = std::make_shared( ETextureType::TEXTURE_2D, std::format( "{}/Color", @@ -36,7 +35,7 @@ namespace OvCore::Rendering::FramebufferUtil if (p_useDepth || p_useStencil) { - const auto renderbuffer = std::make_shared(); + const auto renderbuffer = std::make_shared(); const auto internalFormat = p_useStencil ? EInternalFormat::DEPTH_STENCIL : EInternalFormat::DEPTH_COMPONENT; renderbuffer->Allocate(p_textureDesc.width, p_textureDesc.height, internalFormat); if (p_useStencil) @@ -53,7 +52,7 @@ namespace OvCore::Rendering::FramebufferUtil } void SetupFramebuffer( - OvRendering::HAL::Framebuffer& p_framebuffer, + baregl::Framebuffer& p_framebuffer, uint32_t p_width, uint32_t p_height, bool p_useDepth, @@ -61,8 +60,8 @@ namespace OvCore::Rendering::FramebufferUtil bool p_useMipMaps ) { - using namespace OvRendering::HAL; - using namespace OvRendering::Settings; + using namespace baregl::types; + using namespace baregl::data; p_width = static_cast(std::max(1u, p_width)); p_height = static_cast(std::max(1u, p_height)); diff --git a/Sources/OvCore/src/OvCore/Rendering/PingPongFramebuffer.cpp b/Sources/OvCore/src/OvCore/Rendering/PingPongFramebuffer.cpp index 9cf698432..ab022434a 100644 --- a/Sources/OvCore/src/OvCore/Rendering/PingPongFramebuffer.cpp +++ b/Sources/OvCore/src/OvCore/Rendering/PingPongFramebuffer.cpp @@ -9,16 +9,16 @@ #include OvCore::Rendering::PingPongFramebuffer::PingPongFramebuffer(std::string_view p_debugName) : - CircularIterator(m_framebuffers), + CircularIterator(m_framebuffers), m_framebuffers{ - OvRendering::HAL::Framebuffer{std::format("{}PingPong{}", p_debugName, 0)}, - OvRendering::HAL::Framebuffer{std::format("{}PingPong{}", p_debugName, 1)} + baregl::Framebuffer{std::format("{}PingPong{}", p_debugName, 0)}, + baregl::Framebuffer{std::format("{}PingPong{}", p_debugName, 1)} } { } -std::array& OvCore::Rendering::PingPongFramebuffer::GetFramebuffers() +std::array& OvCore::Rendering::PingPongFramebuffer::GetFramebuffers() { return m_framebuffers; } diff --git a/Sources/OvCore/src/OvCore/Rendering/PostProcess/AutoExposureEffect.cpp b/Sources/OvCore/src/OvCore/Rendering/PostProcess/AutoExposureEffect.cpp index f22b03047..f84e273a4 100644 --- a/Sources/OvCore/src/OvCore/Rendering/PostProcess/AutoExposureEffect.cpp +++ b/Sources/OvCore/src/OvCore/Rendering/PostProcess/AutoExposureEffect.cpp @@ -9,7 +9,7 @@ #include #include #include -#include +#include constexpr uint32_t kLuminanceBufferResolution = 1024; constexpr uint32_t kExposureBufferResolution = 1; @@ -45,8 +45,8 @@ OvCore::Rendering::PostProcess::AutoExposureEffect::AutoExposureEffect( void OvCore::Rendering::PostProcess::AutoExposureEffect::Draw( OvRendering::Data::PipelineState p_pso, - OvRendering::HAL::Framebuffer& p_src, - OvRendering::HAL::Framebuffer& p_dst, + baregl::Framebuffer& p_src, + baregl::Framebuffer& p_dst, const EffectSettings& p_settings ) { @@ -60,8 +60,8 @@ void OvCore::Rendering::PostProcess::AutoExposureEffect::Draw( m_luminanceMaterial.SetProperty("_CenterWeightBias", autoExposureSettings.centerWeightBias, true); m_renderer.Blit(p_pso, p_src, m_luminanceBuffer, m_luminanceMaterial, OvRendering::Settings::EBlitFlags::DEFAULT & ~OvRendering::Settings::EBlitFlags::RESIZE_DST_TO_MATCH_SRC); - const auto luminanceTex = m_luminanceBuffer.GetAttachment(OvRendering::Settings::EFramebufferAttachment::COLOR); - luminanceTex->GenerateMipmaps(); + const auto luminanceTex = m_luminanceBuffer.GetAttachment(baregl::types::EFramebufferAttachment::COLOR); + luminanceTex.value().get().GenerateMipmaps(); float elapsedTime = 1.0f; auto currentTime = std::chrono::high_resolution_clock::now(); @@ -78,7 +78,7 @@ void OvCore::Rendering::PostProcess::AutoExposureEffect::Draw( ++m_exposurePingPongBuffer; // Exposure adaptation - m_exposureMaterial.SetProperty("_LuminanceTexture", &luminanceTex.value(), true); + m_exposureMaterial.SetProperty("_LuminanceTexture", &luminanceTex.value().get(), true); m_exposureMaterial.SetProperty("_MinLuminanceEV", autoExposureSettings.minLuminanceEV, true); m_exposureMaterial.SetProperty("_MaxLuminanceEV", autoExposureSettings.maxLuminanceEV, true); m_exposureMaterial.SetProperty("_ExposureCompensationEV", autoExposureSettings.exposureCompensationEV, true); @@ -89,8 +89,8 @@ void OvCore::Rendering::PostProcess::AutoExposureEffect::Draw( m_renderer.Blit(p_pso, previousExposure, currentExposure, m_exposureMaterial); // Apply the exposure to the final image - const auto exposureTex = currentExposure.GetAttachment(OvRendering::Settings::EFramebufferAttachment::COLOR); - m_compensationMaterial.SetProperty("_ExposureTexture", &exposureTex.value(), true); + const auto exposureTex = currentExposure.GetAttachment(baregl::types::EFramebufferAttachment::COLOR); + m_compensationMaterial.SetProperty("_ExposureTexture", &exposureTex.value().get(), true); m_renderer.Blit(p_pso, p_src, p_dst, m_compensationMaterial); m_firstFrame = false; diff --git a/Sources/OvCore/src/OvCore/Rendering/PostProcess/BloomEffect.cpp b/Sources/OvCore/src/OvCore/Rendering/PostProcess/BloomEffect.cpp index c4f5f22d2..6bc066786 100644 --- a/Sources/OvCore/src/OvCore/Rendering/PostProcess/BloomEffect.cpp +++ b/Sources/OvCore/src/OvCore/Rendering/PostProcess/BloomEffect.cpp @@ -10,7 +10,9 @@ #include #include #include -#include +#include + +#include // Implementation reference: https://learnopengl.com/Guest-Articles/2022/Phys.-Based-Bloom @@ -22,18 +24,18 @@ namespace OvCore::Rendering::PostProcess::BloomConstants namespace { - const auto kBloomTextureDesc = OvRendering::Settings::TextureDesc{ + const auto kBloomTextureDesc = baregl::data::TextureDesc{ .width = 1, // Unknown size at this point .height = 1, - .minFilter = OvRendering::Settings::ETextureFilteringMode::LINEAR, - .magFilter = OvRendering::Settings::ETextureFilteringMode::LINEAR, - .horizontalWrap = OvRendering::Settings::ETextureWrapMode::CLAMP_TO_EDGE, - .verticalWrap = OvRendering::Settings::ETextureWrapMode::CLAMP_TO_EDGE, - .internalFormat = OvRendering::Settings::EInternalFormat::RGBA32F, + .minFilter = baregl::types::ETextureFilteringMode::LINEAR, + .magFilter = baregl::types::ETextureFilteringMode::LINEAR, + .horizontalWrap = baregl::types::ETextureWrapMode::CLAMP_TO_EDGE, + .verticalWrap = baregl::types::ETextureWrapMode::CLAMP_TO_EDGE, + .internalFormat = baregl::types::EInternalFormat::RGBA32F, .useMipMaps = false, - .mutableDesc = OvRendering::Settings::MutableTextureDesc{ - .format = OvRendering::Settings::EFormat::RGBA, - .type = OvRendering::Settings::EPixelDataType::FLOAT + .mutableDesc = baregl::data::MutableTextureDesc{ + .format = baregl::types::EFormat::RGBA, + .type = baregl::types::EPixelDataType::FLOAT } }; @@ -41,23 +43,23 @@ namespace { uint16_t width; uint16_t height; - OvRendering::HAL::Framebuffer& target; + baregl::Framebuffer& target; }; } OvCore::Rendering::PostProcess::BloomEffect::BloomEffect(OvRendering::Core::CompositeRenderer& p_renderer) : AEffect(p_renderer), m_bloomSamplingBuffers{ - OvRendering::HAL::Framebuffer{"BloomSamplingBuffer0"}, - OvRendering::HAL::Framebuffer{"BloomSamplingBuffer1"}, - OvRendering::HAL::Framebuffer{"BloomSamplingBuffer2"}, - OvRendering::HAL::Framebuffer{"BloomSamplingBuffer3"}, - OvRendering::HAL::Framebuffer{"BloomSamplingBuffer4"}, - OvRendering::HAL::Framebuffer{"BloomSamplingBuffer5"}, - OvRendering::HAL::Framebuffer{"BloomSamplingBuffer6"}, - OvRendering::HAL::Framebuffer{"BloomSamplingBuffer7"}, - OvRendering::HAL::Framebuffer{"BloomSamplingBuffer8"}, - OvRendering::HAL::Framebuffer{"BloomSamplingBuffer9"} + baregl::Framebuffer{"BloomSamplingBuffer0"}, + baregl::Framebuffer{"BloomSamplingBuffer1"}, + baregl::Framebuffer{"BloomSamplingBuffer2"}, + baregl::Framebuffer{"BloomSamplingBuffer3"}, + baregl::Framebuffer{"BloomSamplingBuffer4"}, + baregl::Framebuffer{"BloomSamplingBuffer5"}, + baregl::Framebuffer{"BloomSamplingBuffer6"}, + baregl::Framebuffer{"BloomSamplingBuffer7"}, + baregl::Framebuffer{"BloomSamplingBuffer8"}, + baregl::Framebuffer{"BloomSamplingBuffer9"} }, m_bloomOutputBuffer{ "BloomOutputBuffer" } { @@ -99,8 +101,8 @@ bool OvCore::Rendering::PostProcess::BloomEffect::IsApplicable(const EffectSetti void OvCore::Rendering::PostProcess::BloomEffect::Draw( OvRendering::Data::PipelineState p_pso, - OvRendering::HAL::Framebuffer& p_src, - OvRendering::HAL::Framebuffer& p_dst, + baregl::Framebuffer& p_src, + baregl::Framebuffer& p_dst, const EffectSettings& p_settings ) { @@ -149,8 +151,8 @@ void OvCore::Rendering::PostProcess::BloomEffect::Draw( m_renderer.Blit(p_pso, p_src, m_bloomOutputBuffer, m_blitMaterial); auto downsamplingPass = [&]( - OvRendering::HAL::Framebuffer& p_src, - OvRendering::HAL::Framebuffer& p_dst, + baregl::Framebuffer& p_src, + baregl::Framebuffer& p_dst, const OvMaths::FVector2& p_srcRes ) { m_downsamplingMaterial.SetProperty("_InputResolution", p_srcRes, true); @@ -181,15 +183,15 @@ void OvCore::Rendering::PostProcess::BloomEffect::Draw( // Custom PSO for the upsampling pass, allowing us to use additive blending (accumulation) auto upsamplingPSO = p_pso; - upsamplingPSO.blendingSrcFactor = OvRendering::Settings::EBlendingFactor::ONE; - upsamplingPSO.blendingDestFactor = OvRendering::Settings::EBlendingFactor::ONE; - upsamplingPSO.blendingEquation = OvRendering::Settings::EBlendingEquation::FUNC_ADD; + upsamplingPSO.blendingSrcFactor = baregl::types::EBlendingFactor::ONE; + upsamplingPSO.blendingDestFactor = baregl::types::EBlendingFactor::ONE; + upsamplingPSO.blendingEquation = baregl::types::EBlendingEquation::FUNC_ADD; m_upsamplingMaterial.SetProperty("_FilterRadius", BloomConstants::kFilterRadius, true); auto upsamplingPass = [&]( - OvRendering::HAL::Framebuffer& p_src, - OvRendering::HAL::Framebuffer& p_dst + baregl::Framebuffer& p_src, + baregl::Framebuffer& p_dst ) { m_renderer.Blit(upsamplingPSO, p_src, p_dst, m_upsamplingMaterial, (DEFAULT & ~RESIZE_DST_TO_MATCH_SRC) | USE_MATERIAL_STATE_MASK); }; @@ -203,8 +205,8 @@ void OvCore::Rendering::PostProcess::BloomEffect::Draw( upsamplingPass(bloomMips[0].target, m_bloomOutputBuffer); // Final pass, interpolate bloom result with the input image - const auto bloomTex = m_bloomOutputBuffer.GetAttachment(OvRendering::Settings::EFramebufferAttachment::COLOR); - m_bloomMaterial.SetProperty("_BloomTexture", &bloomTex.value()); + const auto bloomTex = m_bloomOutputBuffer.GetAttachment(baregl::types::EFramebufferAttachment::COLOR); + m_bloomMaterial.SetProperty("_BloomTexture", &bloomTex.value().get()); m_bloomMaterial.SetProperty("_BloomStrength", std::min(bloomSettings.intensity * 0.04f, 1.0f)); m_renderer.Blit(p_pso, p_src, p_dst, m_bloomMaterial); } diff --git a/Sources/OvCore/src/OvCore/Rendering/PostProcess/FXAAEffect.cpp b/Sources/OvCore/src/OvCore/Rendering/PostProcess/FXAAEffect.cpp index 9db80fbb4..040b1f4c8 100644 --- a/Sources/OvCore/src/OvCore/Rendering/PostProcess/FXAAEffect.cpp +++ b/Sources/OvCore/src/OvCore/Rendering/PostProcess/FXAAEffect.cpp @@ -7,7 +7,7 @@ #include #include #include -#include +#include OvCore::Rendering::PostProcess::FXAAEffect::FXAAEffect(OvRendering::Core::CompositeRenderer& p_renderer) : AEffect(p_renderer) { @@ -16,8 +16,8 @@ OvCore::Rendering::PostProcess::FXAAEffect::FXAAEffect(OvRendering::Core::Compos void OvCore::Rendering::PostProcess::FXAAEffect::Draw( OvRendering::Data::PipelineState p_pso, - OvRendering::HAL::Framebuffer& p_src, - OvRendering::HAL::Framebuffer& p_dst, + baregl::Framebuffer& p_src, + baregl::Framebuffer& p_dst, const EffectSettings& p_settings ) { diff --git a/Sources/OvCore/src/OvCore/Rendering/PostProcess/TonemappingEffect.cpp b/Sources/OvCore/src/OvCore/Rendering/PostProcess/TonemappingEffect.cpp index 42851416a..09200f849 100644 --- a/Sources/OvCore/src/OvCore/Rendering/PostProcess/TonemappingEffect.cpp +++ b/Sources/OvCore/src/OvCore/Rendering/PostProcess/TonemappingEffect.cpp @@ -7,7 +7,7 @@ #include #include #include -#include +#include OvCore::Rendering::PostProcess::TonemappingEffect::TonemappingEffect(OvRendering::Core::CompositeRenderer& p_renderer) : AEffect(p_renderer) { @@ -16,8 +16,8 @@ OvCore::Rendering::PostProcess::TonemappingEffect::TonemappingEffect(OvRendering void OvCore::Rendering::PostProcess::TonemappingEffect::Draw( OvRendering::Data::PipelineState p_pso, - OvRendering::HAL::Framebuffer& p_src, - OvRendering::HAL::Framebuffer& p_dst, + baregl::Framebuffer& p_src, + baregl::Framebuffer& p_dst, const EffectSettings& p_settings ) { diff --git a/Sources/OvCore/src/OvCore/Rendering/PostProcessRenderPass.cpp b/Sources/OvCore/src/OvCore/Rendering/PostProcessRenderPass.cpp index 7a2d1098c..b9cb86194 100644 --- a/Sources/OvCore/src/OvCore/Rendering/PostProcessRenderPass.cpp +++ b/Sources/OvCore/src/OvCore/Rendering/PostProcessRenderPass.cpp @@ -14,7 +14,7 @@ #include #include -#include +#include OvCore::Rendering::PostProcessRenderPass::PostProcessRenderPass(OvRendering::Core::CompositeRenderer& p_renderer) : OvRendering::Core::ARenderPass(p_renderer), diff --git a/Sources/OvCore/src/OvCore/Rendering/ReflectionRenderFeature.cpp b/Sources/OvCore/src/OvCore/Rendering/ReflectionRenderFeature.cpp index 6f02ff74d..c96ba7476 100644 --- a/Sources/OvCore/src/OvCore/Rendering/ReflectionRenderFeature.cpp +++ b/Sources/OvCore/src/OvCore/Rendering/ReflectionRenderFeature.cpp @@ -159,14 +159,14 @@ void OvCore::Rendering::ReflectionRenderFeature::SendProbeData( { p_material.SetProperty( "_EnvironmentMap", - p_reflectionProbe.has_value() ? p_reflectionProbe->GetCubemap().get() : static_cast(nullptr), + p_reflectionProbe.has_value() ? p_reflectionProbe->GetCubemap().get() : static_cast(nullptr), true ); } void OvCore::Rendering::ReflectionRenderFeature::BindProbe(const OvCore::ECS::Components::CReflectionProbe& p_reflectionProbe) { - p_reflectionProbe._GetUniformBuffer().Bind(1); + p_reflectionProbe._GetUniformBuffer().Bind(baregl::types::EBufferType::UNIFORM, 1); } void OvCore::Rendering::ReflectionRenderFeature::OnBeginFrame(const OvRendering::Data::FrameDescriptor& p_frameDescriptor) diff --git a/Sources/OvCore/src/OvCore/Rendering/ReflectionRenderPass.cpp b/Sources/OvCore/src/OvCore/Rendering/ReflectionRenderPass.cpp index 8fabcaa70..efcdab9e6 100644 --- a/Sources/OvCore/src/OvCore/Rendering/ReflectionRenderPass.cpp +++ b/Sources/OvCore/src/OvCore/Rendering/ReflectionRenderPass.cpp @@ -15,7 +15,7 @@ #include #include -#include +#include namespace { diff --git a/Sources/OvCore/src/OvCore/Rendering/SceneRenderer.cpp b/Sources/OvCore/src/OvCore/Rendering/SceneRenderer.cpp index 08fdbf2df..9983fa6ae 100644 --- a/Sources/OvCore/src/OvCore/Rendering/SceneRenderer.cpp +++ b/Sources/OvCore/src/OvCore/Rendering/SceneRenderer.cpp @@ -26,8 +26,8 @@ #include #include #include -#include #include +#include namespace { @@ -50,9 +50,9 @@ namespace p_pso.stencilWriteMask = 0xFF; p_pso.stencilFuncRef = 1; p_pso.stencilFuncMask = 0xFF; - p_pso.stencilOpFail = OvRendering::Settings::EOperation::REPLACE; - p_pso.depthOpFail = OvRendering::Settings::EOperation::REPLACE; - p_pso.bothOpFail = OvRendering::Settings::EOperation::REPLACE; + p_pso.stencilOpFail = baregl::types::EOperation::REPLACE; + p_pso.depthOpFail = baregl::types::EOperation::REPLACE; + p_pso.bothOpFail = baregl::types::EOperation::REPLACE; p_pso.colorWriting.mask = 0x00; } diff --git a/Sources/OvCore/src/OvCore/Rendering/ShadowRenderFeature.cpp b/Sources/OvCore/src/OvCore/Rendering/ShadowRenderFeature.cpp index 20d5b80e8..89227a158 100644 --- a/Sources/OvCore/src/OvCore/Rendering/ShadowRenderFeature.cpp +++ b/Sources/OvCore/src/OvCore/Rendering/ShadowRenderFeature.cpp @@ -55,11 +55,11 @@ void OvCore::Rendering::ShadowRenderFeature::OnBeforeDraw(OvRendering::Data::Pip { OVASSERT(light.IsSetupForShadowRendering(), "This light isn't setup for shadow rendering"); - const auto shadowTex = light.shadowBuffer->GetAttachment( - OvRendering::Settings::EFramebufferAttachment::DEPTH + const auto shadowTex = light.shadowBuffer->GetAttachment( + baregl::types::EFramebufferAttachment::DEPTH ); - material.SetProperty("_ShadowMap", &shadowTex.value(), true); + material.SetProperty("_ShadowMap", &shadowTex.value().get(), true); material.SetProperty("_LightSpaceMatrix", light.lightSpaceMatrix.value(), true); ++lightIndex; diff --git a/Sources/OvCore/src/OvCore/Rendering/ShadowRenderPass.cpp b/Sources/OvCore/src/OvCore/Rendering/ShadowRenderPass.cpp index 86c4d467b..b2e0c8e38 100644 --- a/Sources/OvCore/src/OvCore/Rendering/ShadowRenderPass.cpp +++ b/Sources/OvCore/src/OvCore/Rendering/ShadowRenderPass.cpp @@ -17,7 +17,7 @@ #include #include -#include +#include constexpr uint8_t kMaxShadowMaps = 1; const std::string kShadowPassName = "SHADOW_PASS"; diff --git a/Sources/OvCore/src/OvCore/Rendering/SkinningRenderFeature.cpp b/Sources/OvCore/src/OvCore/Rendering/SkinningRenderFeature.cpp index 42f1035df..299772221 100644 --- a/Sources/OvCore/src/OvCore/Rendering/SkinningRenderFeature.cpp +++ b/Sources/OvCore/src/OvCore/Rendering/SkinningRenderFeature.cpp @@ -25,10 +25,10 @@ OvCore::Rendering::SkinningRenderFeature::SkinningRenderFeature( { for (auto& skinningBuffer : m_skinningBuffers) { - skinningBuffer = std::make_unique(); + skinningBuffer = std::make_unique(); } - m_identityBuffer = std::make_unique(); + m_identityBuffer = std::make_unique(); } uint32_t OvCore::Rendering::SkinningRenderFeature::GetBufferBindingPoint() const @@ -47,15 +47,13 @@ void OvCore::Rendering::SkinningRenderFeature::OnBeginFrame(const OvRendering::D if (m_identityBuffer->GetSize() == 0) { const auto identity = OvMaths::FMatrix4::Transpose(OvMaths::FMatrix4::Identity); - m_identityBuffer->Allocate(sizeof(OvMaths::FMatrix4), OvRendering::Settings::EAccessSpecifier::STATIC_DRAW); + m_identityBuffer->Allocate(sizeof(OvMaths::FMatrix4), baregl::types::EAccessSpecifier::STATIC_DRAW); m_identityBuffer->Upload(&identity); } } void OvCore::Rendering::SkinningRenderFeature::OnEndFrame() { - GetCurrentSkinningBuffer().Unbind(); - m_identityBuffer->Unbind(); m_bound = {}; } @@ -98,10 +96,10 @@ void OvCore::Rendering::SkinningRenderFeature::OnBeforeDraw( const auto uploadSize = static_cast(skinningDescriptor->count) * sizeof(OvMaths::FMatrix4); if (skinningBuffer.GetSize() < uploadSize) { - skinningBuffer.Allocate(uploadSize, OvRendering::Settings::EAccessSpecifier::STREAM_DRAW); + skinningBuffer.Allocate(uploadSize, baregl::types::EAccessSpecifier::STREAM_DRAW); } - skinningBuffer.Upload(skinningDescriptor->matrices, OvRendering::HAL::BufferMemoryRange{ + skinningBuffer.Upload(skinningDescriptor->matrices, baregl::data::BufferMemoryRange{ .offset = 0, .size = uploadSize }); @@ -117,12 +115,12 @@ void OvCore::Rendering::SkinningRenderFeature::OnBeforeDraw( if (mustBindSkinningPalette) { - skinningBuffer.Bind(m_bufferBindingPoint); + skinningBuffer.Bind(baregl::types::EBufferType::SHADER_STORAGE, m_bufferBindingPoint); m_bound = { EBoundPalette::SKINNING, skinningDescriptor->matrices, skinningDescriptor->count, skinningDescriptor->poseVersion }; } } -OvRendering::HAL::ShaderStorageBuffer& OvCore::Rendering::SkinningRenderFeature::GetCurrentSkinningBuffer() const +baregl::Buffer& OvCore::Rendering::SkinningRenderFeature::GetCurrentSkinningBuffer() const { return *m_skinningBuffers[m_skinningBufferIndex]; } @@ -131,7 +129,7 @@ void OvCore::Rendering::SkinningRenderFeature::BindIdentityPalette() const { if (m_bound.type != EBoundPalette::IDENTITY) { - m_identityBuffer->Bind(m_bufferBindingPoint); + m_identityBuffer->Bind(baregl::types::EBufferType::SHADER_STORAGE, m_bufferBindingPoint); m_bound = { EBoundPalette::IDENTITY }; } } diff --git a/Sources/OvCore/src/OvCore/ResourceManagement/TextureManager.cpp b/Sources/OvCore/src/OvCore/ResourceManagement/TextureManager.cpp index 2bca5b7c5..d84e662c8 100644 --- a/Sources/OvCore/src/OvCore/ResourceManagement/TextureManager.cpp +++ b/Sources/OvCore/src/OvCore/ResourceManagement/TextureManager.cpp @@ -21,10 +21,10 @@ namespace { struct TextureMetadata { - OvRendering::Settings::ETextureFilteringMode minFilter = OvRendering::Settings::ETextureFilteringMode::LINEAR_MIPMAP_LINEAR; - OvRendering::Settings::ETextureFilteringMode magFilter = OvRendering::Settings::ETextureFilteringMode::LINEAR; - OvRendering::Settings::ETextureWrapMode horizontalWrap = OvRendering::Settings::ETextureWrapMode::REPEAT; - OvRendering::Settings::ETextureWrapMode verticalWrap = OvRendering::Settings::ETextureWrapMode::REPEAT; + baregl::types::ETextureFilteringMode minFilter = baregl::types::ETextureFilteringMode::LINEAR_MIPMAP_LINEAR; + baregl::types::ETextureFilteringMode magFilter = baregl::types::ETextureFilteringMode::LINEAR; + baregl::types::ETextureWrapMode horizontalWrap = baregl::types::ETextureWrapMode::REPEAT; + baregl::types::ETextureWrapMode verticalWrap = baregl::types::ETextureWrapMode::REPEAT; bool generateMipmap = true; }; @@ -33,10 +33,10 @@ namespace const auto metaFile = OvTools::Filesystem::IniFile(std::format("{}.meta", p_filePath)); auto metadata = TextureMetadata{}; - metadata.minFilter = static_cast(metaFile.GetOrDefault("MIN_FILTER", static_cast(metadata.minFilter))); - metadata.magFilter = static_cast(metaFile.GetOrDefault("MAG_FILTER", static_cast(metadata.magFilter))); - metadata.horizontalWrap = static_cast(metaFile.GetOrDefault("HORIZONTAL_WRAP", static_cast(metadata.horizontalWrap))); - metadata.verticalWrap = static_cast(metaFile.GetOrDefault("VERTICAL_WRAP", static_cast(metadata.verticalWrap))); + metadata.minFilter = static_cast(metaFile.GetOrDefault("MIN_FILTER", static_cast(metadata.minFilter))); + metadata.magFilter = static_cast(metaFile.GetOrDefault("MAG_FILTER", static_cast(metadata.magFilter))); + metadata.horizontalWrap = static_cast(metaFile.GetOrDefault("HORIZONTAL_WRAP", static_cast(metadata.horizontalWrap))); + metadata.verticalWrap = static_cast(metaFile.GetOrDefault("VERTICAL_WRAP", static_cast(metadata.verticalWrap))); metadata.generateMipmap = metaFile.GetOrDefault("ENABLE_MIPMAPPING", metadata.generateMipmap); return metadata; diff --git a/Sources/OvCore/src/OvCore/Resources/Material.cpp b/Sources/OvCore/src/OvCore/Resources/Material.cpp index 270ea112f..0ff2614e4 100644 --- a/Sources/OvCore/src/OvCore/Resources/Material.cpp +++ b/Sources/OvCore/src/OvCore/Resources/Material.cpp @@ -7,6 +7,8 @@ #include #include +#include + #include void OvCore::Resources::Material::OnSerialize(tinyxml2::XMLDocument& p_doc, tinyxml2::XMLNode* p_node) @@ -70,7 +72,7 @@ void OvCore::Resources::Material::OnSerialize(tinyxml2::XMLDocument& p_doc, tiny auto visitor = [&](auto&& arg) { using T = std::decay_t; - using enum EUniformType; + using enum baregl::types::EUniformType; if constexpr (std::same_as) { @@ -100,7 +102,7 @@ void OvCore::Resources::Material::OnSerialize(tinyxml2::XMLDocument& p_doc, tiny { Serializer::SerializeTexture(p_doc, uniform, "value", arg); } - // No need to handle TextureHandle* here as it's not serializable (only texture assets are) + // No need to handle baregl::Texture* here as it's not serializable (only texture assets are) }; std::visit(visitor, value); @@ -206,7 +208,7 @@ void OvCore::Resources::Material::OnDeserialize(tinyxml2::XMLDocument& p_doc, ti { SetProperty(propName, Serializer::DeserializeTexture(p_doc, uniform, "value")); } - // No need to handle TextureHandle* here as it's not serializable (only texture assets are) + // No need to handle baregl::Texture* here as it's not serializable (only texture assets are) }; std::visit(visitor, prop->value); diff --git a/Sources/OvEditor/include/OvEditor/Core/Context.h b/Sources/OvEditor/include/OvEditor/Core/Context.h index a46fa17fb..2fe366bf0 100644 --- a/Sources/OvEditor/include/OvEditor/Core/Context.h +++ b/Sources/OvEditor/include/OvEditor/Core/Context.h @@ -10,6 +10,8 @@ #include #include +#include + #include #include #include @@ -19,10 +21,7 @@ #include #include #include -#include #include -#include -#include #include #include #include @@ -81,7 +80,6 @@ namespace OvEditor::Core std::unique_ptr device; std::unique_ptr window; std::unique_ptr inputManager; - std::unique_ptr textureRegistry; std::unique_ptr driver; std::unique_ptr uiManager; std::unique_ptr physicsEngine; diff --git a/Sources/OvEditor/include/OvEditor/Panels/AView.h b/Sources/OvEditor/include/OvEditor/Panels/AView.h index 046b32282..f8add2dbd 100644 --- a/Sources/OvEditor/include/OvEditor/Panels/AView.h +++ b/Sources/OvEditor/include/OvEditor/Panels/AView.h @@ -6,11 +6,12 @@ #pragma once +#include +#include + #include -#include -#include #include -#include +#include #include #include @@ -89,7 +90,7 @@ namespace OvEditor::Panels OvMaths::FVector3 m_gridColor = OvMaths::FVector3 { 0.176f, 0.176f, 0.176f }; - OvRendering::HAL::Framebuffer m_framebuffer; + baregl::Framebuffer m_framebuffer; std::unique_ptr m_renderer; }; -} \ No newline at end of file +} diff --git a/Sources/OvEditor/include/OvEditor/Panels/TextureDebugger.h b/Sources/OvEditor/include/OvEditor/Panels/TextureDebugger.h index 26e1bfeb5..45c042078 100644 --- a/Sources/OvEditor/include/OvEditor/Panels/TextureDebugger.h +++ b/Sources/OvEditor/include/OvEditor/Panels/TextureDebugger.h @@ -6,14 +6,11 @@ #pragma once -#include -#include - -#include +#include +#include #include #include #include -#include namespace OvEditor::Panels { @@ -48,7 +45,7 @@ namespace OvEditor::Panels /** * Destroys the texture debugger. */ - ~TextureDebugger(); + virtual ~TextureDebugger(); /** * Updates the texture debugger. @@ -63,6 +60,6 @@ namespace OvEditor::Panels OvUI::Widgets::Visual::Image& m_image; OvTools::Eventing::ListenerID m_creationListenerID; OvTools::Eventing::ListenerID m_destructionListenerID; - OvTools::Utils::OptRef m_selectedTexture; + OvTools::Utils::OptRef m_selectedTexture; }; } diff --git a/Sources/OvEditor/include/OvEditor/Rendering/PickingRenderPass.h b/Sources/OvEditor/include/OvEditor/Rendering/PickingRenderPass.h index fb996835e..262c71c3d 100644 --- a/Sources/OvEditor/include/OvEditor/Rendering/PickingRenderPass.h +++ b/Sources/OvEditor/include/OvEditor/Rendering/PickingRenderPass.h @@ -66,7 +66,7 @@ namespace OvEditor::Rendering ); private: - OvRendering::HAL::Framebuffer m_actorPickingFramebuffer; + baregl::Framebuffer m_actorPickingFramebuffer; OvCore::Resources::Material m_actorPickingFallbackMaterial; OvCore::Resources::Material m_reflectionProbeMaterial; OvCore::Resources::Material m_lightMaterial; diff --git a/Sources/OvEditor/include/OvEditor/Utils/TextureRegistry.h b/Sources/OvEditor/include/OvEditor/Utils/TextureRegistry.h deleted file mode 100644 index 8584320ab..000000000 --- a/Sources/OvEditor/include/OvEditor/Utils/TextureRegistry.h +++ /dev/null @@ -1,63 +0,0 @@ -/** -* @project: Overload -* @author: Overload Tech. -* @licence: MIT -*/ - -#pragma once - -#include -#include - -#include -#include - -namespace OvEditor::Utils -{ - /** - * Structure describing a texture registry entry. - */ - struct TextureRegistryEntryDesc - { - const uint32_t id; - const OvRendering::HAL::Texture* texture; - }; - - /** - * Class exposing tools to manage textures. - */ - class TextureRegistry - { - public: - OvTools::Eventing::Event textureAddedEvent; - OvTools::Eventing::Event textureRemovedEvent; - - public: - /** - * Creates the TextureRegistry. - */ - TextureRegistry(); - - /** - * Destroys the TextureRegistry. - */ - ~TextureRegistry(); - - /** - * Returns the texture associated with the given id - * @param p_id - */ - OvTools::Utils::OptRef GetTexture(uint32_t p_id) const; - - /** - * Returns all the texture ids - */ - std::span GetTextureIDs() const; - - private: - OvTools::Eventing::ListenerID m_creationListenerID; - OvTools::Eventing::ListenerID m_destructionListenerID; - std::unordered_map m_textures; - std::vector m_quickAccessTextureIDs; - }; -} diff --git a/Sources/OvEditor/premake5.lua b/Sources/OvEditor/premake5.lua index 5c7a94f4d..e452086ce 100644 --- a/Sources/OvEditor/premake5.lua +++ b/Sources/OvEditor/premake5.lua @@ -16,7 +16,7 @@ project "OvEditor" includedirs { -- Dependencies - dependdir .. "glad/include", + dependdir .. "baregl/include", dependdir .. "ImGui/include", dependdir .. "tinyxml2/include", dependdir .. "tracy", @@ -38,9 +38,9 @@ project "OvEditor" links { -- Dependencies (order matters on Linux!) + "baregl", "bullet3", "freetype", - "glad", "ImGui", "lua", "soloud", @@ -124,6 +124,7 @@ project "OvEditor" -- Force inclusion of all symbols from these libraries linkoptions { "-Wl,--whole-archive", + outputdir .. "%{cfg.buildcfg}/baregl/libbaregl.a", outputdir .. "%{cfg.buildcfg}/ImGui/libImGui.a", outputdir .. "%{cfg.buildcfg}/bullet3/libbullet3.a", outputdir .. "%{cfg.buildcfg}/lua/liblua.a", @@ -131,7 +132,6 @@ project "OvEditor" outputdir .. "%{cfg.buildcfg}/OvAudio/libOvAudio.a", outputdir .. "%{cfg.buildcfg}/assimp/libassimp.a", outputdir .. "%{cfg.buildcfg}/tinyxml2/libtinyxml2.a", - outputdir .. "%{cfg.buildcfg}/glad/libglad.a", "-Wl,--no-whole-archive", "-Wl,--allow-multiple-definition", -- Tracy and Bullet3 have some duplicate symbols } diff --git a/Sources/OvEditor/src/OvEditor/Core/Context.cpp b/Sources/OvEditor/src/OvEditor/Core/Context.cpp index 72f29b65d..3ae8069ff 100644 --- a/Sources/OvEditor/src/OvEditor/Core/Context.cpp +++ b/Sources/OvEditor/src/OvEditor/Core/Context.cpp @@ -114,7 +114,6 @@ OvEditor::Core::Context::Context(const std::filesystem::path& p_projectFolder) : /* Graphics context creation */ driver = std::make_unique(OvRendering::Settings::DriverSettings{ true }); - textureRegistry = std::make_unique(); std::filesystem::create_directories(Utils::FileSystem::kEditorDataPath); @@ -174,7 +173,6 @@ OvEditor::Core::Context::Context(const std::filesystem::path& p_projectFolder) : ServiceLocator::Provide(sceneManager); ServiceLocator::Provide(*audioEngine); ServiceLocator::Provide(*scriptEngine); - ServiceLocator::Provide(*textureRegistry); ApplyProjectSettings(); } diff --git a/Sources/OvEditor/src/OvEditor/Core/EditorResources.cpp b/Sources/OvEditor/src/OvEditor/Core/EditorResources.cpp index 40e77827b..f5b928b1b 100644 --- a/Sources/OvEditor/src/OvEditor/Core/EditorResources.cpp +++ b/Sources/OvEditor/src/OvEditor/Core/EditorResources.cpp @@ -10,20 +10,20 @@ #include #include #include -#include +#include #include namespace { - template + template auto CreateTexture(const std::filesystem::path& p_path) { return OvRendering::Resources::Loaders::TextureLoader::Create( p_path.string(), FilteringMode, FilteringMode, - OvRendering::Settings::ETextureWrapMode::REPEAT, - OvRendering::Settings::ETextureWrapMode::REPEAT, + baregl::types::ETextureWrapMode::REPEAT, + baregl::types::ETextureWrapMode::REPEAT, false ); } @@ -98,7 +98,7 @@ namespace OvEditor::Core::EditorResources::EditorResources(const std::string& p_editorAssetsPath) { using namespace OvRendering::Resources::Loaders; - using enum OvRendering::Settings::ETextureFilteringMode; + using enum baregl::types::ETextureFilteringMode; const auto editorAssetsPath = std::filesystem::path{ p_editorAssetsPath }; const auto texturesFolder = editorAssetsPath / "Textures"; diff --git a/Sources/OvEditor/src/OvEditor/Main.cpp b/Sources/OvEditor/src/OvEditor/Main.cpp index 7878ed39c..45025de14 100644 --- a/Sources/OvEditor/src/OvEditor/Main.cpp +++ b/Sources/OvEditor/src/OvEditor/Main.cpp @@ -5,7 +5,6 @@ */ #include -#include #include #include @@ -14,6 +13,7 @@ #include #include +#include #include #include @@ -82,6 +82,7 @@ int main(int argc, char** argv) // UpdateWorkingDirectory(argv[0]); OvEditor::Settings::EditorSettings::Load(); + OvRendering::Utils::ResourceTracking::TrackResources(); std::optional projectPath; diff --git a/Sources/OvEditor/src/OvEditor/Panels/AView.cpp b/Sources/OvEditor/src/OvEditor/Panels/AView.cpp index 898ef55b5..040bec3d9 100644 --- a/Sources/OvEditor/src/OvEditor/Panels/AView.cpp +++ b/Sources/OvEditor/src/OvEditor/Panels/AView.cpp @@ -10,7 +10,7 @@ #include #include #include -#include +#include OvEditor::Panels::AView::AView ( @@ -27,8 +27,8 @@ OvEditor::Panels::AView::AView true, true, false ); - const auto tex = m_framebuffer.GetAttachment(OvRendering::Settings::EFramebufferAttachment::COLOR); - m_image = &CreateWidget(tex->GetID(), OvMaths::FVector2{0.f, 0.f}); + const auto tex = m_framebuffer.GetAttachment(baregl::types::EFramebufferAttachment::COLOR); + m_image = &CreateWidget(tex.value().get().GetID(), OvMaths::FVector2{0.f, 0.f}); scrollable = false; } diff --git a/Sources/OvEditor/src/OvEditor/Panels/AssetProperties.cpp b/Sources/OvEditor/src/OvEditor/Panels/AssetProperties.cpp index 43ea784c5..2ba50d0df 100644 --- a/Sources/OvEditor/src/OvEditor/Panels/AssetProperties.cpp +++ b/Sources/OvEditor/src/OvEditor/Panels/AssetProperties.cpp @@ -312,6 +312,7 @@ void OvEditor::Panels::AssetProperties::CreateModelSettings() void OvEditor::Panels::AssetProperties::CreateTextureSettings() { using namespace OvRendering::Settings; + using namespace baregl::types; const std::string kMinFilter = "MIN_FILTER"; const std::string kMagFilter = "MAG_FILTER"; diff --git a/Sources/OvEditor/src/OvEditor/Panels/MaterialEditor.cpp b/Sources/OvEditor/src/OvEditor/Panels/MaterialEditor.cpp index 95099b880..45f3a4e01 100644 --- a/Sources/OvEditor/src/OvEditor/Panels/MaterialEditor.cpp +++ b/Sources/OvEditor/src/OvEditor/Panels/MaterialEditor.cpp @@ -475,7 +475,7 @@ void OvEditor::Panels::MaterialEditor::GenerateMaterialPropertiesContent() { GUIDrawer::DrawTexture(*m_materialPropertiesColumns, formattedType, arg); } - // No UI for TextureHandle* since it's not handled in the original code + // No UI for baregl::Texture* since it's not handled in the original code }; // Apply the visitor to the variant diff --git a/Sources/OvEditor/src/OvEditor/Panels/TextureDebugger.cpp b/Sources/OvEditor/src/OvEditor/Panels/TextureDebugger.cpp index e8dc31574..aaf3ab83d 100644 --- a/Sources/OvEditor/src/OvEditor/Panels/TextureDebugger.cpp +++ b/Sources/OvEditor/src/OvEditor/Panels/TextureDebugger.cpp @@ -4,14 +4,15 @@ * @licence: MIT */ -#include #include +#include + #include #include #include #include -#include +#include #include template <> @@ -59,7 +60,7 @@ struct OvTools::Utils::MappingFor namespace { - void AddOption(OvUI::Widgets::Selection::ComboBox& p_selector, const OvRendering::HAL::Texture& p_texture) + void AddOption(OvUI::Widgets::Selection::ComboBox& p_selector, const baregl::Texture& p_texture) { const auto id = p_texture.GetID(); p_selector.choices[id] = std::format( @@ -69,7 +70,7 @@ namespace ); } - float CalculateOneToOneScale(const OvMaths::FVector2& p_windowSize, OvRendering::HAL::Texture& p_texture) + float CalculateOneToOneScale(const OvMaths::FVector2& p_windowSize, const baregl::Texture& p_texture) { constexpr float kPanelImageMarginX = 45.0f; constexpr float kPanelImageMarginY = 120.0f; // Based on the size of the settings above the image @@ -81,8 +82,10 @@ namespace return std::min(safeSizeX / texDesc.width, safeSizeY / texDesc.height); } - OvMaths::FVector2 CalculateImageSize(OvEditor::Panels::EScaleMode p_mode, const OvMaths::FVector2& p_windowSize, OvRendering::HAL::Texture& p_texture) + OvMaths::FVector2 CalculateImageSize(OvEditor::Panels::EScaleMode p_mode, const OvMaths::FVector2& p_windowSize, const baregl::Texture& p_texture) { + if (!p_texture.IsValid()) { return OvMaths::FVector2::Zero; } + const float scale = p_mode == OvEditor::Panels::EScaleMode::ONE_TO_ONE ? CalculateOneToOneScale(p_windowSize, p_texture) : @@ -94,16 +97,13 @@ namespace }; } - bool IsValidTexture(const OvRendering::HAL::Texture* p_texture) + bool IsValidTexture(const baregl::Texture* p_texture) { return p_texture != nullptr && p_texture->GetID() != 0 && - p_texture->IsValid() && - p_texture->GetDesc().width > 0 && - p_texture->GetDesc().height > 0 && // Only 2D textures are supported in the debugger - p_texture->GetType() == OvRendering::Settings::ETextureType::TEXTURE_2D; + p_texture->GetType() == baregl::types::ETextureType::TEXTURE_2D; } } @@ -119,17 +119,15 @@ namespace OvEditor::Panels m_textureSelector(CreateWidget()), m_scaleSelector(CreateWidget()) { - auto& textureRegistry = OVSERVICE(OvEditor::Utils::TextureRegistry); - allowHorizontalScrollbar = true; constexpr int kNoneTextureID = 0; m_textureSelector.choices = { {kNoneTextureID, "None"} }; - for (auto& textureID : textureRegistry.GetTextureIDs()) + for (auto& textureID : OvRendering::Utils::ResourceTracking::GetTextureIDs()) { - if (auto texture = textureRegistry.GetTexture(textureID); texture.has_value()) + if (auto texture = OvRendering::Utils::ResourceTracking::GetTexture(textureID); texture.has_value()) { if (IsValidTexture(&texture.value())) { @@ -138,7 +136,7 @@ namespace OvEditor::Panels } } - m_textureSelector.ValueChangedEvent += [this, &textureRegistry](int p_selectedTextureID) + m_textureSelector.ValueChangedEvent += [this](int p_selectedTextureID) { if (p_selectedTextureID == kNoneTextureID) { @@ -147,7 +145,7 @@ namespace OvEditor::Panels } else { - if (auto texture = textureRegistry.GetTexture(p_selectedTextureID)) + if (auto texture = OvRendering::Utils::ResourceTracking::GetTexture(p_selectedTextureID)) { m_selectedTexture = texture; m_image.textureID = { texture->GetID() }; @@ -163,7 +161,7 @@ namespace OvEditor::Panels m_textureSelector.ValueChangedEvent.Invoke(m_textureSelector.currentChoice); } - m_creationListenerID = textureRegistry.textureAddedEvent += [this](const auto& p_desc) + m_creationListenerID = OvRendering::Utils::ResourceTracking::TextureAddedEvent += [this](const auto& p_desc) { if (IsValidTexture(p_desc.texture)) { @@ -171,7 +169,7 @@ namespace OvEditor::Panels } }; - m_destructionListenerID = textureRegistry.textureRemovedEvent += [this](const auto& p_desc) + m_destructionListenerID = OvRendering::Utils::ResourceTracking::TextureRemovedEvent += [this](const auto& p_desc) { if (p_desc.id != 0) { @@ -221,8 +219,8 @@ namespace OvEditor::Panels TextureDebugger::~TextureDebugger() { - OvRendering::HAL::Texture::CreationEvent -= m_creationListenerID; - OvRendering::HAL::Texture::DestructionEvent -= m_destructionListenerID; + OvRendering::Utils::ResourceTracking::TextureAddedEvent -= m_creationListenerID; + OvRendering::Utils::ResourceTracking::TextureRemovedEvent -= m_destructionListenerID; } void TextureDebugger::Update(float p_deltaTime) diff --git a/Sources/OvEditor/src/OvEditor/Rendering/DebugSceneRenderer.cpp b/Sources/OvEditor/src/OvEditor/Rendering/DebugSceneRenderer.cpp index f05d274f4..35e01ce58 100644 --- a/Sources/OvEditor/src/OvEditor/Rendering/DebugSceneRenderer.cpp +++ b/Sources/OvEditor/src/OvEditor/Rendering/DebugSceneRenderer.cpp @@ -32,7 +32,7 @@ #include #include #include -#include +#include using namespace OvMaths; using namespace OvRendering::Resources; @@ -95,16 +95,16 @@ namespace }.GenerateMatrix(); } - std::unique_ptr CreateDebugLightBuffer() + std::unique_ptr CreateDebugLightBuffer() { - auto lightBuffer = std::make_unique(); + auto lightBuffer = std::make_unique(); const auto lightMatrices = std::to_array({ CreateDebugDirectionalLight(), CreateDebugAmbientLight() }); - lightBuffer->Allocate(sizeof(lightMatrices), OvRendering::Settings::EAccessSpecifier::STATIC_READ); + lightBuffer->Allocate(sizeof(lightMatrices), baregl::types::EAccessSpecifier::STATIC_READ); lightBuffer->Upload(lightMatrices.data()); return lightBuffer; @@ -142,6 +142,7 @@ class DebugCamerasRenderPass : public OvRendering::Core::ARenderPass // Override the light buffer with fake lights m_fakeLightsBuffer->Bind( + baregl::types::EBufferType::SHADER_STORAGE, lightingRenderFeature ? lightingRenderFeature->GetBufferBindingPoint() : 0 @@ -172,7 +173,7 @@ class DebugCamerasRenderPass : public OvRendering::Core::ARenderPass private: OvCore::Resources::Material m_cameraMaterial; - std::unique_ptr m_fakeLightsBuffer; + std::unique_ptr m_fakeLightsBuffer; }; class DebugReflectionProbesRenderPass : public OvRendering::Core::ARenderPass @@ -207,6 +208,7 @@ class DebugReflectionProbesRenderPass : public OvRendering::Core::ARenderPass // Override the light buffer with fake lights m_fakeLightsBuffer->Bind( + baregl::types::EBufferType::SHADER_STORAGE, lightingRenderFeature ? lightingRenderFeature->GetBufferBindingPoint() : 0 @@ -249,7 +251,7 @@ class DebugReflectionProbesRenderPass : public OvRendering::Core::ARenderPass private: OvCore::Resources::Material m_reflectiveMaterial; - std::unique_ptr m_fakeLightsBuffer; + std::unique_ptr m_fakeLightsBuffer; }; class DebugLightsRenderPass : public OvRendering::Core::ARenderPass diff --git a/Sources/OvEditor/src/OvEditor/Rendering/GridRenderPass.cpp b/Sources/OvEditor/src/OvEditor/Rendering/GridRenderPass.cpp index 3eca1dacf..f46e3c38e 100644 --- a/Sources/OvEditor/src/OvEditor/Rendering/GridRenderPass.cpp +++ b/Sources/OvEditor/src/OvEditor/Rendering/GridRenderPass.cpp @@ -13,7 +13,7 @@ #include #include -#include +#include OvEditor::Rendering::GridRenderPass::GridRenderPass(OvRendering::Core::CompositeRenderer& p_renderer) : OvRendering::Core::ARenderPass(p_renderer) diff --git a/Sources/OvEditor/src/OvEditor/Rendering/OutlineRenderFeature.cpp b/Sources/OvEditor/src/OvEditor/Rendering/OutlineRenderFeature.cpp index f45126b79..13cf24f60 100644 --- a/Sources/OvEditor/src/OvEditor/Rendering/OutlineRenderFeature.cpp +++ b/Sources/OvEditor/src/OvEditor/Rendering/OutlineRenderFeature.cpp @@ -101,9 +101,9 @@ void OvEditor::Rendering::OutlineRenderFeature::DrawStencilPass(OvCore::ECS::Act pso.stencilWriteMask = kStencilMask; pso.stencilFuncRef = kStencilReference; pso.stencilFuncMask = kStencilMask; - pso.stencilOpFail = OvRendering::Settings::EOperation::REPLACE; - pso.depthOpFail = OvRendering::Settings::EOperation::REPLACE; - pso.bothOpFail = OvRendering::Settings::EOperation::REPLACE; + pso.stencilOpFail = baregl::types::EOperation::REPLACE; + pso.depthOpFail = baregl::types::EOperation::REPLACE; + pso.bothOpFail = baregl::types::EOperation::REPLACE; pso.colorWriting.mask = 0x00; DrawActorToStencil(pso, p_actor); @@ -114,13 +114,13 @@ void OvEditor::Rendering::OutlineRenderFeature::DrawOutlinePass(OvCore::ECS::Act auto pso = m_renderer.CreatePipelineState(); pso.stencilTest = true; - pso.stencilOpFail = OvRendering::Settings::EOperation::KEEP; - pso.depthOpFail = OvRendering::Settings::EOperation::KEEP; - pso.bothOpFail = OvRendering::Settings::EOperation::REPLACE; - pso.stencilFuncOp = OvRendering::Settings::EComparaisonAlgorithm::NOTEQUAL; + pso.stencilOpFail = baregl::types::EOperation::KEEP; + pso.depthOpFail = baregl::types::EOperation::KEEP; + pso.bothOpFail = baregl::types::EOperation::REPLACE; + pso.stencilFuncOp = baregl::types::EComparaisonAlgorithm::NOTEQUAL; pso.stencilFuncRef = kStencilReference; pso.stencilFuncMask = kStencilMask; - pso.rasterizationMode = OvRendering::Settings::ERasterizationMode::LINE; + pso.rasterizationMode = baregl::types::ERasterizationMode::LINE; pso.lineWidthPow2 = OvRendering::Utils::Conversions::FloatToPow2(p_thickness); DrawActorOutline(pso, p_actor, p_color); diff --git a/Sources/OvEditor/src/OvEditor/Rendering/PickingRenderPass.cpp b/Sources/OvEditor/src/OvEditor/Rendering/PickingRenderPass.cpp index 688c03e91..cc4a3c098 100644 --- a/Sources/OvEditor/src/OvEditor/Rendering/PickingRenderPass.cpp +++ b/Sources/OvEditor/src/OvEditor/Rendering/PickingRenderPass.cpp @@ -20,7 +20,7 @@ #include #include -#include +#include namespace { @@ -82,8 +82,8 @@ OvEditor::Rendering::PickingRenderPass::PickingResult OvEditor::Rendering::Picki m_actorPickingFramebuffer.ReadPixels( p_x, p_y, 1, 1, - OvRendering::Settings::EPixelDataFormat::RGB, - OvRendering::Settings::EPixelDataType::UNSIGNED_BYTE, + baregl::types::EPixelDataFormat::RGB, + baregl::types::EPixelDataType::UNSIGNED_BYTE, pixel ); diff --git a/Sources/OvEditor/src/OvEditor/Utils/TextureRegistry.cpp b/Sources/OvEditor/src/OvEditor/Utils/TextureRegistry.cpp deleted file mode 100644 index c146bbd73..000000000 --- a/Sources/OvEditor/src/OvEditor/Utils/TextureRegistry.cpp +++ /dev/null @@ -1,58 +0,0 @@ -/** -* @project: Overload -* @author: Overload Tech. -* @licence: MIT -*/ - -#include - -namespace OvEditor::Utils -{ - TextureRegistry::TextureRegistry() - { - using namespace OvRendering::HAL; - - m_creationListenerID = Texture::CreationEvent += [this](Texture& p_texture) - { - const auto id = p_texture.GetID(); - if (id != 0) - { - m_quickAccessTextureIDs.push_back(id); - m_textures[id] = &p_texture; - textureAddedEvent.Invoke({ id, &p_texture }); - } - }; - - m_destructionListenerID = Texture::DestructionEvent += [this](Texture& p_texture) - { - const auto id = p_texture.GetID(); - if (id != 0) - { - m_quickAccessTextureIDs.erase(std::ranges::find(m_quickAccessTextureIDs, id)); - m_textures.erase(id); - textureRemovedEvent.Invoke({ id, &p_texture }); - } - }; - } - - TextureRegistry::~TextureRegistry() - { - OvRendering::HAL::Texture::CreationEvent -= m_creationListenerID; - OvRendering::HAL::Texture::DestructionEvent -= m_destructionListenerID; - } - - OvTools::Utils::OptRef TextureRegistry::GetTexture(uint32_t p_id) const - { - if (m_textures.contains(p_id)) - { - return OvTools::Utils::OptRef(*m_textures.at(p_id)); - } - - return std::nullopt; - } - - std::span TextureRegistry::GetTextureIDs() const - { - return m_quickAccessTextureIDs; - } -} diff --git a/Sources/OvGame/include/OvGame/Core/Context.h b/Sources/OvGame/include/OvGame/Core/Context.h index 898b60093..d505a4aa1 100644 --- a/Sources/OvGame/include/OvGame/Core/Context.h +++ b/Sources/OvGame/include/OvGame/Core/Context.h @@ -6,9 +6,6 @@ #pragma once -#include -#include - #include #include @@ -59,7 +56,7 @@ namespace OvGame::Core std::unique_ptr physicsEngine; std::unique_ptr audioEngine; std::unique_ptr scriptEngine; - std::unique_ptr framebuffer; + std::unique_ptr framebuffer; OvCore::SceneSystem::SceneManager sceneManager; @@ -71,4 +68,4 @@ namespace OvGame::Core OvTools::Filesystem::IniFile projectSettings; }; -} \ No newline at end of file +} diff --git a/Sources/OvGame/premake5.lua b/Sources/OvGame/premake5.lua index f2f03c545..a4d4c68dc 100644 --- a/Sources/OvGame/premake5.lua +++ b/Sources/OvGame/premake5.lua @@ -16,7 +16,7 @@ project "OvGame" includedirs { -- Dependencies - dependdir .. "glad/include", + dependdir .. "baregl/include", dependdir .. "ImGui/include", dependdir .. "tracy", @@ -38,9 +38,9 @@ project "OvGame" links { -- Dependencies "assimp", + "baregl", "bullet3", "freetype", - "glad", "glfw", "ImGui", "lua", @@ -101,6 +101,7 @@ project "OvGame" -- Force inclusion of all symbols from these libraries linkoptions { "-Wl,--whole-archive", + outputdir .. "%{cfg.buildcfg}/baregl/libbaregl.a", outputdir .. "%{cfg.buildcfg}/ImGui/libImGui.a", outputdir .. "%{cfg.buildcfg}/bullet3/libbullet3.a", outputdir .. "%{cfg.buildcfg}/lua/liblua.a", @@ -108,7 +109,6 @@ project "OvGame" outputdir .. "%{cfg.buildcfg}/OvAudio/libOvAudio.a", outputdir .. "%{cfg.buildcfg}/assimp/libassimp.a", outputdir .. "%{cfg.buildcfg}/tinyxml2/libtinyxml2.a", - outputdir .. "%{cfg.buildcfg}/glad/libglad.a", "-Wl,--no-whole-archive", "-Wl,--allow-multiple-definition", -- Tracy and Bullet3 have some duplicate symbols } diff --git a/Sources/OvGame/src/OvGame/Core/Context.cpp b/Sources/OvGame/src/OvGame/Core/Context.cpp index 6cd4e16ff..85fa0639c 100644 --- a/Sources/OvGame/src/OvGame/Core/Context.cpp +++ b/Sources/OvGame/src/OvGame/Core/Context.cpp @@ -168,7 +168,7 @@ OvGame::Core::Context::Context() : ServiceLocator::Provide(*audioEngine); ServiceLocator::Provide(*scriptEngine); - framebuffer = std::make_unique("Main"); + framebuffer = std::make_unique("Main"); OvCore::Rendering::FramebufferUtil::SetupFramebuffer( *framebuffer, diff --git a/Sources/OvRendering/include/OvRendering/Context/Driver.h b/Sources/OvRendering/include/OvRendering/Context/Driver.h index 979a7061e..72752da35 100644 --- a/Sources/OvRendering/include/OvRendering/Context/Driver.h +++ b/Sources/OvRendering/include/OvRendering/Context/Driver.h @@ -10,22 +10,24 @@ #include #include -#include "OvRendering/Settings/DriverSettings.h" -#include "OvRendering/Settings/ERenderingCapability.h" -#include "OvRendering/Settings/EPrimitiveMode.h" -#include "OvRendering/Settings/ERasterizationMode.h" -#include "OvRendering/Settings/EComparaisonAlgorithm.h" -#include "OvRendering/Settings/EOperation.h" -#include "OvRendering/Settings/ECullFace.h" -#include "OvRendering/Settings/ECullingOptions.h" -#include "OvRendering/Settings/EPixelDataFormat.h" -#include "OvRendering/Settings/EPixelDataType.h" -#include "OvRendering/Data/PipelineState.h" -#include "OvRendering/Resources/IMesh.h" - #include #include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + namespace OvRendering::Context { /** @@ -89,7 +91,7 @@ namespace OvRendering::Context void Draw( OvRendering::Data::PipelineState p_pso, const Resources::IMesh& p_mesh, - Settings::EPrimitiveMode p_primitiveMode = Settings::EPrimitiveMode::TRIANGLES, + baregl::types::EPrimitiveMode p_primitiveMode = baregl::types::EPrimitiveMode::TRIANGLES, uint32_t p_instances = 1 ); @@ -123,6 +125,7 @@ namespace OvRendering::Context void ResetPipelineState(); private: + std::unique_ptr m_gfxContext; std::string m_vendor; std::string m_hardware; std::string m_version; @@ -130,4 +133,4 @@ namespace OvRendering::Context Data::PipelineState m_defaultPipelineState; Data::PipelineState m_pipelineState; }; -} \ No newline at end of file +} diff --git a/Sources/OvRendering/include/OvRendering/Core/ABaseRenderer.h b/Sources/OvRendering/include/OvRendering/Core/ABaseRenderer.h index 6850014f4..d3822b6cf 100644 --- a/Sources/OvRendering/include/OvRendering/Core/ABaseRenderer.h +++ b/Sources/OvRendering/include/OvRendering/Core/ABaseRenderer.h @@ -8,13 +8,13 @@ #include -#include "OvRendering/Core/IRenderer.h" -#include "OvRendering/Data/FrameInfo.h" -#include "OvRendering/Resources/IMesh.h" -#include "OvRendering/Resources/Texture.h" -#include "OvRendering/Entities/Drawable.h" -#include "OvRendering/Settings/EBlitFlags.h" -#include "OvRendering/Context/Driver.h" +#include +#include +#include +#include +#include +#include +#include namespace OvRendering::Core { @@ -97,8 +97,8 @@ namespace OvRendering::Core */ virtual void Blit( OvRendering::Data::PipelineState p_pso, - OvRendering::HAL::Framebuffer& p_src, - OvRendering::HAL::Framebuffer& p_dst, + baregl::Framebuffer& p_src, + baregl::Framebuffer& p_dst, OvRendering::Data::Material& p_material, OvRendering::Settings::EBlitFlags p_flags = OvRendering::Settings::EBlitFlags::DEFAULT ); @@ -123,8 +123,8 @@ namespace OvRendering::Core protected: Data::FrameDescriptor m_frameDescriptor; Context::Driver& m_driver; - OvRendering::HAL::Texture m_emptyTexture2D; - OvRendering::HAL::Texture m_emptyTextureCube; + baregl::Texture m_emptyTexture2D; + baregl::Texture m_emptyTextureCube; OvRendering::Resources::Mesh m_unitQuad; OvRendering::Data::PipelineState m_basePipelineState; bool m_isDrawing; diff --git a/Sources/OvRendering/include/OvRendering/Core/ARenderPass.h b/Sources/OvRendering/include/OvRendering/Core/ARenderPass.h index c32b05653..2d052686f 100644 --- a/Sources/OvRendering/include/OvRendering/Core/ARenderPass.h +++ b/Sources/OvRendering/include/OvRendering/Core/ARenderPass.h @@ -7,6 +7,7 @@ #pragma once #include +#include #include namespace OvRendering::Core @@ -68,4 +69,4 @@ namespace OvRendering::Core friend class Core::CompositeRenderer; }; -} \ No newline at end of file +} diff --git a/Sources/OvRendering/include/OvRendering/Core/CompositeRenderer.h b/Sources/OvRendering/include/OvRendering/Core/CompositeRenderer.h index 3a229b9c3..485d99bf2 100644 --- a/Sources/OvRendering/include/OvRendering/Core/CompositeRenderer.h +++ b/Sources/OvRendering/include/OvRendering/Core/CompositeRenderer.h @@ -17,6 +17,8 @@ #include #include +#include + namespace OvRendering::Core { /** diff --git a/Sources/OvRendering/include/OvRendering/Data/Describable.h b/Sources/OvRendering/include/OvRendering/Data/Describable.h index 605c57e14..4c1b8f846 100644 --- a/Sources/OvRendering/include/OvRendering/Data/Describable.h +++ b/Sources/OvRendering/include/OvRendering/Data/Describable.h @@ -9,8 +9,9 @@ #include #include -#include "OvRendering/HAL/Framebuffer.h" -#include "OvRendering/Entities/Camera.h" +#include + +#include namespace OvRendering::Data { diff --git a/Sources/OvRendering/include/OvRendering/Data/FrameDescriptor.h b/Sources/OvRendering/include/OvRendering/Data/FrameDescriptor.h index 7b4b865c9..98d8272c1 100644 --- a/Sources/OvRendering/include/OvRendering/Data/FrameDescriptor.h +++ b/Sources/OvRendering/include/OvRendering/Data/FrameDescriptor.h @@ -8,8 +8,9 @@ #include -#include "OvRendering/HAL/Framebuffer.h" -#include "OvRendering/Entities/Camera.h" +#include + +#include namespace OvRendering::Data { @@ -21,7 +22,7 @@ namespace OvRendering::Data uint16_t renderWidth = 0; uint16_t renderHeight = 0; OvTools::Utils::OptRef camera; - OvTools::Utils::OptRef outputBuffer; + OvTools::Utils::OptRef outputBuffer; /** * Ensures that the data provided in the frame descriptor is valid diff --git a/Sources/OvRendering/include/OvRendering/Data/Frustum.h b/Sources/OvRendering/include/OvRendering/Data/Frustum.h index 2aa138948..96cd68072 100644 --- a/Sources/OvRendering/include/OvRendering/Data/Frustum.h +++ b/Sources/OvRendering/include/OvRendering/Data/Frustum.h @@ -11,8 +11,8 @@ #include #include -#include "OvRendering/Geometry/BoundingSphere.h" -#include "OvRendering/Resources/Model.h" +#include +#include #include namespace OvRendering::Data @@ -97,4 +97,4 @@ namespace OvRendering::Data private: float m_frustum[6][4]; }; -} \ No newline at end of file +} diff --git a/Sources/OvRendering/include/OvRendering/Data/Material.h b/Sources/OvRendering/include/OvRendering/Data/Material.h index d8087dda2..572bd64b5 100644 --- a/Sources/OvRendering/include/OvRendering/Data/Material.h +++ b/Sources/OvRendering/include/OvRendering/Data/Material.h @@ -10,13 +10,17 @@ #include #include +#include + #include +#include +#include #include -#include #include #include #include +#include namespace OvRendering::Data { @@ -30,7 +34,7 @@ namespace OvRendering::Data OvMaths::FVector4, OvMaths::FMatrix3, OvMaths::FMatrix4, - OvRendering::HAL::TextureHandle*, // Texture handle + baregl::Texture*, // Texture graphics object OvRendering::Resources::Texture* // Texture asset (serializable) >; @@ -79,7 +83,7 @@ namespace OvRendering::Data * @param p_pass * @param p_override */ - OvTools::Utils::OptRef GetVariant( + OvTools::Utils::OptRef GetVariant( std::optional p_pass = std::nullopt, OvTools::Utils::OptRef p_override = std::nullopt ) const; @@ -101,8 +105,8 @@ namespace OvRendering::Data MaterialSignatureSet Bind( std::optional p_pass = std::nullopt, OvTools::Utils::OptRef p_featureSetOverride = std::nullopt, - HAL::Texture* p_emptyTexture2D = nullptr, - HAL::Texture* p_emptyTextureCube = nullptr, + baregl::Texture* p_emptyTexture2D = nullptr, + baregl::Texture* p_emptyTextureCube = nullptr, std::optional p_previousMaterialSignature = std::nullopt ); @@ -116,8 +120,8 @@ namespace OvRendering::Data void UploadProperties( bool uploadStableProperties, bool uploadSingleUseProperties, - HAL::Texture* p_emptyTexture2D = nullptr, - HAL::Texture* p_emptyTextureCube = nullptr + baregl::Texture* p_emptyTexture2D = nullptr, + baregl::Texture* p_emptyTextureCube = nullptr ); /** @@ -396,9 +400,9 @@ namespace OvRendering::Data void InvalidatePropertySignature(); MaterialSignatureSet CalculateSignature( - OvRendering::HAL::ShaderProgram& p_selectedProgram, - HAL::Texture* p_emptyTexture2D = nullptr, - HAL::Texture* p_emptyTextureCube = nullptr + baregl::ShaderProgram& p_selectedProgram, + baregl::Texture* p_emptyTexture2D = nullptr, + baregl::Texture* p_emptyTextureCube = nullptr ); protected: @@ -407,7 +411,7 @@ namespace OvRendering::Data Data::FeatureSet m_features; size_t m_stablePropertySignatureVersion = 0ULL; size_t m_singleUsePropertySignatureVersion = 0ULL; - OvTools::Utils::OptRef m_programInUse = std::nullopt; + OvTools::Utils::OptRef m_programInUse = std::nullopt; bool m_supportOrthographic = true; bool m_supportPerspective = true; diff --git a/Sources/OvRendering/include/OvRendering/Data/PipelineState.h b/Sources/OvRendering/include/OvRendering/Data/PipelineState.h index f44bb9971..a20113d45 100644 --- a/Sources/OvRendering/include/OvRendering/Data/PipelineState.h +++ b/Sources/OvRendering/include/OvRendering/Data/PipelineState.h @@ -9,17 +9,16 @@ #include #include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include namespace OvRendering::Data { @@ -47,18 +46,18 @@ namespace OvRendering::Data uint8_t stencilFuncMask : 8; // B3 - Settings::EComparaisonAlgorithm stencilFuncOp : 3; - Settings::EOperation stencilOpFail : 3; - Settings::ECullFace cullFace : 2; + baregl::types::EComparaisonAlgorithm stencilFuncOp : 3; + baregl::types::EOperation stencilOpFail : 3; + baregl::types::ECullFace cullFace : 2; // B4 - Settings::EOperation depthOpFail : 3; - Settings::EOperation bothOpFail : 3; - Settings::ERasterizationMode rasterizationMode : 2; + baregl::types::EOperation depthOpFail : 3; + baregl::types::EOperation bothOpFail : 3; + baregl::types::ERasterizationMode rasterizationMode : 2; // B5 uint8_t lineWidthPow2 : 3; - Settings::EComparaisonAlgorithm depthFunc : 3; + baregl::types::EComparaisonAlgorithm depthFunc : 3; bool depthWriting : 1; bool blending : 1; @@ -88,11 +87,11 @@ namespace OvRendering::Data // 4 bytes left in B7 // B8 - Settings::EBlendingFactor blendingSrcFactor : 5; - Settings::EBlendingEquation blendingEquation : 3; + baregl::types::EBlendingFactor blendingSrcFactor : 5; + baregl::types::EBlendingEquation blendingEquation : 3; // B9 - Settings::EBlendingFactor blendingDestFactor : 5; + baregl::types::EBlendingFactor blendingDestFactor : 5; // 3 bytes left in B9 }; diff --git a/Sources/OvRendering/include/OvRendering/Entities/Camera.h b/Sources/OvRendering/include/OvRendering/Entities/Camera.h index bec5e8e4a..2853f34fa 100644 --- a/Sources/OvRendering/include/OvRendering/Entities/Camera.h +++ b/Sources/OvRendering/include/OvRendering/Entities/Camera.h @@ -12,9 +12,9 @@ #include -#include "OvRendering/Data/Frustum.h" -#include "OvRendering/Settings/EProjectionMode.h" -#include "OvRendering/Entities/Entity.h" +#include +#include +#include namespace OvRendering::Entities { @@ -250,4 +250,4 @@ namespace OvRendering::Entities bool m_clearDepthBuffer; bool m_clearStencilBuffer; }; -} \ No newline at end of file +} diff --git a/Sources/OvRendering/include/OvRendering/Entities/Drawable.h b/Sources/OvRendering/include/OvRendering/Entities/Drawable.h index 77d8efb1e..e5b86f96f 100644 --- a/Sources/OvRendering/include/OvRendering/Entities/Drawable.h +++ b/Sources/OvRendering/include/OvRendering/Entities/Drawable.h @@ -21,8 +21,8 @@ namespace OvRendering::Entities OvTools::Utils::OptRef mesh; OvTools::Utils::OptRef material; Data::StateMask stateMask; - Settings::EPrimitiveMode primitiveMode = OvRendering::Settings::EPrimitiveMode::TRIANGLES; + baregl::types::EPrimitiveMode primitiveMode = baregl::types::EPrimitiveMode::TRIANGLES; std::optional pass = std::nullopt; std::optional featureSetOverride = std::nullopt; }; -} \ No newline at end of file +} diff --git a/Sources/OvRendering/include/OvRendering/Entities/Light.h b/Sources/OvRendering/include/OvRendering/Entities/Light.h index 4cc9b718d..3da8300b6 100644 --- a/Sources/OvRendering/include/OvRendering/Entities/Light.h +++ b/Sources/OvRendering/include/OvRendering/Entities/Light.h @@ -6,6 +6,8 @@ #pragma once +#include + #include #include #include @@ -13,7 +15,6 @@ #include #include #include -#include #include #include @@ -38,7 +39,7 @@ namespace OvRendering::Entities bool shadowFollowCamera = true; int16_t shadowMapResolution = 8192; - std::unique_ptr shadowBuffer; + std::unique_ptr shadowBuffer; std::optional shadowCamera; std::optional lightSpaceMatrix; diff --git a/Sources/OvRendering/include/OvRendering/Features/ARenderFeature.h b/Sources/OvRendering/include/OvRendering/Features/ARenderFeature.h index 8d44dd95b..771ec99fb 100644 --- a/Sources/OvRendering/include/OvRendering/Features/ARenderFeature.h +++ b/Sources/OvRendering/include/OvRendering/Features/ARenderFeature.h @@ -9,6 +9,7 @@ #include #include +#include #include #include @@ -142,4 +143,4 @@ namespace OvRendering::Features friend class Core::CompositeRenderer; }; -} \ No newline at end of file +} diff --git a/Sources/OvRendering/include/OvRendering/Features/LightingRenderFeature.h b/Sources/OvRendering/include/OvRendering/Features/LightingRenderFeature.h index e16380a63..7914bc75c 100644 --- a/Sources/OvRendering/include/OvRendering/Features/LightingRenderFeature.h +++ b/Sources/OvRendering/include/OvRendering/Features/LightingRenderFeature.h @@ -10,9 +10,10 @@ #include "OvRendering/Features/ARenderFeature.h" #include "OvRendering/Data/FrameInfo.h" #include "OvRendering/Entities/Light.h" -#include "OvRendering/HAL/ShaderStorageBuffer.h" #include "OvRendering/Data/Frustum.h" +#include + namespace OvRendering::Features { class LightingRenderFeature : public ARenderFeature @@ -55,6 +56,6 @@ namespace OvRendering::Features private: uint32_t m_bufferBindingPoint; - std::unique_ptr m_lightBuffer; + std::unique_ptr m_lightBuffer; }; } diff --git a/Sources/OvRendering/include/OvRendering/HAL/Backend.h b/Sources/OvRendering/include/OvRendering/HAL/Backend.h deleted file mode 100644 index fbd498d78..000000000 --- a/Sources/OvRendering/include/OvRendering/HAL/Backend.h +++ /dev/null @@ -1,22 +0,0 @@ -/** -* @project: Overload -* @author: Overload Tech. -* @licence: MIT -*/ - -#pragma once - -#if defined(GRAPHICS_API_OPENGL) -#include -#else -#include -#endif // defined(GRAPHICS_API_OPENGL) - -namespace OvRendering::HAL -{ -#if defined(GRAPHICS_API_OPENGL) - using Backend = GLBackend; -#else - using Backend = NoneBackend; -#endif // defined(GRAPHICS_API_OPENGL) -} diff --git a/Sources/OvRendering/include/OvRendering/HAL/Buffer.h b/Sources/OvRendering/include/OvRendering/HAL/Buffer.h deleted file mode 100644 index 412510c10..000000000 --- a/Sources/OvRendering/include/OvRendering/HAL/Buffer.h +++ /dev/null @@ -1,22 +0,0 @@ -/** -* @project: Overload -* @author: Overload Tech. -* @licence: MIT -*/ - -#pragma once - -#if defined(GRAPHICS_API_OPENGL) -#include -#else -#include -#endif // defined(GRAPHICS_API_OPENGL) - -namespace OvRendering::HAL -{ -#if defined(GRAPHICS_API_OPENGL) - using Buffer = GLBuffer; -#else - using Buffer = NoneBuffer; -#endif // defined(GRAPHICS_API_OPENGL) -} diff --git a/Sources/OvRendering/include/OvRendering/HAL/Common/TBuffer.h b/Sources/OvRendering/include/OvRendering/HAL/Common/TBuffer.h deleted file mode 100644 index 68a34463d..000000000 --- a/Sources/OvRendering/include/OvRendering/HAL/Common/TBuffer.h +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @project: Overload -* @author: Overload Tech. -* @licence: MIT -*/ - -#pragma once - -#include - -#include -#include -#include - -namespace OvRendering::HAL -{ - /** - * Represents a range of memory in a buffer - */ - struct BufferMemoryRange - { - uint64_t offset; - uint64_t size; - }; - - /** - * Represents a buffer, used to store data on the GPU - */ - template - class TBuffer - { - public: - /** - * Creates a buffer - * @param p_type - */ - TBuffer(Settings::EBufferType p_type); - - /** - * Destroys the buffer - */ - ~TBuffer(); - - /** - * Allocates memory for the buffer - * @param p_size - * @param p_usage - * @return The size of the allocated memory in bytes - */ - uint64_t Allocate(uint64_t p_size, Settings::EAccessSpecifier p_usage = Settings::EAccessSpecifier::STATIC_DRAW); - - /** - * Uploads data to the buffer - * @param p_data - * @param p_range - */ - void Upload(const void* p_data, std::optional p_range = std::nullopt); - - /** - * Returns true if the buffer is valid (properly allocated) - */ - bool IsValid() const; - - /** - * Returns true if the buffer is empty - */ - bool IsEmpty() const; - - /** - * Returns the size of the allocated buffer in bytes - */ - uint64_t GetSize() const; - - /** - * Binds the buffer - * @param p_index (Optional) Index to bind the buffer to - */ - void Bind(std::optional p_index = std::nullopt) const; - - /** - * Unbinds the buffer - */ - void Unbind() const; - - /** - * Returns the ID of the buffer - */ - uint32_t GetID() const; - - protected: - BufferContext m_buffer; - }; -} diff --git a/Sources/OvRendering/include/OvRendering/HAL/Common/TIndexBuffer.h b/Sources/OvRendering/include/OvRendering/HAL/Common/TIndexBuffer.h deleted file mode 100644 index 4f1020227..000000000 --- a/Sources/OvRendering/include/OvRendering/HAL/Common/TIndexBuffer.h +++ /dev/null @@ -1,28 +0,0 @@ -/** -* @project: Overload -* @author: Overload Tech. -* @licence: MIT -*/ - -#pragma once - -#include - -namespace OvRendering::HAL -{ - /** - * Represents an index buffer, used to store index data for the graphics backend to use. - */ - template - class TIndexBuffer : public TBuffer - { - public: - /** - * Creates an index buffer. - */ - TIndexBuffer(); - - private: - IndexBufferContext m_context; - }; -} diff --git a/Sources/OvRendering/include/OvRendering/HAL/Common/TShaderStage.h b/Sources/OvRendering/include/OvRendering/HAL/Common/TShaderStage.h deleted file mode 100644 index a295fdd0c..000000000 --- a/Sources/OvRendering/include/OvRendering/HAL/Common/TShaderStage.h +++ /dev/null @@ -1,54 +0,0 @@ -/** -* @project: Overload -* @author: Overload Tech. -* @licence: MIT -*/ - -#pragma once - -#include -#include -#include - -namespace OvRendering::HAL -{ - /** - * Represents a part of a shader program that is responsible for a specific stage (vertex, fragment, geometry, etc.). - */ - template - class TShaderStage final - { - public: - /** - * Creates a shader stage of the given type. - * @param p_type - */ - TShaderStage(Settings::EShaderType p_type); - - /** - * Destructor of the shader stage. - */ - ~TShaderStage(); - - /** - * Uploads the shader source to the graphics backend memory. - * @param p_source - */ - void Upload(const std::string& p_source) const; - - /** - * Compiles the uploaded shader source. - * @note Use this method after uploading the shader source. - * @return The compilation result. - */ - Settings::ShaderCompilationResult Compile() const; - - /** - * Returns the ID of the shader stage. - */ - uint32_t GetID() const; - - private: - Context m_context; - }; -} diff --git a/Sources/OvRendering/include/OvRendering/HAL/Common/TShaderStorageBuffer.h b/Sources/OvRendering/include/OvRendering/HAL/Common/TShaderStorageBuffer.h deleted file mode 100644 index df2007549..000000000 --- a/Sources/OvRendering/include/OvRendering/HAL/Common/TShaderStorageBuffer.h +++ /dev/null @@ -1,29 +0,0 @@ -/** -* @project: Overload -* @author: Overload Tech. -* @licence: MIT -*/ - -#pragma once - -#include -#include - -namespace OvRendering::HAL -{ - /** - * Represents a shader storage buffer, used to store data of variable size that can be accessed by shaders. - */ - template - class TShaderStorageBuffer : public TBuffer - { - public: - /** - * Creates a shader storage buffer. - */ - TShaderStorageBuffer(); - - private: - ShaderStorageBufferContext m_context; - }; -} diff --git a/Sources/OvRendering/include/OvRendering/HAL/Common/TTexture.h b/Sources/OvRendering/include/OvRendering/HAL/Common/TTexture.h deleted file mode 100644 index a141daf3c..000000000 --- a/Sources/OvRendering/include/OvRendering/HAL/Common/TTexture.h +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @project: Overload -* @author: Overload Tech. -* @licence: MIT -*/ - -#pragma once - -#include - -#include -#include -#include -#include -#include - -namespace OvRendering::HAL -{ - /** - * Represents a texture, used to store image data for the graphics backend to use. - */ - template - class TTexture final : public TTextureHandle - { - public: - /** - * Creates a texture. - * @param p_type The type of the texture (2D, Cube, etc.) - * @param p_debugName A name used to identify the texture for debugging purposes - */ - TTexture(Settings::ETextureType p_type, std::string_view p_debugName = std::string_view{}); - - /** - * Destroys the texture. - */ - ~TTexture(); - - /** - * Allocates memory for the texture. - * @param p_desc - */ - void Allocate(const Settings::TextureDesc& p_desc); - - /** - * Returns true if the texture has been properly allocated. - */ - bool IsValid() const; - - /** - * Returns true if the texture is mutable. - */ - bool IsMutable() const; - - /** - * Uploads data to the texture. - * @param p_data Pointer to the data to upload. - * @param p_format Format of the data. - * @param p_type Type of the pixel data. - */ - void Upload(const void* p_data, Settings::EFormat p_format, Settings::EPixelDataType p_type); - - /** - * Resizes the texture. - * @param p_width - * @param p_height - */ - void Resize(uint32_t p_width, uint32_t p_height); - - /** - * Returns the texture descriptor structure. - */ - const Settings::TextureDesc& GetDesc() const; - - /** - * Generates mipmaps for the texture. - */ - void GenerateMipmaps() const; - - /** - * Sets the border color for the texture. - * @param p_color - */ - void SetBorderColor(const OvMaths::FVector4& p_color); - - /** - * Returns the debug name of the texture. - */ - const std::string& GetDebugName() const; - - public: - inline static OvTools::Eventing::Event CreationEvent; - inline static OvTools::Eventing::Event DestructionEvent; - - private: - TextureContext m_textureContext; - }; -} diff --git a/Sources/OvRendering/include/OvRendering/HAL/Common/TTextureHandle.h b/Sources/OvRendering/include/OvRendering/HAL/Common/TTextureHandle.h deleted file mode 100644 index 1c58f08c8..000000000 --- a/Sources/OvRendering/include/OvRendering/HAL/Common/TTextureHandle.h +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @project: Overload -* @author: Overload Tech. -* @licence: MIT -*/ - -#pragma once - -#include - -#include -#include - -namespace OvRendering::HAL -{ - /** - * Represents a texture handle, acts as a view to the texture. - */ - template - class TTextureHandle - { - public: - /** - * Binds the texture to the given slot. - * @param p_slot Optional slot to bind the texture to. - */ - void Bind(std::optional p_slot = std::nullopt) const; - - /** - * Unbinds the texture. - */ - void Unbind() const; - - /** - * Returns the ID associated with the texture. - * @return The texture ID. - */ - uint32_t GetID() const; - - /** - * Returns the texture type - */ - Settings::ETextureType GetType() const; - - protected: - TTextureHandle(Settings::ETextureType p_type); - TTextureHandle(Settings::ETextureType p_type, uint32_t p_id); - - protected: - Context m_context; - }; -} diff --git a/Sources/OvRendering/include/OvRendering/HAL/Common/TUniformBuffer.h b/Sources/OvRendering/include/OvRendering/HAL/Common/TUniformBuffer.h deleted file mode 100644 index b5f5470b5..000000000 --- a/Sources/OvRendering/include/OvRendering/HAL/Common/TUniformBuffer.h +++ /dev/null @@ -1,32 +0,0 @@ -/** -* @project: Overload -* @author: Overload Tech. -* @licence: MIT -*/ - -#pragma once - -#include - -#include "OvRendering/HAL/Common/TBuffer.h" - -namespace OvRendering::Resources { class Shader; } - -namespace OvRendering::HAL -{ - /** - * Represents a uniform buffer, used to store uniform data that can be accessed by shaders - */ - template - class TUniformBuffer : public TBuffer - { - public: - /** - * Creates a UniformBuffer - */ - TUniformBuffer(); - - private: - UniformBufferContext m_context; - }; -} diff --git a/Sources/OvRendering/include/OvRendering/HAL/Common/TVertexArray.h b/Sources/OvRendering/include/OvRendering/HAL/Common/TVertexArray.h deleted file mode 100644 index 6a829acaa..000000000 --- a/Sources/OvRendering/include/OvRendering/HAL/Common/TVertexArray.h +++ /dev/null @@ -1,77 +0,0 @@ -/** -* @project: Overload -* @author: Overload Tech. -* @licence: MIT -*/ - -#pragma once - -#include -#include -#include -#include -#include - -namespace OvRendering::HAL -{ - /** - * Represents a vertex array, used to descript the vertex layout to the graphics backend. - */ - template - class TVertexArray final - { - public: - using IndexBuffer = TIndexBuffer; - using VertexBuffer = TVertexBuffer; - - /** - * Creates the vertex array. - */ - TVertexArray(); - - /** - * Destroys the vertex array. - */ - ~TVertexArray(); - - /** - * Returns true if the vertex array is valid (non-empty layout). - */ - bool IsValid() const; - - /** - * Sets the vertex attribute layout. - * @param p_attributes - * @param p_vertexBuffer - * @param p_indexBuffer - */ - void SetLayout( - Settings::VertexAttributeLayout p_attributes, - VertexBuffer& p_vertexBuffer, - IndexBuffer& p_indexBuffer - ); - - /** - * Resets the vertex attribute layout. - */ - void ResetLayout(); - - /** - * Binds the vertex array. - */ - void Bind() const; - - /** - * Unbinds the vertex array. - */ - void Unbind() const; - - /** - * Returns the vertex array ID. - */ - uint32_t GetID() const; - - private: - VertexArrayContext m_context; - }; -} diff --git a/Sources/OvRendering/include/OvRendering/HAL/Common/TVertexBuffer.h b/Sources/OvRendering/include/OvRendering/HAL/Common/TVertexBuffer.h deleted file mode 100644 index 92c0cfd17..000000000 --- a/Sources/OvRendering/include/OvRendering/HAL/Common/TVertexBuffer.h +++ /dev/null @@ -1,28 +0,0 @@ -/** -* @project: Overload -* @author: Overload Tech. -* @licence: MIT -*/ - -#pragma once - -#include - -namespace OvRendering::HAL -{ - /** - * Represents a vertex buffer, used to store vertex data for the graphics backend to use. - */ - template - class TVertexBuffer final : public TBuffer - { - public: - /** - * Creates a vertex buffer. - */ - TVertexBuffer(); - - private: - VertexBufferContext m_context; - }; -} diff --git a/Sources/OvRendering/include/OvRendering/HAL/Framebuffer.h b/Sources/OvRendering/include/OvRendering/HAL/Framebuffer.h deleted file mode 100644 index ffa704f66..000000000 --- a/Sources/OvRendering/include/OvRendering/HAL/Framebuffer.h +++ /dev/null @@ -1,22 +0,0 @@ -/** -* @project: Overload -* @author: Overload Tech. -* @licence: MIT -*/ - -#pragma once - -#if defined(GRAPHICS_API_OPENGL) -#include -#else -#include -#endif // defined(GRAPHICS_API_OPENGL) - -namespace OvRendering::HAL -{ -#if defined(GRAPHICS_API_OPENGL) - using Framebuffer = GLFramebuffer; -#else - using Framebuffer = NoneFramebuffer; -#endif // defined(GRAPHICS_API_OPENGL) -} diff --git a/Sources/OvRendering/include/OvRendering/HAL/IndexBuffer.h b/Sources/OvRendering/include/OvRendering/HAL/IndexBuffer.h deleted file mode 100644 index ce2f9a421..000000000 --- a/Sources/OvRendering/include/OvRendering/HAL/IndexBuffer.h +++ /dev/null @@ -1,22 +0,0 @@ -/** -* @project: Overload -* @author: Overload Tech. -* @licence: MIT -*/ - -#pragma once - -#if defined(GRAPHICS_API_OPENGL) -#include -#else -#include -#endif // defined(GRAPHICS_API_OPENGL) - -namespace OvRendering::HAL -{ -#if defined(GRAPHICS_API_OPENGL) - using IndexBuffer = GLIndexBuffer; -#else - using IndexBuffer = NoneIndexBuffer; -#endif // defined(GRAPHICS_API_OPENGL) -} diff --git a/Sources/OvRendering/include/OvRendering/HAL/None/NoneBackend.h b/Sources/OvRendering/include/OvRendering/HAL/None/NoneBackend.h deleted file mode 100644 index 38e6a7c18..000000000 --- a/Sources/OvRendering/include/OvRendering/HAL/None/NoneBackend.h +++ /dev/null @@ -1,15 +0,0 @@ -/** -* @project: Overload -* @author: Overload Tech. -* @licence: MIT -*/ - -#pragma once - -#include - -namespace OvRendering::HAL -{ - struct NoneBackendContext {}; - using NoneBackend = TBackend; -} diff --git a/Sources/OvRendering/include/OvRendering/HAL/None/NoneBuffer.h b/Sources/OvRendering/include/OvRendering/HAL/None/NoneBuffer.h deleted file mode 100644 index e9174121b..000000000 --- a/Sources/OvRendering/include/OvRendering/HAL/None/NoneBuffer.h +++ /dev/null @@ -1,20 +0,0 @@ -/** -* @project: Overload -* @author: Overload Tech. -* @licence: MIT -*/ - -#pragma once - -#include - -namespace OvRendering::HAL -{ - struct NoneBufferContext - { - uint64_t allocatedBytes = 0; - Settings::EBufferType type = Settings::EBufferType::UNKNOWN; - }; - - using NoneBuffer = TBuffer; -} diff --git a/Sources/OvRendering/include/OvRendering/HAL/None/NoneFramebuffer.h b/Sources/OvRendering/include/OvRendering/HAL/None/NoneFramebuffer.h deleted file mode 100644 index 3f92c1d7d..000000000 --- a/Sources/OvRendering/include/OvRendering/HAL/None/NoneFramebuffer.h +++ /dev/null @@ -1,41 +0,0 @@ -/** -* @project: Overload -* @author: Overload Tech. -* @licence: MIT -*/ - -#pragma once - -#include - -#include -#include -#include - -namespace OvRendering::HAL -{ - template - struct TNoneFramebufferContext - { - using Attachment = TFramebufferAttachment; - - bool valid = false; - std::string debugName = ""; - std::unordered_map, Attachment> attachments; - }; - - using NoneFramebufferContext = TNoneFramebufferContext< - Settings::EGraphicsBackend::NONE, - NoneTextureContext, - NoneTextureHandleContext, - NoneRenderbufferContext - >; - - using NoneFramebuffer = TFramebuffer< - Settings::EGraphicsBackend::NONE, - NoneFramebufferContext, - NoneTextureContext, - NoneTextureHandleContext, - NoneRenderbufferContext - >; -} diff --git a/Sources/OvRendering/include/OvRendering/HAL/None/NoneIndexBuffer.h b/Sources/OvRendering/include/OvRendering/HAL/None/NoneIndexBuffer.h deleted file mode 100644 index 6f31f75f2..000000000 --- a/Sources/OvRendering/include/OvRendering/HAL/None/NoneIndexBuffer.h +++ /dev/null @@ -1,16 +0,0 @@ -/** -* @project: Overload -* @author: Overload Tech. -* @licence: MIT -*/ - -#pragma once - -#include -#include - -namespace OvRendering::HAL -{ - struct NoneIndexBufferContext {}; - using NoneIndexBuffer = TIndexBuffer; -} diff --git a/Sources/OvRendering/include/OvRendering/HAL/None/NoneRenderbuffer.h b/Sources/OvRendering/include/OvRendering/HAL/None/NoneRenderbuffer.h deleted file mode 100644 index be04c8201..000000000 --- a/Sources/OvRendering/include/OvRendering/HAL/None/NoneRenderbuffer.h +++ /dev/null @@ -1,22 +0,0 @@ -/** -* @project: Overload -* @author: Overload Tech. -* @licence: MIT -*/ - -#pragma once - -#include - -namespace OvRendering::HAL -{ - struct NoneRenderbufferContext - { - uint16_t width = 0; - uint16_t height = 0; - Settings::EInternalFormat format = Settings::EInternalFormat::RGBA; - bool allocated = false; - }; - - using NoneRenderbuffer = TRenderbuffer; -} diff --git a/Sources/OvRendering/include/OvRendering/HAL/None/NoneShaderProgram.h b/Sources/OvRendering/include/OvRendering/HAL/None/NoneShaderProgram.h deleted file mode 100644 index 2afbe6a77..000000000 --- a/Sources/OvRendering/include/OvRendering/HAL/None/NoneShaderProgram.h +++ /dev/null @@ -1,16 +0,0 @@ -/** -* @project: Overload -* @author: Overload Tech. -* @licence: MIT -*/ - -#pragma once - -#include -#include - -namespace OvRendering::HAL -{ - struct NoneShaderProgramContext {}; - using NoneShaderProgram = TShaderProgram; -} diff --git a/Sources/OvRendering/include/OvRendering/HAL/None/NoneShaderStage.h b/Sources/OvRendering/include/OvRendering/HAL/None/NoneShaderStage.h deleted file mode 100644 index 3f1ab50b0..000000000 --- a/Sources/OvRendering/include/OvRendering/HAL/None/NoneShaderStage.h +++ /dev/null @@ -1,15 +0,0 @@ -/** -* @project: Overload -* @author: Overload Tech. -* @licence: MIT -*/ - -#pragma once - -#include - -namespace OvRendering::HAL -{ - struct NoneShaderStageContext {}; - using NoneShaderStage = TShaderStage; -} diff --git a/Sources/OvRendering/include/OvRendering/HAL/None/NoneShaderStorageBuffer.h b/Sources/OvRendering/include/OvRendering/HAL/None/NoneShaderStorageBuffer.h deleted file mode 100644 index 7e480bba0..000000000 --- a/Sources/OvRendering/include/OvRendering/HAL/None/NoneShaderStorageBuffer.h +++ /dev/null @@ -1,16 +0,0 @@ -/** -* @project: Overload -* @author: Overload Tech. -* @licence: MIT -*/ - -#pragma once - -#include -#include - -namespace OvRendering::HAL -{ - struct NoneShaderStorageBufferContext {}; - using NoneShaderStorageBuffer = TShaderStorageBuffer; -} diff --git a/Sources/OvRendering/include/OvRendering/HAL/None/NoneTexture.h b/Sources/OvRendering/include/OvRendering/HAL/None/NoneTexture.h deleted file mode 100644 index 09c100ed7..000000000 --- a/Sources/OvRendering/include/OvRendering/HAL/None/NoneTexture.h +++ /dev/null @@ -1,22 +0,0 @@ -/** -* @project: Overload -* @author: Overload Tech. -* @licence: MIT -*/ - -#pragma once - -#include -#include - -namespace OvRendering::HAL -{ - struct NoneTextureContext - { - OvRendering::Settings::TextureDesc desc; - bool allocated = false; - std::string debugName = ""; - }; - - using NoneTexture = TTexture; -} diff --git a/Sources/OvRendering/include/OvRendering/HAL/None/NoneTextureHandle.h b/Sources/OvRendering/include/OvRendering/HAL/None/NoneTextureHandle.h deleted file mode 100644 index c1be651d3..000000000 --- a/Sources/OvRendering/include/OvRendering/HAL/None/NoneTextureHandle.h +++ /dev/null @@ -1,19 +0,0 @@ -/** -* @project: Overload -* @author: Overload Tech. -* @licence: MIT -*/ - -#pragma once - -#include - -namespace OvRendering::HAL -{ - struct NoneTextureHandleContext - { - const Settings::ETextureType type; - }; - - using NoneTextureHandle = TTextureHandle; -} diff --git a/Sources/OvRendering/include/OvRendering/HAL/None/NoneUniformBuffer.h b/Sources/OvRendering/include/OvRendering/HAL/None/NoneUniformBuffer.h deleted file mode 100644 index 72973e0d8..000000000 --- a/Sources/OvRendering/include/OvRendering/HAL/None/NoneUniformBuffer.h +++ /dev/null @@ -1,16 +0,0 @@ -/** -* @project: Overload -* @author: Overload Tech. -* @licence: MIT -*/ - -#pragma once - -#include -#include - -namespace OvRendering::HAL -{ - struct NoneUniformBufferContext {}; - using NoneUniformBuffer = TUniformBuffer; -} diff --git a/Sources/OvRendering/include/OvRendering/HAL/None/NoneVertexArray.h b/Sources/OvRendering/include/OvRendering/HAL/None/NoneVertexArray.h deleted file mode 100644 index dbfd7d40b..000000000 --- a/Sources/OvRendering/include/OvRendering/HAL/None/NoneVertexArray.h +++ /dev/null @@ -1,27 +0,0 @@ -/** -* @project: Overload -* @author: Overload Tech. -* @licence: MIT -*/ - -#pragma once - -#include -#include -#include - -namespace OvRendering::HAL -{ - struct NoneVertexArrayContext - { - uint32_t attributeCount = 0; - }; - - using NoneVertexArray = TVertexArray< - Settings::EGraphicsBackend::NONE, - NoneVertexArrayContext, - NoneVertexBufferContext, - NoneIndexBufferContext, - NoneBufferContext - >; -} diff --git a/Sources/OvRendering/include/OvRendering/HAL/None/NoneVertexBuffer.h b/Sources/OvRendering/include/OvRendering/HAL/None/NoneVertexBuffer.h deleted file mode 100644 index 96cb97bd7..000000000 --- a/Sources/OvRendering/include/OvRendering/HAL/None/NoneVertexBuffer.h +++ /dev/null @@ -1,16 +0,0 @@ -/** -* @project: Overload -* @author: Overload Tech. -* @licence: MIT -*/ - -#pragma once - -#include -#include - -namespace OvRendering::HAL -{ - struct NoneVertexBufferContext {}; - using NoneVertexBuffer = TVertexBuffer; -} diff --git a/Sources/OvRendering/include/OvRendering/HAL/OpenGL/GLBackend.h b/Sources/OvRendering/include/OvRendering/HAL/OpenGL/GLBackend.h deleted file mode 100644 index ee5ad4d20..000000000 --- a/Sources/OvRendering/include/OvRendering/HAL/OpenGL/GLBackend.h +++ /dev/null @@ -1,15 +0,0 @@ -/** -* @project: Overload -* @author: Overload Tech. -* @licence: MIT -*/ - -#pragma once - -#include - -namespace OvRendering::HAL -{ - struct GLBackendContext {}; - using GLBackend = TBackend; -} diff --git a/Sources/OvRendering/include/OvRendering/HAL/OpenGL/GLBuffer.h b/Sources/OvRendering/include/OvRendering/HAL/OpenGL/GLBuffer.h deleted file mode 100644 index c578a6e32..000000000 --- a/Sources/OvRendering/include/OvRendering/HAL/OpenGL/GLBuffer.h +++ /dev/null @@ -1,21 +0,0 @@ -/** -* @project: Overload -* @author: Overload Tech. -* @licence: MIT -*/ - -#pragma once - -#include - -namespace OvRendering::HAL -{ - struct GLBufferContext - { - uint32_t id = 0; - Settings::EBufferType type = Settings::EBufferType::UNKNOWN; - uint64_t allocatedBytes = 0; - }; - - using GLBuffer = TBuffer; -} diff --git a/Sources/OvRendering/include/OvRendering/HAL/OpenGL/GLFramebuffer.h b/Sources/OvRendering/include/OvRendering/HAL/OpenGL/GLFramebuffer.h deleted file mode 100644 index 05503bcc6..000000000 --- a/Sources/OvRendering/include/OvRendering/HAL/OpenGL/GLFramebuffer.h +++ /dev/null @@ -1,42 +0,0 @@ -/** -* @project: Overload -* @author: Overload Tech. -* @licence: MIT -*/ - -#pragma once - -#include - -#include -#include -#include - -namespace OvRendering::HAL -{ - template - struct TGLFramebufferContext - { - using Attachment = TFramebufferAttachment; - - uint32_t id = 0; - bool valid = false; - std::string debugName; - std::unordered_map attachments; - }; - - using GLFramebufferContext = TGLFramebufferContext< - Settings::EGraphicsBackend::OPENGL, - GLTextureContext, - GLTextureHandleContext, - GLRenderbufferContext - >; - - using GLFramebuffer = TFramebuffer< - Settings::EGraphicsBackend::OPENGL, - GLFramebufferContext, - GLTextureContext, - GLTextureHandleContext, - GLRenderbufferContext - >; -} diff --git a/Sources/OvRendering/include/OvRendering/HAL/OpenGL/GLIndexBuffer.h b/Sources/OvRendering/include/OvRendering/HAL/OpenGL/GLIndexBuffer.h deleted file mode 100644 index d8bbfd96b..000000000 --- a/Sources/OvRendering/include/OvRendering/HAL/OpenGL/GLIndexBuffer.h +++ /dev/null @@ -1,16 +0,0 @@ -/** -* @project: Overload -* @author: Overload Tech. -* @licence: MIT -*/ - -#pragma once - -#include -#include - -namespace OvRendering::HAL -{ - struct GLIndexBufferContext {}; - using GLIndexBuffer = TIndexBuffer; -} diff --git a/Sources/OvRendering/include/OvRendering/HAL/OpenGL/GLRenderbuffer.h b/Sources/OvRendering/include/OvRendering/HAL/OpenGL/GLRenderbuffer.h deleted file mode 100644 index 0c6568650..000000000 --- a/Sources/OvRendering/include/OvRendering/HAL/OpenGL/GLRenderbuffer.h +++ /dev/null @@ -1,23 +0,0 @@ -/** -* @project: Overload -* @author: Overload Tech. -* @licence: MIT -*/ - -#pragma once - -#include - -namespace OvRendering::HAL -{ - struct GLRenderbufferContext - { - uint32_t id = 0; - uint16_t width = 0; - uint16_t height = 0; - Settings::EInternalFormat format = Settings::EInternalFormat::RGBA; - bool allocated = false; - }; - - using GLRenderbuffer = TRenderbuffer; -} diff --git a/Sources/OvRendering/include/OvRendering/HAL/OpenGL/GLShaderProgram.h b/Sources/OvRendering/include/OvRendering/HAL/OpenGL/GLShaderProgram.h deleted file mode 100644 index 634d4a5da..000000000 --- a/Sources/OvRendering/include/OvRendering/HAL/OpenGL/GLShaderProgram.h +++ /dev/null @@ -1,28 +0,0 @@ -/** -* @project: Overload -* @author: Overload Tech. -* @licence: MIT -*/ - -#pragma once - -#include -#include - -#include -#include - -namespace OvRendering::HAL -{ - struct GLShaderProgramContext - { - const uint32_t id; - std::unordered_map uniforms; - std::unordered_map uniformsLocationCache; - std::vector> attachedShaders; - - uint32_t GetUniformLocation(std::string_view p_name); - }; - - using GLShaderProgram = TShaderProgram; -} diff --git a/Sources/OvRendering/include/OvRendering/HAL/OpenGL/GLShaderStage.h b/Sources/OvRendering/include/OvRendering/HAL/OpenGL/GLShaderStage.h deleted file mode 100644 index c61968e76..000000000 --- a/Sources/OvRendering/include/OvRendering/HAL/OpenGL/GLShaderStage.h +++ /dev/null @@ -1,20 +0,0 @@ -/** -* @project: Overload -* @author: Overload Tech. -* @licence: MIT -*/ - -#pragma once - -#include - -namespace OvRendering::HAL -{ - struct GLShaderStageContext - { - uint32_t id; - Settings::EShaderType type; - }; - - using GLShaderStage = TShaderStage; -} diff --git a/Sources/OvRendering/include/OvRendering/HAL/OpenGL/GLShaderStorageBuffer.h b/Sources/OvRendering/include/OvRendering/HAL/OpenGL/GLShaderStorageBuffer.h deleted file mode 100644 index 0aab0d1ad..000000000 --- a/Sources/OvRendering/include/OvRendering/HAL/OpenGL/GLShaderStorageBuffer.h +++ /dev/null @@ -1,20 +0,0 @@ -/** -* @project: Overload -* @author: Overload Tech. -* @licence: MIT -*/ - -#pragma once - -#include -#include - -namespace OvRendering::HAL -{ - struct GLShaderStorageBufferContext - { - uint32_t id = 0; - }; - - using GLShaderStorageBuffer = TShaderStorageBuffer; -} diff --git a/Sources/OvRendering/include/OvRendering/HAL/OpenGL/GLTexture.h b/Sources/OvRendering/include/OvRendering/HAL/OpenGL/GLTexture.h deleted file mode 100644 index 2f8a21499..000000000 --- a/Sources/OvRendering/include/OvRendering/HAL/OpenGL/GLTexture.h +++ /dev/null @@ -1,22 +0,0 @@ -/** -* @project: Overload -* @author: Overload Tech. -* @licence: MIT -*/ - -#pragma once - -#include -#include - -namespace OvRendering::HAL -{ - struct GLTextureContext - { - Settings::TextureDesc desc; - bool allocated = false; - std::string debugName; - }; - - using GLTexture = TTexture; -} diff --git a/Sources/OvRendering/include/OvRendering/HAL/OpenGL/GLTextureHandle.h b/Sources/OvRendering/include/OvRendering/HAL/OpenGL/GLTextureHandle.h deleted file mode 100644 index 563ce2085..000000000 --- a/Sources/OvRendering/include/OvRendering/HAL/OpenGL/GLTextureHandle.h +++ /dev/null @@ -1,20 +0,0 @@ -/** -* @project: Overload -* @author: Overload Tech. -* @licence: MIT -*/ - -#pragma once - -#include - -namespace OvRendering::HAL -{ - struct GLTextureHandleContext - { - uint32_t id; - const uint32_t type; - }; - - using GLTextureHandle = TTextureHandle; -} diff --git a/Sources/OvRendering/include/OvRendering/HAL/OpenGL/GLTypes.h b/Sources/OvRendering/include/OvRendering/HAL/OpenGL/GLTypes.h deleted file mode 100644 index 27d65e832..000000000 --- a/Sources/OvRendering/include/OvRendering/HAL/OpenGL/GLTypes.h +++ /dev/null @@ -1,457 +0,0 @@ -/** -* @project: Overload -* @author: Overload Tech. -* @licence: MIT -*/ - -#pragma once - -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -namespace OvRendering::HAL -{ - template - constexpr ValueType EnumToValue(EnumType enumValue) - { - return OvTools::Utils::ToValueImpl(enumValue); - } - - template - constexpr EnumType ValueToEnum(ValueType value) - { - return OvTools::Utils::FromValueImpl(value); - } -} - -template <> -struct OvTools::Utils::MappingFor -{ - using EnumType = OvRendering::Settings::EComparaisonAlgorithm; - using type = std::tuple< - EnumValuePair, - EnumValuePair, - EnumValuePair, - EnumValuePair, - EnumValuePair, - EnumValuePair, - EnumValuePair, - EnumValuePair - >; -}; - -template <> -struct OvTools::Utils::MappingFor -{ - using EnumType = OvRendering::Settings::EBlendingEquation; - using type = std::tuple< - EnumValuePair, - EnumValuePair, - EnumValuePair, - EnumValuePair, - EnumValuePair - >; -}; - -template <> -struct OvTools::Utils::MappingFor -{ - using EnumType = OvRendering::Settings::EBlendingFactor; - using type = std::tuple< - EnumValuePair, - EnumValuePair, - EnumValuePair, - EnumValuePair, - EnumValuePair, - EnumValuePair, - EnumValuePair, - EnumValuePair, - EnumValuePair, - EnumValuePair, - EnumValuePair, - EnumValuePair, - EnumValuePair, - EnumValuePair, - EnumValuePair, - EnumValuePair, - EnumValuePair, - EnumValuePair, - EnumValuePair - >; -}; - -template <> -struct OvTools::Utils::MappingFor -{ - using EnumType = OvRendering::Settings::ERasterizationMode; - using type = std::tuple< - EnumValuePair, - EnumValuePair, - EnumValuePair - >; -}; - -template <> -struct OvTools::Utils::MappingFor -{ - using EnumType = OvRendering::Settings::ECullFace; - using type = std::tuple< - EnumValuePair, - EnumValuePair, - EnumValuePair - >; -}; - -template <> -struct OvTools::Utils::MappingFor -{ - using EnumType = OvRendering::Settings::EOperation; - using type = std::tuple< - EnumValuePair, - EnumValuePair, - EnumValuePair, - EnumValuePair, - EnumValuePair, - EnumValuePair, - EnumValuePair, - EnumValuePair - >; -}; - -template <> -struct OvTools::Utils::MappingFor -{ - using EnumType = OvRendering::Settings::ERenderingCapability; - using type = std::tuple< - EnumValuePair, - EnumValuePair, - EnumValuePair, - EnumValuePair, - EnumValuePair, - EnumValuePair, - EnumValuePair, - EnumValuePair, - EnumValuePair, - EnumValuePair - >; -}; - -template <> -struct OvTools::Utils::MappingFor -{ - using EnumType = OvRendering::Settings::EPrimitiveMode; - using type = std::tuple< - EnumValuePair, - EnumValuePair, - EnumValuePair, - EnumValuePair, - EnumValuePair, - EnumValuePair, - EnumValuePair, - EnumValuePair, - EnumValuePair, - EnumValuePair - >; -}; - -template <> -struct OvTools::Utils::MappingFor -{ - using EnumType = OvRendering::Settings::EFormat; - using type = std::tuple< - EnumValuePair, - EnumValuePair, - EnumValuePair, - EnumValuePair, - EnumValuePair, - EnumValuePair, - EnumValuePair, - EnumValuePair, - EnumValuePair, - EnumValuePair, - EnumValuePair, - EnumValuePair, - EnumValuePair, - EnumValuePair, - EnumValuePair - >; -}; - -template <> -struct OvTools::Utils::MappingFor -{ - using EnumType = OvRendering::Settings::ETextureFilteringMode; - using type = std::tuple< - EnumValuePair, - EnumValuePair, - EnumValuePair, - EnumValuePair, - EnumValuePair, - EnumValuePair - >; -}; - -template <> -struct OvTools::Utils::MappingFor -{ - using EnumType = OvRendering::Settings::ETextureWrapMode; - using type = std::tuple< - EnumValuePair, - EnumValuePair, - EnumValuePair, - EnumValuePair, - EnumValuePair - >; -}; - -template <> -struct OvTools::Utils::MappingFor -{ - using EnumType = OvRendering::Settings::EPixelDataFormat; - using type = std::tuple< - EnumValuePair, - EnumValuePair, - EnumValuePair, - EnumValuePair, - EnumValuePair, - EnumValuePair, - EnumValuePair, - EnumValuePair, - EnumValuePair, - EnumValuePair - >; -}; - -template <> -struct OvTools::Utils::MappingFor -{ - using EnumType = OvRendering::Settings::EPixelDataType; - using type = std::tuple< - EnumValuePair, - EnumValuePair, - EnumValuePair, - EnumValuePair, - EnumValuePair, - EnumValuePair, - EnumValuePair, - EnumValuePair, - EnumValuePair, - EnumValuePair, - EnumValuePair, - EnumValuePair, - EnumValuePair, - EnumValuePair, - EnumValuePair, - EnumValuePair, - EnumValuePair, - EnumValuePair, - EnumValuePair - >; -}; - -template <> -struct OvTools::Utils::MappingFor -{ - using EnumType = OvRendering::Settings::EDataType; - using type = std::tuple< - EnumValuePair, - EnumValuePair, - EnumValuePair, - EnumValuePair, - EnumValuePair, - EnumValuePair, - EnumValuePair, - EnumValuePair - >; -}; - -template <> -struct OvTools::Utils::MappingFor -{ - using EnumType = OvRendering::Settings::EAccessSpecifier; - using type = std::tuple< - EnumValuePair, - EnumValuePair, - EnumValuePair, - EnumValuePair, - EnumValuePair, - EnumValuePair, - EnumValuePair, - EnumValuePair, - EnumValuePair - >; -}; - -template <> -struct OvTools::Utils::MappingFor -{ - using EnumType = OvRendering::Settings::EUniformType; - using type = std::tuple< - EnumValuePair, - EnumValuePair, - EnumValuePair, - EnumValuePair, - EnumValuePair, - EnumValuePair, - EnumValuePair, - EnumValuePair, - EnumValuePair, - EnumValuePair, - EnumValuePair - >; -}; - -template <> -struct OvTools::Utils::MappingFor -{ - using EnumType = OvRendering::Settings::EInternalFormat; - using type = std::tuple< - EnumValuePair, - EnumValuePair, - EnumValuePair, - EnumValuePair, - EnumValuePair, - EnumValuePair, - EnumValuePair, - EnumValuePair, - EnumValuePair, - EnumValuePair, - EnumValuePair, - EnumValuePair, - EnumValuePair, - EnumValuePair, - EnumValuePair, - EnumValuePair, - EnumValuePair, - EnumValuePair, - EnumValuePair, - EnumValuePair, - EnumValuePair, - EnumValuePair, - EnumValuePair, - EnumValuePair, - EnumValuePair, - EnumValuePair, - EnumValuePair, - EnumValuePair, - EnumValuePair, - EnumValuePair, - EnumValuePair, - EnumValuePair, - EnumValuePair, - EnumValuePair, - EnumValuePair, - EnumValuePair, - EnumValuePair, - EnumValuePair, - EnumValuePair, - EnumValuePair, - EnumValuePair, - EnumValuePair, - EnumValuePair, - EnumValuePair, - EnumValuePair, - EnumValuePair, - EnumValuePair, - EnumValuePair, - EnumValuePair, - EnumValuePair, - EnumValuePair, - EnumValuePair, - EnumValuePair, - EnumValuePair, - EnumValuePair, - EnumValuePair, - EnumValuePair, - EnumValuePair, - EnumValuePair, - EnumValuePair, - EnumValuePair, - EnumValuePair, - EnumValuePair, - EnumValuePair, - EnumValuePair, - EnumValuePair, - EnumValuePair, - EnumValuePair, - EnumValuePair, - EnumValuePair, - EnumValuePair, - EnumValuePair, - EnumValuePair, - EnumValuePair, - EnumValuePair, - EnumValuePair, - EnumValuePair, - EnumValuePair, - EnumValuePair, - EnumValuePair, - EnumValuePair - >; -}; - -template <> -struct OvTools::Utils::MappingFor -{ - using EnumType = OvRendering::Settings::EShaderType; - using type = std::tuple< - EnumValuePair, - EnumValuePair - >; -}; - -template <> -struct OvTools::Utils::MappingFor -{ - using EnumType = OvRendering::Settings::EFramebufferAttachment; - using type = std::tuple< - EnumValuePair, - EnumValuePair, - EnumValuePair, - EnumValuePair - > ; -}; - -template <> -struct OvTools::Utils::MappingFor -{ - using EnumType = OvRendering::Settings::EBufferType; - using type = std::tuple< - EnumValuePair, - EnumValuePair, - EnumValuePair, - EnumValuePair - >; -}; - -template <> -struct OvTools::Utils::MappingFor -{ - using EnumType = OvRendering::Settings::ETextureType; - using type = std::tuple< - EnumValuePair, - EnumValuePair - >; -}; diff --git a/Sources/OvRendering/include/OvRendering/HAL/OpenGL/GLUniformBuffer.h b/Sources/OvRendering/include/OvRendering/HAL/OpenGL/GLUniformBuffer.h deleted file mode 100644 index dd3914858..000000000 --- a/Sources/OvRendering/include/OvRendering/HAL/OpenGL/GLUniformBuffer.h +++ /dev/null @@ -1,16 +0,0 @@ -/** -* @project: Overload -* @author: Overload Tech. -* @licence: MIT -*/ - -#pragma once - -#include -#include - -namespace OvRendering::HAL -{ - struct GLUniformBufferContext {}; - using GLUniformBuffer = TUniformBuffer; -} diff --git a/Sources/OvRendering/include/OvRendering/HAL/OpenGL/GLVertexArray.h b/Sources/OvRendering/include/OvRendering/HAL/OpenGL/GLVertexArray.h deleted file mode 100644 index 30529358f..000000000 --- a/Sources/OvRendering/include/OvRendering/HAL/OpenGL/GLVertexArray.h +++ /dev/null @@ -1,29 +0,0 @@ -/** -* @project: Overload -* @author: Overload Tech. -* @licence: MIT -*/ - -#pragma once - -#include -#include -#include -#include - -namespace OvRendering::HAL -{ - struct GLVertexArrayContext - { - uint32_t id = 0; - uint32_t attributeCount = 0; - }; - - using GLVertexArray = TVertexArray< - Settings::EGraphicsBackend::OPENGL, - GLVertexArrayContext, - GLVertexBufferContext, - GLIndexBufferContext, - GLBufferContext - >; -} diff --git a/Sources/OvRendering/include/OvRendering/HAL/OpenGL/GLVertexBuffer.h b/Sources/OvRendering/include/OvRendering/HAL/OpenGL/GLVertexBuffer.h deleted file mode 100644 index e8daf28d3..000000000 --- a/Sources/OvRendering/include/OvRendering/HAL/OpenGL/GLVertexBuffer.h +++ /dev/null @@ -1,16 +0,0 @@ -/** -* @project: Overload -* @author: Overload Tech. -* @licence: MIT -*/ - -#pragma once - -#include -#include - -namespace OvRendering::HAL -{ - struct GLVertexBufferContext{}; - using GLVertexBuffer = TVertexBuffer; -} diff --git a/Sources/OvRendering/include/OvRendering/HAL/Profiling.h b/Sources/OvRendering/include/OvRendering/HAL/Profiling.h deleted file mode 100644 index d447c0bb7..000000000 --- a/Sources/OvRendering/include/OvRendering/HAL/Profiling.h +++ /dev/null @@ -1,17 +0,0 @@ -/** -* @project: Overload -* @author: Overload Tech. -* @licence: MIT -*/ - -#pragma once - -#include - -#if defined(GRAPHICS_API_OPENGL) -#include -#include -#else -#undef TRACY_ENABLE // Disable tracy GPU profiling if not using OpenGL -#include -#endif // defined(GRAPHICS_API_OPENGL) diff --git a/Sources/OvRendering/include/OvRendering/HAL/Renderbuffer.h b/Sources/OvRendering/include/OvRendering/HAL/Renderbuffer.h deleted file mode 100644 index a398c0c65..000000000 --- a/Sources/OvRendering/include/OvRendering/HAL/Renderbuffer.h +++ /dev/null @@ -1,22 +0,0 @@ -/** -* @project: Overload -* @author: Overload Tech. -* @licence: MIT -*/ - -#pragma once - -#if defined(GRAPHICS_API_OPENGL) -#include -#else -#include -#endif // defined(GRAPHICS_API_OPENGL) - -namespace OvRendering::HAL -{ -#if defined(GRAPHICS_API_OPENGL) - using Renderbuffer = GLRenderbuffer; -#else - using Renderbuffer = NoneRenderbuffer; -#endif // defined(GRAPHICS_API_OPENGL) -} diff --git a/Sources/OvRendering/include/OvRendering/HAL/ShaderProgram.h b/Sources/OvRendering/include/OvRendering/HAL/ShaderProgram.h deleted file mode 100644 index 52b357819..000000000 --- a/Sources/OvRendering/include/OvRendering/HAL/ShaderProgram.h +++ /dev/null @@ -1,22 +0,0 @@ -/** -* @project: Overload -* @author: Overload Tech. -* @licence: MIT -*/ - -#pragma once - -#if defined(GRAPHICS_API_OPENGL) -#include -#else -#include -#endif // defined(GRAPHICS_API_OPENGL) - -namespace OvRendering::HAL -{ -#if defined(GRAPHICS_API_OPENGL) - using ShaderProgram = GLShaderProgram; -#else - using ShaderProgram = NoneShaderProgram; -#endif // defined(GRAPHICS_API_OPENGL) -} diff --git a/Sources/OvRendering/include/OvRendering/HAL/ShaderStage.h b/Sources/OvRendering/include/OvRendering/HAL/ShaderStage.h deleted file mode 100644 index 9b67c693d..000000000 --- a/Sources/OvRendering/include/OvRendering/HAL/ShaderStage.h +++ /dev/null @@ -1,22 +0,0 @@ -/** -* @project: Overload -* @author: Overload Tech. -* @licence: MIT -*/ - -#pragma once - -#if defined(GRAPHICS_API_OPENGL) -#include -#else -#include -#endif // defined(GRAPHICS_API_OPENGL) - -namespace OvRendering::HAL -{ -#if defined(GRAPHICS_API_OPENGL) - using ShaderStage = GLShaderStage; -#else - using ShaderStage = NoneShaderStage; -#endif // defined(GRAPHICS_API_OPENGL) -} diff --git a/Sources/OvRendering/include/OvRendering/HAL/ShaderStorageBuffer.h b/Sources/OvRendering/include/OvRendering/HAL/ShaderStorageBuffer.h deleted file mode 100644 index 8c3737c5d..000000000 --- a/Sources/OvRendering/include/OvRendering/HAL/ShaderStorageBuffer.h +++ /dev/null @@ -1,22 +0,0 @@ -/** -* @project: Overload -* @author: Overload Tech. -* @licence: MIT -*/ - -#pragma once - -#if defined(GRAPHICS_API_OPENGL) -#include -#else -#include -#endif // defined(GRAPHICS_API_OPENGL) - -namespace OvRendering::HAL -{ -#if defined(GRAPHICS_API_OPENGL) - using ShaderStorageBuffer = GLShaderStorageBuffer; -#else - using ShaderStorageBuffer = NoneShaderStorageBuffer; -#endif // defined(GRAPHICS_API_OPENGL) -} diff --git a/Sources/OvRendering/include/OvRendering/HAL/Texture.h b/Sources/OvRendering/include/OvRendering/HAL/Texture.h deleted file mode 100644 index 69c2a7806..000000000 --- a/Sources/OvRendering/include/OvRendering/HAL/Texture.h +++ /dev/null @@ -1,22 +0,0 @@ -/** -* @project: Overload -* @author: Overload Tech. -* @licence: MIT -*/ - -#pragma once - -#if defined(GRAPHICS_API_OPENGL) -#include -#else -#include -#endif // defined(GRAPHICS_API_OPENGL) - -namespace OvRendering::HAL -{ -#if defined(GRAPHICS_API_OPENGL) - using Texture = GLTexture; -#else - using Texture = NoneTexture; -#endif // defined(GRAPHICS_API_OPENGL) -} diff --git a/Sources/OvRendering/include/OvRendering/HAL/TextureHandle.h b/Sources/OvRendering/include/OvRendering/HAL/TextureHandle.h deleted file mode 100644 index faa775fff..000000000 --- a/Sources/OvRendering/include/OvRendering/HAL/TextureHandle.h +++ /dev/null @@ -1,22 +0,0 @@ -/** -* @project: Overload -* @author: Overload Tech. -* @licence: MIT -*/ - -#pragma once - -#if defined(GRAPHICS_API_OPENGL) -#include -#else -#include -#endif // defined(GRAPHICS_API_OPENGL) - -namespace OvRendering::HAL -{ -#if defined(GRAPHICS_API_OPENGL) - using TextureHandle = GLTextureHandle; -#else - using TextureHandle = NoneTextureHandle; -#endif // defined(GRAPHICS_API_OPENGL) -} diff --git a/Sources/OvRendering/include/OvRendering/HAL/UniformBuffer.h b/Sources/OvRendering/include/OvRendering/HAL/UniformBuffer.h deleted file mode 100644 index a6f504fa2..000000000 --- a/Sources/OvRendering/include/OvRendering/HAL/UniformBuffer.h +++ /dev/null @@ -1,22 +0,0 @@ -/** -* @project: Overload -* @author: Overload Tech. -* @licence: MIT -*/ - -#pragma once - -#if defined(GRAPHICS_API_OPENGL) -#include -#else -#include -#endif // defined(GRAPHICS_API_OPENGL) - -namespace OvRendering::HAL -{ -#if defined(GRAPHICS_API_OPENGL) - using UniformBuffer = GLUniformBuffer; -#else - using UniformBuffer = NoneUniformBuffer; -#endif // defined(GRAPHICS_API_OPENGL) -} diff --git a/Sources/OvRendering/include/OvRendering/HAL/VertexArray.h b/Sources/OvRendering/include/OvRendering/HAL/VertexArray.h deleted file mode 100644 index 38515296e..000000000 --- a/Sources/OvRendering/include/OvRendering/HAL/VertexArray.h +++ /dev/null @@ -1,22 +0,0 @@ -/** -* @project: Overload -* @author: Overload Tech. -* @licence: MIT -*/ - -#pragma once - -#if defined(GRAPHICS_API_OPENGL) -#include -#else -#include -#endif // defined(GRAPHICS_API_OPENGL) - -namespace OvRendering::HAL -{ -#if defined(GRAPHICS_API_OPENGL) - using VertexArray = GLVertexArray; -#else - using VertexArray = NoneVertexArray; -#endif // defined(GRAPHICS_API_OPENGL) -} diff --git a/Sources/OvRendering/include/OvRendering/HAL/VertexBuffer.h b/Sources/OvRendering/include/OvRendering/HAL/VertexBuffer.h deleted file mode 100644 index 9058816e9..000000000 --- a/Sources/OvRendering/include/OvRendering/HAL/VertexBuffer.h +++ /dev/null @@ -1,22 +0,0 @@ -/** -* @project: Overload -* @author: Overload Tech. -* @licence: MIT -*/ - -#pragma once - -#if defined(GRAPHICS_API_OPENGL) -#include -#else -#include -#endif // defined(GRAPHICS_API_OPENGL) - -namespace OvRendering::HAL -{ -#if defined(GRAPHICS_API_OPENGL) - using VertexBuffer = GLVertexBuffer; -#else - using VertexBuffer = NoneVertexBuffer; -#endif // defined(GRAPHICS_API_OPENGL) -} diff --git a/Sources/OvRendering/include/OvRendering/Resources/IMesh.h b/Sources/OvRendering/include/OvRendering/Resources/IMesh.h index 42a4d0de6..5ee03061a 100644 --- a/Sources/OvRendering/include/OvRendering/Resources/IMesh.h +++ b/Sources/OvRendering/include/OvRendering/Resources/IMesh.h @@ -6,7 +6,7 @@ #pragma once -#include +#include #include namespace OvRendering::Resources @@ -23,4 +23,4 @@ namespace OvRendering::Resources virtual uint32_t GetIndexCount() const = 0; virtual const OvRendering::Geometry::BoundingSphere& GetBoundingSphere() const = 0; }; -} \ No newline at end of file +} diff --git a/Sources/OvRendering/include/OvRendering/Resources/Loaders/TextureLoader.h b/Sources/OvRendering/include/OvRendering/Resources/Loaders/TextureLoader.h index 644eda236..3e204f7de 100644 --- a/Sources/OvRendering/include/OvRendering/Resources/Loaders/TextureLoader.h +++ b/Sources/OvRendering/include/OvRendering/Resources/Loaders/TextureLoader.h @@ -10,8 +10,7 @@ #include #include -#include "OvRendering/Resources/Texture.h" - +#include namespace OvRendering::Resources::Loaders { @@ -37,10 +36,10 @@ namespace OvRendering::Resources::Loaders */ static Texture* Create( const std::string& p_filepath, - OvRendering::Settings::ETextureFilteringMode p_minFilter, - OvRendering::Settings::ETextureFilteringMode p_magFilter, - OvRendering::Settings::ETextureWrapMode p_horizontalWrapMode, - OvRendering::Settings::ETextureWrapMode p_verticalWrapMode, + baregl::types::ETextureFilteringMode p_minFilter, + baregl::types::ETextureFilteringMode p_magFilter, + baregl::types::ETextureWrapMode p_horizontalWrapMode, + baregl::types::ETextureWrapMode p_verticalWrapMode, bool p_generateMipmap ); @@ -68,10 +67,10 @@ namespace OvRendering::Resources::Loaders const uint8_t* p_data, uint32_t p_width, uint32_t p_height, - OvRendering::Settings::ETextureFilteringMode p_minFilter, - OvRendering::Settings::ETextureFilteringMode p_magFilter, - OvRendering::Settings::ETextureWrapMode p_horizontalWrapMode, - OvRendering::Settings::ETextureWrapMode p_verticalWrapMode, + baregl::types::ETextureFilteringMode p_minFilter, + baregl::types::ETextureFilteringMode p_magFilter, + baregl::types::ETextureWrapMode p_horizontalWrapMode, + baregl::types::ETextureWrapMode p_verticalWrapMode, bool p_generateMipmap ); @@ -88,10 +87,10 @@ namespace OvRendering::Resources::Loaders static Texture* CreateFromEncodedMemory( const uint8_t* p_data, size_t p_size, - OvRendering::Settings::ETextureFilteringMode p_minFilter, - OvRendering::Settings::ETextureFilteringMode p_magFilter, - OvRendering::Settings::ETextureWrapMode p_horizontalWrapMode, - OvRendering::Settings::ETextureWrapMode p_verticalWrapMode, + baregl::types::ETextureFilteringMode p_minFilter, + baregl::types::ETextureFilteringMode p_magFilter, + baregl::types::ETextureWrapMode p_horizontalWrapMode, + baregl::types::ETextureWrapMode p_verticalWrapMode, bool p_generateMipmap ); @@ -108,10 +107,10 @@ namespace OvRendering::Resources::Loaders static void Reload( Texture& p_texture, const std::string& p_filePath, - OvRendering::Settings::ETextureFilteringMode p_minFilter, - OvRendering::Settings::ETextureFilteringMode p_magFilter, - OvRendering::Settings::ETextureWrapMode p_horizontalWrapMode, - OvRendering::Settings::ETextureWrapMode p_verticalWrapMode, + baregl::types::ETextureFilteringMode p_minFilter, + baregl::types::ETextureFilteringMode p_magFilter, + baregl::types::ETextureWrapMode p_horizontalWrapMode, + baregl::types::ETextureWrapMode p_verticalWrapMode, bool p_generateMipmap ); @@ -132,10 +131,10 @@ namespace OvRendering::Resources::Loaders const uint8_t* p_data, uint32_t p_width, uint32_t p_height, - OvRendering::Settings::ETextureFilteringMode p_minFilter, - OvRendering::Settings::ETextureFilteringMode p_magFilter, - OvRendering::Settings::ETextureWrapMode p_horizontalWrapMode, - OvRendering::Settings::ETextureWrapMode p_verticalWrapMode, + baregl::types::ETextureFilteringMode p_minFilter, + baregl::types::ETextureFilteringMode p_magFilter, + baregl::types::ETextureWrapMode p_horizontalWrapMode, + baregl::types::ETextureWrapMode p_verticalWrapMode, bool p_generateMipmap ); @@ -154,10 +153,10 @@ namespace OvRendering::Resources::Loaders Texture& p_texture, const uint8_t* p_data, size_t p_size, - OvRendering::Settings::ETextureFilteringMode p_minFilter, - OvRendering::Settings::ETextureFilteringMode p_magFilter, - OvRendering::Settings::ETextureWrapMode p_horizontalWrapMode, - OvRendering::Settings::ETextureWrapMode p_verticalWrapMode, + baregl::types::ETextureFilteringMode p_minFilter, + baregl::types::ETextureFilteringMode p_magFilter, + baregl::types::ETextureWrapMode p_horizontalWrapMode, + baregl::types::ETextureWrapMode p_verticalWrapMode, bool p_generateMipmap ); diff --git a/Sources/OvRendering/include/OvRendering/Resources/Mesh.h b/Sources/OvRendering/include/OvRendering/Resources/Mesh.h index 370745ea4..2daca6c51 100644 --- a/Sources/OvRendering/include/OvRendering/Resources/Mesh.h +++ b/Sources/OvRendering/include/OvRendering/Resources/Mesh.h @@ -7,10 +7,10 @@ #pragma once #include +#include -#include -#include -#include +#include +#include #include #include #include @@ -92,9 +92,9 @@ namespace OvRendering::Resources const uint32_t m_materialIndex; const bool m_hasSkinningData; - HAL::VertexArray m_vertexArray; - HAL::VertexBuffer m_vertexBuffer; - HAL::IndexBuffer m_indexBuffer; + baregl::VertexArray m_vertexArray; + baregl::Buffer m_vertexBuffer; + baregl::Buffer m_indexBuffer; Geometry::BoundingSphere m_boundingSphere; }; diff --git a/Sources/OvRendering/include/OvRendering/Resources/Shader.h b/Sources/OvRendering/include/OvRendering/Resources/Shader.h index 755ebdebd..070a684ad 100644 --- a/Sources/OvRendering/include/OvRendering/Resources/Shader.h +++ b/Sources/OvRendering/include/OvRendering/Resources/Shader.h @@ -12,7 +12,7 @@ #include #include -#include +#include namespace OvRendering::Resources { @@ -30,7 +30,7 @@ namespace OvRendering::Resources // Shader programs for each feature combination using FeatureVariants = std::unordered_map< Data::FeatureSet, - std::unique_ptr, + std::unique_ptr, Data::FeatureSetHash, Data::FeatureSetEqual >; @@ -46,7 +46,7 @@ namespace OvRendering::Resources * @param p_pass (optional) The pass to use. If not provided, the default pass will be selected. * @param p_featureSet (optional) The feature set to use. If not provided, the default program will be used. */ - HAL::ShaderProgram& GetVariant( + baregl::ShaderProgram& GetVariant( std::optional p_pass = std::nullopt, const Data::FeatureSet& p_featureSet = {} ); diff --git a/Sources/OvRendering/include/OvRendering/Resources/Texture.h b/Sources/OvRendering/include/OvRendering/Resources/Texture.h index 5f3636ae5..37558b49c 100644 --- a/Sources/OvRendering/include/OvRendering/Resources/Texture.h +++ b/Sources/OvRendering/include/OvRendering/Resources/Texture.h @@ -10,8 +10,8 @@ #include #include -#include -#include +#include +#include namespace OvRendering::Resources { @@ -26,19 +26,19 @@ namespace OvRendering::Resources public: /** - * Returns the associated HAL::Texture instance + * Returns the associated baregl::Texture instance */ - HAL::Texture& GetTexture(); + baregl::Texture& GetTexture(); private: - Texture(const std::string p_path, std::unique_ptr&& p_texture); + Texture(const std::string p_path, std::unique_ptr&& p_texture); ~Texture() = default; - void SetTexture(std::unique_ptr&& p_texture); + void SetTexture(std::unique_ptr&& p_texture); public: const std::string path; private: - std::unique_ptr m_texture; + std::unique_ptr m_texture; }; -} \ No newline at end of file +} diff --git a/Sources/OvRendering/include/OvRendering/Settings/EGraphicsBackend.h b/Sources/OvRendering/include/OvRendering/Settings/EGraphicsBackend.h deleted file mode 100644 index a232193c1..000000000 --- a/Sources/OvRendering/include/OvRendering/Settings/EGraphicsBackend.h +++ /dev/null @@ -1,21 +0,0 @@ -/** -* @project: Overload -* @author: Overload Tech. -* @licence: MIT -*/ - -#pragma once - -#include - -namespace OvRendering::Settings -{ - /** - * Enumerate graphics backend implementations - */ - enum class EGraphicsBackend : uint8_t - { - NONE, - OPENGL - }; -} \ No newline at end of file diff --git a/Sources/OvRendering/include/OvRendering/Settings/ERasterizationMode.h b/Sources/OvRendering/include/OvRendering/Settings/ERasterizationMode.h deleted file mode 100644 index 962e8b239..000000000 --- a/Sources/OvRendering/include/OvRendering/Settings/ERasterizationMode.h +++ /dev/null @@ -1,22 +0,0 @@ -/** -* @project: Overload -* @author: Overload Tech. -* @licence: MIT -*/ - -#pragma once - -#include - -namespace OvRendering::Settings -{ - /** - * OpenGL rasterization mode enum wrapper - */ - enum class ERasterizationMode : uint8_t - { - POINT, // Polygon vertices that are marked as the start of a boundary edge are drawn as points. Point attributes such as GL_POINT_SIZE and GL_POINT_SMOOTH control the rasterization of the points. Polygon rasterization attributes other than GL_POLYGON_MODE have no effect. - LINE, // Boundary edges of the polygon are drawn as line segments. Line attributes such as GL_LINE_WIDTH and GL_LINE_SMOOTH control the rasterization of the lines. Polygon rasterization attributes other than GL_POLYGON_MODE have no effect. - FILL // The interior of the polygon is filled. Polygon attributes such as GL_POLYGON_SMOOTH control the rasterization of the polygon. - }; -} \ No newline at end of file diff --git a/Sources/OvRendering/include/OvRendering/Settings/ERenderingCapability.h b/Sources/OvRendering/include/OvRendering/Settings/ERenderingCapability.h deleted file mode 100644 index 8af92752c..000000000 --- a/Sources/OvRendering/include/OvRendering/Settings/ERenderingCapability.h +++ /dev/null @@ -1,29 +0,0 @@ -/** -* @project: Overload -* @author: Overload Tech. -* @licence: MIT -*/ - -#pragma once - -#include - -namespace OvRendering::Settings -{ - /** - * Rendering Capabilities - */ - enum class ERenderingCapability : uint8_t - { - BLEND, // Blend the computed fragment color values with the values in the color buffers. See glBlendFunc. - CULL_FACE, // Cull polygons based on their winding in window coordinates. - DEPTH_TEST, // Do depth comparisons and update the depth buffer. Note that even if the depth buffer exists and the depth mask is non-zero, the depth buffer is not updated if the depth test is disabled. - DITHER, // Dither color components or indices before they are written to the color buffer. - POLYGON_OFFSET_FILL, // An offset is added to depth values of a polygon's fragments produced by rasterization. - SAMPLE_ALPHA_TO_COVERAGE, // Compute a temporary coverage value where each bit is determined by the alpha value at the corresponding sample location. The temporary coverage value is then ANDed with the fragment coverage value. - SAMPLE_COVERAGE, // The fragment's coverage is ANDed with the temporary coverage value. If GL_SAMPLE_COVERAGE_INVERT is set to GL_TRUE, invert the coverage value. - SCISSOR_TEST, // Discard fragments that are outside the scissor rectangle. - STENCIL_TEST, // Do stencil testing and update the stencil buffer. - MULTISAMPLE // Use multiple fragment samples in computing the final color of a pixel. - }; -} \ No newline at end of file diff --git a/Sources/OvRendering/include/OvRendering/Settings/EShaderType.h b/Sources/OvRendering/include/OvRendering/Settings/EShaderType.h deleted file mode 100644 index 2a4c85434..000000000 --- a/Sources/OvRendering/include/OvRendering/Settings/EShaderType.h +++ /dev/null @@ -1,22 +0,0 @@ -/** -* @project: Overload -* @author: Overload Tech. -* @licence: MIT -*/ - -#pragma once - -#include - -namespace OvRendering::Settings -{ - /** - * OpenGL rasterization mode enum wrapper - */ - enum class EShaderType : uint8_t - { - NONE, - VERTEX, - FRAGMENT, - }; -} diff --git a/Sources/OvRendering/include/OvRendering/Settings/TextureDesc.h b/Sources/OvRendering/include/OvRendering/Settings/TextureDesc.h deleted file mode 100644 index 41a812719..000000000 --- a/Sources/OvRendering/include/OvRendering/Settings/TextureDesc.h +++ /dev/null @@ -1,42 +0,0 @@ -/** -* @project: Overload -* @author: Overload Tech. -* @licence: MIT -*/ - -#pragma once - -#include -#include -#include -#include -#include - -namespace OvRendering::Settings -{ - /** - * Structure that holds additional data for mutable textures - */ - struct MutableTextureDesc - { - EFormat format = EFormat::RGBA; - EPixelDataType type = EPixelDataType::UNSIGNED_BYTE; - const void* data = nullptr; - }; - - /** - * Structure that holds the description of a texture - */ - struct TextureDesc - { - uint32_t width = 0; - uint32_t height = 0; - ETextureFilteringMode minFilter = ETextureFilteringMode::LINEAR_MIPMAP_LINEAR; - ETextureFilteringMode magFilter = ETextureFilteringMode::LINEAR; - ETextureWrapMode horizontalWrap = ETextureWrapMode::REPEAT; - ETextureWrapMode verticalWrap = ETextureWrapMode::REPEAT; - EInternalFormat internalFormat = EInternalFormat::RGBA; - bool useMipMaps = true; - std::optional mutableDesc = std::nullopt; - }; -} diff --git a/Sources/OvRendering/include/OvRendering/Settings/VertexAttribute.h b/Sources/OvRendering/include/OvRendering/Settings/VertexAttribute.h deleted file mode 100644 index 21b596cbd..000000000 --- a/Sources/OvRendering/include/OvRendering/Settings/VertexAttribute.h +++ /dev/null @@ -1,26 +0,0 @@ -/** -* @project: Overload -* @author: Overload Tech. -* @licence: MIT -*/ - -#pragma once - -#include - -#include - -namespace OvRendering::Settings -{ - /** - * Structure that holds information about a uniform - */ - struct VertexAttribute - { - EDataType type = EDataType::FLOAT; - uint8_t count = 4; - bool normalized = false; - }; - - using VertexAttributeLayout = std::span; -} diff --git a/Sources/OvRendering/include/OvRendering/Utils/Profiling.h b/Sources/OvRendering/include/OvRendering/Utils/Profiling.h new file mode 100644 index 000000000..39c4322e9 --- /dev/null +++ b/Sources/OvRendering/include/OvRendering/Utils/Profiling.h @@ -0,0 +1,12 @@ +/** +* @project: Overload +* @author: Overload Tech. +* @licence: MIT +*/ + +#pragma once + +#include + +#include +#include diff --git a/Sources/OvRendering/include/OvRendering/Utils/ResourceTracking.h b/Sources/OvRendering/include/OvRendering/Utils/ResourceTracking.h new file mode 100644 index 000000000..2dab79340 --- /dev/null +++ b/Sources/OvRendering/include/OvRendering/Utils/ResourceTracking.h @@ -0,0 +1,45 @@ +/** +* @project: Overload +* @author: Overload Tech. +* @licence: MIT +*/ + +#pragma once + +#include + +#include +#include +#include + +namespace OvRendering::Utils::ResourceTracking +{ + /** + * Structure describing a texture registry entry. + */ + struct TextureRegistryEntryDesc + { + const uint32_t id; + const baregl::Texture* texture; + }; + + extern OvTools::Eventing::Event TextureAddedEvent; + extern OvTools::Eventing::Event TextureRemovedEvent; + + /** + * Start tracking resource events + */ + void TrackResources(); + + /** + * Returns the texture associated with the given id + * @param p_id + */ + OvTools::Utils::OptRef GetTexture(uint32_t p_id); + + /** + * Returns all the texture ids + */ + std::span GetTextureIDs(); +} + diff --git a/Sources/OvRendering/include/OvRendering/Utils/ShaderUtil.h b/Sources/OvRendering/include/OvRendering/Utils/ShaderUtil.h index 0f238319f..ba3e849ee 100644 --- a/Sources/OvRendering/include/OvRendering/Utils/ShaderUtil.h +++ b/Sources/OvRendering/include/OvRendering/Utils/ShaderUtil.h @@ -8,10 +8,10 @@ #include -#include +#include namespace OvRendering::Utils { - std::string GetShaderTypeName(Settings::EShaderType p_type); + std::string GetShaderTypeName(baregl::types::EShaderType p_type); } diff --git a/Sources/OvRendering/premake5.lua b/Sources/OvRendering/premake5.lua index f4c16ac50..542226c05 100644 --- a/Sources/OvRendering/premake5.lua +++ b/Sources/OvRendering/premake5.lua @@ -17,7 +17,7 @@ project "OvRendering" includedirs { -- Dependencies dependdir .. "assimp/include", - dependdir .. "glad/include", + dependdir .. "baregl/include", dependdir .. "stb_image/include", dependdir .. "tracy", diff --git a/Sources/OvRendering/src/OvRendering/Context/Driver.cpp b/Sources/OvRendering/src/OvRendering/Context/Driver.cpp index eb6c3b6df..92d29c4ad 100644 --- a/Sources/OvRendering/src/OvRendering/Context/Driver.cpp +++ b/Sources/OvRendering/src/OvRendering/Context/Driver.cpp @@ -6,40 +6,119 @@ #include +#include #include #include #include #include -#include #include +#include namespace { - std::unique_ptr m_gfxBackend; + class AssertHandler : public baregl::debug::IAssertHandler + { + void OnAssert(const std::string_view p_message) override { OVASSERT(false, p_message); } + }; + + class LogHandler : public baregl::debug::ILogHandler + { + void LogInfo(const std::string_view p_message) override { OVLOG_INFO(std::string{p_message}); } + void LogWarning(const std::string_view p_message) override { OVLOG_WARNING(std::string{p_message}); } + void LogError(const std::string_view p_message) override { OVLOG_ERROR(std::string{p_message}); } + }; + + /** + * Very expensive! Call it once, and make sure you always keep track of state changes + */ + OvRendering::Data::PipelineState RetrieveOpenGLPipelineState(baregl::Context &p_ctx) + { + using namespace OvRendering::Settings; + using namespace baregl::types; + using namespace baregl::utils; + + OvRendering::Data::PipelineState pso; + + // Rasterization + pso.rasterizationMode = p_ctx.Get(); + pso.lineWidthPow2 = OvRendering::Utils::Conversions::FloatToPow2( + p_ctx.Get()); + + // Color write mask + { + std::array colorWriteMask = + p_ctx.Get(); + pso.colorWriting.r = colorWriteMask[0]; + pso.colorWriting.g = colorWriteMask[1]; + pso.colorWriting.b = colorWriteMask[2]; + pso.colorWriting.a = colorWriteMask[3]; + } + + // Capabilities + pso.depthWriting = p_ctx.Get(); + pso.blending = p_ctx.GetCapability(ERenderingCapability::BLEND); + pso.culling = p_ctx.GetCapability(ERenderingCapability::CULL_FACE); + pso.dither = p_ctx.GetCapability(ERenderingCapability::DITHER); + pso.polygonOffsetFill = p_ctx.GetCapability(ERenderingCapability::POLYGON_OFFSET_FILL); + pso.sampleAlphaToCoverage = p_ctx.GetCapability(ERenderingCapability::SAMPLE_ALPHA_TO_COVERAGE); + pso.depthTest = p_ctx.GetCapability(ERenderingCapability::DEPTH_TEST); + pso.scissorTest = p_ctx.GetCapability(ERenderingCapability::SCISSOR_TEST); + pso.stencilTest = p_ctx.GetCapability(ERenderingCapability::STENCIL_TEST); + pso.multisample = p_ctx.GetCapability(ERenderingCapability::MULTISAMPLE); + + // Stencil + pso.stencilFuncOp = p_ctx.Get(); + pso.stencilFuncRef = p_ctx.Get(); + pso.stencilFuncMask = static_cast(p_ctx.Get()); + + pso.stencilWriteMask = static_cast(p_ctx.Get()); + + pso.stencilOpFail = p_ctx.Get(); + pso.depthOpFail = p_ctx.Get(); + pso.bothOpFail = p_ctx.Get(); + + // Depth + pso.depthFunc = p_ctx.Get(); + + // Culling + pso.cullFace = p_ctx.Get(); + + // Blending + pso.blendingSrcFactor = p_ctx.Get(); + pso.blendingDestFactor = p_ctx.Get(); + pso.blendingEquation = p_ctx.Get(); + + return pso; + } } OvRendering::Context::Driver::Driver(const OvRendering::Settings::DriverSettings& p_driverSettings) { - m_gfxBackend = std::make_unique(); + baregl::debug::SetAssertHandler(std::make_unique()); + baregl::debug::SetLogHandler(std::make_unique()); - auto initialPipelineState = m_gfxBackend->Init(p_driverSettings.debugMode); + m_gfxContext = std::make_unique(baregl::data::ContextDesc{ + p_driverSettings.debugMode + }); - OVASSERT(initialPipelineState.has_value(), "Failed to initialized driver!"); + TracyGpuContext; + + auto initialPipelineState = RetrieveOpenGLPipelineState(*m_gfxContext); if (p_driverSettings.defaultPipelineState) { m_defaultPipelineState = p_driverSettings.defaultPipelineState.value(); } - m_pipelineState = initialPipelineState.value(); + m_pipelineState = initialPipelineState; SetPipelineState(m_defaultPipelineState); - m_vendor = m_gfxBackend->GetVendor(); - m_hardware = m_gfxBackend->GetHardware(); - m_version = m_gfxBackend->GetVersion(); - m_shadingLanguageVersion = m_gfxBackend->GetShadingLanguageVersion(); + m_vendor = m_gfxContext->Get(); + m_hardware = m_gfxContext->Get(); + m_version = m_gfxContext->Get(); + m_shadingLanguageVersion = m_gfxContext->Get(); OVLOG_INFO("Graphics driver initialized:"); OVLOG_INFO("\tVendor => " + m_vendor); @@ -50,11 +129,12 @@ OvRendering::Context::Driver::Driver(const OvRendering::Settings::DriverSettings OvRendering::Context::Driver::~Driver() { + m_gfxContext.reset(); } void OvRendering::Context::Driver::OnFrameCompleted() { - m_gfxBackend->OnFrameCompleted(); + TracyGpuCollect; // Prevents state leak between frames, and especially useful when external code (like ImGui) // requires a "neutral" pipeline state. @@ -63,7 +143,7 @@ void OvRendering::Context::Driver::OnFrameCompleted() void OvRendering::Context::Driver::SetViewport(uint32_t p_x, uint32_t p_y, uint32_t p_width, uint32_t p_height) { - m_gfxBackend->SetViewport(p_x, p_y, p_width, p_height); + m_gfxContext->SetViewport(p_x, p_y, p_width, p_height); } void OvRendering::Context::Driver::Clear( @@ -75,7 +155,7 @@ void OvRendering::Context::Driver::Clear( { if (p_colorBuffer) { - m_gfxBackend->SetClearColor(p_color.x, p_color.y, p_color.z, p_color.w); + m_gfxContext->SetClearColor(p_color.x, p_color.y, p_color.z, p_color.w); } auto pso = CreatePipelineState(); @@ -89,13 +169,13 @@ void OvRendering::Context::Driver::Clear( SetPipelineState(pso); - m_gfxBackend->Clear(p_colorBuffer, p_depthBuffer, p_stencilBuffer); + m_gfxContext->Clear(p_colorBuffer, p_depthBuffer, p_stencilBuffer); } void OvRendering::Context::Driver::Draw( Data::PipelineState p_pso, const Resources::IMesh& p_mesh, - Settings::EPrimitiveMode p_primitiveMode, + baregl::types::EPrimitiveMode p_primitiveMode, uint32_t p_instances ) { @@ -111,22 +191,22 @@ void OvRendering::Context::Driver::Draw( { if (p_instances == 1) { - m_gfxBackend->DrawElements(p_primitiveMode, p_mesh.GetIndexCount()); + m_gfxContext->DrawElements(p_primitiveMode, p_mesh.GetIndexCount()); } else { - m_gfxBackend->DrawElementsInstanced(p_primitiveMode, p_mesh.GetIndexCount(), p_instances); + m_gfxContext->DrawElementsInstanced(p_primitiveMode, p_mesh.GetIndexCount(), p_instances); } } else { if (p_instances == 1) { - m_gfxBackend->DrawArrays(p_primitiveMode, p_mesh.GetVertexCount()); + m_gfxContext->DrawArrays(p_primitiveMode, p_mesh.GetVertexCount()); } else { - m_gfxBackend->DrawArraysInstanced(p_primitiveMode, p_mesh.GetVertexCount(), p_instances); + m_gfxContext->DrawArraysInstanced(p_primitiveMode, p_mesh.GetVertexCount(), p_instances); } } @@ -136,7 +216,7 @@ void OvRendering::Context::Driver::Draw( void OvRendering::Context::Driver::SetPipelineState(OvRendering::Data::PipelineState p_state) { - using namespace OvRendering::Settings; + using namespace baregl::types; if (p_state._bits != m_pipelineState._bits) { @@ -144,42 +224,42 @@ void OvRendering::Context::Driver::SetPipelineState(OvRendering::Data::PipelineS auto& c = m_pipelineState; // Rasterization - if (i.rasterizationMode != c.rasterizationMode) m_gfxBackend->SetRasterizationMode(i.rasterizationMode); - if (i.lineWidthPow2 != c.lineWidthPow2) m_gfxBackend->SetRasterizationLinesWidth(Utils::Conversions::Pow2toFloat(i.lineWidthPow2)); - - if (i.colorWriting.mask != c.colorWriting.mask) m_gfxBackend->SetColorWriting(i.colorWriting.r, i.colorWriting.g, i.colorWriting.b, i.colorWriting.a); - if (i.depthWriting != c.depthWriting) m_gfxBackend->SetDepthWriting(i.depthWriting); - - if (i.blending != c.blending) m_gfxBackend->SetCapability(ERenderingCapability::BLEND, i.blending); - if (i.culling != c.culling) m_gfxBackend->SetCapability(ERenderingCapability::CULL_FACE, i.culling); - if (i.dither != c.dither) m_gfxBackend->SetCapability(ERenderingCapability::DITHER, i.dither); - if (i.polygonOffsetFill != c.polygonOffsetFill) m_gfxBackend->SetCapability(ERenderingCapability::POLYGON_OFFSET_FILL, i.polygonOffsetFill); - if (i.sampleAlphaToCoverage != c.sampleAlphaToCoverage) m_gfxBackend->SetCapability(ERenderingCapability::SAMPLE_ALPHA_TO_COVERAGE, i.sampleAlphaToCoverage); - if (i.depthTest != c.depthTest) m_gfxBackend->SetCapability(ERenderingCapability::DEPTH_TEST, i.depthTest); - if (i.scissorTest != c.scissorTest) m_gfxBackend->SetCapability(ERenderingCapability::SCISSOR_TEST, i.scissorTest); - if (i.stencilTest != c.stencilTest) m_gfxBackend->SetCapability(ERenderingCapability::STENCIL_TEST, i.stencilTest); - if (i.multisample != c.multisample) m_gfxBackend->SetCapability(ERenderingCapability::MULTISAMPLE, i.multisample); + if (i.rasterizationMode != c.rasterizationMode) m_gfxContext->SetRasterizationMode(i.rasterizationMode); + if (i.lineWidthPow2 != c.lineWidthPow2) m_gfxContext->SetRasterizationLinesWidth(Utils::Conversions::Pow2toFloat(i.lineWidthPow2)); + + if (i.colorWriting.mask != c.colorWriting.mask) m_gfxContext->SetColorWriting(i.colorWriting.r, i.colorWriting.g, i.colorWriting.b, i.colorWriting.a); + if (i.depthWriting != c.depthWriting) m_gfxContext->SetDepthWriting(i.depthWriting); + + if (i.blending != c.blending) m_gfxContext->SetCapability(ERenderingCapability::BLEND, i.blending); + if (i.culling != c.culling) m_gfxContext->SetCapability(ERenderingCapability::CULL_FACE, i.culling); + if (i.dither != c.dither) m_gfxContext->SetCapability(ERenderingCapability::DITHER, i.dither); + if (i.polygonOffsetFill != c.polygonOffsetFill) m_gfxContext->SetCapability(ERenderingCapability::POLYGON_OFFSET_FILL, i.polygonOffsetFill); + if (i.sampleAlphaToCoverage != c.sampleAlphaToCoverage) m_gfxContext->SetCapability(ERenderingCapability::SAMPLE_ALPHA_TO_COVERAGE, i.sampleAlphaToCoverage); + if (i.depthTest != c.depthTest) m_gfxContext->SetCapability(ERenderingCapability::DEPTH_TEST, i.depthTest); + if (i.scissorTest != c.scissorTest) m_gfxContext->SetCapability(ERenderingCapability::SCISSOR_TEST, i.scissorTest); + if (i.stencilTest != c.stencilTest) m_gfxContext->SetCapability(ERenderingCapability::STENCIL_TEST, i.stencilTest); + if (i.multisample != c.multisample) m_gfxContext->SetCapability(ERenderingCapability::MULTISAMPLE, i.multisample); // Stencil algorithm if (i.stencilFuncOp != c.stencilFuncOp || i.stencilFuncRef != c.stencilFuncRef || i.stencilFuncMask != c.stencilFuncMask) - m_gfxBackend->SetStencilAlgorithm(i.stencilFuncOp, i.stencilFuncRef, i.stencilFuncMask); + m_gfxContext->SetStencilAlgorithm(i.stencilFuncOp, i.stencilFuncRef, i.stencilFuncMask); - if (i.stencilWriteMask != c.stencilWriteMask) m_gfxBackend->SetStencilMask(i.stencilWriteMask); - if (i.stencilOpFail != c.stencilOpFail || i.depthOpFail != c.depthOpFail || i.bothOpFail != c.bothOpFail) m_gfxBackend->SetStencilOperations(i.stencilOpFail, i.depthOpFail, i.bothOpFail); + if (i.stencilWriteMask != c.stencilWriteMask) m_gfxContext->SetStencilMask(i.stencilWriteMask); + if (i.stencilOpFail != c.stencilOpFail || i.depthOpFail != c.depthOpFail || i.bothOpFail != c.bothOpFail) m_gfxContext->SetStencilOperations(i.stencilOpFail, i.depthOpFail, i.bothOpFail); // Blending equation & function - if (i.blendingEquation != c.blendingEquation) m_gfxBackend->SetBlendingEquation(i.blendingEquation); + if (i.blendingEquation != c.blendingEquation) m_gfxContext->SetBlendingEquation(i.blendingEquation); if (i.blendingSrcFactor != c.blendingSrcFactor || i.blendingDestFactor != c.blendingDestFactor) - m_gfxBackend->SetBlendingFunction(i.blendingSrcFactor, i.blendingDestFactor); + m_gfxContext->SetBlendingFunction(i.blendingSrcFactor, i.blendingDestFactor); // Depth - if (i.depthFunc != c.depthFunc) m_gfxBackend->SetDepthAlgorithm(i.depthFunc); + if (i.depthFunc != c.depthFunc) m_gfxContext->SetDepthAlgorithm(i.depthFunc); // Culling - if (i.cullFace != c.cullFace) m_gfxBackend->SetCullFace(i.cullFace); + if (i.cullFace != c.cullFace) m_gfxContext->SetCullFace(i.cullFace); m_pipelineState = p_state; } diff --git a/Sources/OvRendering/src/OvRendering/Core/ABaseRenderer.cpp b/Sources/OvRendering/src/OvRendering/Core/ABaseRenderer.cpp index 939ca5ab6..f71e94321 100644 --- a/Sources/OvRendering/src/OvRendering/Core/ABaseRenderer.cpp +++ b/Sources/OvRendering/src/OvRendering/Core/ABaseRenderer.cpp @@ -6,10 +6,10 @@ #include +#include #include #include -#include #include std::atomic_bool OvRendering::Core::ABaseRenderer::s_isDrawing{ false }; @@ -37,26 +37,26 @@ namespace OvRendering::Core::ABaseRenderer::ABaseRenderer(Context::Driver& p_driver) : m_driver(p_driver), m_isDrawing(false), - m_emptyTexture2D{ Settings::ETextureType::TEXTURE_2D }, - m_emptyTextureCube{ Settings::ETextureType::TEXTURE_CUBE }, + m_emptyTexture2D{ baregl::types::ETextureType::TEXTURE_2D }, + m_emptyTextureCube{ baregl::types::ETextureType::TEXTURE_CUBE }, m_unitQuad(kUnitQuadVertices, kUnitQuadIndices) { - const auto kEmptyTextureDesc = Settings::TextureDesc{ + const auto kEmptyTextureDesc = baregl::data::TextureDesc{ .width = 1, .height = 1, - .minFilter = Settings::ETextureFilteringMode::NEAREST, - .magFilter = Settings::ETextureFilteringMode::NEAREST, - .horizontalWrap = Settings::ETextureWrapMode::REPEAT, - .verticalWrap = Settings::ETextureWrapMode::REPEAT, - .internalFormat = Settings::EInternalFormat::RGBA8, + .minFilter = baregl::types::ETextureFilteringMode::NEAREST, + .magFilter = baregl::types::ETextureFilteringMode::NEAREST, + .horizontalWrap = baregl::types::ETextureWrapMode::REPEAT, + .verticalWrap = baregl::types::ETextureWrapMode::REPEAT, + .internalFormat = baregl::types::EInternalFormat::RGBA8, .useMipMaps = false }; m_emptyTexture2D.Allocate(kEmptyTextureDesc); - m_emptyTexture2D.Upload(kWhitePixel.data(), Settings::EFormat::RGBA, Settings::EPixelDataType::UNSIGNED_BYTE); + m_emptyTexture2D.Upload(kWhitePixel.data(), baregl::types::EFormat::RGBA, baregl::types::EPixelDataType::UNSIGNED_BYTE); m_emptyTextureCube.Allocate(kEmptyTextureDesc); - m_emptyTextureCube.Upload(kBlackPixel.data(), Settings::EFormat::RGBA, Settings::EPixelDataType::UNSIGNED_BYTE); + m_emptyTextureCube.Upload(kBlackPixel.data(), baregl::types::EFormat::RGBA, baregl::types::EPixelDataType::UNSIGNED_BYTE); } void OvRendering::Core::ABaseRenderer::BeginFrame(const Data::FrameDescriptor& p_frameDescriptor) @@ -140,8 +140,8 @@ void OvRendering::Core::ABaseRenderer::Clear( void OvRendering::Core::ABaseRenderer::Blit( OvRendering::Data::PipelineState p_pso, - OvRendering::HAL::Framebuffer& p_src, - OvRendering::HAL::Framebuffer& p_dst, + baregl::Framebuffer& p_src, + baregl::Framebuffer& p_dst, OvRendering::Data::Material& p_material, OvRendering::Settings::EBlitFlags p_flags ) @@ -157,9 +157,9 @@ void OvRendering::Core::ABaseRenderer::Blit( if (OvRendering::Settings::IsFlagSet(OvRendering::Settings::EBlitFlags::FILL_INPUT_TEXTURE, p_flags)) { - const auto colorTex = p_src.GetAttachment(Settings::EFramebufferAttachment::COLOR); + const auto colorTex = p_src.GetAttachment(baregl::types::EFramebufferAttachment::COLOR); OVASSERT(colorTex.has_value(), "Invalid color attachment"); - p_material.SetProperty("_InputTexture", &colorTex.value()); + p_material.SetProperty("_InputTexture", &colorTex.value().get()); } OvRendering::Entities::Drawable blit; @@ -221,14 +221,14 @@ void OvRendering::Core::ABaseRenderer::DrawEntity( { if (p_drawable.stateMask.backfaceCulling && p_drawable.stateMask.frontfaceCulling) { - p_pso.cullFace = Settings::ECullFace::FRONT_AND_BACK; + p_pso.cullFace = baregl::types::ECullFace::FRONT_AND_BACK; } else { p_pso.cullFace = p_drawable.stateMask.backfaceCulling ? - Settings::ECullFace::BACK : - Settings::ECullFace::FRONT; + baregl::types::ECullFace::BACK : + baregl::types::ECullFace::FRONT; } } diff --git a/Sources/OvRendering/src/OvRendering/Core/ARenderPass.cpp b/Sources/OvRendering/src/OvRendering/Core/ARenderPass.cpp index 829dcc662..9b6727135 100644 --- a/Sources/OvRendering/src/OvRendering/Core/ARenderPass.cpp +++ b/Sources/OvRendering/src/OvRendering/Core/ARenderPass.cpp @@ -5,8 +5,9 @@ */ -#include "OvRendering/Core/ARenderPass.h" -#include "OvRendering/Core/CompositeRenderer.h" +#include +#include +#include #include diff --git a/Sources/OvRendering/src/OvRendering/Core/CompositeRenderer.cpp b/Sources/OvRendering/src/OvRendering/Core/CompositeRenderer.cpp index a85009395..8f147c205 100644 --- a/Sources/OvRendering/src/OvRendering/Core/CompositeRenderer.cpp +++ b/Sources/OvRendering/src/OvRendering/Core/CompositeRenderer.cpp @@ -9,7 +9,7 @@ #include #include -#include +#include OvRendering::Core::CompositeRenderer::CompositeRenderer(Context::Driver& p_driver) : ABaseRenderer(p_driver) diff --git a/Sources/OvRendering/src/OvRendering/Data/Material.cpp b/Sources/OvRendering/src/OvRendering/Data/Material.cpp index 8b43e4e21..5e88259a9 100644 --- a/Sources/OvRendering/src/OvRendering/Data/Material.cpp +++ b/Sources/OvRendering/src/OvRendering/Data/Material.cpp @@ -4,16 +4,23 @@ * @licence: MIT */ +#include #include +#include +#include +#include +#include +#include +#include +#include +#include #include #include #include #include -#include -#include #include #include @@ -41,6 +48,7 @@ namespace using namespace OvMaths; using namespace OvRendering; + using namespace baregl::math; auto as = [&]() -> std::optional { return @@ -52,22 +60,29 @@ namespace if (auto value = as.operator()()) return *value; if (auto value = as.operator()()) return *value; if (auto value = as.operator()()) return *value; - if (auto value = as.operator()()) return *value; - if (auto value = as.operator()()) return *value; - if (auto value = as.operator()()) return *value; - if (auto value = as.operator()()) return *value; - if (auto value = as.operator()()) return *value; - if (auto value = as.operator()()) return *value; + if (auto value = as.operator()()) return (FVector2&)*value; + if (auto value = as.operator()()) return (FVector3&)*value; + if (auto value = as.operator()()) return (FVector4&)*value; + if (auto value = as.operator()()) return (FMatrix3&)*value; + if (auto value = as.operator()()) return (FMatrix4&)*value; + if (auto value = as.operator()()) + { + // If the baregl::Texture has a value use it as is + if (*value) return *value; + + // If it's nullptr, default to an empty OvRendering::Resources::Texture* + return static_cast(nullptr); + } if (auto value = as.operator()()) return *value; return std::monostate{}; } void BindTexture( - OvRendering::HAL::ShaderProgram& p_shader, + baregl::ShaderProgram& p_shader, const std::string& p_uniformName, - OvRendering::HAL::TextureHandle* p_texture, - OvRendering::HAL::TextureHandle* p_fallback, + baregl::Texture* p_texture, + baregl::Texture* p_fallback, uint32_t p_textureSlot ) { @@ -100,7 +115,7 @@ void OvRendering::Data::Material::SetShader(OvRendering::Resources::Shader* p_sh } } -OvTools::Utils::OptRef OvRendering::Data::Material::GetVariant( +OvTools::Utils::OptRef OvRendering::Data::Material::GetVariant( std::optional p_pass, OvTools::Utils::OptRef p_override ) const @@ -154,8 +169,8 @@ void OvRendering::Data::Material::UpdateProperties() OvRendering::Data::MaterialSignatureSet OvRendering::Data::Material::Bind( std::optional p_pass, OvTools::Utils::OptRef p_featureSetOverride, - HAL::Texture* p_emptyTexture2D, - HAL::Texture* p_emptyTextureCube, + baregl::Texture* p_emptyTexture2D, + baregl::Texture* p_emptyTextureCube, std::optional p_previousMaterialSignature ) { @@ -187,8 +202,8 @@ OvRendering::Data::MaterialSignatureSet OvRendering::Data::Material::Bind( void OvRendering::Data::Material::UploadProperties( bool uploadStableProperties, bool uploadSingleUseProperties, - HAL::Texture* p_emptyTexture2D, - HAL::Texture* p_emptyTextureCube + baregl::Texture* p_emptyTexture2D, + baregl::Texture* p_emptyTextureCube ) { ZoneScoped; @@ -196,7 +211,8 @@ void OvRendering::Data::Material::UploadProperties( OVASSERT(m_programInUse.has_value(), "Cannot upload properties before binding"); using namespace OvMaths; - using enum OvRendering::Settings::EUniformType; + using namespace baregl::math; + using enum baregl::types::EUniformType; auto& program = m_programInUse.value(); @@ -214,7 +230,7 @@ void OvRendering::Data::Material::UploadProperties( } auto& value = prop.value; - auto uniformType = uniformData->type; + auto uniformType = uniformData.value().get().type; // Iterating over the properties to set them in the shader. // This could have been cleaner with a visitor, but the performance impact @@ -234,28 +250,30 @@ void OvRendering::Data::Material::UploadProperties( } else if (uniformType == FLOAT_VEC2) { - program.SetUniform(name, std::get(value)); + program.SetUniform(name, (Vec2&)(std::get(value))); } else if (uniformType == FLOAT_VEC3) { - program.SetUniform(name, std::get(value)); + program.SetUniform(name, (Vec3&)std::get(value)); } else if (uniformType == FLOAT_VEC4) { - program.SetUniform(name, std::get(value)); + program.SetUniform(name, (Vec4&)std::get(value)); } else if (uniformType == FLOAT_MAT3) { - program.SetUniform(name, std::get(value)); + const auto t = FMatrix3::Transpose(std::get(value)); + program.SetUniform(name, (Mat3&)t); } else if (uniformType == FLOAT_MAT4) { - program.SetUniform(name, std::get(value)); + const auto t = FMatrix4::Transpose(std::get(value)); + program.SetUniform(name, (Mat4&)t); } else if (uniformType == SAMPLER_2D || uniformType == SAMPLER_CUBE) { - HAL::TextureHandle* handle = nullptr; - if (auto textureHandle = std::get_if(&value)) + baregl::Texture* handle = nullptr; + if (auto textureHandle = std::get_if(&value)) { handle = *textureHandle; } @@ -266,7 +284,20 @@ void OvRendering::Data::Material::UploadProperties( handle = &(*texture)->GetTexture(); } } - BindTexture(program, name, handle, uniformType == SAMPLER_2D ? p_emptyTexture2D : p_emptyTextureCube, uniformData->textureSlot); + + const auto textureIndex = uniformData.value().get().textureIndex; + + OVASSERT(textureIndex.has_value(), std::format("No texture index found for uniform: {}", name)); + + BindTexture( + program, + name, + handle, + uniformType == SAMPLER_2D ? + p_emptyTexture2D : + p_emptyTextureCube, + textureIndex.value() + ); } if (prop.singleUse) @@ -577,9 +608,9 @@ void OvRendering::Data::Material::InvalidatePropertySignature() } OvRendering::Data::MaterialSignatureSet OvRendering::Data::Material::CalculateSignature( - OvRendering::HAL::ShaderProgram& p_selectedProgram, - HAL::Texture* p_emptyTexture2D, - HAL::Texture* p_emptyTextureCube + baregl::ShaderProgram& p_selectedProgram, + baregl::Texture* p_emptyTexture2D, + baregl::Texture* p_emptyTextureCube ) { ZoneScoped; diff --git a/Sources/OvRendering/src/OvRendering/Data/PipelineState.cpp b/Sources/OvRendering/src/OvRendering/Data/PipelineState.cpp index e2970991d..c9b56ac3e 100644 --- a/Sources/OvRendering/src/OvRendering/Data/PipelineState.cpp +++ b/Sources/OvRendering/src/OvRendering/Data/PipelineState.cpp @@ -17,20 +17,20 @@ OvRendering::Data::PipelineState::PipelineState() : scissorTest(false), stencilTest(false), multisample(true), - rasterizationMode(Settings::ERasterizationMode::FILL), - stencilFuncOp(Settings::EComparaisonAlgorithm::ALWAYS), + rasterizationMode(baregl::types::ERasterizationMode::FILL), + stencilFuncOp(baregl::types::EComparaisonAlgorithm::ALWAYS), stencilFuncRef(0x00), stencilFuncMask(0xFF), stencilWriteMask(0xFF), - stencilOpFail(Settings::EOperation::KEEP), - depthOpFail(Settings::EOperation::KEEP), - bothOpFail(Settings::EOperation::KEEP), - depthFunc(Settings::EComparaisonAlgorithm::LESS), - cullFace(Settings::ECullFace::BACK), + stencilOpFail(baregl::types::EOperation::KEEP), + depthOpFail(baregl::types::EOperation::KEEP), + bothOpFail(baregl::types::EOperation::KEEP), + depthFunc(baregl::types::EComparaisonAlgorithm::LESS), + cullFace(baregl::types::ECullFace::BACK), lineWidthPow2(0x00), blending(false), - blendingSrcFactor(Settings::EBlendingFactor::SRC_ALPHA), - blendingEquation(Settings::EBlendingEquation::FUNC_ADD), - blendingDestFactor(Settings::EBlendingFactor::ONE_MINUS_SRC_ALPHA) + blendingSrcFactor(baregl::types::EBlendingFactor::SRC_ALPHA), + blendingEquation(baregl::types::EBlendingEquation::FUNC_ADD), + blendingDestFactor(baregl::types::EBlendingFactor::ONE_MINUS_SRC_ALPHA) { } diff --git a/Sources/OvRendering/src/OvRendering/Entities/Light.cpp b/Sources/OvRendering/src/OvRendering/Entities/Light.cpp index ad46d2497..e6af2349d 100644 --- a/Sources/OvRendering/src/OvRendering/Entities/Light.cpp +++ b/Sources/OvRendering/src/OvRendering/Entities/Light.cpp @@ -9,19 +9,20 @@ #include #include -#include +#include namespace { void SetupFramebufferForShadowMapping( - OvRendering::HAL::Framebuffer& p_framebuffer, + baregl::Framebuffer& p_framebuffer, uint32_t p_resolution ) { - using namespace OvRendering::HAL; + using namespace baregl::types; + using namespace baregl::data; using namespace OvRendering::Settings; - const auto renderTexture = std::make_shared( + const auto renderTexture = std::make_shared( ETextureType::TEXTURE_2D, std::format( "{}/Depth", @@ -45,8 +46,8 @@ namespace }; renderTexture->Allocate(renderTextureDesc); - renderTexture->SetBorderColor(OvMaths::FVector4::One); - p_framebuffer.Attach(renderTexture, EFramebufferAttachment::DEPTH); + renderTexture->SetBorderColor(baregl::math::Vec4{0.0f, 0.0f, 0.0f}); + p_framebuffer.Attach(renderTexture, EFramebufferAttachment::DEPTH); p_framebuffer.Validate(); p_framebuffer.SetTargetDrawBuffer(std::nullopt); p_framebuffer.SetTargetReadBuffer(std::nullopt); @@ -105,7 +106,7 @@ void OvRendering::Entities::Light::PrepareForShadowRendering(const OvRendering:: if (!shadowBuffer) { - shadowBuffer = std::make_unique("DirectionalShadow"); + shadowBuffer = std::make_unique("DirectionalShadow"); SetupFramebufferForShadowMapping(*shadowBuffer, static_cast(shadowMapResolution)); } else diff --git a/Sources/OvRendering/src/OvRendering/Features/DebugShapeRenderFeature.cpp b/Sources/OvRendering/src/OvRendering/Features/DebugShapeRenderFeature.cpp index 03db3a2c6..0df749a39 100644 --- a/Sources/OvRendering/src/OvRendering/Features/DebugShapeRenderFeature.cpp +++ b/Sources/OvRendering/src/OvRendering/Features/DebugShapeRenderFeature.cpp @@ -104,14 +104,14 @@ void OvRendering::Features::DebugShapeRenderFeature::DrawLine( m_lineMaterial->SetProperty("end", p_end); m_lineMaterial->SetProperty("color", p_color); - p_pso.rasterizationMode = Settings::ERasterizationMode::LINE; + p_pso.rasterizationMode = baregl::types::ERasterizationMode::LINE; p_pso.lineWidthPow2 = Utils::Conversions::FloatToPow2(p_lineWidth); OvRendering::Entities::Drawable drawable; drawable.material = *m_lineMaterial; drawable.mesh = m_lineMesh.get(); drawable.stateMask = m_lineMaterial->GenerateStateMask(); - drawable.primitiveMode = Settings::EPrimitiveMode::LINES; + drawable.primitiveMode = baregl::types::EPrimitiveMode::LINES; m_renderer.DrawEntity(p_pso, drawable); } diff --git a/Sources/OvRendering/src/OvRendering/Features/FrameInfoRenderFeature.cpp b/Sources/OvRendering/src/OvRendering/Features/FrameInfoRenderFeature.cpp index 6a6fbf998..bd33fdb26 100644 --- a/Sources/OvRendering/src/OvRendering/Features/FrameInfoRenderFeature.cpp +++ b/Sources/OvRendering/src/OvRendering/Features/FrameInfoRenderFeature.cpp @@ -4,8 +4,9 @@ * @licence: MIT */ -#include "OvRendering/Features/FrameInfoRenderFeature.h" -#include "OvRendering/Core/CompositeRenderer.h" +#include +#include +#include OvRendering::Features::FrameInfoRenderFeature::FrameInfoRenderFeature( OvRendering::Core::CompositeRenderer& p_renderer, @@ -57,4 +58,4 @@ void OvRendering::Features::FrameInfoRenderFeature::OnAfterDraw(const OvRenderin m_frameInfo.polyCount += (p_drawable.mesh.value().GetIndexCount() / kVertexCountPerPolygon) * instances; m_frameInfo.vertexCount += p_drawable.mesh.value().GetVertexCount() * instances; } -} \ No newline at end of file +} diff --git a/Sources/OvRendering/src/OvRendering/Features/LightingRenderFeature.cpp b/Sources/OvRendering/src/OvRendering/Features/LightingRenderFeature.cpp index 6acbc3cfc..b121ca382 100644 --- a/Sources/OvRendering/src/OvRendering/Features/LightingRenderFeature.cpp +++ b/Sources/OvRendering/src/OvRendering/Features/LightingRenderFeature.cpp @@ -17,7 +17,7 @@ OvRendering::Features::LightingRenderFeature::LightingRenderFeature( ARenderFeature(p_renderer, p_executionPolicy), m_bufferBindingPoint(p_bufferBindingPoint) { - m_lightBuffer = std::make_unique(); + m_lightBuffer = std::make_unique(); } bool IsLightInFrustum(const OvRendering::Entities::Light& p_light, const OvRendering::Data::Frustum& p_frustum) @@ -35,7 +35,7 @@ bool IsLightInFrustum(const OvRendering::Entities::Light& p_light, const OvRende void OvRendering::Features::LightingRenderFeature::Bind() const { - m_lightBuffer->Bind(m_bufferBindingPoint); + m_lightBuffer->Bind(baregl::types::EBufferType::SHADER_STORAGE, m_bufferBindingPoint); } uint32_t OvRendering::Features::LightingRenderFeature::GetBufferBindingPoint() const @@ -67,7 +67,7 @@ void OvRendering::Features::LightingRenderFeature::OnBeginFrame(const Data::Fram const auto lightMatricesView = std::span{ lightMatrices }; - if (m_lightBuffer->Allocate(lightMatricesView.size_bytes(), Settings::EAccessSpecifier::STREAM_DRAW)) + if (m_lightBuffer->Allocate(lightMatricesView.size_bytes(), baregl::types::EAccessSpecifier::STREAM_DRAW)) { m_lightBuffer->Upload(lightMatricesView.data()); } diff --git a/Sources/OvRendering/src/OvRendering/HAL/None/NoneBackend.cpp b/Sources/OvRendering/src/OvRendering/HAL/None/NoneBackend.cpp deleted file mode 100644 index 9447b6939..000000000 --- a/Sources/OvRendering/src/OvRendering/HAL/None/NoneBackend.cpp +++ /dev/null @@ -1,135 +0,0 @@ -/** -* @project: Overload -* @author: Overload Tech. -* @licence: MIT -*/ - -/** -* Although this is intended as a Null implementation, certain components of the engine rely on OpenGL, -* such as resource creation, binding, and the user interface. Consequently, GLAD must be initialized to -* support these functionalities. This implementation exclusively initializes GLAD without making any -* additional calls. -*/ -#include - -#include - -namespace OvRendering::HAL -{ - template<> - std::optional NoneBackend::Init(bool debug) - { - gladLoadGL(); // <-- initialize GLAD; see comment above the GLAD include directive for more details. - return OvRendering::Data::PipelineState{}; - } - - template<> - void NoneBackend::OnFrameCompleted() - {} - - template<> - void NoneBackend::Clear(bool p_colorBuffer, bool p_depthBuffer, bool p_stencilBuffer) - {} - - template<> - void NoneBackend::DrawElements(Settings::EPrimitiveMode p_primitiveMode, uint32_t p_indexCount) - {} - - template<> - void NoneBackend::DrawElementsInstanced(Settings::EPrimitiveMode p_primitiveMode, uint32_t p_indexCount, uint32_t p_instances) - {} - - template<> - void NoneBackend::DrawArrays(Settings::EPrimitiveMode p_primitiveMode, uint32_t p_vertexCount) - {} - - template<> - void NoneBackend::DrawArraysInstanced(Settings::EPrimitiveMode p_primitiveMode, uint32_t p_vertexCount, uint32_t p_instances) - {} - - template<> - void NoneBackend::SetClearColor(float p_red, float p_green, float p_blue, float p_alpha) - {} - - template<> - void NoneBackend::SetRasterizationLinesWidth(float p_width) - {} - - template<> - void NoneBackend::SetRasterizationMode(Settings::ERasterizationMode p_rasterizationMode) - {} - - template<> - void NoneBackend::SetCapability(Settings::ERenderingCapability p_capability, bool p_value) - {} - - template<> - bool NoneBackend::GetCapability(Settings::ERenderingCapability p_capability) - { - return false; - } - - template<> - void NoneBackend::SetStencilAlgorithm(Settings::EComparaisonAlgorithm p_algorithm, int32_t p_reference, uint32_t p_mask) - {} - - template<> - void NoneBackend::SetDepthAlgorithm(Settings::EComparaisonAlgorithm p_algorithm) - {} - - template<> - void NoneBackend::SetStencilMask(uint32_t p_mask) - {} - - template<> - void NoneBackend::SetStencilOperations(Settings::EOperation p_stencilFail, Settings::EOperation p_depthFail, Settings::EOperation p_bothPass) - {} - - template<> - void NoneBackend::SetBlendingFunction(Settings::EBlendingFactor p_sourceFactor, Settings::EBlendingFactor p_destinationFactor) - {} - - template<> - void NoneBackend::SetBlendingEquation(Settings::EBlendingEquation p_equation) - {} - - template<> - void NoneBackend::SetCullFace(Settings::ECullFace p_cullFace) - {} - - template<> - void NoneBackend::SetDepthWriting(bool p_enable) - {} - - template<> - void NoneBackend::SetColorWriting(bool p_enableRed, bool p_enableGreen, bool p_enableBlue, bool p_enableAlpha) - {} - - template<> - void NoneBackend::SetViewport(uint32_t x, uint32_t y, uint32_t width, uint32_t height) - {} - - template<> - std::string NoneBackend::GetVendor() - { - return "None"; - } - - template<> - std::string NoneBackend::GetHardware() - { - return "None"; - } - - template<> - std::string NoneBackend::GetVersion() - { - return "None"; - } - - template<> - std::string NoneBackend::GetShadingLanguageVersion() - { - return "None"; - } -} diff --git a/Sources/OvRendering/src/OvRendering/HAL/None/NoneBuffer.cpp b/Sources/OvRendering/src/OvRendering/HAL/None/NoneBuffer.cpp deleted file mode 100644 index f4049a3d3..000000000 --- a/Sources/OvRendering/src/OvRendering/HAL/None/NoneBuffer.cpp +++ /dev/null @@ -1,73 +0,0 @@ -/** -* @project: Overload -* @author: Overload Tech. -* @licence: MIT -*/ - -#include -#include - -template<> -OvRendering::HAL::NoneBuffer::TBuffer(Settings::EBufferType p_type) : m_buffer{ - .type = p_type -} -{ -} - -template<> -OvRendering::HAL::NoneBuffer::~TBuffer() -{ -} - -template<> -uint64_t OvRendering::HAL::NoneBuffer::Allocate(size_t p_size, Settings::EAccessSpecifier p_usage) -{ - return m_buffer.allocatedBytes = p_size; -} - -template<> -bool OvRendering::HAL::NoneBuffer::IsValid() const -{ - return - m_buffer.type != Settings::EBufferType::UNKNOWN && - m_buffer.allocatedBytes > 0; -} - -template<> -uint64_t OvRendering::HAL::NoneBuffer::GetSize() const -{ - OVASSERT(IsValid(), "Cannot get size of an invalid buffer"); - return m_buffer.allocatedBytes; -} - -template<> -bool OvRendering::HAL::NoneBuffer::IsEmpty() const -{ - return GetSize() == 0; -} - -template<> -void OvRendering::HAL::NoneBuffer::Upload(const void* p_data, std::optional p_range) -{ - OVASSERT(IsValid(), "Trying to upload data to an invalid buffer"); - OVASSERT(!IsEmpty(), "Trying to upload data to an empty buffer"); -} - -template<> -void OvRendering::HAL::NoneBuffer::Bind(std::optional p_index) const -{ - OVASSERT(IsValid(), "Cannot bind an invalid buffer"); -} - -template<> -void OvRendering::HAL::NoneBuffer::Unbind() const -{ - OVASSERT(IsValid(), "Cannot unbind an invalid buffer"); -} - -template<> -uint32_t OvRendering::HAL::NoneBuffer::GetID() const -{ - OVASSERT(IsValid(), "Cannot get ID of an invalid buffer"); - return 0; -} diff --git a/Sources/OvRendering/src/OvRendering/HAL/None/NoneFramebuffer.cpp b/Sources/OvRendering/src/OvRendering/HAL/None/NoneFramebuffer.cpp deleted file mode 100644 index f705f9679..000000000 --- a/Sources/OvRendering/src/OvRendering/HAL/None/NoneFramebuffer.cpp +++ /dev/null @@ -1,160 +0,0 @@ -/** -* @project: Overload -* @author: Overload Tech. -* @licence: MIT -*/ - -#include -#include -#include - -template<> -template<> -void OvRendering::HAL::NoneFramebuffer::Attach(std::shared_ptr p_toAttach, Settings::EFramebufferAttachment p_attachment, uint32_t p_index, std::optional p_layer) -{ - OVASSERT(p_toAttach != nullptr, "Cannot attach a null renderbuffer"); - OVASSERT(!p_layer.has_value(), "Renderbuffer cannot use layers"); - const auto index = std::underlying_type_t(p_attachment); - m_context.attachments[index] = p_toAttach; -} - -template<> -template<> -void OvRendering::HAL::NoneFramebuffer::Attach(std::shared_ptr p_toAttach, Settings::EFramebufferAttachment p_attachment, uint32_t p_index, std::optional p_layer) -{ - OVASSERT(p_toAttach != nullptr, "Cannot attach a null texture"); - const auto index = std::underlying_type_t(p_attachment); - m_context.attachments[index] = p_toAttach; -} - -template<> -OvRendering::HAL::NoneFramebuffer::TFramebuffer(std::string_view p_debugName) : - m_context{ .debugName = std::string{p_debugName} } -{ -} - -template<> -OvRendering::HAL::NoneFramebuffer::~TFramebuffer() -{ -} - -template<> -void OvRendering::HAL::NoneFramebuffer::Bind() const -{ -} - -template<> -void OvRendering::HAL::NoneFramebuffer::Unbind() const -{ -} - -template<> -bool OvRendering::HAL::NoneFramebuffer::Validate() -{ - return m_context.valid = true; -} - -template<> -bool OvRendering::HAL::NoneFramebuffer::IsValid() const -{ - return m_context.valid; -} - -template<> -template<> -OvTools::Utils::OptRef OvRendering::HAL::NoneFramebuffer::GetAttachment(OvRendering::Settings::EFramebufferAttachment p_attachment, uint32_t p_index) const -{ - const auto index = std::underlying_type_t(p_attachment); - - if (m_context.attachments.contains(index)) - { - auto attachment = m_context.attachments.at(index); - - if (auto pval = std::get_if>(&attachment); pval && *pval) - { - return **pval; - } - } - - return std::nullopt; -} - -template<> -template<> -OvTools::Utils::OptRef OvRendering::HAL::NoneFramebuffer::GetAttachment(OvRendering::Settings::EFramebufferAttachment p_attachment, uint32_t p_index) const -{ - const auto index = std::underlying_type_t(p_attachment); - - if (m_context.attachments.contains(index)) - { - auto attachment = m_context.attachments.at(index); - - if (auto pval = std::get_if>(&attachment); pval && *pval) - { - return **pval; - } - } - - return std::nullopt; -} - -template<> -void OvRendering::HAL::NoneFramebuffer::Resize(uint16_t p_width, uint16_t p_height) -{ - OVASSERT(IsValid(), "Cannot resize an invalid framebuffer"); - - for (auto& attachment : m_context.attachments) - { - if (const auto pval = std::get_if>(&attachment.second); pval && *pval) - { - (*pval)->Resize(p_width, p_height); - } - else if (const auto* pval = std::get_if>(&attachment.second); pval && *pval) - { - (*pval)->Resize(p_width, p_height); - } - } -} - -template<> -void OvRendering::HAL::NoneFramebuffer::SetTargetDrawBuffer(std::optional p_index) -{ - OVASSERT(IsValid(), "Cannot set target draw buffer on an invalid framebuffer"); -} - -template<> -void OvRendering::HAL::NoneFramebuffer::SetTargetReadBuffer(std::optional p_index) -{ - OVASSERT(IsValid(), "Cannot set target read buffer on an invalid framebuffer"); -} - -template<> -uint32_t OvRendering::HAL::NoneFramebuffer::GetID() const -{ - return 0; -} - -template<> -std::pair OvRendering::HAL::NoneFramebuffer::GetSize(Settings::EFramebufferAttachment p_attachment) const -{ - return { {}, {} }; // <-- I swear it's not an emoji -} - -template<> -void OvRendering::HAL::NoneFramebuffer::BlitToBackBuffer(uint16_t p_backBufferWidth, uint16_t p_backBufferHeight) const -{ - OVASSERT(IsValid(), "Cannot blit an invalid framebuffer to the back buffer"); -} - -template<> -void OvRendering::HAL::NoneFramebuffer::ReadPixels( - uint32_t p_x, - uint32_t p_y, - uint32_t p_width, - uint32_t p_height, - Settings::EPixelDataFormat p_format, - Settings::EPixelDataType p_type, - void* p_data) const -{ - OVASSERT(IsValid(), "Cannot read pixels from an invalid framebuffer"); -} diff --git a/Sources/OvRendering/src/OvRendering/HAL/None/NoneIndexBuffer.cpp b/Sources/OvRendering/src/OvRendering/HAL/None/NoneIndexBuffer.cpp deleted file mode 100644 index 10e6ca405..000000000 --- a/Sources/OvRendering/src/OvRendering/HAL/None/NoneIndexBuffer.cpp +++ /dev/null @@ -1,12 +0,0 @@ -/** -* @project: Overload -* @author: Overload Tech. -* @licence: MIT -*/ - -#include - -template<> -OvRendering::HAL::NoneIndexBuffer::TIndexBuffer() : TBuffer(Settings::EBufferType::INDEX) -{ -} diff --git a/Sources/OvRendering/src/OvRendering/HAL/None/NoneRenderbuffer.cpp b/Sources/OvRendering/src/OvRendering/HAL/None/NoneRenderbuffer.cpp deleted file mode 100644 index 9a5feb860..000000000 --- a/Sources/OvRendering/src/OvRendering/HAL/None/NoneRenderbuffer.cpp +++ /dev/null @@ -1,69 +0,0 @@ -/** -* @project: Overload -* @author: Overload Tech. -* @licence: MIT -*/ - -#include -#include - -template<> -OvRendering::HAL::NoneRenderbuffer::TRenderbuffer() -{ -} - -template<> -OvRendering::HAL::NoneRenderbuffer::~TRenderbuffer() -{ -} - -template<> -void OvRendering::HAL::NoneRenderbuffer::Bind() const -{ -} - -template<> -void OvRendering::HAL::NoneRenderbuffer::Unbind() const -{ -} - -template<> -uint32_t OvRendering::HAL::NoneRenderbuffer::GetID() const -{ - return 0; -} - -template<> -void OvRendering::HAL::NoneRenderbuffer::Allocate(uint16_t p_width, uint16_t p_height, Settings::EInternalFormat p_format) -{ - m_context.width = p_width; - m_context.height = p_height; - m_context.format = p_format; - m_context.allocated = true; -} - -template<> -bool OvRendering::HAL::NoneRenderbuffer::IsValid() const -{ - return m_context.allocated; -} - -template<> -void OvRendering::HAL::NoneRenderbuffer::Resize(uint16_t p_width, uint16_t p_height) -{ - OVASSERT(IsValid(), "Cannot resize a renderbuffer that has not been allocated"); -} - -template<> -uint16_t OvRendering::HAL::NoneRenderbuffer::GetWidth() const -{ - OVASSERT(IsValid(), "Cannot get the height of a renderbuffer that has not been allocated"); - return m_context.width; -} - -template<> -uint16_t OvRendering::HAL::NoneRenderbuffer::GetHeight() const -{ - OVASSERT(IsValid(), "Cannot get the height of a renderbuffer that has not been allocated"); - return m_context.height; -} diff --git a/Sources/OvRendering/src/OvRendering/HAL/None/NoneShaderProgram.cpp b/Sources/OvRendering/src/OvRendering/HAL/None/NoneShaderProgram.cpp deleted file mode 100644 index 75e9ea907..000000000 --- a/Sources/OvRendering/src/OvRendering/HAL/None/NoneShaderProgram.cpp +++ /dev/null @@ -1,109 +0,0 @@ -/** -* @project: Overload -* @author: Overload Tech. -* @licence: MIT -*/ - -#include -#include - -namespace -{ - std::unordered_map emptyUniforms; -} - -template<> -OvRendering::HAL::NoneShaderProgram::TShaderProgram() -{ -} - -template<> -OvRendering::HAL::NoneShaderProgram::~TShaderProgram() -{ -} - -template<> -void OvRendering::HAL::NoneShaderProgram::Bind() const -{ -} - -template<> -void OvRendering::HAL::NoneShaderProgram::Unbind() const -{ -} - -template<> -uint32_t OvRendering::HAL::NoneShaderProgram::GetID() const -{ - return 0; -} - -template<> -void OvRendering::HAL::NoneShaderProgram::Attach(const NoneShaderStage& p_shader) -{ -} - -template<> -void OvRendering::HAL::NoneShaderProgram::Detach(const NoneShaderStage& p_shader) -{ - -} - -template<> -void OvRendering::HAL::NoneShaderProgram::DetachAll() -{ -} - -template<> -OvRendering::Settings::ShaderLinkingResult OvRendering::HAL::NoneShaderProgram::Link() -{ - return { - .success = true - }; -} - -#define DECLARE_SET_UNIFORM_FUNCTION(type) \ -template<> \ -template<> \ -void OvRendering::HAL::NoneShaderProgram::SetUniform(const std::string&, const type&) \ -{ \ -} - -#define DECLARE_GET_UNIFORM_FUNCTION(type) \ -template<> \ -template<> \ -type OvRendering::HAL::NoneShaderProgram::GetUniform(const std::string&) \ -{ \ - return type{}; \ -} - -DECLARE_SET_UNIFORM_FUNCTION(int); -DECLARE_SET_UNIFORM_FUNCTION(float); -DECLARE_SET_UNIFORM_FUNCTION(OvMaths::FVector2); -DECLARE_SET_UNIFORM_FUNCTION(OvMaths::FVector3); -DECLARE_SET_UNIFORM_FUNCTION(OvMaths::FVector4); -DECLARE_SET_UNIFORM_FUNCTION(OvMaths::FMatrix4); - -DECLARE_GET_UNIFORM_FUNCTION(int); -DECLARE_GET_UNIFORM_FUNCTION(float); -DECLARE_GET_UNIFORM_FUNCTION(OvMaths::FVector2); -DECLARE_GET_UNIFORM_FUNCTION(OvMaths::FVector3); -DECLARE_GET_UNIFORM_FUNCTION(OvMaths::FVector4); -DECLARE_GET_UNIFORM_FUNCTION(OvMaths::FMatrix4); - -template<> -void OvRendering::HAL::NoneShaderProgram::QueryUniforms() -{ -} - -template<> -OvTools::Utils::OptRef OvRendering::HAL::NoneShaderProgram::GetUniformInfo(const std::string& p_name) const -{ - return std::nullopt; -} - -template<> -const std::unordered_map& OvRendering::HAL::NoneShaderProgram::GetUniforms() const -{ - return emptyUniforms; -} diff --git a/Sources/OvRendering/src/OvRendering/HAL/None/NoneShaderStage.cpp b/Sources/OvRendering/src/OvRendering/HAL/None/NoneShaderStage.cpp deleted file mode 100644 index bf03badf0..000000000 --- a/Sources/OvRendering/src/OvRendering/HAL/None/NoneShaderStage.cpp +++ /dev/null @@ -1,36 +0,0 @@ -/** -* @project: Overload -* @author: Overload Tech. -* @licence: MIT -*/ - -#include - -template<> -OvRendering::HAL::NoneShaderStage::TShaderStage(Settings::EShaderType p_type) -{ -} - -template<> -OvRendering::HAL::NoneShaderStage::~TShaderStage() -{ -} - -template<> -void OvRendering::HAL::NoneShaderStage::Upload(const std::string& p_source) const -{ -} - -template<> -OvRendering::Settings::ShaderCompilationResult OvRendering::HAL::NoneShaderStage::Compile() const -{ - return { - .success = true - }; -} - -template<> -uint32_t OvRendering::HAL::NoneShaderStage::GetID() const -{ - return 0; -} diff --git a/Sources/OvRendering/src/OvRendering/HAL/None/NoneShaderStorageBuffer.cpp b/Sources/OvRendering/src/OvRendering/HAL/None/NoneShaderStorageBuffer.cpp deleted file mode 100644 index 897671cab..000000000 --- a/Sources/OvRendering/src/OvRendering/HAL/None/NoneShaderStorageBuffer.cpp +++ /dev/null @@ -1,12 +0,0 @@ -/** -* @project: Overload -* @author: Overload Tech. -* @licence: MIT -*/ - -#include - -template<> -OvRendering::HAL::NoneShaderStorageBuffer::TShaderStorageBuffer() : NoneBuffer(Settings::EBufferType::SHADER_STORAGE) -{ -} diff --git a/Sources/OvRendering/src/OvRendering/HAL/None/NoneTexture.cpp b/Sources/OvRendering/src/OvRendering/HAL/None/NoneTexture.cpp deleted file mode 100644 index 86c89a142..000000000 --- a/Sources/OvRendering/src/OvRendering/HAL/None/NoneTexture.cpp +++ /dev/null @@ -1,92 +0,0 @@ -/** -* @project: Overload -* @author: Overload Tech. -* @licence: MIT -*/ - -#include - -#include - -template<> -OvRendering::HAL::NoneTexture::TTexture(Settings::ETextureType p_type, std::string_view p_debugName) : TTextureHandle{ p_type, 0 } -{ - m_textureContext.debugName = p_debugName; - CreationEvent.Invoke(*this); -} - -template<> -OvRendering::HAL::NoneTexture::~TTexture() -{ - DestructionEvent.Invoke(*this); -} - -template<> -void OvRendering::HAL::NoneTexture::Allocate(const Settings::TextureDesc& p_desc) -{ - m_textureContext.desc = p_desc; - m_textureContext.allocated = true; -} - -template<> -bool OvRendering::HAL::NoneTexture::IsValid() const -{ - return m_textureContext.allocated; -} - -template<> -bool OvRendering::HAL::NoneTexture::IsMutable() const -{ - OVASSERT(IsValid(), "Cannot check if a texture is mutable before it has been allocated"); - return m_textureContext.desc.mutableDesc.has_value(); -} - -template<> -void OvRendering::HAL::NoneTexture::Upload(const void* p_data, Settings::EFormat p_format, Settings::EPixelDataType p_type) -{ - OVASSERT(IsValid(), "Cannot upload data to a texture before it has been allocated"); - - if (IsMutable()) - { - auto& mutableDesc = m_textureContext.desc.mutableDesc.value(); - mutableDesc.format = p_format; - mutableDesc.type = p_type; - } -} - -template<> -void OvRendering::HAL::NoneTexture::Resize(uint32_t p_width, uint32_t p_height) -{ - OVASSERT(IsValid(), "Cannot resize a texture before it has been allocated"); - OVASSERT(IsMutable(), "Cannot resize an immutable texture"); - - auto& desc = m_textureContext.desc; - - if (p_width != desc.width || p_height != desc.width) - { - desc.width = p_width; - desc.height = p_height; - - Allocate(desc); - } -} - -template<> -const OvRendering::Settings::TextureDesc& OvRendering::HAL::NoneTexture::GetDesc() const -{ - OVASSERT(IsValid(), "Cannot get the descriptor of a texture before it has been allocated"); - return m_textureContext.desc; -} - -template<> -void OvRendering::HAL::NoneTexture::GenerateMipmaps() const -{ - OVASSERT(IsValid(), "Cannot generate mipmaps for a texture before it has been allocated"); - OVASSERT(m_textureContext.desc.useMipMaps, "Cannot generate mipmaps for a texture that doesn't use them"); -} - -template<> -void OvRendering::HAL::NoneTexture::SetBorderColor(const OvMaths::FVector4& p_color) -{ - OVASSERT(IsValid(), "Cannot set border color for a texture before it has been allocated"); -} diff --git a/Sources/OvRendering/src/OvRendering/HAL/None/NoneTextureHandle.cpp b/Sources/OvRendering/src/OvRendering/HAL/None/NoneTextureHandle.cpp deleted file mode 100644 index b048ea024..000000000 --- a/Sources/OvRendering/src/OvRendering/HAL/None/NoneTextureHandle.cpp +++ /dev/null @@ -1,41 +0,0 @@ -/** -* @project: Overload -* @author: Overload Tech. -* @licence: MIT -*/ - -#include - -template<> -OvRendering::HAL::NoneTextureHandle::TTextureHandle(Settings::ETextureType p_type) : m_context{ - .type = p_type, -} -{ -} - -template<> -OvRendering::HAL::NoneTextureHandle::TTextureHandle(Settings::ETextureType p_type, uint32_t p_id) : TTextureHandle(p_type) -{ -} - -template<> -void OvRendering::HAL::NoneTextureHandle::Bind(std::optional p_slot) const -{ -} - -template<> -void OvRendering::HAL::NoneTextureHandle::Unbind() const -{ -} - -template<> -uint32_t OvRendering::HAL::NoneTextureHandle::GetID() const -{ - return 0; -} - -template<> -OvRendering::Settings::ETextureType OvRendering::HAL::NoneTextureHandle::GetType() const -{ - return m_context.type; -} diff --git a/Sources/OvRendering/src/OvRendering/HAL/None/NoneUniformBuffer.cpp b/Sources/OvRendering/src/OvRendering/HAL/None/NoneUniformBuffer.cpp deleted file mode 100644 index f66fa6846..000000000 --- a/Sources/OvRendering/src/OvRendering/HAL/None/NoneUniformBuffer.cpp +++ /dev/null @@ -1,12 +0,0 @@ -/** -* @project: Overload -* @author: Overload Tech. -* @licence: MIT -*/ - -#include - -template<> -OvRendering::HAL::NoneUniformBuffer::TUniformBuffer() : NoneBuffer(Settings::EBufferType::UNIFORM) -{ -} diff --git a/Sources/OvRendering/src/OvRendering/HAL/None/NoneVertexArray.cpp b/Sources/OvRendering/src/OvRendering/HAL/None/NoneVertexArray.cpp deleted file mode 100644 index f486c31a9..000000000 --- a/Sources/OvRendering/src/OvRendering/HAL/None/NoneVertexArray.cpp +++ /dev/null @@ -1,63 +0,0 @@ -/** -* @project: Overload -* @author: Overload Tech. -* @licence: MIT -*/ - -#include -#include - -template<> -OvRendering::HAL::NoneVertexArray::TVertexArray() -{ -} - -template<> -OvRendering::HAL::NoneVertexArray::~TVertexArray() -{ -} - -template<> -void OvRendering::HAL::NoneVertexArray::Bind() const -{ -} - -template<> -void OvRendering::HAL::NoneVertexArray::Unbind() const -{ -} - -template<> -bool OvRendering::HAL::NoneVertexArray::IsValid() const -{ - return m_context.attributeCount > 0; -} - -template<> -void OvRendering::HAL::NoneVertexArray::SetLayout( - Settings::VertexAttributeLayout p_attributes, - VertexBuffer& p_vertexBuffer, - IndexBuffer& p_indexBuffer -) -{ - OVASSERT(!IsValid(), "Vertex array layout already set"); - - for (const auto& attribute : p_attributes) - { - OVASSERT(attribute.count >= 1 && attribute.count <= 4, "Attribute count must be between 1 and 4"); - ++m_context.attributeCount; - } -} - -template<> -void OvRendering::HAL::NoneVertexArray::ResetLayout() -{ - OVASSERT(IsValid(), "Vertex array layout not already set"); - m_context.attributeCount = 0; -} - -template<> -uint32_t OvRendering::HAL::NoneVertexArray::GetID() const -{ - return 0; -} diff --git a/Sources/OvRendering/src/OvRendering/HAL/None/NoneVertexBuffer.cpp b/Sources/OvRendering/src/OvRendering/HAL/None/NoneVertexBuffer.cpp deleted file mode 100644 index d3f065513..000000000 --- a/Sources/OvRendering/src/OvRendering/HAL/None/NoneVertexBuffer.cpp +++ /dev/null @@ -1,12 +0,0 @@ -/** -* @project: Overload -* @author: Overload Tech. -* @licence: MIT -*/ - -#include - -template<> -OvRendering::HAL::NoneVertexBuffer::TVertexBuffer() : TBuffer(Settings::EBufferType::VERTEX) -{ -} diff --git a/Sources/OvRendering/src/OvRendering/HAL/OpenGL/GLBackend.cpp b/Sources/OvRendering/src/OvRendering/HAL/OpenGL/GLBackend.cpp deleted file mode 100644 index ffdff0977..000000000 --- a/Sources/OvRendering/src/OvRendering/HAL/OpenGL/GLBackend.cpp +++ /dev/null @@ -1,408 +0,0 @@ -/** -* @project: Overload -* @author: Overload Tech. -* @licence: MIT -*/ - -#include - -#include - -// Needs to be included after OpenGL headers -#include - -#include -#include -#include -#include -#include - -namespace -{ - void GLDebugMessageCallback(uint32_t source, uint32_t type, uint32_t id, uint32_t severity, int32_t length, const char* message, const void* userParam) - { - // ignore non-significant error/warning codes - if (id == 131169 || id == 131185 || id == 131218 || id == 131204) return; - - std::string output; - - output += "OpenGL Debug Message:\n"; - output += "Debug message (" + std::to_string(id) + "): " + message + "\n"; - - switch (source) - { - case GL_DEBUG_SOURCE_API: output += "Source: API"; break; - case GL_DEBUG_SOURCE_WINDOW_SYSTEM: output += "Source: Window System"; break; - case GL_DEBUG_SOURCE_SHADER_COMPILER: output += "Source: Shader Compiler"; break; - case GL_DEBUG_SOURCE_THIRD_PARTY: output += "Source: Third Party"; break; - case GL_DEBUG_SOURCE_APPLICATION: output += "Source: Application"; break; - case GL_DEBUG_SOURCE_OTHER: output += "Source: Other"; break; - } - - output += "\n"; - - switch (type) - { - case GL_DEBUG_TYPE_ERROR: output += "Type: Error"; break; - case GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR: output += "Type: Deprecated Behaviour"; break; - case GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR: output += "Type: Undefined Behaviour"; break; - case GL_DEBUG_TYPE_PORTABILITY: output += "Type: Portability"; break; - case GL_DEBUG_TYPE_PERFORMANCE: output += "Type: Performance"; break; - case GL_DEBUG_TYPE_MARKER: output += "Type: Marker"; break; - case GL_DEBUG_TYPE_PUSH_GROUP: output += "Type: Push Group"; break; - case GL_DEBUG_TYPE_POP_GROUP: output += "Type: Pop Group"; break; - case GL_DEBUG_TYPE_OTHER: output += "Type: Other"; break; - } - - output += "\n"; - - switch (severity) - { - case GL_DEBUG_SEVERITY_HIGH: output += "Severity: High"; break; - case GL_DEBUG_SEVERITY_MEDIUM: output += "Severity: Medium"; break; - case GL_DEBUG_SEVERITY_LOW: output += "Severity: Low"; break; - case GL_DEBUG_SEVERITY_NOTIFICATION: output += "Severity: Notification"; break; - } - - switch (severity) - { - case GL_DEBUG_SEVERITY_HIGH: OVLOG_ERROR(output); break; - case GL_DEBUG_SEVERITY_MEDIUM: OVLOG_WARNING(output); break; - case GL_DEBUG_SEVERITY_LOW: OVLOG_INFO(output); break; - case GL_DEBUG_SEVERITY_NOTIFICATION: OVLOG_INFO(output); break; - } - } - - bool GetBool(uint32_t p_parameter) - { - GLboolean result; - glGetBooleanv(p_parameter, &result); - return static_cast(result); - } - - bool GetBool(uint32_t p_parameter, uint32_t p_index) - { - GLboolean result; - glGetBooleani_v(p_parameter, p_index, &result); - return static_cast(result); - } - - int GetInt(uint32_t p_parameter) - { - GLint result[4]; - glGetIntegerv(p_parameter, result); - return static_cast(result[0]); - } - - int GetInt(uint32_t p_parameter, uint32_t p_index) - { - GLint result[4]; - glGetIntegeri_v(p_parameter, p_index, result); - return static_cast(result[0]); - } - - float GetFloat(uint32_t p_parameter) - { - GLfloat result; - glGetFloatv(p_parameter, &result); - return static_cast(result); - } - - float GetFloat(uint32_t p_parameter, uint32_t p_index) - { - GLfloat result; - glGetFloati_v(p_parameter, p_index, &result); - return static_cast(result); - } - - double GetDouble(uint32_t p_parameter) - { - GLdouble result; - glGetDoublev(p_parameter, &result); - return static_cast(result); - } - - double GetDouble(uint32_t p_parameter, uint32_t p_index) - { - GLdouble result; - glGetDoublei_v(p_parameter, p_index, &result); - return static_cast(result); - } - - int64_t GetInt64(uint32_t p_parameter) - { - GLint64 result; - glGetInteger64v(p_parameter, &result); - return static_cast(result); - } - - int64_t GetInt64(uint32_t p_parameter, uint32_t p_index) - { - GLint64 result; - glGetInteger64i_v(p_parameter, p_index, &result); - return static_cast(result); - } - - std::string GetString(uint32_t p_parameter) - { - const GLubyte* result = glGetString(p_parameter); - return result ? reinterpret_cast(result) : std::string(); - } - - std::string GetString(uint32_t p_parameter, uint32_t p_index) - { - const GLubyte* result = glGetStringi(p_parameter, p_index); - return result ? reinterpret_cast(result) : std::string(); - } - - /** - * Very expensive! Call it once, and make sure you always keep track of state changes - */ - OvRendering::Data::PipelineState RetrieveOpenGLPipelineState() - { - using namespace OvRendering::Settings; - using namespace OvRendering::HAL; - - OvRendering::Data::PipelineState pso; - - // Rasterization - pso.rasterizationMode = static_cast(GetInt(GL_POLYGON_MODE)); - pso.lineWidthPow2 = OvRendering::Utils::Conversions::FloatToPow2(GetFloat(GL_LINE_WIDTH)); - - // Color write mask - GLboolean colorWriteMask[4]; - glGetBooleanv(GL_COLOR_WRITEMASK, colorWriteMask); - pso.colorWriting.r = colorWriteMask[0]; - pso.colorWriting.g = colorWriteMask[1]; - pso.colorWriting.b = colorWriteMask[2]; - pso.colorWriting.a = colorWriteMask[3]; - - // Capability - pso.depthWriting = GetBool(GL_DEPTH_WRITEMASK); - pso.blending = GetBool(GL_BLEND); - pso.culling = GetBool(GL_CULL_FACE); - pso.dither = GetBool(GL_DITHER); - pso.polygonOffsetFill = GetBool(GL_POLYGON_OFFSET_FILL); - pso.sampleAlphaToCoverage = GetBool(GL_SAMPLE_ALPHA_TO_COVERAGE); - pso.depthTest = GetBool(GL_DEPTH_TEST); - pso.scissorTest = GetBool(GL_SCISSOR_TEST); - pso.stencilTest = GetBool(GL_STENCIL_TEST); - pso.multisample = GetBool(GL_MULTISAMPLE); - - // Stencil - pso.stencilFuncOp = ValueToEnum(static_cast(GetInt(GL_STENCIL_FUNC))); - pso.stencilFuncRef = GetInt(GL_STENCIL_REF); - pso.stencilFuncMask = static_cast(GetInt(GL_STENCIL_VALUE_MASK)); - - pso.stencilWriteMask = static_cast(GetInt(GL_STENCIL_WRITEMASK)); - - pso.stencilOpFail = ValueToEnum(static_cast(GetInt(GL_STENCIL_FAIL))); - pso.depthOpFail = ValueToEnum(static_cast(GetInt(GL_STENCIL_PASS_DEPTH_FAIL))); - pso.bothOpFail = ValueToEnum(static_cast(GetInt(GL_STENCIL_PASS_DEPTH_PASS))); - - // Depth - pso.depthFunc = ValueToEnum(static_cast(GetInt(GL_DEPTH_FUNC))); - - // Culling - pso.cullFace = ValueToEnum(static_cast(GetInt(GL_CULL_FACE_MODE))); - - // Blending - pso.blendingSrcFactor = ValueToEnum(static_cast(GetInt(GL_BLEND_SRC))); - pso.blendingDestFactor = ValueToEnum(static_cast(GetInt(GL_BLEND_DST))); - pso.blendingEquation = ValueToEnum(static_cast(GetInt(GL_BLEND_EQUATION))); - - return pso; - } -} - -namespace OvRendering::HAL -{ - template<> - std::optional GLBackend::Init(bool debug) - { - const int error = gladLoadGL(); - - if (error == 0) - { - OVLOG_ERROR("GLAD failed to initialize"); - return std::nullopt; - } - - TracyGpuContext; - - if (debug) - { - glEnable(GL_DEBUG_OUTPUT); - glEnable(GL_DEBUG_OUTPUT_SYNCHRONOUS); - glDebugMessageCallback(GLDebugMessageCallback, nullptr); - } - - // Seamless cubemap (always on) - glEnable(GL_TEXTURE_CUBE_MAP_SEAMLESS); - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - glCullFace(GL_BACK); - - return RetrieveOpenGLPipelineState(); - } - - template<> - void GLBackend::OnFrameCompleted() - { - TracyGpuCollect; - } - - template<> - void GLBackend::Clear(bool p_colorBuffer, bool p_depthBuffer, bool p_stencilBuffer) - { - GLbitfield clearMask = 0; - if (p_colorBuffer) clearMask |= GL_COLOR_BUFFER_BIT; - if (p_depthBuffer) clearMask |= GL_DEPTH_BUFFER_BIT; - if (p_stencilBuffer) clearMask |= GL_STENCIL_BUFFER_BIT; - - if (clearMask != 0) - { - glClear(clearMask); - } - } - - template<> - void GLBackend::DrawElements(Settings::EPrimitiveMode p_primitiveMode, uint32_t p_indexCount) - { - glDrawElements(EnumToValue(p_primitiveMode), p_indexCount, GL_UNSIGNED_INT, nullptr); - } - - template<> - void GLBackend::DrawElementsInstanced(Settings::EPrimitiveMode p_primitiveMode, uint32_t p_indexCount, uint32_t p_instances) - { - glDrawElementsInstanced(EnumToValue(p_primitiveMode), p_indexCount, GL_UNSIGNED_INT, nullptr, p_instances); - } - - template<> - void GLBackend::DrawArrays(Settings::EPrimitiveMode p_primitiveMode, uint32_t p_vertexCount) - { - glDrawArrays(EnumToValue(p_primitiveMode), 0, p_vertexCount); - } - - template<> - void GLBackend::DrawArraysInstanced(Settings::EPrimitiveMode p_primitiveMode, uint32_t p_vertexCount, uint32_t p_instances) - { - glDrawArraysInstanced(EnumToValue(p_primitiveMode), 0, p_vertexCount, p_instances); - } - - template<> - void GLBackend::SetClearColor(float p_red, float p_green, float p_blue, float p_alpha) - { - glClearColor(p_red, p_green, p_blue, p_alpha); - } - - template<> - void GLBackend::SetRasterizationLinesWidth(float p_width) - { - glLineWidth(p_width); - } - - template<> - void GLBackend::SetRasterizationMode(Settings::ERasterizationMode p_rasterizationMode) - { - glPolygonMode(GL_FRONT_AND_BACK, EnumToValue(p_rasterizationMode)); - } - - template<> - void GLBackend::SetCapability(Settings::ERenderingCapability p_capability, bool p_value) - { - (p_value ? glEnable : glDisable)(EnumToValue(p_capability)); - } - - template<> - bool GLBackend::GetCapability(Settings::ERenderingCapability p_capability) - { - return glIsEnabled(EnumToValue(p_capability)); - } - - template<> - void GLBackend::SetStencilAlgorithm(Settings::EComparaisonAlgorithm p_algorithm, int32_t p_reference, uint32_t p_mask) - { - glStencilFunc(EnumToValue(p_algorithm), p_reference, p_mask); - } - - template<> - void GLBackend::SetDepthAlgorithm(Settings::EComparaisonAlgorithm p_algorithm) - { - glDepthFunc(EnumToValue(p_algorithm)); - } - - template<> - void GLBackend::SetStencilMask(uint32_t p_mask) - { - glStencilMask(p_mask); - } - - template<> - void GLBackend::SetStencilOperations(Settings::EOperation p_stencilFail, Settings::EOperation p_depthFail, Settings::EOperation p_bothPass) - { - glStencilOp(EnumToValue(p_stencilFail), EnumToValue(p_depthFail), EnumToValue(p_bothPass)); - } - - template<> - void GLBackend::SetBlendingFunction(Settings::EBlendingFactor p_sourceFactor, Settings::EBlendingFactor p_destinationFactor) - { - glBlendFunc( - EnumToValue(p_sourceFactor), - EnumToValue(p_destinationFactor) - ); - } - - template<> - void GLBackend::SetBlendingEquation(Settings::EBlendingEquation p_equation) - { - glBlendEquation(EnumToValue(p_equation)); - } - - template<> - void GLBackend::SetCullFace(Settings::ECullFace p_cullFace) - { - glCullFace(EnumToValue(p_cullFace)); - } - - template<> - void GLBackend::SetDepthWriting(bool p_enable) - { - glDepthMask(p_enable); - } - - template<> - void GLBackend::SetColorWriting(bool p_enableRed, bool p_enableGreen, bool p_enableBlue, bool p_enableAlpha) - { - glColorMask(p_enableRed, p_enableGreen, p_enableBlue, p_enableAlpha); - } - - template<> - void GLBackend::SetViewport(uint32_t x, uint32_t y, uint32_t width, uint32_t height) - { - glViewport(x, y, width, height); - } - - template<> - std::string GLBackend::GetVendor() - { - return GetString(GL_VENDOR); - } - - template<> - std::string GLBackend::GetHardware() - { - return GetString(GL_RENDERER); - } - - template<> - std::string GLBackend::GetVersion() - { - return GetString(GL_VERSION); - } - - template<> - std::string GLBackend::GetShadingLanguageVersion() - { - return GetString(GL_SHADING_LANGUAGE_VERSION); - } -} diff --git a/Sources/OvRendering/src/OvRendering/HAL/OpenGL/GLBuffer.cpp b/Sources/OvRendering/src/OvRendering/HAL/OpenGL/GLBuffer.cpp deleted file mode 100644 index 3534bd65a..000000000 --- a/Sources/OvRendering/src/OvRendering/HAL/OpenGL/GLBuffer.cpp +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @project: Overload -* @author: Overload Tech. -* @licence: MIT -*/ - -#include - -#include -#include -#include - -template<> -OvRendering::HAL::GLBuffer::TBuffer(Settings::EBufferType p_type) : m_buffer{ - .type = p_type -} -{ - glCreateBuffers(1, &m_buffer.id); -} - -template<> -OvRendering::HAL::GLBuffer::~TBuffer() -{ - glDeleteBuffers(1, &m_buffer.id); -} - -template<> -bool OvRendering::HAL::GLBuffer::IsValid() const -{ - return - m_buffer.id != 0 && - m_buffer.type != Settings::EBufferType::UNKNOWN; -} - -template<> -uint64_t OvRendering::HAL::GLBuffer::GetSize() const -{ - OVASSERT(IsValid(), "Cannot get size of an invalid buffer"); - return m_buffer.allocatedBytes; -} - -template<> -bool OvRendering::HAL::GLBuffer::IsEmpty() const -{ - return GetSize() == 0; -} - -template<> -uint64_t OvRendering::HAL::GLBuffer::Allocate(uint64_t p_size, Settings::EAccessSpecifier p_usage) -{ - OVASSERT(IsValid(), "Cannot allocate memory for an invalid buffer"); - glNamedBufferData(m_buffer.id, p_size, nullptr, EnumToValue(p_usage)); - return m_buffer.allocatedBytes = p_size; -} - -template<> -void OvRendering::HAL::GLBuffer::Upload(const void* p_data, std::optional p_range) -{ - OVASSERT(IsValid(), "Trying to upload data to an invalid buffer"); - OVASSERT(!IsEmpty(), "Trying to upload data to an empty buffer"); - - glNamedBufferSubData( - m_buffer.id, - p_range ? p_range->offset : 0, - p_range ? p_range->size : m_buffer.allocatedBytes, - p_data - ); -} - -template<> -void OvRendering::HAL::GLBuffer::Bind(std::optional p_index) const -{ - OVASSERT(IsValid(), "Cannot bind an invalid buffer"); - - if (p_index.has_value()) - { - glBindBufferBase(EnumToValue(m_buffer.type), p_index.value(), m_buffer.id); - } - else - { - glBindBuffer(EnumToValue(m_buffer.type), m_buffer.id); - } -} - -template<> -void OvRendering::HAL::GLBuffer::Unbind() const -{ - OVASSERT(IsValid(), "Cannot unbind an invalid buffer"); - glBindBuffer(EnumToValue(m_buffer.type), 0); -} - -template<> -uint32_t OvRendering::HAL::GLBuffer::GetID() const -{ - OVASSERT(IsValid(), "Cannot get ID of an invalid buffer"); - return m_buffer.id; -} diff --git a/Sources/OvRendering/src/OvRendering/HAL/OpenGL/GLFramebuffer.cpp b/Sources/OvRendering/src/OvRendering/HAL/OpenGL/GLFramebuffer.cpp deleted file mode 100644 index ae75c5a28..000000000 --- a/Sources/OvRendering/src/OvRendering/HAL/OpenGL/GLFramebuffer.cpp +++ /dev/null @@ -1,273 +0,0 @@ -/** -* @project: Overload -* @author: Overload Tech. -* @licence: MIT -*/ - -#include - -#include -#include -#include -#include -#include - -template<> -template<> -void OvRendering::HAL::GLFramebuffer::Attach( - std::shared_ptr p_toAttach, - Settings::EFramebufferAttachment p_attachment, - uint32_t p_index, - std::optional p_layer -) -{ - OVASSERT(p_toAttach != nullptr, "Cannot attach a null renderbuffer"); - OVASSERT(!p_layer.has_value(), "Renderbuffer cannot use layers"); - - const auto attachmentIndex = EnumToValue(p_attachment) + static_cast(p_index); - glNamedFramebufferRenderbuffer(m_context.id, attachmentIndex, GL_RENDERBUFFER, p_toAttach->GetID()); - m_context.attachments[attachmentIndex] = p_toAttach; -} - -template<> -template<> -void OvRendering::HAL::GLFramebuffer::Attach( - std::shared_ptr p_toAttach, - Settings::EFramebufferAttachment p_attachment, - uint32_t p_index, - std::optional p_layer -) -{ - OVASSERT(p_toAttach != nullptr, "Cannot attach a null texture"); - - const auto attachmentIndex = EnumToValue(p_attachment) + static_cast(p_index); - constexpr uint32_t kMipMapLevel = 0; - - if (p_layer.has_value()) - { - glNamedFramebufferTextureLayer(m_context.id, attachmentIndex, p_toAttach->GetID(), kMipMapLevel, p_layer.value()); - } - else - { - glNamedFramebufferTexture(m_context.id, attachmentIndex, p_toAttach->GetID(), kMipMapLevel); - } - - m_context.attachments[attachmentIndex] = p_toAttach; -} - -template<> -OvRendering::HAL::GLFramebuffer::TFramebuffer(std::string_view p_debugName) : - m_context{ .debugName = std::string{p_debugName} } -{ - glCreateFramebuffers(1, &m_context.id); -} - -template<> -OvRendering::HAL::GLFramebuffer::~TFramebuffer() -{ - glDeleteFramebuffers(1, &m_context.id); -} - -template<> -void OvRendering::HAL::GLFramebuffer::Bind() const -{ - glBindFramebuffer(GL_FRAMEBUFFER, m_context.id); -} - -template<> -void OvRendering::HAL::GLFramebuffer::Unbind() const -{ - glBindFramebuffer(GL_FRAMEBUFFER, 0); -} - -template<> -bool OvRendering::HAL::GLFramebuffer::Validate() -{ - const GLenum status = glCheckNamedFramebufferStatus(m_context.id, GL_FRAMEBUFFER); - - if (status != GL_FRAMEBUFFER_COMPLETE) - { - OVLOG_ERROR("Framebuffer validation failed with status: " + std::to_string(status)); - return m_context.valid = false; - } - - return m_context.valid = true; -} - -template<> -bool OvRendering::HAL::GLFramebuffer::IsValid() const -{ - return m_context.valid; -} - -template<> -template<> -OvTools::Utils::OptRef OvRendering::HAL::GLFramebuffer::GetAttachment( - OvRendering::Settings::EFramebufferAttachment p_attachment, - uint32_t p_index -) const -{ - const auto attachmentIndex = EnumToValue(p_attachment) + static_cast(p_index); - - if (m_context.attachments.contains(attachmentIndex)) - { - auto attachment = m_context.attachments.at(attachmentIndex); - - if (auto pval = std::get_if>(&attachment); pval && *pval) - { - return **pval; - } - } - - return std::nullopt; -} - -template<> -template<> -OvTools::Utils::OptRef OvRendering::HAL::GLFramebuffer::GetAttachment( - OvRendering::Settings::EFramebufferAttachment p_attachment, - uint32_t p_index -) const -{ - const auto attachmentIndex = EnumToValue(p_attachment) + static_cast(p_index); - - if (m_context.attachments.contains(attachmentIndex)) - { - auto attachment = m_context.attachments.at(attachmentIndex); - - if (auto pval = std::get_if>(&attachment); pval && *pval) - { - return **pval; - } - } - - return std::nullopt; -} - -template<> -void OvRendering::HAL::GLFramebuffer::Resize(uint16_t p_width, uint16_t p_height) -{ - OVASSERT(IsValid(), "Cannot resize an invalid framebuffer"); - - for (auto& attachment : m_context.attachments) - { - if (const auto pval = std::get_if>(&attachment.second); pval && *pval) - { - (*pval)->Resize(p_width, p_height); - } - else if (const auto* pval = std::get_if>(&attachment.second); pval && *pval) - { - (*pval)->Resize(p_width, p_height); - } - } -} - -template<> -void OvRendering::HAL::GLFramebuffer::SetTargetDrawBuffer(std::optional p_index) -{ - OVASSERT(IsValid(), "Invalid framebuffer"); - - if (p_index.has_value()) - { - glNamedFramebufferDrawBuffer(m_context.id, GL_COLOR_ATTACHMENT0 + p_index.value()); - } - else - { - glNamedFramebufferDrawBuffer(m_context.id, GL_NONE); - } -} - -template<> -void OvRendering::HAL::GLFramebuffer::SetTargetReadBuffer(std::optional p_index) -{ - OVASSERT(IsValid(), "Invalid framebuffer"); - - if (p_index.has_value()) - { - glNamedFramebufferReadBuffer(m_context.id, GL_COLOR_ATTACHMENT0 + p_index.value()); - } - else - { - glNamedFramebufferReadBuffer(m_context.id, GL_NONE); - } -} - -template<> -uint32_t OvRendering::HAL::GLFramebuffer::GetID() const -{ - return m_context.id; -} - -template<> -std::pair OvRendering::HAL::GLFramebuffer::GetSize( - Settings::EFramebufferAttachment p_attachment -) const -{ - OVASSERT(IsValid(), "Cannot get width of an invalid framebuffer"); - - for (auto& attachment : m_context.attachments) - { - if (const auto pval = std::get_if>(&attachment.second); pval && *pval) - { - return { - (*pval)->GetDesc().width, - (*pval)->GetDesc().height - }; - } - else if (const auto* pval = std::get_if>(&attachment.second); pval && *pval) - { - return { - (*pval)->GetWidth(), - (*pval)->GetHeight() - }; - } - } - - return { {}, {} }; // <-- not an emoji -} - -template<> -void OvRendering::HAL::GLFramebuffer::BlitToBackBuffer(uint16_t p_backBufferWidth, uint16_t p_backBufferHeight) const -{ - OVASSERT(IsValid(), "Cannot blit an invalid framebuffer"); - - auto [width, height] = GetSize(Settings::EFramebufferAttachment::COLOR); - - glBlitNamedFramebuffer( - m_context.id, 0, - 0, 0, width, height, - 0, 0, p_backBufferWidth, p_backBufferHeight, - GL_COLOR_BUFFER_BIT, GL_LINEAR - ); -} - -template<> -void OvRendering::HAL::GLFramebuffer::ReadPixels( - uint32_t p_x, - uint32_t p_y, - uint32_t p_width, - uint32_t p_height, - Settings::EPixelDataFormat p_format, - Settings::EPixelDataType p_type, - void* p_data) const -{ - OVASSERT(IsValid(), "Cannot read pixels from an invalid framebuffer"); - OVASSERT(p_width > 0 && p_height > 0, "Invalid read size"); - - Bind(); - glReadPixels( - p_x, p_y, - p_width, - p_height, - EnumToValue(p_format), - EnumToValue(p_type), - p_data - ); - Unbind(); -} - -template<> -const std::string& OvRendering::HAL::GLFramebuffer::GetDebugName() const -{ - return m_context.debugName; -} diff --git a/Sources/OvRendering/src/OvRendering/HAL/OpenGL/GLIndexBuffer.cpp b/Sources/OvRendering/src/OvRendering/HAL/OpenGL/GLIndexBuffer.cpp deleted file mode 100644 index 3781bcb9d..000000000 --- a/Sources/OvRendering/src/OvRendering/HAL/OpenGL/GLIndexBuffer.cpp +++ /dev/null @@ -1,15 +0,0 @@ -/** -* @project: Overload -* @author: Overload Tech. -* @licence: MIT -*/ - -#include - -#include -#include - -template<> -OvRendering::HAL::GLIndexBuffer::TIndexBuffer() : TBuffer(Settings::EBufferType::INDEX) -{ -} diff --git a/Sources/OvRendering/src/OvRendering/HAL/OpenGL/GLRenderbuffer.cpp b/Sources/OvRendering/src/OvRendering/HAL/OpenGL/GLRenderbuffer.cpp deleted file mode 100644 index dd7c9efd2..000000000 --- a/Sources/OvRendering/src/OvRendering/HAL/OpenGL/GLRenderbuffer.cpp +++ /dev/null @@ -1,87 +0,0 @@ -/** -* @project: Overload -* @author: Overload Tech. -* @licence: MIT -*/ - -#include - -#include -#include -#include - -template<> -OvRendering::HAL::GLRenderbuffer::TRenderbuffer() -{ - glCreateRenderbuffers(1, &m_context.id); -} - -template<> -OvRendering::HAL::GLRenderbuffer::~TRenderbuffer() -{ - glDeleteRenderbuffers(1, &m_context.id); -} - -template<> -void OvRendering::HAL::GLRenderbuffer::Bind() const -{ - glBindRenderbuffer(GL_RENDERBUFFER, m_context.id); -} - -template<> -void OvRendering::HAL::GLRenderbuffer::Unbind() const -{ - glBindRenderbuffer(GL_RENDERBUFFER, 0); -} - -template<> -uint32_t OvRendering::HAL::GLRenderbuffer::GetID() const -{ - return m_context.id; -} - -template<> -void OvRendering::HAL::GLRenderbuffer::Allocate(uint16_t p_width, uint16_t p_height, Settings::EInternalFormat p_format) -{ - m_context.width = p_width; - m_context.height = p_height; - m_context.format = p_format; - - glNamedRenderbufferStorage(m_context.id, EnumToValue(m_context.format), m_context.width, m_context.height); - - m_context.allocated = true; -} - -template<> -bool OvRendering::HAL::GLRenderbuffer::IsValid() const -{ - return m_context.allocated; -} - -template<> -void OvRendering::HAL::GLRenderbuffer::Resize(uint16_t p_width, uint16_t p_height) -{ - OVASSERT(IsValid(), "Cannot resize a renderbuffer that has not been allocated"); - - if (m_context.width == p_width && m_context.height == p_height) - { - return; - } - - Allocate(p_width, p_height, m_context.format); -} - - -template<> -uint16_t OvRendering::HAL::GLRenderbuffer::GetWidth() const -{ - OVASSERT(IsValid(), "Cannot get width of an invalid renderbuffer"); - return m_context.width; -} - -template<> -uint16_t OvRendering::HAL::GLRenderbuffer::GetHeight() const -{ - OVASSERT(IsValid(), "Cannot get height of an invalid renderbuffer"); - return m_context.height; -} diff --git a/Sources/OvRendering/src/OvRendering/HAL/OpenGL/GLShaderProgram.cpp b/Sources/OvRendering/src/OvRendering/HAL/OpenGL/GLShaderProgram.cpp deleted file mode 100644 index fc9e4370f..000000000 --- a/Sources/OvRendering/src/OvRendering/HAL/OpenGL/GLShaderProgram.cpp +++ /dev/null @@ -1,240 +0,0 @@ -/** -* @project: Overload -* @author: Overload Tech. -* @licence: MIT -*/ - -#include -#include - -#include - -#include -#include -#include -#include -#include -#include - -namespace -{ - constexpr bool IsReservedUniform(std::string_view p_name) - { - return p_name.starts_with("ubo_") || p_name.starts_with("ReflectionUBO"); - } -} - -template<> -OvRendering::HAL::GLShaderProgram::TShaderProgram() : m_context{ .id = glCreateProgram() } -{ - -} - -template<> -OvRendering::HAL::GLShaderProgram::~TShaderProgram() -{ - glDeleteProgram(m_context.id); -} - -template<> -void OvRendering::HAL::GLShaderProgram::Bind() const -{ - glUseProgram(m_context.id); -} - -template<> -void OvRendering::HAL::GLShaderProgram::Unbind() const -{ - glUseProgram(0); -} - -template<> -uint32_t OvRendering::HAL::GLShaderProgram::GetID() const -{ - return m_context.id; -} - -template<> -void OvRendering::HAL::GLShaderProgram::Attach(const GLShaderStage& p_shader) -{ - glAttachShader(m_context.id, p_shader.GetID()); - m_context.attachedShaders.push_back(std::ref(p_shader)); -} - -template<> -void OvRendering::HAL::GLShaderProgram::Detach(const GLShaderStage& p_shader) -{ - glDetachShader(m_context.id, p_shader.GetID()); - m_context.attachedShaders.erase(std::remove_if( - m_context.attachedShaders.begin(), - m_context.attachedShaders.end(), - [&p_shader](const std::reference_wrapper shader) { - return shader.get().GetID() == p_shader.GetID(); - } - )); -} - -template<> -void OvRendering::HAL::GLShaderProgram::DetachAll() -{ - for (auto& shader : m_context.attachedShaders) - { - glDetachShader(m_context.id, shader.get().GetID()); - } - - m_context.attachedShaders.clear(); -} - -#define DECLARE_GET_UNIFORM_FUNCTION(type, glType, func) \ -template<> \ -template<> \ -type OvRendering::HAL::GLShaderProgram::GetUniform(const std::string& p_name) \ -{ \ - type result{}; \ - if (auto it = m_context.uniformsLocationCache.find(p_name); it != m_context.uniformsLocationCache.end()) \ - { \ - func(m_context.id, it->second, reinterpret_cast(&result)); \ - } \ - return result; \ -} - -DECLARE_GET_UNIFORM_FUNCTION(int, GLint, glGetUniformiv); -DECLARE_GET_UNIFORM_FUNCTION(float, GLfloat, glGetUniformfv); -DECLARE_GET_UNIFORM_FUNCTION(OvMaths::FVector2, GLfloat, glGetUniformfv); -DECLARE_GET_UNIFORM_FUNCTION(OvMaths::FVector3, GLfloat, glGetUniformfv); -DECLARE_GET_UNIFORM_FUNCTION(OvMaths::FVector4, GLfloat, glGetUniformfv); -DECLARE_GET_UNIFORM_FUNCTION(OvMaths::FMatrix3, GLfloat, glGetUniformfv); -DECLARE_GET_UNIFORM_FUNCTION(OvMaths::FMatrix4, GLfloat, glGetUniformfv); - -#define DECLARE_SET_UNIFORM_FUNCTION(type, func, ...) \ -template<> \ -template<> \ -void OvRendering::HAL::GLShaderProgram::SetUniform(const std::string& p_name, const type& value) \ -{ \ - if (auto it = m_context.uniformsLocationCache.find(p_name); it != m_context.uniformsLocationCache.end()) \ - { \ - func(it->second, __VA_ARGS__); \ - } \ -} - -DECLARE_SET_UNIFORM_FUNCTION(int, glUniform1i, value); -DECLARE_SET_UNIFORM_FUNCTION(float, glUniform1f, value); -DECLARE_SET_UNIFORM_FUNCTION(OvMaths::FVector2, glUniform2f, value.x, value.y); -DECLARE_SET_UNIFORM_FUNCTION(OvMaths::FVector3, glUniform3f, value.x, value.y, value.z); -DECLARE_SET_UNIFORM_FUNCTION(OvMaths::FVector4, glUniform4f, value.x, value.y, value.z, value.w); -DECLARE_SET_UNIFORM_FUNCTION(OvMaths::FMatrix3, glUniformMatrix3fv, 1, GL_TRUE, &value.data[0]); -DECLARE_SET_UNIFORM_FUNCTION(OvMaths::FMatrix4, glUniformMatrix4fv, 1, GL_TRUE, &value.data[0]); - -template<> -void OvRendering::HAL::GLShaderProgram::QueryUniforms() -{ - m_context.uniforms.clear(); - - std::array nameBuffer; - - GLint activeUniformCount = 0; - glGetProgramiv(m_context.id, GL_ACTIVE_UNIFORMS, &activeUniformCount); - - uint32_t textureSlotCounter = 0; - - for (GLint i = 0; i < activeUniformCount; ++i) - { - GLint arraySize = 0; - GLenum type = 0; - GLsizei actualLength = 0; - - glGetActiveUniform(m_context.id, i, static_cast(nameBuffer.size()), &actualLength, &arraySize, &type, nameBuffer.data()); - - const auto name = std::string{ nameBuffer.data(), static_cast(actualLength) }; - const auto uniformType = ValueToEnum(type); - - // Skip reserved uniforms (e.g. ubo uniforms) - if (IsReservedUniform(name)) - { - continue; - } - - const auto location = glGetUniformLocation(m_context.id, name.c_str()); - OVASSERT(location != -1, "Failed to get uniform location for: " + name); - m_context.uniformsLocationCache.emplace(name, static_cast(location)); - - const std::any uniformValue = [&]() -> std::any { - switch (uniformType) - { - using enum Settings::EUniformType; - case BOOL: return static_cast(GetUniform(name)); - case INT: return GetUniform(name); - case FLOAT: return GetUniform(name); - case FLOAT_VEC2: return GetUniform(name); - case FLOAT_VEC3: return GetUniform(name); - case FLOAT_VEC4: return GetUniform(name); - case FLOAT_MAT3: return GetUniform(name); - case FLOAT_MAT4: return GetUniform(name); - case SAMPLER_2D: return std::make_any(nullptr); - case SAMPLER_CUBE: return std::make_any(nullptr); - default: return std::nullopt; - } - }(); - - // Only add the uniform if it has a value (unsupported uniform types will be ignored) - if (uniformValue.has_value()) - { - const bool isTexture = - uniformType == Settings::EUniformType::SAMPLER_2D || - uniformType == Settings::EUniformType::SAMPLER_CUBE; - - m_context.uniforms.emplace(name, Settings::UniformInfo{ - .type = uniformType, - .name = name, - .defaultValue = uniformValue, - .textureSlot = isTexture ? textureSlotCounter++ : 0 - }); - } - } -} - -template<> -OvRendering::Settings::ShaderLinkingResult OvRendering::HAL::GLShaderProgram::Link() -{ - glLinkProgram(m_context.id); - - GLint linkStatus; - glGetProgramiv(m_context.id, GL_LINK_STATUS, &linkStatus); - - if (linkStatus == GL_FALSE) - { - GLint maxLength; - glGetProgramiv(m_context.id, GL_INFO_LOG_LENGTH, &maxLength); - - std::string errorLog(maxLength, ' '); - glGetProgramInfoLog(m_context.id, maxLength, &maxLength, errorLog.data()); - - return { - .success = false, - .message = errorLog - }; - } - - QueryUniforms(); - - return { - .success = true - }; -} - -template<> -OvTools::Utils::OptRef OvRendering::HAL::GLShaderProgram::GetUniformInfo(const std::string& p_name) const -{ - if (auto it = m_context.uniforms.find(p_name); it != m_context.uniforms.end()) - { - return it->second; - } - - return std::nullopt; -} - -template<> -const std::unordered_map& OvRendering::HAL::GLShaderProgram::GetUniforms() const -{ - return m_context.uniforms; -} diff --git a/Sources/OvRendering/src/OvRendering/HAL/OpenGL/GLShaderStage.cpp b/Sources/OvRendering/src/OvRendering/HAL/OpenGL/GLShaderStage.cpp deleted file mode 100644 index 4acadf3d7..000000000 --- a/Sources/OvRendering/src/OvRendering/HAL/OpenGL/GLShaderStage.cpp +++ /dev/null @@ -1,72 +0,0 @@ -/** -* @project: Overload -* @author: Overload Tech. -* @licence: MIT -*/ - -#include - -#include - -#include -#include -#include -#include - -template<> -OvRendering::HAL::GLShaderStage::TShaderStage(Settings::EShaderType p_type) : m_context{ - .id = static_cast(glCreateShader(EnumToValue(p_type))), - .type = p_type, -} -{ -} - -template<> -OvRendering::HAL::GLShaderStage::~TShaderStage() -{ - glDeleteShader(m_context.id); -} - -template<> -void OvRendering::HAL::GLShaderStage::Upload(const std::string& p_source) const -{ - const char* source = p_source.c_str(); - glShaderSource(m_context.id, 1, &source, nullptr); -} - -template<> -OvRendering::Settings::ShaderCompilationResult OvRendering::HAL::GLShaderStage::Compile() const -{ - glCompileShader(m_context.id); - - GLint compileStatus; - glGetShaderiv(m_context.id, GL_COMPILE_STATUS, &compileStatus); - - if (compileStatus == GL_FALSE) - { - GLint maxLength; - glGetShaderiv(m_context.id, GL_INFO_LOG_LENGTH, &maxLength); - - std::string errorLog(maxLength, ' '); - glGetShaderInfoLog(m_context.id, maxLength, &maxLength, errorLog.data()); - - std::string shaderTypeStr = Utils::GetShaderTypeName(m_context.type); - std::transform(shaderTypeStr.begin(), shaderTypeStr.end(), shaderTypeStr.begin(), toupper); - std::string errorHeader = "[" + shaderTypeStr + " SHADER] \""; - - return { - .success = false, - .message = errorLog - }; - } - - return { - .success = true - }; -} - -template<> -uint32_t OvRendering::HAL::GLShaderStage::GetID() const -{ - return m_context.id; -} diff --git a/Sources/OvRendering/src/OvRendering/HAL/OpenGL/GLShaderStorageBuffer.cpp b/Sources/OvRendering/src/OvRendering/HAL/OpenGL/GLShaderStorageBuffer.cpp deleted file mode 100644 index 394902612..000000000 --- a/Sources/OvRendering/src/OvRendering/HAL/OpenGL/GLShaderStorageBuffer.cpp +++ /dev/null @@ -1,15 +0,0 @@ -/** -* @project: Overload -* @author: Overload Tech. -* @licence: MIT -*/ - -#include - -#include -#include - -template<> -OvRendering::HAL::GLShaderStorageBuffer::TShaderStorageBuffer() : GLBuffer(Settings::EBufferType::SHADER_STORAGE) -{ -} diff --git a/Sources/OvRendering/src/OvRendering/HAL/OpenGL/GLTexture.cpp b/Sources/OvRendering/src/OvRendering/HAL/OpenGL/GLTexture.cpp deleted file mode 100644 index 0b734e4b2..000000000 --- a/Sources/OvRendering/src/OvRendering/HAL/OpenGL/GLTexture.cpp +++ /dev/null @@ -1,225 +0,0 @@ -/** -* @project: Overload -* @author: Overload Tech. -* @licence: MIT -*/ - -#include - -#include -#include -#include -#include - -namespace -{ - constexpr uint32_t CalculateMipMapLevels(uint32_t p_width, uint32_t p_height) - { - uint32_t maxDim = p_width > p_height ? p_width : p_height; - - uint32_t levels = 0; - while (maxDim > 1) - { - maxDim >>= 1; - ++levels; - } - - return levels ? levels + 1 : 1u; - } - - constexpr bool IsValidMipMapFilter(OvRendering::Settings::ETextureFilteringMode p_mode) - { - return - p_mode == OvRendering::Settings::ETextureFilteringMode::NEAREST_MIPMAP_NEAREST || - p_mode == OvRendering::Settings::ETextureFilteringMode::NEAREST_MIPMAP_LINEAR || - p_mode == OvRendering::Settings::ETextureFilteringMode::LINEAR_MIPMAP_NEAREST || - p_mode == OvRendering::Settings::ETextureFilteringMode::LINEAR_MIPMAP_LINEAR; - } -} - -template<> -OvRendering::HAL::GLTexture::TTexture(Settings::ETextureType p_type, std::string_view p_debugName) : GLTextureHandle(p_type) -{ - glCreateTextures(m_context.type, 1, &m_context.id); - m_textureContext.debugName = p_debugName; - CreationEvent.Invoke(*this); -} - -template<> -OvRendering::HAL::GLTexture::~TTexture() -{ - glDeleteTextures(1, &m_context.id); - DestructionEvent.Invoke(*this); -} - -template<> -void OvRendering::HAL::GLTexture::Allocate(const Settings::TextureDesc& p_desc) -{ - auto& desc = m_textureContext.desc; - - desc = p_desc; - desc.width = std::max(1u, desc.width); - desc.height = std::max(1u, desc.height); - - if (desc.mutableDesc.has_value()) - { - const auto& mutableDesc = desc.mutableDesc.value(); - - OVASSERT(m_context.type == GL_TEXTURE_2D, "Mutable textures are only supported for 2D textures"); - - // No DSA version for glTexImage2D (mutable texture), - // so we need to Bind/Unbind the texture. - Bind(); - glTexImage2D( - m_context.type, - 0, - EnumToValue(desc.internalFormat), - desc.width, - desc.height, - 0, - EnumToValue(mutableDesc.format), - EnumToValue(mutableDesc.type), - mutableDesc.data - ); - Unbind(); - } - else - { - // If the underlying texture is a cube map, this will allocate all 6 sides. - // No need to iterate over each side. - glTextureStorage2D( - m_context.id, - desc.useMipMaps ? CalculateMipMapLevels(desc.width, desc.height) : 1, - EnumToValue(desc.internalFormat), - desc.width, - desc.height - ); - } - - // Once the texture is allocated, we don't need to set the parameters again - if (!m_textureContext.allocated) - { - glTextureParameteri(m_context.id, GL_TEXTURE_WRAP_S, EnumToValue(p_desc.horizontalWrap)); - glTextureParameteri(m_context.id, GL_TEXTURE_WRAP_T, EnumToValue(p_desc.verticalWrap)); - glTextureParameteri(m_context.id, GL_TEXTURE_MIN_FILTER, EnumToValue(p_desc.minFilter)); - glTextureParameteri(m_context.id, GL_TEXTURE_MAG_FILTER, EnumToValue(p_desc.magFilter)); - } - - m_textureContext.allocated = true; -} - -template<> -bool OvRendering::HAL::GLTexture::IsValid() const -{ - return m_textureContext.allocated; -} - -template<> -bool OvRendering::HAL::GLTexture::IsMutable() const -{ - OVASSERT(IsValid(), "Cannot check if a texture is mutable before it has been allocated"); - return m_textureContext.desc.mutableDesc.has_value(); -} - -template<> -void OvRendering::HAL::GLTexture::Upload(const void* p_data, Settings::EFormat p_format, Settings::EPixelDataType p_type) -{ - OVASSERT(IsValid(), "Cannot upload data to a texture before it has been allocated"); - OVASSERT(p_data, "Cannot upload texture data from a null pointer"); - - if (IsMutable()) - { - m_textureContext.desc.mutableDesc.value().data = p_data; - Allocate(m_textureContext.desc); - } - else - { - if (m_context.type == GL_TEXTURE_CUBE_MAP) - { - for (uint32_t i = 0; i < 6; ++i) - { - glTextureSubImage3D( - m_context.id, - 0, - 0, - 0, - i, - m_textureContext.desc.width, - m_textureContext.desc.height, - 1, - EnumToValue(p_format), - EnumToValue(p_type), - p_data - ); - } - } - else - { - glTextureSubImage2D( - m_context.id, - 0, - 0, - 0, - m_textureContext.desc.width, - m_textureContext.desc.height, - EnumToValue(p_format), - EnumToValue(p_type), - p_data - ); - } - } -} - -template<> -void OvRendering::HAL::GLTexture::Resize(uint32_t p_width, uint32_t p_height) -{ - OVASSERT(IsValid(), "Cannot resize a texture before it has been allocated"); - OVASSERT(IsMutable(), "Cannot resize an immutable texture"); - - auto& desc = m_textureContext.desc; - - if (p_width != desc.width || p_height != desc.height) - { - desc.width = p_width; - desc.height = p_height; - - Allocate(desc); - } -} - -template<> -const OvRendering::Settings::TextureDesc& OvRendering::HAL::GLTexture::GetDesc() const -{ - OVASSERT(IsValid(), "Cannot get the descriptor of a texture before it has been allocated"); - return m_textureContext.desc; -} - -template<> -void OvRendering::HAL::GLTexture::GenerateMipmaps() const -{ - OVASSERT(IsValid(), "Cannot generate mipmaps for a texture before it has been allocated"); - OVASSERT(m_textureContext.desc.useMipMaps, "Cannot generate mipmaps for a texture that doesn't use them"); - - if (IsValidMipMapFilter(m_textureContext.desc.minFilter)) - { - glGenerateTextureMipmap(m_context.id); - } - else - { - // In the event a user tries to generate mipmaps for a texture that doesn't use a valid mipmap filter - OVLOG_ERROR("Cannot generate mipmaps for a texture that doesn't use a valid mipmap filter"); - } -} - -template<> -void OvRendering::HAL::GLTexture::SetBorderColor(const OvMaths::FVector4& p_color) -{ - OVASSERT(IsValid(), "Cannot set border color for a texture before it has been allocated"); - glTextureParameterfv(m_context.id, GL_TEXTURE_BORDER_COLOR, &p_color.x); -} - -template<> -const std::string& OvRendering::HAL::GLTexture::GetDebugName() const -{ - return m_textureContext.debugName; -} diff --git a/Sources/OvRendering/src/OvRendering/HAL/OpenGL/GLTextureHandle.cpp b/Sources/OvRendering/src/OvRendering/HAL/OpenGL/GLTextureHandle.cpp deleted file mode 100644 index 122a14822..000000000 --- a/Sources/OvRendering/src/OvRendering/HAL/OpenGL/GLTextureHandle.cpp +++ /dev/null @@ -1,56 +0,0 @@ -/** -* @project: Overload -* @author: Overload Tech. -* @licence: MIT -*/ - -#include - -#include -#include - -template<> -OvRendering::HAL::GLTextureHandle::TTextureHandle(Settings::ETextureType p_type) : m_context{ - .type = EnumToValue(p_type) -} -{ -} - -template<> -OvRendering::HAL::GLTextureHandle::TTextureHandle(Settings::ETextureType p_type, uint32_t p_id) : m_context{ - .id = p_id, - .type = EnumToValue(p_type) -} -{ -} - -template<> -void OvRendering::HAL::GLTextureHandle::Bind(std::optional p_slot) const -{ - if (p_slot.has_value()) - { - glBindTextureUnit(p_slot.value(), m_context.id); - } - else - { - glBindTexture(m_context.type, m_context.id); - } -} - -template<> -void OvRendering::HAL::GLTextureHandle::Unbind() const -{ - glBindTexture(m_context.type, 0); -} - -template<> -uint32_t OvRendering::HAL::GLTextureHandle::GetID() const -{ - return m_context.id; -} - -template<> -OvRendering::Settings::ETextureType OvRendering::HAL::GLTextureHandle::GetType() const -{ - return ValueToEnum(m_context.type); -} diff --git a/Sources/OvRendering/src/OvRendering/HAL/OpenGL/GLUniformBuffer.cpp b/Sources/OvRendering/src/OvRendering/HAL/OpenGL/GLUniformBuffer.cpp deleted file mode 100644 index d229d5848..000000000 --- a/Sources/OvRendering/src/OvRendering/HAL/OpenGL/GLUniformBuffer.cpp +++ /dev/null @@ -1,14 +0,0 @@ -/** -* @project: Overload -* @author: Overload Tech. -* @licence: MIT -*/ - -#include - -#include - -template<> -OvRendering::HAL::GLUniformBuffer::TUniformBuffer() : GLBuffer(Settings::EBufferType::UNIFORM) -{ -} diff --git a/Sources/OvRendering/src/OvRendering/HAL/OpenGL/GLVertexArray.cpp b/Sources/OvRendering/src/OvRendering/HAL/OpenGL/GLVertexArray.cpp deleted file mode 100644 index a3c0bee4e..000000000 --- a/Sources/OvRendering/src/OvRendering/HAL/OpenGL/GLVertexArray.cpp +++ /dev/null @@ -1,154 +0,0 @@ -/** -* @project: Overload -* @author: Overload Tech. -* @licence: MIT -*/ - -#include - -#include -#include -#include - -namespace -{ - uint32_t GetDataTypeSizeInBytes(OvRendering::Settings::EDataType p_type) - { - switch (p_type) - { - case OvRendering::Settings::EDataType::BYTE: return sizeof(GLbyte); - case OvRendering::Settings::EDataType::UNSIGNED_BYTE: return sizeof(GLubyte); - case OvRendering::Settings::EDataType::SHORT: return sizeof(GLshort); - case OvRendering::Settings::EDataType::UNSIGNED_SHORT: return sizeof(GLushort); - case OvRendering::Settings::EDataType::INT: return sizeof(GLint); - case OvRendering::Settings::EDataType::UNSIGNED_INT: return sizeof(GLuint); - case OvRendering::Settings::EDataType::FLOAT: return sizeof(GLfloat); - case OvRendering::Settings::EDataType::DOUBLE: return sizeof(GLdouble); - default: return 0; - } - } - - uint32_t CalculateTotalVertexSize(std::span p_attributes) - { - uint32_t result = 0; - - for (const auto& attribute : p_attributes) - { - result += GetDataTypeSizeInBytes(attribute.type) * attribute.count; - } - - return result; - } -} - -template<> -OvRendering::HAL::GLVertexArray::TVertexArray() -{ - glCreateVertexArrays(1, &m_context.id); -} - -template<> -OvRendering::HAL::GLVertexArray::~TVertexArray() -{ - glDeleteVertexArrays(1, &m_context.id); -} - -template<> -bool OvRendering::HAL::GLVertexArray::IsValid() const -{ - return m_context.attributeCount > 0; -} - -template<> -void OvRendering::HAL::GLVertexArray::Bind() const -{ - glBindVertexArray(m_context.id); -} - -template<> -void OvRendering::HAL::GLVertexArray::Unbind() const -{ - glBindVertexArray(0); -} - -template<> -void OvRendering::HAL::GLVertexArray::SetLayout( - Settings::VertexAttributeLayout p_attributes, - VertexBuffer& p_vertexBuffer, - IndexBuffer& p_indexBuffer -) -{ - OVASSERT(!IsValid(), "Vertex array layout already set"); - - Bind(); - p_indexBuffer.Bind(); - p_vertexBuffer.Bind(); - - uint32_t attributeIndex = 0; - - const uint32_t totalSize = CalculateTotalVertexSize(p_attributes); - intptr_t currentOffset = 0; - - for (const auto& attribute : p_attributes) - { - OVASSERT(attribute.count >= 1 && attribute.count <= 4, "Attribute count must be between 1 and 4"); - - glEnableVertexAttribArray(attributeIndex); - - const bool isIntegerType = - attribute.type != Settings::EDataType::FLOAT && - attribute.type != Settings::EDataType::DOUBLE; - - if (isIntegerType && !attribute.normalized) - { - glVertexAttribIPointer( - static_cast(attributeIndex), - static_cast(attribute.count), - EnumToValue(attribute.type), - static_cast(totalSize), - reinterpret_cast(currentOffset) - ); - } - else - { - glVertexAttribPointer( - static_cast(attributeIndex), - static_cast(attribute.count), - EnumToValue(attribute.type), - static_cast(attribute.normalized), - static_cast(totalSize), - reinterpret_cast(currentOffset) - ); - } - - const uint64_t typeSize = GetDataTypeSizeInBytes(attribute.type); - const uint64_t attributeSize = typeSize * attribute.count; - currentOffset += attributeSize; - ++attributeIndex; - ++m_context.attributeCount; - } - - Unbind(); - p_indexBuffer.Unbind(); - p_vertexBuffer.Unbind(); -} - -template<> -void OvRendering::HAL::GLVertexArray::ResetLayout() -{ - OVASSERT(IsValid(), "Vertex array layout not already set"); - - Bind(); - for (uint32_t i = 0; i < m_context.attributeCount; ++i) - { - glDisableVertexAttribArray(i); - } - m_context.attributeCount = 0; - Unbind(); -} - -template<> -uint32_t OvRendering::HAL::GLVertexArray::GetID() const -{ - return m_context.id; -} diff --git a/Sources/OvRendering/src/OvRendering/HAL/OpenGL/GLVertexBuffer.cpp b/Sources/OvRendering/src/OvRendering/HAL/OpenGL/GLVertexBuffer.cpp deleted file mode 100644 index 1a19c4658..000000000 --- a/Sources/OvRendering/src/OvRendering/HAL/OpenGL/GLVertexBuffer.cpp +++ /dev/null @@ -1,12 +0,0 @@ -/** -* @project: Overload -* @author: Overload Tech. -* @licence: MIT -*/ - -#include - -template<> -OvRendering::HAL::GLVertexBuffer::TVertexBuffer() : TBuffer(Settings::EBufferType::VERTEX) -{ -} diff --git a/Sources/OvRendering/src/OvRendering/Resources/Loaders/ShaderLoader.cpp b/Sources/OvRendering/src/OvRendering/Resources/Loaders/ShaderLoader.cpp index 0c678f06e..50bbdca32 100644 --- a/Sources/OvRendering/src/OvRendering/Resources/Loaders/ShaderLoader.cpp +++ b/Sources/OvRendering/src/OvRendering/Resources/Loaders/ShaderLoader.cpp @@ -6,6 +6,7 @@ #include #include +#include #include #include #include @@ -19,8 +20,8 @@ #include #include -#include -#include +#include +#include #include #include #include @@ -80,13 +81,13 @@ namespace struct ShaderStageDesc { const std::string source; - const OvRendering::Settings::EShaderType type; + const baregl::types::EShaderType type; }; struct ProcessedShaderStage { - const OvRendering::HAL::ShaderStage stage; - std::optional compilationResult; + const baregl::ShaderStage stage; + std::optional compilationResult; }; std::string Trim(const std::string_view p_str) @@ -158,7 +159,7 @@ namespace return result; } - std::unique_ptr CreateProgram( + std::unique_ptr CreateProgram( const ShaderInputInfo& p_shaderInputInfo, std::span p_stages, const std::string_view p_pass, @@ -167,8 +168,7 @@ namespace ) { // Process and compile all shader stages - std::vector processedStages; - processedStages.reserve(p_stages.size()); + std::deque processedStages; bool compilationFailed = false; @@ -219,7 +219,7 @@ namespace } // Link the program - auto program = std::make_unique(); + auto program = std::make_unique(); // Attach all stages for (const auto& processedStage : processedStages) @@ -267,7 +267,7 @@ namespace } } - std::unique_ptr CreateDefaultProgram() + std::unique_ptr CreateDefaultProgram() { const std::string vertex = R"( #version 450 core @@ -292,8 +292,8 @@ void main() )"; auto shaders = std::array{ - ShaderStageDesc{vertex, OvRendering::Settings::EShaderType::VERTEX}, - ShaderStageDesc{fragment, OvRendering::Settings::EShaderType::FRAGMENT} + ShaderStageDesc{vertex, baregl::types::EShaderType::VERTEX}, + ShaderStageDesc{fragment, baregl::types::EShaderType::FRAGMENT} }; auto program = CreateProgram( @@ -381,17 +381,15 @@ void main() */ ShaderParseResult ParseShader(const ShaderLoadResult& p_shaderLoadResult) { - using namespace OvRendering::Settings; - std::istringstream stream(p_shaderLoadResult.source); // Add this line to create a stringstream from shaderCode std::string line; - std::unordered_map shaderSources; + std::unordered_map shaderSources; OvRendering::Data::FeatureSet userFeatures; OvRendering::Data::FeatureSet engineFeatures; std::unordered_set passes; passes.emplace(); // Default pass if none is specified (empty string) - auto currentType = EShaderType::NONE; + auto currentType = baregl::types::EShaderType::NONE; while (std::getline(stream, line)) { @@ -444,13 +442,13 @@ void main() } else if (trimmedLine.starts_with(Grammar::kVertexShaderToken)) { - currentType = EShaderType::VERTEX; + currentType = baregl::types::EShaderType::VERTEX; } else if (trimmedLine.starts_with(Grammar::kFragmentShaderToken)) { - currentType = EShaderType::FRAGMENT; + currentType = baregl::types::EShaderType::FRAGMENT; } - else if (currentType != EShaderType::NONE) + else if (currentType != baregl::types::EShaderType::NONE) { shaderSources[currentType] << line << '\n'; } @@ -458,8 +456,8 @@ void main() return ShaderParseResult{ .inputInfo = p_shaderLoadResult.inputInfo, - .vertexShader = shaderSources[EShaderType::VERTEX].str(), - .fragmentShader = shaderSources[EShaderType::FRAGMENT].str(), + .vertexShader = shaderSources[baregl::types::EShaderType::VERTEX].str(), + .fragmentShader = shaderSources[baregl::types::EShaderType::FRAGMENT].str(), .passes = passes, .userFeatures = userFeatures, .engineFeatures = engineFeatures @@ -502,8 +500,8 @@ void main() } const auto stages = std::to_array({ - { p_parseResult.vertexShader, OvRendering::Settings::EShaderType::VERTEX }, - { p_parseResult.fragmentShader, OvRendering::Settings::EShaderType::FRAGMENT } + { p_parseResult.vertexShader, baregl::types::EShaderType::VERTEX }, + { p_parseResult.fragmentShader, baregl::types::EShaderType::FRAGMENT } }); auto program = CreateProgram( diff --git a/Sources/OvRendering/src/OvRendering/Resources/Loaders/TextureLoader.cpp b/Sources/OvRendering/src/OvRendering/Resources/Loaders/TextureLoader.cpp index 0daffbd64..08bb431b9 100644 --- a/Sources/OvRendering/src/OvRendering/Resources/Loaders/TextureLoader.cpp +++ b/Sources/OvRendering/src/OvRendering/Resources/Loaders/TextureLoader.cpp @@ -15,19 +15,19 @@ namespace { void PrepareTexture( - OvRendering::HAL::Texture& p_texture, + baregl::Texture& p_texture, const void* p_data, - OvRendering::Settings::ETextureFilteringMode p_minFilter, - OvRendering::Settings::ETextureFilteringMode p_magFilter, - OvRendering::Settings::ETextureWrapMode p_horizontalWrapMode, - OvRendering::Settings::ETextureWrapMode p_verticalWrapMode, + baregl::types::ETextureFilteringMode p_minFilter, + baregl::types::ETextureFilteringMode p_magFilter, + baregl::types::ETextureWrapMode p_horizontalWrapMode, + baregl::types::ETextureWrapMode p_verticalWrapMode, uint32_t p_width, uint32_t p_height, bool p_generateMipmap, bool p_hdr ) { - using namespace OvRendering::Settings; + using namespace baregl::types; p_texture.Allocate({ .width = p_width, @@ -51,17 +51,17 @@ namespace OvRendering::Resources::Texture* OvRendering::Resources::Loaders::TextureLoader::Create( const std::string& p_filepath, - OvRendering::Settings::ETextureFilteringMode p_minFilter, - OvRendering::Settings::ETextureFilteringMode p_magFilter, - OvRendering::Settings::ETextureWrapMode p_horizontalWrapMode, - OvRendering::Settings::ETextureWrapMode p_verticalWrapMode, + baregl::types::ETextureFilteringMode p_minFilter, + baregl::types::ETextureFilteringMode p_magFilter, + baregl::types::ETextureWrapMode p_horizontalWrapMode, + baregl::types::ETextureWrapMode p_verticalWrapMode, bool p_generateMipmap ) { if (Data::Image image{ p_filepath }) { - auto texture = std::make_unique( - Settings::ETextureType::TEXTURE_2D, + auto texture = std::make_unique( + baregl::types::ETextureType::TEXTURE_2D, OvTools::Utils::PathParser::GetElementName(p_filepath) ); @@ -95,10 +95,10 @@ OvRendering::Resources::Texture* OvRendering::Resources::Loaders::TextureLoader: return OvRendering::Resources::Loaders::TextureLoader::CreateFromMemory( colorData.data(), 1, 1, - OvRendering::Settings::ETextureFilteringMode::NEAREST, - OvRendering::Settings::ETextureFilteringMode::NEAREST, - OvRendering::Settings::ETextureWrapMode::REPEAT, - OvRendering::Settings::ETextureWrapMode::REPEAT, + baregl::types::ETextureFilteringMode::NEAREST, + baregl::types::ETextureFilteringMode::NEAREST, + baregl::types::ETextureWrapMode::REPEAT, + baregl::types::ETextureWrapMode::REPEAT, false ); } @@ -107,14 +107,14 @@ OvRendering::Resources::Texture* OvRendering::Resources::Loaders::TextureLoader: const uint8_t* p_data, uint32_t p_width, uint32_t p_height, - OvRendering::Settings::ETextureFilteringMode p_minFilter, - OvRendering::Settings::ETextureFilteringMode p_magFilter, - OvRendering::Settings::ETextureWrapMode p_horizontalWrapMode, - OvRendering::Settings::ETextureWrapMode p_verticalWrapMode, + baregl::types::ETextureFilteringMode p_minFilter, + baregl::types::ETextureFilteringMode p_magFilter, + baregl::types::ETextureWrapMode p_horizontalWrapMode, + baregl::types::ETextureWrapMode p_verticalWrapMode, bool p_generateMipmap ) { - auto texture = std::make_unique(Settings::ETextureType::TEXTURE_2D, "FromMemory"); + auto texture = std::make_unique(baregl::types::ETextureType::TEXTURE_2D, "FromMemory"); PrepareTexture( *texture, @@ -135,16 +135,16 @@ OvRendering::Resources::Texture* OvRendering::Resources::Loaders::TextureLoader: OvRendering::Resources::Texture* OvRendering::Resources::Loaders::TextureLoader::CreateFromEncodedMemory( const uint8_t* p_data, size_t p_size, - OvRendering::Settings::ETextureFilteringMode p_minFilter, - OvRendering::Settings::ETextureFilteringMode p_magFilter, - OvRendering::Settings::ETextureWrapMode p_horizontalWrapMode, - OvRendering::Settings::ETextureWrapMode p_verticalWrapMode, + baregl::types::ETextureFilteringMode p_minFilter, + baregl::types::ETextureFilteringMode p_magFilter, + baregl::types::ETextureWrapMode p_horizontalWrapMode, + baregl::types::ETextureWrapMode p_verticalWrapMode, bool p_generateMipmap ) { if (Data::Image image{ p_data, p_size }) { - auto texture = std::make_unique(Settings::ETextureType::TEXTURE_2D, "FromEncodedMemory"); + auto texture = std::make_unique(baregl::types::ETextureType::TEXTURE_2D, "FromEncodedMemory"); PrepareTexture( *texture, @@ -168,17 +168,17 @@ OvRendering::Resources::Texture* OvRendering::Resources::Loaders::TextureLoader: void OvRendering::Resources::Loaders::TextureLoader::Reload( Texture& p_texture, const std::string& p_filePath, - OvRendering::Settings::ETextureFilteringMode p_minFilter, - OvRendering::Settings::ETextureFilteringMode p_magFilter, - OvRendering::Settings::ETextureWrapMode p_horizontalWrapMode, - OvRendering::Settings::ETextureWrapMode p_verticalWrapMode, + baregl::types::ETextureFilteringMode p_minFilter, + baregl::types::ETextureFilteringMode p_magFilter, + baregl::types::ETextureWrapMode p_horizontalWrapMode, + baregl::types::ETextureWrapMode p_verticalWrapMode, bool p_generateMipmap ) { if (Data::Image image{ p_filePath }) { - auto texture = std::make_unique( - Settings::ETextureType::TEXTURE_2D, + auto texture = std::make_unique( + baregl::types::ETextureType::TEXTURE_2D, OvTools::Utils::PathParser::GetElementName(p_filePath) ); @@ -204,14 +204,14 @@ void OvRendering::Resources::Loaders::TextureLoader::ReloadFromMemory( const uint8_t* p_data, uint32_t p_width, uint32_t p_height, - OvRendering::Settings::ETextureFilteringMode p_minFilter, - OvRendering::Settings::ETextureFilteringMode p_magFilter, - OvRendering::Settings::ETextureWrapMode p_horizontalWrapMode, - OvRendering::Settings::ETextureWrapMode p_verticalWrapMode, + baregl::types::ETextureFilteringMode p_minFilter, + baregl::types::ETextureFilteringMode p_magFilter, + baregl::types::ETextureWrapMode p_horizontalWrapMode, + baregl::types::ETextureWrapMode p_verticalWrapMode, bool p_generateMipmap ) { - auto texture = std::make_unique(Settings::ETextureType::TEXTURE_2D, "FromMemory"); + auto texture = std::make_unique(baregl::types::ETextureType::TEXTURE_2D, "FromMemory"); PrepareTexture( *texture, @@ -233,16 +233,16 @@ void OvRendering::Resources::Loaders::TextureLoader::ReloadFromEncodedMemory( Texture& p_texture, const uint8_t* p_data, size_t p_size, - OvRendering::Settings::ETextureFilteringMode p_minFilter, - OvRendering::Settings::ETextureFilteringMode p_magFilter, - OvRendering::Settings::ETextureWrapMode p_horizontalWrapMode, - OvRendering::Settings::ETextureWrapMode p_verticalWrapMode, + baregl::types::ETextureFilteringMode p_minFilter, + baregl::types::ETextureFilteringMode p_magFilter, + baregl::types::ETextureWrapMode p_horizontalWrapMode, + baregl::types::ETextureWrapMode p_verticalWrapMode, bool p_generateMipmap ) { if (Data::Image image{ p_data, p_size }) { - auto texture = std::make_unique(Settings::ETextureType::TEXTURE_2D, "FromEncodedMemory"); + auto texture = std::make_unique(baregl::types::ETextureType::TEXTURE_2D, "FromEncodedMemory"); PrepareTexture( *texture, diff --git a/Sources/OvRendering/src/OvRendering/Resources/Mesh.cpp b/Sources/OvRendering/src/OvRendering/Resources/Mesh.cpp index 7b07de86b..d73308c29 100644 --- a/Sources/OvRendering/src/OvRendering/Resources/Mesh.cpp +++ b/Sources/OvRendering/src/OvRendering/Resources/Mesh.cpp @@ -121,14 +121,6 @@ bool OvRendering::Resources::Mesh::HasSkinningData() const void OvRendering::Resources::Mesh::Upload(std::span p_vertices, std::span p_indices) { - const auto layout = std::to_array({ - { Settings::EDataType::FLOAT, 3 }, // position - { Settings::EDataType::FLOAT, 2 }, // texCoords - { Settings::EDataType::FLOAT, 3 }, // normal - { Settings::EDataType::FLOAT, 3 }, // tangent - { Settings::EDataType::FLOAT, 3 } // bitangent - }); - if (m_vertexBuffer.Allocate(p_vertices.size_bytes())) { m_vertexBuffer.Upload(p_vertices.data()); @@ -136,7 +128,13 @@ void OvRendering::Resources::Mesh::Upload(std::span p_ve if (m_indexBuffer.Allocate(p_indices.size_bytes())) { m_indexBuffer.Upload(p_indices.data()); - m_vertexArray.SetLayout(layout, m_vertexBuffer, m_indexBuffer); + m_vertexArray.SetLayout({ + baregl::data::FloatVertexAttribute{ baregl::types::EDataType::FLOAT, 3 }, // position + baregl::data::FloatVertexAttribute{ baregl::types::EDataType::FLOAT, 2 }, // texCoords + baregl::data::FloatVertexAttribute{ baregl::types::EDataType::FLOAT, 3 }, // normal + baregl::data::FloatVertexAttribute{ baregl::types::EDataType::FLOAT, 3 }, // tangent + baregl::data::FloatVertexAttribute{ baregl::types::EDataType::FLOAT, 3 }, // bitangent + }, m_vertexBuffer, m_indexBuffer); } else { @@ -151,16 +149,6 @@ void OvRendering::Resources::Mesh::Upload(std::span p_ve void OvRendering::Resources::Mesh::Upload(std::span p_vertices, std::span p_indices) { - const auto layout = std::to_array({ - { Settings::EDataType::FLOAT, 3 }, // position - { Settings::EDataType::FLOAT, 2 }, // texCoords - { Settings::EDataType::FLOAT, 3 }, // normal - { Settings::EDataType::FLOAT, 3 }, // tangent - { Settings::EDataType::FLOAT, 3 }, // bitangent - { Settings::EDataType::UNSIGNED_INT, 4 }, // boneIDs - { Settings::EDataType::FLOAT, 4 } // boneWeights - }); - if (m_vertexBuffer.Allocate(p_vertices.size_bytes())) { m_vertexBuffer.Upload(p_vertices.data()); @@ -168,7 +156,15 @@ void OvRendering::Resources::Mesh::Upload(std::span p_pass, const Data::FeatureSet& p_featureSet) +baregl::ShaderProgram& OvRendering::Resources::Shader::GetVariant(std::optional p_pass, const Data::FeatureSet& p_featureSet) { ZoneScoped; diff --git a/Sources/OvRendering/src/OvRendering/Resources/Texture.cpp b/Sources/OvRendering/src/OvRendering/Resources/Texture.cpp index e114f76b6..e9bb9673e 100644 --- a/Sources/OvRendering/src/OvRendering/Resources/Texture.cpp +++ b/Sources/OvRendering/src/OvRendering/Resources/Texture.cpp @@ -7,18 +7,18 @@ #include #include -OvRendering::HAL::Texture& OvRendering::Resources::Texture::GetTexture() +baregl::Texture& OvRendering::Resources::Texture::GetTexture() { OVASSERT(m_texture != nullptr, "Trying to access a null Texture"); return *m_texture; } -OvRendering::Resources::Texture::Texture(const std::string p_path, std::unique_ptr&& p_texture) : path(p_path) +OvRendering::Resources::Texture::Texture(const std::string p_path, std::unique_ptr&& p_texture) : path(p_path) { SetTexture(std::move(p_texture)); } -void OvRendering::Resources::Texture::SetTexture(std::unique_ptr&& p_texture) +void OvRendering::Resources::Texture::SetTexture(std::unique_ptr&& p_texture) { OVASSERT(p_texture != nullptr, "Cannot assign an invalid texture!"); m_texture = std::move(p_texture); diff --git a/Sources/OvRendering/src/OvRendering/Utils/ResourceTracking.cpp b/Sources/OvRendering/src/OvRendering/Utils/ResourceTracking.cpp new file mode 100644 index 000000000..e61a635e0 --- /dev/null +++ b/Sources/OvRendering/src/OvRendering/Utils/ResourceTracking.cpp @@ -0,0 +1,87 @@ +/** +* @project: Overload +* @author: Overload Tech. +* @licence: MIT +*/ + +#include + +#include + +#include + +#include + +namespace OvRendering::Utils::ResourceTracking +{ + OvTools::Eventing::Event TextureAddedEvent; + OvTools::Eventing::Event TextureRemovedEvent; +} + +namespace +{ + std::unordered_map m_textures; + std::vector m_quickAccessTextureIDs; + + class EventHandler : public baregl::debug::IEventHandler + { + public: + virtual void OnBufferCreated([[maybe_unused]] const baregl::Buffer&) override {} + virtual void OnBufferDestroyed([[maybe_unused]] const baregl::Buffer&) override {} + virtual void OnFramebufferCreated([[maybe_unused]] const baregl::Framebuffer&) override {} + virtual void OnFramebufferDestroyed([[maybe_unused]] const baregl::Framebuffer&) override {} + virtual void OnRenderbufferCreated([[maybe_unused]] const baregl::Renderbuffer&) override {} + virtual void OnRenderbufferDestroyed([[maybe_unused]] const baregl::Renderbuffer&) override {} + virtual void OnShaderProgramCreated([[maybe_unused]] const baregl::ShaderProgram&) override {} + virtual void OnShaderProgramDestroyed([[maybe_unused]] const baregl::ShaderProgram&) override {} + virtual void OnShaderStageCreated([[maybe_unused]] const baregl::ShaderStage&) override {} + virtual void OnShaderStageDestroyed([[maybe_unused]] const baregl::ShaderStage&) override {} + virtual void OnVertexArrayCreated([[maybe_unused]] const baregl::VertexArray&) override {} + virtual void OnVertexArrayDestroyed([[maybe_unused]] const baregl::VertexArray&) override {} + + virtual void OnTextureCreated(const baregl::Texture& p_texture) override + { + const auto id = p_texture.GetID(); + if (id != 0) + { + m_quickAccessTextureIDs.push_back(id); + m_textures[id] = &p_texture; + OvRendering::Utils::ResourceTracking::TextureAddedEvent.Invoke({ id, &p_texture }); + } + } + + virtual void OnTextureDestroyed(const baregl::Texture& p_texture) override + { + const auto id = p_texture.GetID(); + if (id != 0) + { + m_quickAccessTextureIDs.erase(std::ranges::find(m_quickAccessTextureIDs, id)); + m_textures.erase(id); + OvRendering::Utils::ResourceTracking::TextureRemovedEvent.Invoke({ id, &p_texture }); + } + } + }; +} + +namespace OvRendering::Utils::ResourceTracking +{ + void TrackResources() + { + baregl::debug::SetEventHandler(std::make_unique()); + } + + OvTools::Utils::OptRef GetTexture(uint32_t p_id) + { + if (m_textures.contains(p_id)) + { + return OvTools::Utils::OptRef(*m_textures.at(p_id)); + } + + return std::nullopt; + } + + std::span GetTextureIDs() + { + return m_quickAccessTextureIDs; + } +} diff --git a/Sources/OvRendering/src/OvRendering/Utils/ShaderUtil.cpp b/Sources/OvRendering/src/OvRendering/Utils/ShaderUtil.cpp index fe19c7cbb..3158d81cc 100644 --- a/Sources/OvRendering/src/OvRendering/Utils/ShaderUtil.cpp +++ b/Sources/OvRendering/src/OvRendering/Utils/ShaderUtil.cpp @@ -4,17 +4,17 @@ * @licence: MIT */ -#include "OvRendering/Utils/ShaderUtil.h" +#include namespace OvRendering::Utils { - std::string GetShaderTypeName(Settings::EShaderType p_type) + std::string GetShaderTypeName(baregl::types::EShaderType p_type) { switch (p_type) { - case OvRendering::Settings::EShaderType::VERTEX: return "Vertex"; - case OvRendering::Settings::EShaderType::FRAGMENT: return "Fragment"; - default: return "None"; + case baregl::types::EShaderType::VERTEX: return "Vertex"; + case baregl::types::EShaderType::FRAGMENT: return "Fragment"; + default: return "None"; } } } diff --git a/premake5.lua b/premake5.lua index 921dc6a03..471efcd54 100644 --- a/premake5.lua +++ b/premake5.lua @@ -18,7 +18,6 @@ workspace "Overload" startproject "OvEditor" defines { "LUA_SCRIPTING", - "GRAPHICS_API_OPENGL", "OVERLOAD_VERSION=\"" .. version .. "\"", "SOL_NO_LUA_HPP" } @@ -54,11 +53,11 @@ group "Dependencies" include "Dependencies/tracy" include "Dependencies/lua" include "Dependencies/freetype" - include "Dependencies/glad" include "Dependencies/soloud" include "Dependencies/assimp" include "Dependencies/glfw" include "Dependencies/bullet3" + include "Dependencies/baregl" group "" group "Dependencies/Prebuilt"