From: Jacob Lifshay Date: Sat, 19 Aug 2017 00:53:27 +0000 (-0700) Subject: start working on adding Image class X-Git-Tag: gsoc-2017~38 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=4c1af66aa90cdd6ee163fdb55691287fe40abba0;p=kazan.git start working on adding Image class --- diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 306bcc6..cdfb701 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -22,6 +22,7 @@ cmake_minimum_required(VERSION 3.1 FATAL_ERROR) include_directories(${CMAKE_CURRENT_SOURCE_DIR}) add_subdirectory(demo) add_subdirectory(generate_spirv_parser) +add_subdirectory(image) add_subdirectory(json) add_subdirectory(llvm_wrapper) add_subdirectory(pipeline) diff --git a/src/image/CMakeLists.txt b/src/image/CMakeLists.txt new file mode 100644 index 0000000..297725f --- /dev/null +++ b/src/image/CMakeLists.txt @@ -0,0 +1,24 @@ +# Copyright 2017 Jacob Lifshay +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. +# +cmake_minimum_required(VERSION 3.1 FATAL_ERROR) +set(sources image.cpp) +add_library(vulkan_cpu_image STATIC ${sources}) +target_link_libraries(vulkan_cpu_image vulkan_cpu_util vulkan_cpu_llvm_wrapper vulkan_cpu_vulkan) diff --git a/src/image/image.cpp b/src/image/image.cpp new file mode 100644 index 0000000..7f59214 --- /dev/null +++ b/src/image/image.cpp @@ -0,0 +1,23 @@ +/* + * Copyright 2017 Jacob Lifshay + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + */ +#include "image.h" diff --git a/src/image/image.h b/src/image/image.h new file mode 100644 index 0000000..6fe65fb --- /dev/null +++ b/src/image/image.h @@ -0,0 +1,74 @@ +/* + * Copyright 2017 Jacob Lifshay + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + */ +#ifndef IMAGE_IMAGE_H_ +#define IMAGE_IMAGE_H_ + +#include "vulkan/vulkan.h" +#include +#include +#include +#include "util/constexpr_array.h" + +namespace vulkan_cpu +{ +namespace image +{ +struct Image +{ + const VkImageType type; + const VkImageTiling tiling; + const VkFormat format; + const util::Constexpr_array dimensions; + const std::size_t memory_size; + std::unique_ptr memory; + Image(VkImageType type, + VkImageTiling tiling, + VkFormat format, + const util::Constexpr_array &dimensions, + std::unique_ptr memory = nullptr) noexcept + : type(type), + tiling(tiling), + format(format), + dimensions(dimensions), + memory_size(get_memory_size(type, tiling, format, dimensions)), + memory(std::move(memory)) + { + } + static constexpr std::size_t get_memory_size( + VkImageType type, + VkImageTiling tiling, + VkFormat format, + const util::Constexpr_array &dimensions) noexcept + { +#warning finish implementing Image + assert(type == VK_IMAGE_TYPE_2D); + assert(tiling == VK_IMAGE_TILING_LINEAR); + assert(format == VK_FORMAT_R8G8B8A8_SRGB); + return sizeof(std::uint32_t) * dimensions[0] * dimensions[1]; + } +#warning finish implementing Image +}; +} +} + +#endif // IMAGE_IMAGE_H_