OSDN Git Service

Initial implementation of Image
authorAlexis Hetu <sugoi@google.com>
Thu, 15 Nov 2018 19:51:15 +0000 (14:51 -0500)
committerAlexis Hétu <sugoi@google.com>
Fri, 16 Nov 2018 14:54:34 +0000 (14:54 +0000)
Basic shell class for Image

Bug b/119620767

Change-Id: I75d37dd8c1a9b98264fe6dae68cd4753d6942103
Reviewed-on: https://swiftshader-review.googlesource.com/c/22610
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
src/Vulkan/VkDestroy.h
src/Vulkan/VkImage.cpp [new file with mode: 0644]
src/Vulkan/VkImage.hpp [new file with mode: 0644]
src/Vulkan/libVulkan.cpp
src/Vulkan/vulkan.vcxproj
src/Vulkan/vulkan.vcxproj.filters

index 1686bf0..0931bb7 100644 (file)
@@ -19,6 +19,7 @@
 #include "VkDeviceMemory.hpp"
 #include "VkEvent.hpp"
 #include "VkFence.hpp"
+#include "VkImage.hpp"
 #include "VkInstance.hpp"
 #include "VkPipeline.hpp"
 #include "VkPipelineLayout.hpp"
diff --git a/src/Vulkan/VkImage.cpp b/src/Vulkan/VkImage.cpp
new file mode 100644 (file)
index 0000000..e5856ac
--- /dev/null
@@ -0,0 +1,33 @@
+// Copyright 2018 The SwiftShader Authors. All Rights Reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//    http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include "VkImage.hpp"
+
+namespace vk
+{
+
+Image::Image(const VkImageCreateInfo* pCreateInfo, void* mem)
+{
+}
+
+void Image::destroy(const VkAllocationCallbacks* pAllocator)
+{
+}
+
+size_t Image::ComputeRequiredAllocationSize(const VkImageCreateInfo* pCreateInfo)
+{
+       return 0;
+}
+
+} // namespace vk
\ No newline at end of file
diff --git a/src/Vulkan/VkImage.hpp b/src/Vulkan/VkImage.hpp
new file mode 100644 (file)
index 0000000..9e4261f
--- /dev/null
@@ -0,0 +1,42 @@
+// Copyright 2018 The SwiftShader Authors. All Rights Reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//    http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef VK_IMAGE_HPP_
+#define VK_IMAGE_HPP_
+
+#include "VkObject.hpp"
+
+namespace vk
+{
+
+class Image : public Object<Image, VkImage>
+{
+public:
+       Image(const VkImageCreateInfo* pCreateInfo, void* mem);
+       ~Image() = delete;
+       void destroy(const VkAllocationCallbacks* pAllocator);
+
+       static size_t ComputeRequiredAllocationSize(const VkImageCreateInfo* pCreateInfo);
+
+private:
+};
+
+static inline Image* Cast(VkImage object)
+{
+       return reinterpret_cast<Image*>(object);
+}
+
+} // namespace vk
+
+#endif // VK_IMAGE_HPP_
\ No newline at end of file
index 2d4df6f..c4180cb 100644 (file)
@@ -23,6 +23,7 @@
 #include "VkEvent.hpp"
 #include "VkFence.hpp"
 #include "VkGetProcAddress.h"
+#include "VkImage.hpp"
 #include "VkInstance.hpp"
 #include "VkPhysicalDevice.hpp"
 #include "VkPipeline.hpp"
@@ -711,9 +712,12 @@ VKAPI_ATTR VkResult VKAPI_CALL vkCreateImage(VkDevice device, const VkImageCreat
        TRACE("(VkDevice device = 0x%X, const VkImageCreateInfo* pCreateInfo = 0x%X, const VkAllocationCallbacks* pAllocator = 0x%X, VkImage* pImage = 0x%X)",
                    device, pCreateInfo, pAllocator, pImage);
 
-       UNIMPLEMENTED();
+       if(pCreateInfo->pNext)
+       {
+               UNIMPLEMENTED();
+       }
 
-       return VK_SUCCESS;
+       return vk::Image::Create(pAllocator, pCreateInfo, pImage);
 }
 
 VKAPI_ATTR void VKAPI_CALL vkDestroyImage(VkDevice device, VkImage image, const VkAllocationCallbacks* pAllocator)
@@ -721,7 +725,7 @@ VKAPI_ATTR void VKAPI_CALL vkDestroyImage(VkDevice device, VkImage image, const
        TRACE("(VkDevice device = 0x%X, VkImage image = 0x%X, const VkAllocationCallbacks* pAllocator = 0x%X)",
                    device, image, pAllocator);
 
-       UNIMPLEMENTED();
+       vk::destroy(image, pAllocator);
 }
 
 VKAPI_ATTR void VKAPI_CALL vkGetImageSubresourceLayout(VkDevice device, VkImage image, const VkImageSubresource* pSubresource, VkSubresourceLayout* pLayout)
index 1f44cc4..266dcea 100644 (file)
@@ -106,6 +106,7 @@ copy "$(OutDir)vk_swiftshader.dll" "$(SolutionDir)out\$(Configuration)_$(Platfor
     <ClCompile Include="VkDevice.cpp" />\r
     <ClCompile Include="VkDeviceMemory.cpp" />\r
     <ClCompile Include="VkGetProcAddress.cpp" />\r
+    <ClCompile Include="VkImage.cpp" />\r
     <ClCompile Include="VkInstance.cpp" />\r
     <ClCompile Include="VkMemory.cpp" />\r
     <ClCompile Include="VkPhysicalDevice.cpp" />\r
@@ -196,6 +197,7 @@ copy "$(OutDir)vk_swiftshader.dll" "$(SolutionDir)out\$(Configuration)_$(Platfor
     <ClInclude Include="VkEvent.hpp" />\r
     <ClInclude Include="VkFence.hpp" />\r
     <ClInclude Include="VkGetProcAddress.h" />\r
+    <ClInclude Include="VkImage.hpp" />\r
     <ClInclude Include="VkInstance.hpp" />\r
     <ClInclude Include="VkMemory.h" />\r
     <ClInclude Include="VkObject.hpp" />\r
index de1d38f..642ff05 100644 (file)
     <ClCompile Include="VkPipelineLayout.cpp">\r
       <Filter>Source Files\Vulkan</Filter>\r
     </ClCompile>\r
+    <ClCompile Include="VkImage.cpp">\r
+      <Filter>Source Files\Vulkan</Filter>\r
+    </ClCompile>\r
     <ClCompile Include="VkPromotedExtensions.cpp">\r
       <Filter>Source Files\Vulkan</Filter>\r
     </ClCompile>\r
     <ClInclude Include="VkGetProcAddress.h">\r
       <Filter>Header Files\Vulkan</Filter>\r
     </ClInclude>\r
+    <ClInclude Include="VkImage.hpp">\r
+      <Filter>Header Files\Vulkan</Filter>\r
+    </ClInclude>\r
     <ClInclude Include="VkInstance.hpp">\r
       <Filter>Header Files\Vulkan</Filter>\r
     </ClInclude>\r