[vulkan] Add validation mechanism to encoder
bug: 111137294
bug: 120118806
The places where validation interfaces with the encoder will
be autogenerated, while the logic of it is not...for now at least.
First, validate the flush/invalidate APIs to some approx degree
(it doesnt currently care whether the host visible regions were
actually mapped at the user level)
Change-Id: I0f942a8c889eb0dcd164b2fa12ef1b01ab617762
diff --git a/system/vulkan_enc/VkEncoder.cpp b/system/vulkan_enc/VkEncoder.cpp
index f51744c..a247658 100644
--- a/system/vulkan_enc/VkEncoder.cpp
+++ b/system/vulkan_enc/VkEncoder.cpp
@@ -28,6 +28,7 @@
#include "IOStream.h"
#include "Resources.h"
#include "ResourceTracker.h"
+#include "Validation.h"
#include "VulkanStream.h"
#include "android/base/AlignedBuf.h"
@@ -63,6 +64,15 @@
VkEncoder::VkEncoder(IOStream *stream) :
mImpl(new VkEncoder::Impl(stream)) { }
+
+#define VALIDATE_RET(retType, success, validate) \
+ retType goldfish_vk_validateResult = validate; \
+ if (goldfish_vk_validateResult != success) return goldfish_vk_validateResult; \
+
+#define VALIDATE_VOID(validate) \
+ VkResult goldfish_vk_validateResult = validate; \
+ if (goldfish_vk_validateResult != VK_SUCCESS) return; \
+
#ifdef VK_VERSION_1_0
VkResult VkEncoder::vkCreateInstance(
const VkInstanceCreateInfo* pCreateInfo,
@@ -1399,6 +1409,7 @@
uint32_t memoryRangeCount,
const VkMappedMemoryRange* pMemoryRanges)
{
+ VALIDATE_RET(VkResult, VK_SUCCESS, validate_vkFlushMappedMemoryRanges(device, memoryRangeCount, pMemoryRanges));
auto stream = mImpl->stream();
auto countingStream = mImpl->countingStream();
auto resources = mImpl->resources();
@@ -1489,6 +1500,7 @@
uint32_t memoryRangeCount,
const VkMappedMemoryRange* pMemoryRanges)
{
+ VALIDATE_RET(VkResult, VK_SUCCESS, validate_vkInvalidateMappedMemoryRanges(device, memoryRangeCount, pMemoryRanges));
auto stream = mImpl->stream();
auto countingStream = mImpl->countingStream();
auto resources = mImpl->resources();