Download third_party/ktx-src/tests/loadtests/vkloadtests/VulkanLoadTestSample.h from kimjunhan/vkgs-sim: direct link, hf CLI and curl.
- Browser
- Download file 4.58 kB
-
https://huggingface.co/kimjunhan/vkgs-sim/resolve/main/third_party/ktx-src/tests/loadtests/vkloadtests/VulkanLoadTestSample.h
- Command line
-
hf download hf://kimjunhan/vkgs-sim/third_party/ktx-src/tests/loadtests/vkloadtests/VulkanLoadTestSample.h
-
curl -L -o VulkanLoadTestSample.h https://huggingface.co/kimjunhan/vkgs-sim/resolve/main/third_party/ktx-src/tests/loadtests/vkloadtests/VulkanLoadTestSample.h
4.58 kB
| /* -*- tab-width: 4; -*- */ | |
| /* vi: set sw=2 ts=4 expandtab: */ | |
| /* | |
| * Copyright 2017-2020 Mark Callow. | |
| * SPDX-License-Identifier: Apache-2.0 | |
| */ | |
| // MeshLoader needs vulkantools.h to be already included. It is included by | |
| // vulkantextoverlay.hpp via VulkanAppSDL.h. | |
| namespace VMA_CALLBACKS | |
| { | |
| void InitVMA(VkPhysicalDevice& physicalDevice, VkDevice& device, VkInstance& instance, | |
| VkPhysicalDeviceMemoryProperties& devMemProps); | |
| void DestroyVMA(); | |
| uint64_t AllocMemCWrapper(VkMemoryAllocateInfo* allocInfo, VkMemoryRequirements* memReq, uint64_t* numPages); | |
| VkResult BindBufferMemoryCWrapper(VkBuffer buffer, uint64_t allocId); | |
| VkResult BindImageMemoryCWrapper(VkImage image, uint64_t allocId); | |
| VkResult MapMemoryCWrapper(uint64_t allocId, uint64_t, VkDeviceSize* mapLength, void** dataPtr); | |
| void UnmapMemoryCWrapper(uint64_t allocId, uint64_t); | |
| void FreeMemCWrapper(uint64_t allocId); | |
| } | |
| extern "C" const char* vkFormatString(VkFormat format); | |
| class VulkanLoadTestSample : public LoadTestSample { | |
| public: | |
| typedef uint64_t ticks_t; | |
| VulkanLoadTestSample(VulkanContext& vkctx, | |
| uint32_t width, uint32_t height, | |
| /* const char* const szArgs, */ | |
| const std::string sBasePath, int32_t yflip = -1) | |
| : LoadTestSample(width, height, /*szArgs,*/ sBasePath, yflip), | |
| vkctx(vkctx), | |
| defaultClearColor(std::array<float,4>({0.025f, 0.025f, 0.025f, 1.0f})) | |
| { | |
| } | |
| virtual ~VulkanLoadTestSample(); | |
| virtual int doEvent(SDL_Event* event) { return LoadTestSample::doEvent(event); }; | |
| virtual void resize(uint32_t width, uint32_t height) = 0; | |
| virtual void run(uint32_t msTicks) = 0; | |
| virtual void getOverlayText(VulkanTextOverlay* /*textOverlay*/, | |
| float /*yoffset*/) { } | |
| virtual const char* customizeTitle(const char* const title) { | |
| return title; | |
| } | |
| typedef VulkanLoadTestSample* (*PFN_create)(VulkanContext&, | |
| uint32_t width, uint32_t height, | |
| const char* const szArgs, | |
| const std::string sBasePath); | |
| protected: | |
| ktxVulkanTexture_subAllocatorCallbacks subAllocatorCallbacks = { | |
| VMA_CALLBACKS::AllocMemCWrapper, | |
| VMA_CALLBACKS::BindBufferMemoryCWrapper, | |
| VMA_CALLBACKS::BindImageMemoryCWrapper, | |
| VMA_CALLBACKS::MapMemoryCWrapper, | |
| VMA_CALLBACKS::UnmapMemoryCWrapper, | |
| VMA_CALLBACKS::FreeMemCWrapper | |
| }; | |
| virtual void keyPressed(uint32_t /*keyCode*/) { } | |
| virtual void viewChanged() { } | |
| bool gpuSupportsSwizzle() { | |
| return vkctx.gpuSupportsSwizzle(); | |
| } | |
| std::string ktxfilename; | |
| int externalFile = 0; | |
| vk::PipelineShaderStageCreateInfo | |
| loadShader(std::string filename, | |
| vk::ShaderStageFlagBits stage, | |
| const char* modname = "main"); | |
| void loadMesh(std::string filename, | |
| vkMeshLoader::MeshBuffer* meshBuffer, | |
| std::vector<vkMeshLoader::VertexLayout> vertexLayout, | |
| float scale); | |
| struct MeshBufferInfo | |
| { | |
| vk::Buffer buf; | |
| vk::DeviceMemory mem; | |
| vk::DeviceSize size = 0; | |
| void freeResources(vk::Device& device) { | |
| if (buf) device.destroyBuffer(buf); | |
| if (mem) device.freeMemory(mem); | |
| } | |
| }; | |
| struct MeshBuffer | |
| { | |
| MeshBufferInfo vertices; | |
| MeshBufferInfo indices; | |
| uint32_t indexCount; | |
| glm::vec3 dim; | |
| void freeResources(vk::Device& device) { | |
| vertices.freeResources(device); | |
| indices.freeResources(device); | |
| } | |
| }; | |
| struct UniformData | |
| { | |
| vk::Buffer buffer; | |
| vk::DeviceMemory memory; | |
| vk::DescriptorBufferInfo descriptor; | |
| uint32_t allocSize; | |
| void* mapped = nullptr; | |
| void freeResources(vk::Device& device) { | |
| device.destroyBuffer(buffer); | |
| device.freeMemory(memory); | |
| } | |
| }; | |
| VulkanContext& vkctx; | |
| // Saved for clean-up | |
| std::vector<VkShaderModule> shaderModules; | |
| const vk::ClearColorValue defaultClearColor; | |
| }; | |