mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-20 10:25:28 +00:00
Deprecate ShaderModuleDescriptor.code in favor of chained descriptor
This also adds the definition of the WGSL sub descriptor but forbids using it for now. Bug: dawn:22 Change-Id: I0514eec95bbcda28911547d6bda4d5257b62432b Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/19865 Commit-Queue: Corentin Wallez <cwallez@chromium.org> Reviewed-by: Ryan Harrison <rharrison@chromium.org> Reviewed-by: Austin Eng <enga@chromium.org> Reviewed-by: Kai Ninomiya <kainino@chromium.org>
This commit is contained in:
committed by
Commit Bot service account
parent
21744d0fb8
commit
fee2783cb0
@@ -51,9 +51,13 @@ namespace utils {
|
||||
ptrdiff_t resultSize = resultEnd - resultBegin;
|
||||
// SetSource takes data as uint32_t*.
|
||||
|
||||
wgpu::ShaderModuleSPIRVDescriptor spirvDesc;
|
||||
spirvDesc.codeSize = static_cast<uint32_t>(resultSize);
|
||||
spirvDesc.code = result.cbegin();
|
||||
|
||||
wgpu::ShaderModuleDescriptor descriptor;
|
||||
descriptor.codeSize = static_cast<uint32_t>(resultSize);
|
||||
descriptor.code = result.cbegin();
|
||||
descriptor.nextInChain = &spirvDesc;
|
||||
|
||||
return device.CreateShaderModule(&descriptor);
|
||||
}
|
||||
|
||||
@@ -113,6 +117,18 @@ namespace utils {
|
||||
return CreateShaderModuleFromResult(device, result);
|
||||
}
|
||||
|
||||
std::vector<uint32_t> CompileGLSLToSpirv(SingleShaderStage stage, const char* source) {
|
||||
shaderc_shader_kind kind = ShadercShaderKind(stage);
|
||||
|
||||
shaderc::Compiler compiler;
|
||||
auto result = compiler.CompileGlslToSpv(source, strlen(source), kind, "myshader?");
|
||||
if (result.GetCompilationStatus() != shaderc_compilation_status_success) {
|
||||
dawn::ErrorLog() << result.GetErrorMessage();
|
||||
return {};
|
||||
}
|
||||
return {result.cbegin(), result.cend()};
|
||||
}
|
||||
|
||||
wgpu::Buffer CreateBufferFromData(const wgpu::Device& device,
|
||||
const void* data,
|
||||
uint64_t size,
|
||||
|
||||
@@ -32,6 +32,7 @@ namespace utils {
|
||||
SingleShaderStage stage,
|
||||
const char* source);
|
||||
wgpu::ShaderModule CreateShaderModuleFromASM(const wgpu::Device& device, const char* source);
|
||||
std::vector<uint32_t> CompileGLSLToSpirv(SingleShaderStage stage, const char* source);
|
||||
|
||||
wgpu::Buffer CreateBufferFromData(const wgpu::Device& device,
|
||||
const void* data,
|
||||
|
||||
Reference in New Issue
Block a user