vulkan: implement getAPIStats

This commit is contained in:
niki
2022-07-16 23:46:03 +02:00
parent 913aab0226
commit 6916182a79
6 changed files with 37 additions and 7 deletions
+8
View File
@@ -250,6 +250,8 @@ namespace love {
currentViewportWidth = 0.0f; currentViewportWidth = 0.0f;
currentViewportHeight = 0.0f; currentViewportHeight = 0.0f;
Vulkan::resetShaderSwitches();
return true; return true;
} }
@@ -298,6 +300,10 @@ namespace love {
capabilities.textureTypes[TEXTURE_CUBE] = false; capabilities.textureTypes[TEXTURE_CUBE] = false;
} }
void Graphics::getAPIStats(int& shaderswitches) const {
shaderswitches = Vulkan::getNumShaderSwitches();
}
void Graphics::unSetMode() { void Graphics::unSetMode() {
created = false; created = false;
vkDeviceWaitIdle(device); vkDeviceWaitIdle(device);
@@ -498,6 +504,8 @@ namespace love {
Vulkan::cmdTransitionImageLayout(commandBuffers.at(imageIndex), swapChainImages[imageIndex], VK_IMAGE_LAYOUT_UNDEFINED, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL); Vulkan::cmdTransitionImageLayout(commandBuffers.at(imageIndex), swapChainImages[imageIndex], VK_IMAGE_LAYOUT_UNDEFINED, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL);
startRenderPass(nullptr, swapChainExtent.width, swapChainExtent.height); startRenderPass(nullptr, swapChainExtent.width, swapChainExtent.height);
Vulkan::resetShaderSwitches();
} }
void Graphics::endRecordingGraphicsCommands() { void Graphics::endRecordingGraphicsCommands() {
+1 -1
View File
@@ -135,7 +135,7 @@ namespace love {
graphics::StreamBuffer* newStreamBuffer(BufferUsage type, size_t size) override; graphics::StreamBuffer* newStreamBuffer(BufferUsage type, size_t size) override;
bool dispatch(int x, int y, int z) override { return false; } bool dispatch(int x, int y, int z) override { return false; }
void initCapabilities() override; void initCapabilities() override;
void getAPIStats(int& shaderswitches) const override { } void getAPIStats(int& shaderswitches) const override;
void setRenderTargetsInternal(const RenderTargets& rts, int pixelw, int pixelh, bool hasSRGBtexture) override; void setRenderTargetsInternal(const RenderTargets& rts, int pixelw, int pixelh, bool hasSRGBtexture) override;
private: private:
+8
View File
@@ -35,6 +35,14 @@ namespace love {
} }
} }
void Shader::attach() {
if (Shader::current != this) {
Graphics::flushBatchedDrawsGlobal();
Shader::current = this;
Vulkan::shaderSwitch();
}
}
int Shader::getVertexAttributeIndex(const std::string& name) { int Shader::getVertexAttributeIndex(const std::string& name) {
return vertexAttributeIndices.at(name); return vertexAttributeIndices.at(name);
} }
+2 -6
View File
@@ -3,6 +3,7 @@
#include <graphics/Shader.h> #include <graphics/Shader.h>
#include <graphics/vulkan/ShaderStage.h> #include <graphics/vulkan/ShaderStage.h>
#include "Vulkan.h"
#include <vulkan/vulkan.h> #include <vulkan/vulkan.h>
#include <map> #include <map>
@@ -21,12 +22,7 @@ namespace love {
return shaderStages; return shaderStages;
} }
void attach() override { void attach() override;
if (Shader::current != this) {
Graphics::flushBatchedDrawsGlobal();
Shader::current = this;
}
}
ptrdiff_t getHandle() const { return 0; } ptrdiff_t getHandle() const { return 0; }
+14
View File
@@ -6,6 +6,20 @@
namespace love { namespace love {
namespace graphics { namespace graphics {
namespace vulkan { namespace vulkan {
static uint32_t numShaderSwitches;
void Vulkan::shaderSwitch() {
numShaderSwitches++;
}
uint32_t Vulkan::getNumShaderSwitches() {
return numShaderSwitches;
}
void Vulkan::resetShaderSwitches() {
numShaderSwitches = 0;
}
VkFormat Vulkan::getVulkanVertexFormat(DataFormat format) { VkFormat Vulkan::getVulkanVertexFormat(DataFormat format) {
switch (format) { switch (format) {
case DATAFORMAT_FLOAT: case DATAFORMAT_FLOAT:
+4
View File
@@ -18,6 +18,10 @@ namespace love {
class Vulkan { class Vulkan {
public: public:
static void shaderSwitch();
static uint32_t getNumShaderSwitches();
static void resetShaderSwitches();
static VkFormat getVulkanVertexFormat(DataFormat format); static VkFormat getVulkanVertexFormat(DataFormat format);
static TextureFormat getTextureFormat(PixelFormat); static TextureFormat getTextureFormat(PixelFormat);
static std::string getVendorName(uint32_t vendorId); static std::string getVendorName(uint32_t vendorId);