Commit 259ad3d7 by Alexis Hetu Committed by Alexis Hétu

Initial implementation of ShaderModule

Basic shell class for ShaderModule Bug b/118386749 Change-Id: Ia41957ba1ef3be179d20c37cea0227a9a4509c7b Reviewed-on: https://swiftshader-review.googlesource.com/c/22609Tested-by: 's avatarAlexis Hétu <sugoi@google.com> Reviewed-by: 's avatarNicolas Capens <nicolascapens@google.com>
parent 000df8b4
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
#include "VkPhysicalDevice.hpp" #include "VkPhysicalDevice.hpp"
#include "VkQueue.hpp" #include "VkQueue.hpp"
#include "VkSemaphore.hpp" #include "VkSemaphore.hpp"
#include "VkShaderModule.hpp"
namespace vk namespace vk
{ {
......
// 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 "VkShaderModule.hpp"
#include <memory.h>
namespace vk
{
ShaderModule::ShaderModule(const VkShaderModuleCreateInfo* pCreateInfo, void* mem) : code(reinterpret_cast<uint32_t*>(mem))
{
memcpy(code, pCreateInfo->pCode, pCreateInfo->codeSize);
}
void ShaderModule::destroy(const VkAllocationCallbacks* pAllocator)
{
vk::deallocate(code, pAllocator);
}
size_t ShaderModule::ComputeRequiredAllocationSize(const VkShaderModuleCreateInfo* pCreateInfo)
{
return pCreateInfo->codeSize;
}
} // namespace vk
// 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_SHADER_MODULE_HPP_
#define VK_SHADER_MODULE_HPP_
#include "VkObject.hpp"
namespace vk
{
class ShaderModule : public Object<ShaderModule, VkShaderModule>
{
public:
ShaderModule(const VkShaderModuleCreateInfo* pCreateInfo, void* mem);
~ShaderModule() = delete;
void destroy(const VkAllocationCallbacks* pAllocator);
static size_t ComputeRequiredAllocationSize(const VkShaderModuleCreateInfo* pCreateInfo);
private:
uint32_t* code = nullptr;
};
static inline ShaderModule* Cast(VkShaderModule object)
{
return reinterpret_cast<ShaderModule*>(object);
}
} // namespace vk
#endif // VK_SHADER_MODULE_HPP_
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
#include "VkPipelineLayout.hpp" #include "VkPipelineLayout.hpp"
#include "VkQueue.hpp" #include "VkQueue.hpp"
#include "VkSemaphore.hpp" #include "VkSemaphore.hpp"
#include "VkShaderModule.hpp"
#include <algorithm> #include <algorithm>
#include <cstring> #include <cstring>
...@@ -750,9 +751,12 @@ VKAPI_ATTR VkResult VKAPI_CALL vkCreateShaderModule(VkDevice device, const VkSha ...@@ -750,9 +751,12 @@ VKAPI_ATTR VkResult VKAPI_CALL vkCreateShaderModule(VkDevice device, const VkSha
TRACE("(VkDevice device = 0x%X, const VkShaderModuleCreateInfo* pCreateInfo = 0x%X, const VkAllocationCallbacks* pAllocator = 0x%X, VkShaderModule* pShaderModule = 0x%X)", TRACE("(VkDevice device = 0x%X, const VkShaderModuleCreateInfo* pCreateInfo = 0x%X, const VkAllocationCallbacks* pAllocator = 0x%X, VkShaderModule* pShaderModule = 0x%X)",
device, pCreateInfo, pAllocator, pShaderModule); device, pCreateInfo, pAllocator, pShaderModule);
if(pCreateInfo->pNext || pCreateInfo->flags)
{
UNIMPLEMENTED(); UNIMPLEMENTED();
}
return VK_SUCCESS; return vk::ShaderModule::Create(pAllocator, pCreateInfo, pShaderModule);
} }
VKAPI_ATTR void VKAPI_CALL vkDestroyShaderModule(VkDevice device, VkShaderModule shaderModule, const VkAllocationCallbacks* pAllocator) VKAPI_ATTR void VKAPI_CALL vkDestroyShaderModule(VkDevice device, VkShaderModule shaderModule, const VkAllocationCallbacks* pAllocator)
...@@ -760,7 +764,7 @@ VKAPI_ATTR void VKAPI_CALL vkDestroyShaderModule(VkDevice device, VkShaderModule ...@@ -760,7 +764,7 @@ VKAPI_ATTR void VKAPI_CALL vkDestroyShaderModule(VkDevice device, VkShaderModule
TRACE("(VkDevice device = 0x%X, VkShaderModule shaderModule = 0x%X, const VkAllocationCallbacks* pAllocator = 0x%X)", TRACE("(VkDevice device = 0x%X, VkShaderModule shaderModule = 0x%X, const VkAllocationCallbacks* pAllocator = 0x%X)",
device, shaderModule, pAllocator); device, shaderModule, pAllocator);
UNIMPLEMENTED(); vk::destroy(shaderModule, pAllocator);
} }
VKAPI_ATTR VkResult VKAPI_CALL vkCreatePipelineCache(VkDevice device, const VkPipelineCacheCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkPipelineCache* pPipelineCache) VKAPI_ATTR VkResult VKAPI_CALL vkCreatePipelineCache(VkDevice device, const VkPipelineCacheCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkPipelineCache* pPipelineCache)
......
...@@ -113,6 +113,7 @@ copy "$(OutDir)vk_swiftshader.dll" "$(SolutionDir)out\$(Configuration)_$(Platfor ...@@ -113,6 +113,7 @@ copy "$(OutDir)vk_swiftshader.dll" "$(SolutionDir)out\$(Configuration)_$(Platfor
<ClCompile Include="VkPipelineLayout.cpp" /> <ClCompile Include="VkPipelineLayout.cpp" />
<ClCompile Include="VkPromotedExtensions.cpp" /> <ClCompile Include="VkPromotedExtensions.cpp" />
<ClCompile Include="VkQueue.cpp" /> <ClCompile Include="VkQueue.cpp" />
<ClCompile Include="VkShaderModule.cpp" />
<ClCompile Include="..\Device\Blitter.cpp" /> <ClCompile Include="..\Device\Blitter.cpp" />
<ClCompile Include="..\Device\Clipper.cpp" /> <ClCompile Include="..\Device\Clipper.cpp" />
<ClCompile Include="..\Device\Color.cpp" /> <ClCompile Include="..\Device\Color.cpp" />
...@@ -203,6 +204,7 @@ copy "$(OutDir)vk_swiftshader.dll" "$(SolutionDir)out\$(Configuration)_$(Platfor ...@@ -203,6 +204,7 @@ copy "$(OutDir)vk_swiftshader.dll" "$(SolutionDir)out\$(Configuration)_$(Platfor
<ClInclude Include="VkPipelineLayout.hpp" /> <ClInclude Include="VkPipelineLayout.hpp" />
<ClInclude Include="VkQueue.hpp" /> <ClInclude Include="VkQueue.hpp" />
<ClInclude Include="VkSemaphore.hpp" /> <ClInclude Include="VkSemaphore.hpp" />
<ClInclude Include="VkShaderModule.hpp" />
<ClInclude Include="..\Device\Blitter.hpp" /> <ClInclude Include="..\Device\Blitter.hpp" />
<ClInclude Include="..\Device\Clipper.hpp" /> <ClInclude Include="..\Device\Clipper.hpp" />
<ClInclude Include="..\Device\Color.hpp" /> <ClInclude Include="..\Device\Color.hpp" />
......
...@@ -237,6 +237,9 @@ ...@@ -237,6 +237,9 @@
<ClCompile Include="VkQueue.cpp"> <ClCompile Include="VkQueue.cpp">
<Filter>Source Files\Vulkan</Filter> <Filter>Source Files\Vulkan</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="VkShaderModule.cpp">
<Filter>Source Files\Vulkan</Filter>
</ClCompile>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClInclude Include="resource.h"> <ClInclude Include="resource.h">
...@@ -293,6 +296,9 @@ ...@@ -293,6 +296,9 @@
<ClInclude Include="VkSemaphore.hpp"> <ClInclude Include="VkSemaphore.hpp">
<Filter>Header Files\Vulkan</Filter> <Filter>Header Files\Vulkan</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="VkShaderModule.hpp">
<Filter>Header Files\Vulkan</Filter>
</ClInclude>
<ClInclude Include="..\Device\VertexProcessor.hpp"> <ClInclude Include="..\Device\VertexProcessor.hpp">
<Filter>Header Files\Device</Filter> <Filter>Header Files\Device</Filter>
</ClInclude> </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