mirror of
https://github.com/love2d/love.git
synced 2026-08-16 08:11:02 +02:00
vulkan: implement getAPIStats
This commit is contained in:
@@ -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() {
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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; }
|
||||
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user