GLSL bindings and Vulkan bug fixes

This commit is contained in:
Jack Andersen
2016-02-23 17:11:58 -10:00
parent 74e2f47bcf
commit 6de30424e3
13 changed files with 301 additions and 96 deletions

View File

@@ -51,7 +51,7 @@ public:
virtual const std::vector<SystemString>& getArgs() const=0;
/* Constructors/initializers for sub-objects */
virtual IWindow* newWindow(const SystemString& title)=0;
virtual IWindow* newWindow(const SystemString& title, uint32_t drawSamples)=0;
};

View File

@@ -4,6 +4,7 @@
#include "IGraphicsDataFactory.hpp"
#include "IGraphicsCommandQueue.hpp"
#include "boo/IGraphicsContext.hpp"
#include "GLSLMacros.hpp"
#include <vector>
#include <unordered_set>
#include <mutex>
@@ -15,6 +16,7 @@ class GLDataFactory : public IGraphicsDataFactory
{
friend struct GLCommandQueue;
IGraphicsContext* m_parent;
uint32_t m_drawSamples;
static ThreadLocalPtr<struct GLData> m_deferredData;
std::unordered_set<struct GLData*> m_committedData;
std::mutex m_committedMutex;
@@ -22,7 +24,7 @@ class GLDataFactory : public IGraphicsDataFactory
void destroyData(IGraphicsData*);
void destroyAllData();
public:
GLDataFactory(IGraphicsContext* parent);
GLDataFactory(IGraphicsContext* parent, uint32_t drawSamples);
~GLDataFactory() {destroyAllData();}
Platform platform() const {return Platform::OGL;}
@@ -39,7 +41,7 @@ public:
ITextureSA* newStaticArrayTexture(size_t width, size_t height, size_t layers, TextureFormat fmt,
const void* data, size_t sz);
ITextureD* newDynamicTexture(size_t width, size_t height, TextureFormat fmt);
ITextureR* newRenderTexture(size_t width, size_t height, size_t samples);
ITextureR* newRenderTexture(size_t width, size_t height);
bool bindingNeedsVertexFormat() const {return true;}
IVertexFormat* newVertexFormat(size_t elementCount, const VertexElementDescriptor* elements);

View File

@@ -0,0 +1,45 @@
#ifndef GDEV_GLSLMACROS_HPP
#define GDEV_GLSLMACROS_HPP
#define BOO_GLSL_MAX_UNIFORM_COUNT 8
#define BOO_GLSL_MAX_TEXTURE_COUNT 8
#define BOO_GLSL_BINDING_HEAD \
"#extension GL_ARB_shading_language_420pack: enable\n" \
"#ifdef GL_ARB_shading_language_420pack\n" \
"#define UBINDING0 layout(binding=0)\n" \
"#define UBINDING1 layout(binding=1)\n" \
"#define UBINDING2 layout(binding=2)\n" \
"#define UBINDING3 layout(binding=3)\n" \
"#define UBINDING4 layout(binding=4)\n" \
"#define UBINDING5 layout(binding=5)\n" \
"#define UBINDING6 layout(binding=6)\n" \
"#define UBINDING7 layout(binding=7)\n" \
"#define TBINDING0 layout(binding=8)\n" \
"#define TBINDING1 layout(binding=9)\n" \
"#define TBINDING2 layout(binding=10)\n" \
"#define TBINDING3 layout(binding=11)\n" \
"#define TBINDING4 layout(binding=12)\n" \
"#define TBINDING5 layout(binding=13)\n" \
"#define TBINDING6 layout(binding=14)\n" \
"#define TBINDING7 layout(binding=15)\n" \
"#else\n" \
"#define UBINDING0\n" \
"#define UBINDING1\n" \
"#define UBINDING2\n" \
"#define UBINDING3\n" \
"#define UBINDING4\n" \
"#define UBINDING5\n" \
"#define UBINDING6\n" \
"#define UBINDING7\n" \
"#define TBINDING0\n" \
"#define TBINDING1\n" \
"#define TBINDING2\n" \
"#define TBINDING3\n" \
"#define TBINDING4\n" \
"#define TBINDING5\n" \
"#define TBINDING6\n" \
"#define TBINDING7\n" \
"#endif\n"
#endif // GDEV_GLSLMACROS_HPP

View File

@@ -208,7 +208,7 @@ struct IGraphicsDataFactory
virtual ITextureD*
newDynamicTexture(size_t width, size_t height, TextureFormat fmt)=0;
virtual ITextureR*
newRenderTexture(size_t width, size_t height, size_t samples)=0;
newRenderTexture(size_t width, size_t height)=0;
virtual bool bindingNeedsVertexFormat() const=0;
virtual IVertexFormat*

View File

@@ -5,6 +5,7 @@
#include "IGraphicsDataFactory.hpp"
#include "IGraphicsCommandQueue.hpp"
#include "boo/IGraphicsContext.hpp"
#include "GLSLMacros.hpp"
#include <vector>
#include <unordered_set>
#include <unordered_map>
@@ -36,7 +37,7 @@ struct VulkanContext
std::vector<VkQueueFamilyProperties> m_queueProps;
VkQueue m_queue;
VkDescriptorSetLayout m_descSetLayout;
VkPipelineLayout m_layout;
VkPipelineLayout m_pipelinelayout;
VkRenderPass m_pass;
VkCommandPool m_loadPool;
VkCommandBuffer m_loadCmdBuf;
@@ -72,6 +73,7 @@ class VulkanDataFactory : public IGraphicsDataFactory
friend struct VulkanCommandQueue;
IGraphicsContext* m_parent;
VulkanContext* m_ctx;
uint32_t m_drawSamples;
static ThreadLocalPtr<struct VulkanData> m_deferredData;
std::unordered_set<struct VulkanData*> m_committedData;
std::mutex m_committedMutex;
@@ -79,7 +81,7 @@ class VulkanDataFactory : public IGraphicsDataFactory
void destroyData(IGraphicsData*);
void destroyAllData();
public:
VulkanDataFactory(IGraphicsContext* parent, VulkanContext* ctx);
VulkanDataFactory(IGraphicsContext* parent, VulkanContext* ctx, uint32_t drawSamples);
~VulkanDataFactory() {destroyAllData();}
Platform platform() const {return Platform::Vulkan;}
@@ -95,7 +97,7 @@ public:
ITextureSA* newStaticArrayTexture(size_t width, size_t height, size_t layers, TextureFormat fmt,
const void* data, size_t sz);
ITextureD* newDynamicTexture(size_t width, size_t height, TextureFormat fmt);
ITextureR* newRenderTexture(size_t width, size_t height, size_t samples);
ITextureR* newRenderTexture(size_t width, size_t height);
bool bindingNeedsVertexFormat() const {return true;}
IVertexFormat* newVertexFormat(size_t elementCount, const VertexElementDescriptor* elements);