mirror of
https://github.com/love2d/love.git
synced 2026-08-16 16:20:42 +02:00
partially implement initCapabilities for vulkan
This commit is contained in:
@@ -207,13 +207,17 @@ namespace love {
|
||||
}
|
||||
|
||||
void Graphics::setViewportSize(int width, int height, int pixelwidth, int pixelheight) {
|
||||
std::cout << "setViewPortSize";
|
||||
std::cout << "setViewPortSize ";
|
||||
recreateSwapChain();
|
||||
}
|
||||
|
||||
bool Graphics::setMode(void* context, int width, int height, int pixelwidth, int pixelheight, bool windowhasstencil, int msaa) {
|
||||
std::cout << "setMode ";
|
||||
|
||||
initCapabilities();
|
||||
|
||||
created = true;
|
||||
|
||||
if (batchedDrawState.vb[0] == nullptr)
|
||||
{
|
||||
// Initial sizes that should be good enough for most cases. It will
|
||||
@@ -226,6 +230,59 @@ namespace love {
|
||||
return true;
|
||||
}
|
||||
|
||||
void Graphics::initCapabilities() {
|
||||
std::cout << "initCapabilities ";
|
||||
|
||||
VkPhysicalDeviceProperties properties;
|
||||
vkGetPhysicalDeviceProperties(physicalDevice, &properties);
|
||||
|
||||
// todo
|
||||
capabilities.features[FEATURE_MULTI_RENDER_TARGET_FORMATS] = false;
|
||||
capabilities.features[FEATURE_CLAMP_ZERO] = false;
|
||||
capabilities.features[FEATURE_CLAMP_ONE] = false;
|
||||
capabilities.features[FEATURE_BLEND_MINMAX] = false;
|
||||
capabilities.features[FEATURE_LIGHTEN] = false;
|
||||
capabilities.features[FEATURE_FULL_NPOT] = false;
|
||||
capabilities.features[FEATURE_PIXEL_SHADER_HIGHP] = false;
|
||||
capabilities.features[FEATURE_SHADER_DERIVATIVES] = false;
|
||||
capabilities.features[FEATURE_GLSL3] = false;
|
||||
capabilities.features[FEATURE_GLSL4] = false;
|
||||
capabilities.features[FEATURE_INSTANCING] = false;
|
||||
capabilities.features[FEATURE_TEXEL_BUFFER] = false;
|
||||
capabilities.features[FEATURE_INDEX_BUFFER_32BIT] = true;
|
||||
capabilities.features[FEATURE_COPY_BUFFER] = false;
|
||||
capabilities.features[FEATURE_COPY_BUFFER_TO_TEXTURE] = false;
|
||||
capabilities.features[FEATURE_COPY_TEXTURE_TO_BUFFER] = false;
|
||||
capabilities.features[FEATURE_COPY_RENDER_TARGET_TO_BUFFER] = false;
|
||||
static_assert(FEATURE_MAX_ENUM == 17, "Graphics::initCapabilities must be updated when adding a new graphics feature!");
|
||||
|
||||
capabilities.limits[LIMIT_POINT_SIZE] = properties.limits.pointSizeRange[1];
|
||||
capabilities.limits[LIMIT_TEXTURE_SIZE] = properties.limits.maxImageDimension2D;
|
||||
capabilities.limits[LIMIT_TEXTURE_LAYERS] = properties.limits.maxImageArrayLayers;
|
||||
capabilities.limits[LIMIT_VOLUME_TEXTURE_SIZE] = properties.limits.maxImageDimension3D;
|
||||
capabilities.limits[LIMIT_CUBE_TEXTURE_SIZE] = properties.limits.maxImageDimensionCube;
|
||||
capabilities.limits[LIMIT_TEXEL_BUFFER_SIZE] = properties.limits.maxTexelBufferElements; // ?
|
||||
capabilities.limits[LIMIT_SHADER_STORAGE_BUFFER_SIZE] = properties.limits.maxStorageBufferRange; // ?
|
||||
capabilities.limits[LIMIT_THREADGROUPS_X] = 0; // todo
|
||||
capabilities.limits[LIMIT_THREADGROUPS_Y] = 0; // todo
|
||||
capabilities.limits[LIMIT_THREADGROUPS_Z] = 0; // todo
|
||||
capabilities.limits[LIMIT_RENDER_TARGETS] = 1; // todo
|
||||
capabilities.limits[LIMIT_TEXTURE_MSAA] = 1; // todo
|
||||
capabilities.limits[LIMIT_ANISOTROPY] = 1.0f; // todo
|
||||
static_assert(LIMIT_MAX_ENUM == 13, "Graphics::initCapabilities must be updated when adding a new system limit!");
|
||||
|
||||
capabilities.textureTypes[TEXTURE_2D] = true;
|
||||
capabilities.textureTypes[TEXTURE_VOLUME] = false;
|
||||
capabilities.textureTypes[TEXTURE_2D_ARRAY] = false;
|
||||
capabilities.textureTypes[TEXTURE_CUBE] = false;
|
||||
}
|
||||
|
||||
void Graphics::unSetMode() {
|
||||
created = false;
|
||||
|
||||
std::cout << "unSetMode ";
|
||||
}
|
||||
|
||||
void Graphics::draw(const DrawIndexedCommand& cmd) {
|
||||
std::cout << "drawIndexed ";
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#include "StreamBuffer.h"
|
||||
#include "ShaderStage.h"
|
||||
#include "Shader.h"
|
||||
#include "Texture.h"
|
||||
#include <vulkan/vulkan.h>
|
||||
#include "vk_mem_alloc.h"
|
||||
|
||||
@@ -37,7 +38,7 @@ namespace love {
|
||||
}
|
||||
|
||||
// implementation for virtual functions
|
||||
Texture* newTexture(const Texture::Settings& settings, const Texture::Slices* data = nullptr) override { std::cout << "newTexture"; return nullptr; }
|
||||
Texture* newTexture(const Texture::Settings& settings, const Texture::Slices* data = nullptr) override { std::cout << "newTexture "; return new Texture(this, settings, data); }
|
||||
love::graphics::Buffer* newBuffer(const love::graphics::Buffer::Settings& settings, const std::vector<love::graphics::Buffer::DataDeclaration>& format, const void* data, size_t size, size_t arraylength) override;
|
||||
void clear(OptionalColorD color, OptionalInt stencil, OptionalDouble depth) override { std::cout << "clear1 "; }
|
||||
void clear(const std::vector<OptionalColorD>& colors, OptionalInt stencil, OptionalDouble depth) override { std::cout << "clear2 "; }
|
||||
@@ -46,7 +47,7 @@ namespace love {
|
||||
void present(void* screenshotCallbackdata) override;
|
||||
void setViewportSize(int width, int height, int pixelwidth, int pixelheight) override;
|
||||
bool setMode(void* context, int width, int height, int pixelwidth, int pixelheight, bool windowhasstencil, int msaa) override;
|
||||
void unSetMode() override { std::cout << "unSetMode "; }
|
||||
void unSetMode() override;
|
||||
void setActive(bool active) override { std::cout << "setActive "; }
|
||||
int getRequestedBackbufferMSAA() const override { std::cout << "getRequestedBackbufferMSAA "; return 0; }
|
||||
int getBackbufferMSAA() const override { std::cout << "getBackbufferMSAA "; return 0; }
|
||||
@@ -60,14 +61,14 @@ namespace love {
|
||||
void setBlendState(const BlendState& blend) override { std::cout << "setBlendState "; }
|
||||
void setPointSize(float size) override { std::cout << "setPointSize "; }
|
||||
void setWireframe(bool enable) override { std::cout << "setWireframe "; }
|
||||
PixelFormat getSizedFormat(PixelFormat format, bool rendertarget, bool readable) const override { std::cout << "getSizedFormat "; return PIXELFORMAT_UNKNOWN; }
|
||||
bool isPixelFormatSupported(PixelFormat format, PixelFormatUsageFlags usage, bool sRGB = false) override { std::cout << "isPixelFormatSupported "; return false; }
|
||||
PixelFormat getSizedFormat(PixelFormat format, bool rendertarget, bool readable) const override { std::cout << "getSizedFormat "; return format; }
|
||||
bool isPixelFormatSupported(PixelFormat format, PixelFormatUsageFlags usage, bool sRGB = false) override { std::cout << "isPixelFormatSupported "; return true; }
|
||||
Renderer getRenderer() const override { std::cout << "getRenderer "; return RENDERER_VULKAN; }
|
||||
bool usesGLSLES() const override { std::cout << "usesGLSES "; return false; }
|
||||
RendererInfo getRendererInfo() const override { std::cout << "getRendererInfo "; return {}; }
|
||||
void draw(const DrawCommand& cmd) override { std::cout << "draw "; }
|
||||
void draw(const DrawIndexedCommand& cmd) override;
|
||||
void drawQuads(int start, int count, const VertexAttributes& attributes, const BufferBindings& buffers, Texture* texture) override { std::cout << "drawQuads "; }
|
||||
void drawQuads(int start, int count, const VertexAttributes& attributes, const BufferBindings& buffers, graphics::Texture* texture) override { std::cout << "drawQuads "; }
|
||||
|
||||
protected:
|
||||
graphics::ShaderStage* newShaderStageInternal(ShaderStageType stage, const std::string& cachekey, const std::string& source, bool gles) override {
|
||||
@@ -80,7 +81,7 @@ namespace love {
|
||||
}
|
||||
graphics::StreamBuffer* newStreamBuffer(BufferUsage type, size_t size) override;
|
||||
bool dispatch(int x, int y, int z) override { std::cout << "dispatch "; return false; }
|
||||
void initCapabilities() override { std::cout << "initCapabilities "; }
|
||||
void initCapabilities() override;
|
||||
void getAPIStats(int& shaderswitches) const override { std::cout << "getAPIStats "; }
|
||||
void setRenderTargetsInternal(const RenderTargets& rts, int pixelw, int pixelh, bool hasSRGBtexture) override { std::cout << "setRenderTargetsInternal "; }
|
||||
|
||||
@@ -168,8 +169,6 @@ namespace love {
|
||||
uint32_t imageIndex;
|
||||
bool framebufferResized = false;
|
||||
VmaAllocator vmaAllocator;
|
||||
|
||||
friend class StreamBuffer;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,12 +33,12 @@ namespace love {
|
||||
|
||||
void updateUniform(const UniformInfo* info, int count) override {}
|
||||
|
||||
void sendTextures(const UniformInfo* info, Texture** textures, int count) override {}
|
||||
void sendTextures(const UniformInfo* info, graphics::Texture** textures, int count) override {}
|
||||
void sendBuffers(const UniformInfo* info, love::graphics::Buffer** buffers, int count) override {}
|
||||
|
||||
bool hasUniform(const std::string& name) const override { return false; }
|
||||
|
||||
void setVideoTextures(Texture* ytexture, Texture* cbtexture, Texture* crtexture) override {}
|
||||
void setVideoTextures(graphics::Texture* ytexture, graphics::Texture* cbtexture, graphics::Texture* crtexture) override {}
|
||||
|
||||
struct UniformBufferObject {
|
||||
float windowWidth;
|
||||
|
||||
@@ -6,6 +6,10 @@ namespace love {
|
||||
Texture::Texture(love::graphics::Graphics* gfx, const Settings& settings, const Slices* data)
|
||||
: love::graphics::Texture(gfx, settings, data) {
|
||||
}
|
||||
|
||||
void Texture::uploadByteData(PixelFormat pixelformat, const void* data, size_t size, int level, int slice, const Rect& r) {
|
||||
std::cout << "Texture::uploadByteData ";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "graphics/Texture.h"
|
||||
#include <iostream>
|
||||
|
||||
|
||||
namespace love {
|
||||
@@ -8,16 +9,19 @@ namespace love {
|
||||
public:
|
||||
Texture(love::graphics::Graphics* gfx, const Settings& settings, const Slices* data);
|
||||
|
||||
void copyFromBuffer(Buffer* source, size_t sourceoffset, int sourcewidth, size_t size, int slice, int mipmap, const Rect& rect) override {};
|
||||
void copyToBuffer(Buffer* dest, int slice, int mipmap, const Rect& rect, size_t destoffset, int destwidth, size_t size) override {};
|
||||
void copyFromBuffer(graphics::Buffer* source, size_t sourceoffset, int sourcewidth, size_t size, int slice, int mipmap, const Rect& rect) override { std::cout << "Texture::copyFromBuffer "; };
|
||||
void copyToBuffer(graphics::Buffer* dest, int slice, int mipmap, const Rect& rect, size_t destoffset, int destwidth, size_t size) override { std::cout << "Texture::copyToBuffer "; };
|
||||
|
||||
ptrdiff_t getRenderTargetHandle() const override { return (ptrdiff_t)0; };
|
||||
ptrdiff_t getSamplerHandle() const override { return (ptrdiff_t)0; };
|
||||
ptrdiff_t getRenderTargetHandle() const override { std::cout << "Texture::getRenderTargetHandle "; return (ptrdiff_t)0; };
|
||||
ptrdiff_t getSamplerHandle() const override { std::cout << "Texture::getSamplerHandle "; return (ptrdiff_t)0; };
|
||||
|
||||
void uploadByteData(PixelFormat pixelformat, const void* data, size_t size, int level, int slice, const Rect& r) override {};
|
||||
void uploadByteData(PixelFormat pixelformat, const void* data, size_t size, int level, int slice, const Rect& r) override;
|
||||
|
||||
void generateMipmapsInternal() override {};
|
||||
void readbackImageData(love::image::ImageData* imagedata, int slice, int mipmap, const Rect& rect) override {};
|
||||
void generateMipmapsInternal() override { std::cout << "Texture::generateMipmapsInternal "; };
|
||||
void readbackImageData(love::image::ImageData* imagedata, int slice, int mipmap, const Rect& rect) override { std::cout << "Texture::readbackImageData "; };
|
||||
|
||||
int getMSAA() const override { std::cout << "Texture::getMSAA "; return 0; };
|
||||
ptrdiff_t getHandle() const override { std::cout << "Texture::getHandle "; return (ptrdiff_t)0; }
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user