diff --git a/WickedEngine/CommonInclude.h b/WickedEngine/CommonInclude.h index c1b17206e..e0e752e7d 100644 --- a/WickedEngine/CommonInclude.h +++ b/WickedEngine/CommonInclude.h @@ -8,9 +8,16 @@ // Platform specific: #include #include + #ifdef WINSTORE_SUPPORT #include -#endif +#endif // WINSTORE_SUPPORT + +#if __has_include("vulkan/vulkan.h") +#define WICKEDENGINE_BUILD_VULKAN +#endif // HAS VULKAN + + // Platform agnostic: diff --git a/WickedEngine/Include_Vulkan.h b/WickedEngine/Include_Vulkan.h new file mode 100644 index 000000000..c31e8f8e3 --- /dev/null +++ b/WickedEngine/Include_Vulkan.h @@ -0,0 +1,9 @@ +#ifndef _INCLUDE_VULKAN_H_ +#define _INCLUDE_VULKAN_H_ + + +#ifdef WICKEDENGINE_BUILD_VULKAN +#include +#endif // WICKEDENGINE_BUILD_VULKAN + +#endif // _INCLUDE_VULKAN_H_ diff --git a/WickedEngine/WickedEngine_SHARED.vcxitems b/WickedEngine/WickedEngine_SHARED.vcxitems index c9034bef7..314f1f964 100644 --- a/WickedEngine/WickedEngine_SHARED.vcxitems +++ b/WickedEngine/WickedEngine_SHARED.vcxitems @@ -235,6 +235,7 @@ + @@ -251,6 +252,7 @@ + @@ -531,6 +533,7 @@ + diff --git a/WickedEngine/WickedEngine_SHARED.vcxitems.filters b/WickedEngine/WickedEngine_SHARED.vcxitems.filters index 58032cbda..2198be1db 100644 --- a/WickedEngine/WickedEngine_SHARED.vcxitems.filters +++ b/WickedEngine/WickedEngine_SHARED.vcxitems.filters @@ -1146,6 +1146,12 @@ ENGINE\Graphics\GPUMapping + + ENGINE\Graphics\API + + + ENGINE\Graphics\API + @@ -1952,6 +1958,9 @@ ENGINE\Helpers + + ENGINE\Graphics\API + diff --git a/WickedEngine/WickedEngine_Windows.vcxproj b/WickedEngine/WickedEngine_Windows.vcxproj index f598760e9..6d5c494ef 100644 --- a/WickedEngine/WickedEngine_Windows.vcxproj +++ b/WickedEngine/WickedEngine_Windows.vcxproj @@ -91,7 +91,7 @@ Level3 Disabled WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions) - BULLET;%(AdditionalIncludeDirectories) + $(VULKAN_SDK)/Include;BULLET;%(AdditionalIncludeDirectories) true false true @@ -110,6 +110,7 @@ true + $(VULKAN_SDK)/Lib32;%(AdditionalLibraryDirectories) @@ -119,7 +120,7 @@ Level3 Disabled _DEBUG;_LIB;%(PreprocessorDefinitions) - BULLET;%(AdditionalIncludeDirectories) + $(VULKAN_SDK)/Include;BULLET;%(AdditionalIncludeDirectories) true false true @@ -138,6 +139,7 @@ true + $(VULKAN_SDK)/Lib;%(AdditionalLibraryDirectories) @@ -149,7 +151,7 @@ true true WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions) - BULLET;%(AdditionalIncludeDirectories) + $(VULKAN_SDK)/Include;BULLET;%(AdditionalIncludeDirectories) MultiThreaded true Speed @@ -163,6 +165,9 @@ shaders/%(Filename).cso + + $(VULKAN_SDK)/Lib32;%(AdditionalLibraryDirectories) + @@ -173,7 +178,7 @@ true true NDEBUG;_LIB;%(PreprocessorDefinitions) - BULLET;%(AdditionalIncludeDirectories) + $(VULKAN_SDK)/Include;BULLET;%(AdditionalIncludeDirectories) MultiThreaded true Speed @@ -187,6 +192,9 @@ shaders/%(Filename).cso + + $(VULKAN_SDK)/Lib;%(AdditionalLibraryDirectories) + diff --git a/WickedEngine/wiGraphicsDevice_Vulkan.cpp b/WickedEngine/wiGraphicsDevice_Vulkan.cpp new file mode 100644 index 000000000..237364688 --- /dev/null +++ b/WickedEngine/wiGraphicsDevice_Vulkan.cpp @@ -0,0 +1,292 @@ +#include "wiGraphicsDevice_Vulkan.h" +#include "wiHelper.h" +#include "ResourceMapping.h" + +#include + +using namespace std; + + + +#ifdef WICKEDENGINE_BUILD_VULKAN +#pragma comment(lib,"vulkan-1.lib") + +namespace wiGraphicsTypes +{ + // Engine functions + GraphicsDevice_Vulkan::GraphicsDevice_Vulkan(wiWindowRegistration::window_type window, bool fullscreen) : GraphicsDevice() + { + } + GraphicsDevice_Vulkan::~GraphicsDevice_Vulkan() + { + } + + void GraphicsDevice_Vulkan::SetResolution(int width, int height) + { + if (width != SCREENWIDTH || height != SCREENHEIGHT) + { + SCREENWIDTH = width; + SCREENHEIGHT = height; + //swapChain->ResizeBuffers(2, width, height, _ConvertFormat(GetBackBufferFormat()), 0); + RESOLUTIONCHANGED = true; + } + } + + Texture2D GraphicsDevice_Vulkan::GetBackBuffer() + { + return Texture2D(); + } + + HRESULT GraphicsDevice_Vulkan::CreateBuffer(const GPUBufferDesc *pDesc, const SubresourceData* pInitialData, GPUBuffer *ppBuffer) + { + return E_FAIL; + } + HRESULT GraphicsDevice_Vulkan::CreateTexture2D(const Texture2DDesc* pDesc, const SubresourceData *pInitialData, Texture2D **ppTexture2D) + { + return E_FAIL; + } + HRESULT GraphicsDevice_Vulkan::CreateTexture3D(const Texture3DDesc* pDesc, const SubresourceData *pInitialData, Texture3D **ppTexture3D) + { + return E_FAIL; + } + HRESULT GraphicsDevice_Vulkan::CreateInputLayout(const VertexLayoutDesc *pInputElementDescs, UINT NumElements, + const void *pShaderBytecodeWithInputSignature, SIZE_T BytecodeLength, VertexLayout *pInputLayout) + { + return E_FAIL; + } + HRESULT GraphicsDevice_Vulkan::CreateVertexShader(const void *pShaderBytecode, SIZE_T BytecodeLength, VertexShader *pVertexShader) + { + return E_FAIL; + } + HRESULT GraphicsDevice_Vulkan::CreatePixelShader(const void *pShaderBytecode, SIZE_T BytecodeLength, PixelShader *pPixelShader) + { + return E_FAIL; + } + HRESULT GraphicsDevice_Vulkan::CreateGeometryShader(const void *pShaderBytecode, SIZE_T BytecodeLength, GeometryShader *pGeometryShader) + { + return E_FAIL; + } + HRESULT GraphicsDevice_Vulkan::CreateHullShader(const void *pShaderBytecode, SIZE_T BytecodeLength, HullShader *pHullShader) + { + return E_FAIL; + } + HRESULT GraphicsDevice_Vulkan::CreateDomainShader(const void *pShaderBytecode, SIZE_T BytecodeLength, DomainShader *pDomainShader) + { + return E_FAIL; + } + HRESULT GraphicsDevice_Vulkan::CreateComputeShader(const void *pShaderBytecode, SIZE_T BytecodeLength, ComputeShader *pComputeShader) + { + return E_FAIL; + } + HRESULT GraphicsDevice_Vulkan::CreateBlendState(const BlendStateDesc *pBlendStateDesc, BlendState *pBlendState) + { + return E_FAIL; + } + HRESULT GraphicsDevice_Vulkan::CreateDepthStencilState(const DepthStencilStateDesc *pDepthStencilStateDesc, DepthStencilState *pDepthStencilState) + { + return E_FAIL; + } + HRESULT GraphicsDevice_Vulkan::CreateRasterizerState(const RasterizerStateDesc *pRasterizerStateDesc, RasterizerState *pRasterizerState) + { + return E_FAIL; + } + HRESULT GraphicsDevice_Vulkan::CreateSamplerState(const SamplerDesc *pSamplerDesc, Sampler *pSamplerState) + { + return E_FAIL; + } + HRESULT GraphicsDevice_Vulkan::CreateQuery(const GPUQueryDesc *pDesc, GPUQuery *pQuery) + { + return E_FAIL; + } + HRESULT GraphicsDevice_Vulkan::CreateGraphicsPSO(const GraphicsPSODesc* pDesc, GraphicsPSO* pso) + { + return E_FAIL; + } + HRESULT GraphicsDevice_Vulkan::CreateComputePSO(const ComputePSODesc* pDesc, ComputePSO* pso) + { + return E_FAIL; + } + + + void GraphicsDevice_Vulkan::PresentBegin() + { + } + void GraphicsDevice_Vulkan::PresentEnd() + { + } + + void GraphicsDevice_Vulkan::ExecuteDeferredContexts() + { + } + void GraphicsDevice_Vulkan::FinishCommandList(GRAPHICSTHREAD threadID) + { + } + + + void GraphicsDevice_Vulkan::BindViewports(UINT NumViewports, const ViewPort *pViewports, GRAPHICSTHREAD threadID) + { + } + void GraphicsDevice_Vulkan::BindRenderTargetsUAVs(UINT NumViews, Texture* const *ppRenderTargets, Texture2D* depthStencilTexture, GPUResource* const *ppUAVs, int slotUAV, int countUAV, + GRAPHICSTHREAD threadID, int arrayIndex) + { + } + void GraphicsDevice_Vulkan::BindRenderTargets(UINT NumViews, Texture* const *ppRenderTargets, Texture2D* depthStencilTexture, GRAPHICSTHREAD threadID, int arrayIndex) + { + } + void GraphicsDevice_Vulkan::ClearRenderTarget(Texture* pTexture, const FLOAT ColorRGBA[4], GRAPHICSTHREAD threadID, int arrayIndex) + { + } + void GraphicsDevice_Vulkan::ClearDepthStencil(Texture2D* pTexture, UINT ClearFlags, FLOAT Depth, UINT8 Stencil, GRAPHICSTHREAD threadID, int arrayIndex) + { + } + void GraphicsDevice_Vulkan::BindResource(SHADERSTAGE stage, GPUResource* resource, int slot, GRAPHICSTHREAD threadID, int arrayIndex) + { + } + void GraphicsDevice_Vulkan::BindResources(SHADERSTAGE stage, GPUResource *const* resources, int slot, int count, GRAPHICSTHREAD threadID) + { + } + void GraphicsDevice_Vulkan::BindUnorderedAccessResource(SHADERSTAGE stage, GPUResource* resource, int slot, GRAPHICSTHREAD threadID, int arrayIndex) + { + } + void GraphicsDevice_Vulkan::BindUnorderedAccessResources(SHADERSTAGE stage, GPUResource *const* resources, int slot, int count, GRAPHICSTHREAD threadID) + { + } + void GraphicsDevice_Vulkan::BindUnorderedAccessResourceCS(GPUResource* resource, int slot, GRAPHICSTHREAD threadID, int arrayIndex) + { + } + void GraphicsDevice_Vulkan::BindUnorderedAccessResourcesCS(GPUResource *const* resources, int slot, int count, GRAPHICSTHREAD threadID) + { + } + void GraphicsDevice_Vulkan::UnBindResources(int slot, int num, GRAPHICSTHREAD threadID) + { + } + void GraphicsDevice_Vulkan::UnBindUnorderedAccessResources(int slot, int num, GRAPHICSTHREAD threadID) + { + } + void GraphicsDevice_Vulkan::BindSampler(SHADERSTAGE stage, Sampler* sampler, int slot, GRAPHICSTHREAD threadID) + { + } + void GraphicsDevice_Vulkan::BindConstantBuffer(SHADERSTAGE stage, GPUBuffer* buffer, int slot, GRAPHICSTHREAD threadID) + { + } + void GraphicsDevice_Vulkan::BindVertexBuffers(GPUBuffer* const *vertexBuffers, int slot, int count, const UINT* strides, const UINT* offsets, GRAPHICSTHREAD threadID) + { + } + void GraphicsDevice_Vulkan::BindIndexBuffer(GPUBuffer* indexBuffer, const INDEXBUFFER_FORMAT format, UINT offset, GRAPHICSTHREAD threadID) + { + } + void GraphicsDevice_Vulkan::BindPrimitiveTopology(PRIMITIVETOPOLOGY type, GRAPHICSTHREAD threadID) + { + } + void GraphicsDevice_Vulkan::BindStencilRef(UINT value, GRAPHICSTHREAD threadID) + { + } + void GraphicsDevice_Vulkan::BindBlendFactor(XMFLOAT4 value, GRAPHICSTHREAD threadID) + { + } + void GraphicsDevice_Vulkan::BindGraphicsPSO(GraphicsPSO* pso, GRAPHICSTHREAD threadID) + { + } + void GraphicsDevice_Vulkan::BindComputePSO(ComputePSO* pso, GRAPHICSTHREAD threadID) + { + } + void GraphicsDevice_Vulkan::Draw(int vertexCount, UINT startVertexLocation, GRAPHICSTHREAD threadID) + { + } + void GraphicsDevice_Vulkan::DrawIndexed(int indexCount, UINT startIndexLocation, UINT baseVertexLocation, GRAPHICSTHREAD threadID) + { + } + void GraphicsDevice_Vulkan::DrawInstanced(int vertexCount, int instanceCount, UINT startVertexLocation, UINT startInstanceLocation, GRAPHICSTHREAD threadID) + { + } + void GraphicsDevice_Vulkan::DrawIndexedInstanced(int indexCount, int instanceCount, UINT startIndexLocation, UINT baseVertexLocation, UINT startInstanceLocation, GRAPHICSTHREAD threadID) + { + } + void GraphicsDevice_Vulkan::DrawInstancedIndirect(GPUBuffer* args, UINT args_offset, GRAPHICSTHREAD threadID) + { + } + void GraphicsDevice_Vulkan::DrawIndexedInstancedIndirect(GPUBuffer* args, UINT args_offset, GRAPHICSTHREAD threadID) + { + } + void GraphicsDevice_Vulkan::Dispatch(UINT threadGroupCountX, UINT threadGroupCountY, UINT threadGroupCountZ, GRAPHICSTHREAD threadID) + { + } + void GraphicsDevice_Vulkan::DispatchIndirect(GPUBuffer* args, UINT args_offset, GRAPHICSTHREAD threadID) + { + } + void GraphicsDevice_Vulkan::GenerateMips(Texture* texture, GRAPHICSTHREAD threadID, int arrayIndex) + { + } + void GraphicsDevice_Vulkan::CopyTexture2D(Texture2D* pDst, Texture2D* pSrc, GRAPHICSTHREAD threadID) + { + } + void GraphicsDevice_Vulkan::CopyTexture2D_Region(Texture2D* pDst, UINT dstMip, UINT dstX, UINT dstY, Texture2D* pSrc, UINT srcMip, GRAPHICSTHREAD threadID) + { + } + void GraphicsDevice_Vulkan::MSAAResolve(Texture2D* pDst, Texture2D* pSrc, GRAPHICSTHREAD threadID) + { + } + void GraphicsDevice_Vulkan::UpdateBuffer(GPUBuffer* buffer, const void* data, GRAPHICSTHREAD threadID, int dataSize) + { + } + void* GraphicsDevice_Vulkan::AllocateFromRingBuffer(GPURingBuffer* buffer, size_t dataSize, UINT& offsetIntoBuffer, GRAPHICSTHREAD threadID) + { + offsetIntoBuffer = 0; + return nullptr; + } + void GraphicsDevice_Vulkan::InvalidateBufferAccess(GPUBuffer* buffer, GRAPHICSTHREAD threadID) + { + } + bool GraphicsDevice_Vulkan::DownloadBuffer(GPUBuffer* bufferToDownload, GPUBuffer* bufferDest, void* dataDest, GRAPHICSTHREAD threadID) + { + return false; + } + void GraphicsDevice_Vulkan::SetScissorRects(UINT numRects, const Rect* rects, GRAPHICSTHREAD threadID) + { + } + + void GraphicsDevice_Vulkan::QueryBegin(GPUQuery *query, GRAPHICSTHREAD threadID) + { + } + void GraphicsDevice_Vulkan::QueryEnd(GPUQuery *query, GRAPHICSTHREAD threadID) + { + } + bool GraphicsDevice_Vulkan::QueryRead(GPUQuery *query, GRAPHICSTHREAD threadID) + { + return true; + } + + void GraphicsDevice_Vulkan::UAVBarrier(GPUResource *const* uavs, UINT NumBarriers, GRAPHICSTHREAD threadID) + { + } + void GraphicsDevice_Vulkan::TransitionBarrier(GPUResource *const* resources, UINT NumBarriers, RESOURCE_STATES stateBefore, RESOURCE_STATES stateAfter, GRAPHICSTHREAD threadID) + { + } + + + HRESULT GraphicsDevice_Vulkan::CreateTextureFromFile(const std::string& fileName, Texture2D **ppTexture, bool mipMaps, GRAPHICSTHREAD threadID) + { + return E_FAIL; + } + HRESULT GraphicsDevice_Vulkan::SaveTexturePNG(const std::string& fileName, Texture2D *pTexture, GRAPHICSTHREAD threadID) + { + return E_FAIL; + } + HRESULT GraphicsDevice_Vulkan::SaveTextureDDS(const std::string& fileName, Texture *pTexture, GRAPHICSTHREAD threadID) + { + return E_FAIL; + } + + void GraphicsDevice_Vulkan::EventBegin(const std::string& name, GRAPHICSTHREAD threadID) + { + } + void GraphicsDevice_Vulkan::EventEnd(GRAPHICSTHREAD threadID) + { + } + void GraphicsDevice_Vulkan::SetMarker(const std::string& name, GRAPHICSTHREAD threadID) + { + } + +} + +#endif // WICKEDENGINE_BUILD_VULKAN diff --git a/WickedEngine/wiGraphicsDevice_Vulkan.h b/WickedEngine/wiGraphicsDevice_Vulkan.h new file mode 100644 index 000000000..7c8ebb700 --- /dev/null +++ b/WickedEngine/wiGraphicsDevice_Vulkan.h @@ -0,0 +1,183 @@ +#ifndef _GRAPHICSDEVICE_VULKAN_H_ +#define _GRAPHICSDEVICE_VULKAN_H_ + +#include "CommonInclude.h" +#include "wiGraphicsDevice.h" +#include "wiWindowRegistration.h" + + +#ifdef WICKEDENGINE_BUILD_VULKAN +#include "Include_Vulkan.h" + +namespace wiGraphicsTypes +{ + + class GraphicsDevice_Vulkan : public GraphicsDevice + { + private: + VkSurfaceKHR surface; + bool prepared; + bool use_staging_buffer; + bool separate_present_queue; + + bool VK_KHR_incremental_present_enabled; + + bool VK_GOOGLE_display_timing_enabled; + bool syncd_with_actual_presents; + uint64_t refresh_duration; + uint64_t refresh_duration_multiplier; + uint64_t target_IPD; // image present duration (inverse of frame rate) + uint64_t prev_desired_present_time; + uint32_t next_present_id; + uint32_t last_early_id; // 0 if no early images + uint32_t last_late_id; // 0 if no late images + + VkInstance inst; + VkPhysicalDevice gpu; + VkDevice device; + VkQueue graphics_queue; + VkQueue present_queue; + uint32_t graphics_queue_family_index; + uint32_t present_queue_family_index; + VkSemaphore image_acquired_semaphores[BACKBUFFER_COUNT]; + VkSemaphore draw_complete_semaphores[BACKBUFFER_COUNT]; + VkSemaphore image_ownership_semaphores[BACKBUFFER_COUNT]; + VkPhysicalDeviceProperties gpu_props; + VkQueueFamilyProperties *queue_props; + VkPhysicalDeviceMemoryProperties memory_properties; + + uint32_t enabled_extension_count; + uint32_t enabled_layer_count; + char *extension_names[64]; + char *enabled_layers[64]; + + int width, height; + VkFormat format; + VkColorSpaceKHR color_space; + + typedef struct { + VkImage image; + VkCommandBuffer cmd; + VkCommandBuffer graphics_to_present_cmd; + VkImageView view; + VkBuffer uniform_buffer; + VkDeviceMemory uniform_memory; + VkFramebuffer framebuffer; + VkDescriptorSet descriptor_set; + } SwapchainImageResources; + + PFN_vkGetPhysicalDeviceSurfaceSupportKHR fpGetPhysicalDeviceSurfaceSupportKHR; + PFN_vkGetPhysicalDeviceSurfaceCapabilitiesKHR fpGetPhysicalDeviceSurfaceCapabilitiesKHR; + PFN_vkGetPhysicalDeviceSurfaceFormatsKHR fpGetPhysicalDeviceSurfaceFormatsKHR; + PFN_vkGetPhysicalDeviceSurfacePresentModesKHR fpGetPhysicalDeviceSurfacePresentModesKHR; + PFN_vkCreateSwapchainKHR fpCreateSwapchainKHR; + PFN_vkDestroySwapchainKHR fpDestroySwapchainKHR; + PFN_vkGetSwapchainImagesKHR fpGetSwapchainImagesKHR; + PFN_vkAcquireNextImageKHR fpAcquireNextImageKHR; + PFN_vkQueuePresentKHR fpQueuePresentKHR; + PFN_vkGetRefreshCycleDurationGOOGLE fpGetRefreshCycleDurationGOOGLE; + PFN_vkGetPastPresentationTimingGOOGLE fpGetPastPresentationTimingGOOGLE; + uint32_t swapchainImageCount; + VkSwapchainKHR swapchain; + SwapchainImageResources *swapchain_image_resources; + VkPresentModeKHR presentMode; + VkFence fences[BACKBUFFER_COUNT]; + int frame_index; + + public: + GraphicsDevice_Vulkan(wiWindowRegistration::window_type window, bool fullscreen = false); + + ~GraphicsDevice_Vulkan(); + + virtual HRESULT CreateBuffer(const GPUBufferDesc *pDesc, const SubresourceData* pInitialData, GPUBuffer *ppBuffer) override; + virtual HRESULT CreateTexture1D(const Texture1DDesc* pDesc, const SubresourceData *pInitialData, Texture1D **ppTexture1D) override; + virtual HRESULT CreateTexture2D(const Texture2DDesc* pDesc, const SubresourceData *pInitialData, Texture2D **ppTexture2D) override; + virtual HRESULT CreateTexture3D(const Texture3DDesc* pDesc, const SubresourceData *pInitialData, Texture3D **ppTexture3D) override; + virtual HRESULT CreateInputLayout(const VertexLayoutDesc *pInputElementDescs, UINT NumElements, + const void *pShaderBytecodeWithInputSignature, SIZE_T BytecodeLength, VertexLayout *pInputLayout) override; + virtual HRESULT CreateVertexShader(const void *pShaderBytecode, SIZE_T BytecodeLength, VertexShader *pVertexShader) override; + virtual HRESULT CreatePixelShader(const void *pShaderBytecode, SIZE_T BytecodeLength, PixelShader *pPixelShader) override; + virtual HRESULT CreateGeometryShader(const void *pShaderBytecode, SIZE_T BytecodeLength, GeometryShader *pGeometryShader) override; + virtual HRESULT CreateHullShader(const void *pShaderBytecode, SIZE_T BytecodeLength, HullShader *pHullShader) override; + virtual HRESULT CreateDomainShader(const void *pShaderBytecode, SIZE_T BytecodeLength, DomainShader *pDomainShader) override; + virtual HRESULT CreateComputeShader(const void *pShaderBytecode, SIZE_T BytecodeLength, ComputeShader *pComputeShader) override; + virtual HRESULT CreateBlendState(const BlendStateDesc *pBlendStateDesc, BlendState *pBlendState) override; + virtual HRESULT CreateDepthStencilState(const DepthStencilStateDesc *pDepthStencilStateDesc, DepthStencilState *pDepthStencilState) override; + virtual HRESULT CreateRasterizerState(const RasterizerStateDesc *pRasterizerStateDesc, RasterizerState *pRasterizerState) override; + virtual HRESULT CreateSamplerState(const SamplerDesc *pSamplerDesc, Sampler *pSamplerState) override; + virtual HRESULT CreateQuery(const GPUQueryDesc *pDesc, GPUQuery *pQuery) override; + virtual HRESULT CreateGraphicsPSO(const GraphicsPSODesc* pDesc, GraphicsPSO* pso) override; + virtual HRESULT CreateComputePSO(const ComputePSODesc* pDesc, ComputePSO* pso) override; + + virtual void PresentBegin() override; + virtual void PresentEnd() override; + + virtual void ExecuteDeferredContexts() override; + virtual void FinishCommandList(GRAPHICSTHREAD thread) override; + + virtual void SetResolution(int width, int height) override; + + virtual Texture2D GetBackBuffer() override; + + ///////////////Thread-sensitive//////////////////////// + + virtual void BindViewports(UINT NumViewports, const ViewPort *pViewports, GRAPHICSTHREAD threadID) override; + virtual void BindRenderTargetsUAVs(UINT NumViews, Texture* const *ppRenderTargets, Texture2D* depthStencilTexture, GPUResource* const *ppUAVs, int slotUAV, int countUAV, + GRAPHICSTHREAD threadID, int arrayIndex = -1) override; + virtual void BindRenderTargets(UINT NumViews, Texture* const *ppRenderTargets, Texture2D* depthStencilTexture, GRAPHICSTHREAD threadID, int arrayIndex = -1) override; + virtual void ClearRenderTarget(Texture* pTexture, const FLOAT ColorRGBA[4], GRAPHICSTHREAD threadID, int arrayIndex = -1) override; + virtual void ClearDepthStencil(Texture2D* pTexture, UINT ClearFlags, FLOAT Depth, UINT8 Stencil, GRAPHICSTHREAD threadID, int arrayIndex = -1) override; + virtual void BindResource(SHADERSTAGE stage, GPUResource* resource, int slot, GRAPHICSTHREAD threadID, int arrayIndex = -1) override; + virtual void BindResources(SHADERSTAGE stage, GPUResource *const* resources, int slot, int count, GRAPHICSTHREAD threadID) override; + void BindUnorderedAccessResource(SHADERSTAGE stage, GPUResource* resource, int slot, GRAPHICSTHREAD threadID, int arrayIndex = -1); + void BindUnorderedAccessResources(SHADERSTAGE stage, GPUResource *const* resources, int slot, int count, GRAPHICSTHREAD threadID); + virtual void BindUnorderedAccessResourceCS(GPUResource* resource, int slot, GRAPHICSTHREAD threadID, int arrayIndex = -1) override; + virtual void BindUnorderedAccessResourcesCS(GPUResource *const* resources, int slot, int count, GRAPHICSTHREAD threadID) override; + virtual void UnBindResources(int slot, int num, GRAPHICSTHREAD threadID) override; + virtual void UnBindUnorderedAccessResources(int slot, int num, GRAPHICSTHREAD threadID) override; + virtual void BindSampler(SHADERSTAGE stage, Sampler* sampler, int slot, GRAPHICSTHREAD threadID) override; + virtual void BindConstantBuffer(SHADERSTAGE stage, GPUBuffer* buffer, int slot, GRAPHICSTHREAD threadID) override; + virtual void BindVertexBuffers(GPUBuffer* const *vertexBuffers, int slot, int count, const UINT* strides, const UINT* offsets, GRAPHICSTHREAD threadID) override; + virtual void BindIndexBuffer(GPUBuffer* indexBuffer, const INDEXBUFFER_FORMAT format, UINT offset, GRAPHICSTHREAD threadID) override; + virtual void BindPrimitiveTopology(PRIMITIVETOPOLOGY type, GRAPHICSTHREAD threadID) override; + virtual void BindStencilRef(UINT value, GRAPHICSTHREAD threadID) override; + virtual void BindBlendFactor(XMFLOAT4 value, GRAPHICSTHREAD threadID) override; + virtual void BindGraphicsPSO(GraphicsPSO* pso, GRAPHICSTHREAD threadID) override; + virtual void BindComputePSO(ComputePSO* pso, GRAPHICSTHREAD threadID) override; + virtual void Draw(int vertexCount, UINT startVertexLocation, GRAPHICSTHREAD threadID) override; + virtual void DrawIndexed(int indexCount, UINT startIndexLocation, UINT baseVertexLocation, GRAPHICSTHREAD threadID) override; + virtual void DrawInstanced(int vertexCount, int instanceCount, UINT startVertexLocation, UINT startInstanceLocation, GRAPHICSTHREAD threadID) override; + virtual void DrawIndexedInstanced(int indexCount, int instanceCount, UINT startIndexLocation, UINT baseVertexLocation, UINT startInstanceLocation, GRAPHICSTHREAD threadID) override; + virtual void DrawInstancedIndirect(GPUBuffer* args, UINT args_offset, GRAPHICSTHREAD threadID) override; + virtual void DrawIndexedInstancedIndirect(GPUBuffer* args, UINT args_offset, GRAPHICSTHREAD threadID) override; + virtual void Dispatch(UINT threadGroupCountX, UINT threadGroupCountY, UINT threadGroupCountZ, GRAPHICSTHREAD threadID) override; + virtual void DispatchIndirect(GPUBuffer* args, UINT args_offset, GRAPHICSTHREAD threadID) override; + virtual void GenerateMips(Texture* texture, GRAPHICSTHREAD threadID, int arrayIndex = -1) override; + virtual void CopyTexture2D(Texture2D* pDst, Texture2D* pSrc, GRAPHICSTHREAD threadID) override; + virtual void CopyTexture2D_Region(Texture2D* pDst, UINT dstMip, UINT dstX, UINT dstY, Texture2D* pSrc, UINT srcMip, GRAPHICSTHREAD threadID) override; + virtual void MSAAResolve(Texture2D* pDst, Texture2D* pSrc, GRAPHICSTHREAD threadID) override; + virtual void UpdateBuffer(GPUBuffer* buffer, const void* data, GRAPHICSTHREAD threadID, int dataSize = -1) override; + virtual void* AllocateFromRingBuffer(GPURingBuffer* buffer, size_t dataSize, UINT& offsetIntoBuffer, GRAPHICSTHREAD threadID) override; + virtual void InvalidateBufferAccess(GPUBuffer* buffer, GRAPHICSTHREAD threadID) override; + virtual bool DownloadBuffer(GPUBuffer* bufferToDownload, GPUBuffer* bufferDest, void* dataDest, GRAPHICSTHREAD threadID) override; + virtual void SetScissorRects(UINT numRects, const Rect* rects, GRAPHICSTHREAD threadID) override; + virtual void QueryBegin(GPUQuery *query, GRAPHICSTHREAD threadID) override; + virtual void QueryEnd(GPUQuery *query, GRAPHICSTHREAD threadID) override; + virtual bool QueryRead(GPUQuery *query, GRAPHICSTHREAD threadID) override; + virtual void UAVBarrier(GPUResource *const* uavs, UINT NumBarriers, GRAPHICSTHREAD threadID) override; + virtual void TransitionBarrier(GPUResource *const* resources, UINT NumBarriers, RESOURCE_STATES stateBefore, RESOURCE_STATES stateAfter, GRAPHICSTHREAD threadID) override; + + virtual HRESULT CreateTextureFromFile(const std::string& fileName, Texture2D **ppTexture, bool mipMaps, GRAPHICSTHREAD threadID) override; + virtual HRESULT SaveTexturePNG(const std::string& fileName, Texture2D *pTexture, GRAPHICSTHREAD threadID) override; + virtual HRESULT SaveTextureDDS(const std::string& fileName, Texture *pTexture, GRAPHICSTHREAD threadID) override; + + virtual void EventBegin(const std::string& name, GRAPHICSTHREAD threadID) override; + virtual void EventEnd(GRAPHICSTHREAD threadID) override; + virtual void SetMarker(const std::string& name, GRAPHICSTHREAD threadID) override; + + }; +} + +#endif // WICKEDENGINE_BUILD_VULKAN + +#endif // _GRAPHICSDEVICE_VULKAN_H_