Commit 5174c572 by Alexis Hetu Committed by Alexis Hétu

Vulkan Sampler implementation

The Vulkan sampler is simply a state, similar to the existing sw::Sampler::State(), which will eventually be used by the texture sampling code. Bug b/119823006 Change-Id: Ib2f09683f82dbf5b5aacde1555ee850c76cda9e2 Reviewed-on: https://swiftshader-review.googlesource.com/c/22728Tested-by: 's avatarAlexis Hétu <sugoi@google.com> Reviewed-by: 's avatarNicolas Capens <nicolascapens@google.com>
parent dcb803a7
......@@ -26,6 +26,7 @@
#include "VkPipelineLayout.hpp"
#include "VkPhysicalDevice.hpp"
#include "VkQueue.hpp"
#include "VkSampler.hpp"
#include "VkSemaphore.hpp"
#include "VkShaderModule.hpp"
#include "VkRenderPass.hpp"
......
// 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_SAMPLER_HPP_
#define VK_SAMPLER_HPP_
#include "VkDevice.hpp"
namespace vk
{
class Sampler : public Object<Sampler, VkSampler>
{
public:
Sampler(const VkSamplerCreateInfo* pCreateInfo, void* mem) :
magFilter(pCreateInfo->magFilter),
minFilter(pCreateInfo->minFilter),
mipmapMode(pCreateInfo->mipmapMode),
addressModeU(pCreateInfo->addressModeU),
addressModeV(pCreateInfo->addressModeV),
addressModeW(pCreateInfo->addressModeW),
mipLodBias(pCreateInfo->mipLodBias),
anisotropyEnable(pCreateInfo->anisotropyEnable),
maxAnisotropy(pCreateInfo->maxAnisotropy),
compareEnable(pCreateInfo->compareEnable),
compareOp(pCreateInfo->compareOp),
minLod(pCreateInfo->minLod),
maxLod(pCreateInfo->maxLod),
borderColor(pCreateInfo->borderColor),
unnormalizedCoordinates(pCreateInfo->unnormalizedCoordinates)
{
}
~Sampler() = delete;
static size_t ComputeRequiredAllocationSize(const VkSamplerCreateInfo* pCreateInfo)
{
return 0;
}
private:
VkFilter magFilter = VK_FILTER_NEAREST;
VkFilter minFilter = VK_FILTER_NEAREST;
VkSamplerMipmapMode mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST;
VkSamplerAddressMode addressModeU = VK_SAMPLER_ADDRESS_MODE_REPEAT;
VkSamplerAddressMode addressModeV = VK_SAMPLER_ADDRESS_MODE_REPEAT;
VkSamplerAddressMode addressModeW = VK_SAMPLER_ADDRESS_MODE_REPEAT;
float mipLodBias = 0.0f;
VkBool32 anisotropyEnable = VK_FALSE;
float maxAnisotropy = 0.0f;
VkBool32 compareEnable = VK_FALSE;
VkCompareOp compareOp = VK_COMPARE_OP_NEVER;
float minLod = 0.0f;
float maxLod = 0.0f;
VkBorderColor borderColor = VK_BORDER_COLOR_FLOAT_TRANSPARENT_BLACK;
VkBool32 unnormalizedCoordinates = VK_FALSE;
};
static inline Sampler* Cast(VkSampler object)
{
return reinterpret_cast<Sampler*>(object);
}
} // namespace vk
#endif // VK_SAMPLER_HPP_
\ No newline at end of file
......@@ -30,6 +30,7 @@
#include "VkPipeline.hpp"
#include "VkPipelineLayout.hpp"
#include "VkQueue.hpp"
#include "VkSampler.hpp"
#include "VkSemaphore.hpp"
#include "VkShaderModule.hpp"
#include "VkRenderPass.hpp"
......@@ -768,7 +769,7 @@ VKAPI_ATTR VkResult VKAPI_CALL vkCreateShaderModule(VkDevice device, const VkSha
VKAPI_ATTR void VKAPI_CALL vkDestroyShaderModule(VkDevice device, VkShaderModule shaderModule, const VkAllocationCallbacks* pAllocator)
{
TRACE("(VkDevice device = 0x%X, VkShaderModule shaderModule = 0x%X, const VkAllocationCallbacks* pAllocator = 0x%X)",
device, shaderModule, pAllocator);
device, shaderModule, pAllocator);
vk::destroy(shaderModule, pAllocator);
}
......@@ -898,9 +899,12 @@ VKAPI_ATTR VkResult VKAPI_CALL vkCreateSampler(VkDevice device, const VkSamplerC
TRACE("(VkDevice device = 0x%X, const VkSamplerCreateInfo* pCreateInfo = 0x%X, const VkAllocationCallbacks* pAllocator = 0x%X, VkSampler* pSampler = 0x%X)",
device, pCreateInfo, pAllocator, pSampler);
UNIMPLEMENTED();
if(pCreateInfo->pNext || pCreateInfo->flags)
{
UNIMPLEMENTED();
}
return VK_SUCCESS;
return vk::Sampler::Create(pAllocator, pCreateInfo, pSampler);
}
VKAPI_ATTR void VKAPI_CALL vkDestroySampler(VkDevice device, VkSampler sampler, const VkAllocationCallbacks* pAllocator)
......@@ -908,7 +912,7 @@ VKAPI_ATTR void VKAPI_CALL vkDestroySampler(VkDevice device, VkSampler sampler,
TRACE("(VkDevice device = 0x%X, VkSampler sampler = 0x%X, const VkAllocationCallbacks* pAllocator = 0x%X)",
device, sampler, pAllocator);
UNIMPLEMENTED();
vk::destroy(sampler, pAllocator);
}
VKAPI_ATTR VkResult VKAPI_CALL vkCreateDescriptorSetLayout(VkDevice device, const VkDescriptorSetLayoutCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkDescriptorSetLayout* pSetLayout)
......
......@@ -209,6 +209,7 @@ copy "$(OutDir)vk_swiftshader.dll" "$(SolutionDir)out\$(Configuration)_$(Platfor
<ClInclude Include="VkPipelineLayout.hpp" />
<ClInclude Include="VkQueue.hpp" />
<ClInclude Include="VkRenderPass.hpp" />
<ClInclude Include="VkSampler.hpp" />
<ClInclude Include="VkSemaphore.hpp" />
<ClInclude Include="VkShaderModule.hpp" />
<ClInclude Include="..\Device\Blitter.hpp" />
......
......@@ -311,6 +311,9 @@
<ClInclude Include="VkRenderPass.hpp">
<Filter>Header Files\Vulkan</Filter>
</ClInclude>
<ClInclude Include="VkSampler.hpp">
<Filter>Header Files\Vulkan</Filter>
</ClInclude>
<ClInclude Include="VkSemaphore.hpp">
<Filter>Header Files\Vulkan</Filter>
</ClInclude>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment