mirror of
https://github.com/hrydgard/ppsspp.git
synced 2025-02-17 04:39:34 +00:00
Enable support for Android Vulkan validation. Fix a minor validation error.
This commit is contained in:
parent
f68ba55f96
commit
31d5881c90
@ -298,11 +298,22 @@ public:
|
||||
const VulkanPhysicalDeviceInfo &GetDeviceInfo() const { return deviceInfo_; }
|
||||
const VkSurfaceCapabilitiesKHR &GetSurfaceCapabilities() const { return surfCapabilities_; }
|
||||
|
||||
bool IsInstanceExtensionAvailable(const char *name) const {
|
||||
for (auto &iter : instance_extension_properties_) {
|
||||
if (!strcmp(name, iter.extensionName))
|
||||
bool IsInstanceExtensionAvailable(const char *extensionName) const {
|
||||
for (const auto &iter : instance_extension_properties_) {
|
||||
if (!strcmp(extensionName, iter.extensionName))
|
||||
return true;
|
||||
}
|
||||
|
||||
// Also search through the layers, one of them might carry the extension (especially DEBUG_utils)
|
||||
for (const auto &iter : instance_layer_properties_) {
|
||||
for (const auto &ext : iter.extensions) {
|
||||
if (!strcmp(extensionName, ext.extensionName)) {
|
||||
INFO_LOG(G3D, "%s found in layer extensions: %s", extensionName, iter.properties.layerName);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -112,8 +112,10 @@ VkCommandBuffer FrameData::GetInitCmd(VulkanContext *vulkan) {
|
||||
}
|
||||
|
||||
// Good spot to reset the query pool.
|
||||
vkCmdResetQueryPool(initCmd, profile.queryPool, 0, MAX_TIMESTAMP_QUERIES);
|
||||
vkCmdWriteTimestamp(initCmd, VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, profile.queryPool, 0);
|
||||
if (profilingEnabled_) {
|
||||
vkCmdResetQueryPool(initCmd, profile.queryPool, 0, MAX_TIMESTAMP_QUERIES);
|
||||
vkCmdWriteTimestamp(initCmd, VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, profile.queryPool, 0);
|
||||
}
|
||||
|
||||
hasInitCommands = true;
|
||||
}
|
||||
|
@ -8,17 +8,27 @@ using namespace PPSSPP_VK;
|
||||
void VulkanProfiler::Init(VulkanContext *vulkan) {
|
||||
vulkan_ = vulkan;
|
||||
|
||||
VkQueryPoolCreateInfo ci{ VK_STRUCTURE_TYPE_QUERY_POOL_CREATE_INFO };
|
||||
ci.queryCount = MAX_QUERY_COUNT;
|
||||
ci.queryType = VK_QUERY_TYPE_TIMESTAMP;
|
||||
vkCreateQueryPool(vulkan->GetDevice(), &ci, nullptr, &queryPool_);
|
||||
validBits_ = vulkan_->GetQueueFamilyProperties(vulkan_->GetGraphicsQueueFamilyIndex()).timestampValidBits;
|
||||
|
||||
if (validBits_) {
|
||||
VkQueryPoolCreateInfo ci{ VK_STRUCTURE_TYPE_QUERY_POOL_CREATE_INFO };
|
||||
ci.queryCount = MAX_QUERY_COUNT;
|
||||
ci.queryType = VK_QUERY_TYPE_TIMESTAMP;
|
||||
vkCreateQueryPool(vulkan->GetDevice(), &ci, nullptr, &queryPool_);
|
||||
}
|
||||
}
|
||||
|
||||
void VulkanProfiler::Shutdown() {
|
||||
vkDestroyQueryPool(vulkan_->GetDevice(), queryPool_, nullptr);
|
||||
if (queryPool_) {
|
||||
vkDestroyQueryPool(vulkan_->GetDevice(), queryPool_, nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
void VulkanProfiler::BeginFrame(VulkanContext *vulkan, VkCommandBuffer firstCommandBuf) {
|
||||
if (!validBits_) {
|
||||
return;
|
||||
}
|
||||
|
||||
vulkan_ = vulkan;
|
||||
|
||||
// Check for old queries belonging to this frame context that we can log out - these are now
|
||||
@ -28,8 +38,7 @@ void VulkanProfiler::BeginFrame(VulkanContext *vulkan, VkCommandBuffer firstComm
|
||||
vkGetQueryPoolResults(vulkan->GetDevice(), queryPool_, 0, numQueries_, sizeof(uint64_t) * numQueries_, results.data(), sizeof(uint64_t), VK_QUERY_RESULT_64_BIT);
|
||||
|
||||
double timestampConversionFactor = (double)vulkan_->GetPhysicalDeviceProperties().properties.limits.timestampPeriod * (1.0 / 1000000.0);
|
||||
int validBits = vulkan_->GetQueueFamilyProperties(vulkan_->GetGraphicsQueueFamilyIndex()).timestampValidBits;
|
||||
uint64_t timestampDiffMask = validBits == 64 ? 0xFFFFFFFFFFFFFFFFULL : ((1ULL << validBits) - 1);
|
||||
uint64_t timestampDiffMask = validBits_ == 64 ? 0xFFFFFFFFFFFFFFFFULL : ((1ULL << validBits_) - 1);
|
||||
|
||||
static const char * const indent[4] = { "", " ", " ", " " };
|
||||
|
||||
@ -69,7 +78,7 @@ void VulkanProfiler::BeginFrame(VulkanContext *vulkan, VkCommandBuffer firstComm
|
||||
}
|
||||
|
||||
void VulkanProfiler::Begin(VkCommandBuffer cmdBuf, VkPipelineStageFlagBits stageFlags, const char *fmt, ...) {
|
||||
if ((enabledPtr_ && !*enabledPtr_) || numQueries_ >= MAX_QUERY_COUNT - 1) {
|
||||
if (!validBits_ || (enabledPtr_ && !*enabledPtr_) || numQueries_ >= MAX_QUERY_COUNT - 1) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -90,7 +99,7 @@ void VulkanProfiler::Begin(VkCommandBuffer cmdBuf, VkPipelineStageFlagBits stage
|
||||
}
|
||||
|
||||
void VulkanProfiler::End(VkCommandBuffer cmdBuf, VkPipelineStageFlagBits stageFlags) {
|
||||
if ((enabledPtr_ && !*enabledPtr_) || numQueries_ >= MAX_QUERY_COUNT - 1) {
|
||||
if (!validBits_ || (enabledPtr_ && !*enabledPtr_) || numQueries_ >= MAX_QUERY_COUNT - 1) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -47,6 +47,7 @@ private:
|
||||
int numQueries_ = 0;
|
||||
bool firstFrame_ = true;
|
||||
bool *enabledPtr_ = nullptr;
|
||||
int validBits_ = 0;
|
||||
|
||||
std::vector<size_t> scopeStack_;
|
||||
|
||||
|
@ -451,8 +451,10 @@ void VulkanRenderManager::BeginFrame(bool enableProfiling, bool enableLogProfile
|
||||
}
|
||||
vkResetFences(device, 1, &frameData.fence);
|
||||
|
||||
int validBits = vulkan_->GetQueueFamilyProperties(vulkan_->GetGraphicsQueueFamilyIndex()).timestampValidBits;
|
||||
|
||||
// Can't set this until after the fence.
|
||||
frameData.profilingEnabled_ = enableProfiling;
|
||||
frameData.profilingEnabled_ = enableProfiling && validBits > 0;
|
||||
|
||||
uint64_t queryResults[MAX_TIMESTAMP_QUERIES];
|
||||
|
||||
@ -466,7 +468,6 @@ void VulkanRenderManager::BeginFrame(bool enableProfiling, bool enableLogProfile
|
||||
VK_QUERY_RESULT_64_BIT);
|
||||
if (res == VK_SUCCESS) {
|
||||
double timestampConversionFactor = (double)vulkan_->GetPhysicalDeviceProperties().properties.limits.timestampPeriod * (1.0 / 1000000.0);
|
||||
int validBits = vulkan_->GetQueueFamilyProperties(vulkan_->GetGraphicsQueueFamilyIndex()).timestampValidBits;
|
||||
uint64_t timestampDiffMask = validBits == 64 ? 0xFFFFFFFFFFFFFFFFULL : ((1ULL << validBits) - 1);
|
||||
std::stringstream str;
|
||||
|
||||
|
@ -21,10 +21,17 @@ AndroidVulkanContext::~AndroidVulkanContext() {
|
||||
}
|
||||
|
||||
static uint32_t FlagsFromConfig() {
|
||||
uint32_t flags;
|
||||
|
||||
if (g_Config.bVSync) {
|
||||
return VULKAN_FLAG_PRESENT_FIFO;
|
||||
flags = VULKAN_FLAG_PRESENT_FIFO;
|
||||
} else {
|
||||
flags = VULKAN_FLAG_PRESENT_MAILBOX | VULKAN_FLAG_PRESENT_FIFO_RELAXED;
|
||||
}
|
||||
return VULKAN_FLAG_PRESENT_MAILBOX | VULKAN_FLAG_PRESENT_FIFO_RELAXED;
|
||||
#ifdef _DEBUG
|
||||
flags |= VULKAN_FLAG_VALIDATE;
|
||||
#endif
|
||||
return flags;
|
||||
}
|
||||
|
||||
bool AndroidVulkanContext::InitAPI() {
|
||||
|
4
android/src/main/jniLibs/.gitignore
vendored
Normal file
4
android/src/main/jniLibs/.gitignore
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
arm64-v8a
|
||||
armeabi-v7a
|
||||
x86
|
||||
x86_64
|
1
android/src/main/jniLibs/README.txt
Normal file
1
android/src/main/jniLibs/README.txt
Normal file
@ -0,0 +1 @@
|
||||
Put the arm64-v8a and the other folders here, downloaded from https://github.com/KhronosGroup/Vulkan-ValidationLayers/releases
|
Loading…
x
Reference in New Issue
Block a user