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;
currentViewportHeight = 0.0f;
Vulkan::resetShaderSwitches();
return true;
}
@@ -298,6 +300,10 @@ namespace love {
capabilities.textureTypes[TEXTURE_CUBE] = false;
}
void Graphics::getAPIStats(int& shaderswitches) const {
shaderswitches = Vulkan::getNumShaderSwitches();
}
void Graphics::unSetMode() {
created = false;
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);
startRenderPass(nullptr, swapChainExtent.width, swapChainExtent.height);
Vulkan::resetShaderSwitches();
}
void Graphics::endRecordingGraphicsCommands() {
+1 -1
View File
@@ -135,7 +135,7 @@ namespace love {
graphics::StreamBuffer* newStreamBuffer(BufferUsage type, size_t size) override;
bool dispatch(int x, int y, int z) override { return false; }
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;
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) {
return vertexAttributeIndices.at(name);
}
+2 -6
View File
@@ -3,6 +3,7 @@
#include <graphics/Shader.h>
#include <graphics/vulkan/ShaderStage.h>
#include "Vulkan.h"
#include <vulkan/vulkan.h>
#include <map>
@@ -21,12 +22,7 @@ namespace love {
return shaderStages;
}
void attach() override {
if (Shader::current != this) {
Graphics::flushBatchedDrawsGlobal();
Shader::current = this;
}
}
void attach() override;
ptrdiff_t getHandle() const { return 0; }
+14
View File
@@ -6,6 +6,20 @@
namespace love {
namespace graphics {
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) {
switch (format) {
case DATAFORMAT_FLOAT:
+4
View File
@@ -18,6 +18,10 @@ namespace love {
class Vulkan {
public:
static void shaderSwitch();
static uint32_t getNumShaderSwitches();
static void resetShaderSwitches();
static VkFormat getVulkanVertexFormat(DataFormat format);
static TextureFormat getTextureFormat(PixelFormat);
static std::string getVendorName(uint32_t vendorId);