vulkan: implement setPointSize

This commit is contained in:
niki
2022-07-13 16:05:12 +02:00
parent 4190807a20
commit 04fb789649
2 changed files with 71 additions and 54 deletions
+68 -49
View File
@@ -72,60 +72,15 @@ namespace love {
// START OVERRIDEN FUNCTIONS
love::graphics::Texture* Graphics::newTexture(const love::graphics::Texture::Settings& settings, const love::graphics::Texture::Slices* data) {
return new Texture(this, settings, data);
}
love::graphics::Buffer* Graphics::newBuffer(const love::graphics::Buffer::Settings& settings, const std::vector<love::graphics::Buffer::DataDeclaration>& format, const void* data, size_t size, size_t arraylength) {
std::cout << "newBuffer ";
return new Buffer(vmaAllocator, this, settings, format, data, size, arraylength);
}
void Graphics::startRecordingGraphicsCommands() {
vkWaitForFences(device, 1, &inFlightFences[currentFrame], VK_TRUE, UINT64_MAX);
while (true) {
VkResult result = vkAcquireNextImageKHR(device, swapChain, UINT64_MAX, imageAvailableSemaphores[currentFrame], VK_NULL_HANDLE, &imageIndex);
if (result == VK_ERROR_OUT_OF_DATE_KHR) {
recreateSwapChain();
continue;
}
else if (result != VK_SUCCESS && result != VK_SUBOPTIMAL_KHR) {
throw love::Exception("failed to acquire swap chain image");
}
break;
}
VkCommandBufferBeginInfo beginInfo{};
beginInfo.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO;
beginInfo.flags = 0;
beginInfo.pInheritanceInfo = nullptr;
std::cout << "beginCommandBuffer(imageIndex=" << imageIndex << ") ";
if (vkBeginCommandBuffer(commandBuffers.at(imageIndex), &beginInfo) != VK_SUCCESS) {
throw love::Exception("failed to begin recording command buffer");
}
VkRenderPassBeginInfo renderPassInfo{};
renderPassInfo.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO;
renderPassInfo.renderPass = renderPass;
renderPassInfo.framebuffer = swapChainFramBuffers.at(imageIndex);
renderPassInfo.renderArea.offset = { 0, 0 };
renderPassInfo.renderArea.extent = swapChainExtent;
renderPassInfo.clearValueCount = 1;
renderPassInfo.pClearValues = &clearColor;
vkCmdBeginRenderPass(commandBuffers.at(imageIndex), &renderPassInfo, VK_SUBPASS_CONTENTS_INLINE);
currentGraphicsPipeline = VK_NULL_HANDLE;
}
void Graphics::endRecordingGraphicsCommands() {
const auto& commandBuffer = commandBuffers.at(imageIndex);
std::cout << "endCommandBuffer(imageIndex=" << imageIndex << ") ";
vkCmdEndRenderPass(commandBuffers.at(imageIndex));
if (vkEndCommandBuffer(commandBuffers.at(imageIndex)) != VK_SUCCESS) {
throw love::Exception("failed to record command buffer");
}
}
void Graphics::present(void* screenshotCallbackdata) {
flushBatchedDraws();
@@ -309,6 +264,21 @@ namespace love {
Volatile::unloadAll();
cleanup();
}
void Graphics::setPointSize(float size) {
std::cout << "setPointSize ";
if (size != states.back().pointSize)
flushBatchedDraws();
states.back().pointSize = size;
}
bool Graphics::usesGLSLES() const {
std::cout << "usesGLSLES ";
return false;
}
Graphics::RendererInfo Graphics::getRendererInfo() const {
VkPhysicalDeviceProperties deviceProperties;
@@ -428,6 +398,55 @@ namespace love {
// END IMPLEMENTATION OVERRIDDEN FUNCTIONS
void Graphics::startRecordingGraphicsCommands() {
vkWaitForFences(device, 1, &inFlightFences[currentFrame], VK_TRUE, UINT64_MAX);
while (true) {
VkResult result = vkAcquireNextImageKHR(device, swapChain, UINT64_MAX, imageAvailableSemaphores[currentFrame], VK_NULL_HANDLE, &imageIndex);
if (result == VK_ERROR_OUT_OF_DATE_KHR) {
recreateSwapChain();
continue;
}
else if (result != VK_SUCCESS && result != VK_SUBOPTIMAL_KHR) {
throw love::Exception("failed to acquire swap chain image");
}
break;
}
VkCommandBufferBeginInfo beginInfo{};
beginInfo.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO;
beginInfo.flags = 0;
beginInfo.pInheritanceInfo = nullptr;
std::cout << "beginCommandBuffer(imageIndex=" << imageIndex << ") ";
if (vkBeginCommandBuffer(commandBuffers.at(imageIndex), &beginInfo) != VK_SUCCESS) {
throw love::Exception("failed to begin recording command buffer");
}
VkRenderPassBeginInfo renderPassInfo{};
renderPassInfo.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO;
renderPassInfo.renderPass = renderPass;
renderPassInfo.framebuffer = swapChainFramBuffers.at(imageIndex);
renderPassInfo.renderArea.offset = { 0, 0 };
renderPassInfo.renderArea.extent = swapChainExtent;
renderPassInfo.clearValueCount = 1;
renderPassInfo.pClearValues = &clearColor;
vkCmdBeginRenderPass(commandBuffers.at(imageIndex), &renderPassInfo, VK_SUBPASS_CONTENTS_INLINE);
currentGraphicsPipeline = VK_NULL_HANDLE;
}
void Graphics::endRecordingGraphicsCommands() {
const auto& commandBuffer = commandBuffers.at(imageIndex);
std::cout << "endCommandBuffer(imageIndex=" << imageIndex << ") ";
vkCmdEndRenderPass(commandBuffers.at(imageIndex));
if (vkEndCommandBuffer(commandBuffers.at(imageIndex)) != VK_SUCCESS) {
throw love::Exception("failed to record command buffer");
}
}
void Graphics::setTexture(graphics::Texture* texture) {
currentTexture = texture;
}
+3 -5
View File
@@ -79,9 +79,7 @@ namespace love {
const VmaAllocator getVmaAllocator() const;
// implementation for virtual functions
love::graphics::Texture* newTexture(const love::graphics::Texture::Settings& settings, const love::graphics::Texture::Slices* data = nullptr) override {
return new Texture(this, settings, data);
}
love::graphics::Texture* newTexture(const love::graphics::Texture::Settings& settings, const love::graphics::Texture::Slices* data = nullptr) override;
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 "; }
@@ -102,12 +100,12 @@ namespace love {
void setFrontFaceWinding(Winding winding) override { std::cout << "setFrontFaceWinding "; }
void setColorMask(ColorChannelMask mask) override { std::cout << "setColorMask "; }
void setBlendState(const BlendState& blend) override { std::cout << "setBlendState "; }
void setPointSize(float size) override { std::cout << "setPointSize "; }
void setPointSize(float size) override;
void setWireframe(bool enable) override;
PixelFormat getSizedFormat(PixelFormat format, bool rendertarget, bool readable) const override;
bool isPixelFormatSupported(PixelFormat format, uint32 usage, bool sRGB = false) override;
Renderer getRenderer() const override;
bool usesGLSLES() const override { std::cout << "usesGLSES "; return false; }
bool usesGLSLES() const override;
RendererInfo getRendererInfo() const override;
void draw(const DrawCommand& cmd) override;
void draw(const DrawIndexedCommand& cmd) override;