Commit d34aa362 by Jamie Madill Committed by Commit Bot

Vulkan: Add a create shader helper.

This will be useful for line segment rasterization. Bug: angleproject:2598 Change-Id: I84912c976665ecb32903181fa820b8db88786a28 Reviewed-on: https://chromium-review.googlesource.com/1127299 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org>
parent ddd8eaa8
......@@ -243,29 +243,10 @@ gl::LinkResult ProgramVk::link(const gl::Context *glContext,
return false;
}
{
VkShaderModuleCreateInfo vertexShaderInfo;
vertexShaderInfo.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO;
vertexShaderInfo.pNext = nullptr;
vertexShaderInfo.flags = 0;
vertexShaderInfo.codeSize = vertexCode.size() * sizeof(uint32_t);
vertexShaderInfo.pCode = vertexCode.data();
ANGLE_TRY(mDefaultVertexShaderAndSerial.get().init(contextVk, vertexShaderInfo));
mDefaultVertexShaderAndSerial.updateSerial(renderer->issueShaderSerial());
}
{
VkShaderModuleCreateInfo fragmentShaderInfo;
fragmentShaderInfo.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO;
fragmentShaderInfo.pNext = nullptr;
fragmentShaderInfo.flags = 0;
fragmentShaderInfo.codeSize = fragmentCode.size() * sizeof(uint32_t);
fragmentShaderInfo.pCode = fragmentCode.data();
ANGLE_TRY(mDefaultFragmentShaderAndSerial.get().init(contextVk, fragmentShaderInfo));
mDefaultFragmentShaderAndSerial.updateSerial(renderer->issueShaderSerial());
}
ANGLE_TRY(vk::InitShaderAndSerial(contextVk, &mDefaultVertexShaderAndSerial, vertexCode.data(),
vertexCode.size() * sizeof(uint32_t)));
ANGLE_TRY(vk::InitShaderAndSerial(contextVk, &mDefaultFragmentShaderAndSerial,
fragmentCode.data(), fragmentCode.size() * sizeof(uint32_t)));
ANGLE_TRY(initDefaultUniformBlocks(glContext));
......
......@@ -42,19 +42,9 @@ angle::Result ShaderLibrary::getShader(vk::Context *context,
return angle::Result::Continue();
}
const priv::ShaderBlob &shaderCode = priv::GetInternalShaderBlob(shaderID);
// Create shader lazily. Access will need to be locked for multi-threading.
VkShaderModuleCreateInfo createInfo;
createInfo.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO;
createInfo.pNext = nullptr;
createInfo.flags = 0;
createInfo.codeSize = shaderCode.codeSize;
createInfo.pCode = shaderCode.code;
ANGLE_TRY(shader.get().init(context, createInfo));
shader.updateSerial(context->getRenderer()->issueShaderSerial());
return angle::Result::Continue();
const priv::ShaderBlob &shaderCode = priv::GetInternalShaderBlob(shaderID);
return InitShaderAndSerial(context, &shader, shaderCode.code, shaderCode.codeSize);
}
} // namespace vk
} // namespace rx
......@@ -1095,6 +1095,23 @@ angle::Result AllocateImageMemory(vk::Context *context,
return AllocateBufferOrImageMemory(context, memoryPropertyFlags, image, deviceMemoryOut);
}
angle::Result InitShaderAndSerial(Context *context,
ShaderAndSerial *shaderAndSerial,
const uint32_t *shaderCode,
size_t shaderCodeSize)
{
VkShaderModuleCreateInfo createInfo;
createInfo.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO;
createInfo.pNext = nullptr;
createInfo.flags = 0;
createInfo.codeSize = shaderCodeSize;
createInfo.pCode = shaderCode;
ANGLE_TRY(shaderAndSerial->get().init(context, createInfo));
shaderAndSerial->updateSerial(context->getRenderer()->issueShaderSerial());
return angle::Result::Continue();
}
// GarbageObject implementation.
GarbageObject::GarbageObject()
: mSerial(), mHandleType(HandleType::Invalid), mHandle(VK_NULL_HANDLE)
......
......@@ -680,6 +680,11 @@ using ShaderMap = angle::PackedEnumMap<ShaderType, T>;
using AllShaderTypes = angle::AllEnums<vk::ShaderType>;
angle::Result InitShaderAndSerial(Context *context,
ShaderAndSerial *shaderAndSerial,
const uint32_t *shaderCode,
size_t shaderCodeSize);
enum class RecordingMode
{
Start,
......
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