OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2016 Google Inc. | 2 * Copyright 2016 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #include "vk/GrVkPipelineStateBuilder.h" | 8 #include "vk/GrVkPipelineStateBuilder.h" |
9 | 9 |
10 #include "vk/GrVkGpu.h" | 10 #include "vk/GrVkGpu.h" |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 } | 43 } |
44 | 44 |
45 const GrCaps* GrVkPipelineStateBuilder::caps() const { | 45 const GrCaps* GrVkPipelineStateBuilder::caps() const { |
46 return fGpu->caps(); | 46 return fGpu->caps(); |
47 } | 47 } |
48 const GrGLSLCaps* GrVkPipelineStateBuilder::glslCaps() const { | 48 const GrGLSLCaps* GrVkPipelineStateBuilder::glslCaps() const { |
49 return fGpu->vkCaps().glslCaps(); | 49 return fGpu->vkCaps().glslCaps(); |
50 } | 50 } |
51 | 51 |
52 void GrVkPipelineStateBuilder::finalizeFragmentOutputColor(GrGLSLShaderVar& outp
utColor) { | 52 void GrVkPipelineStateBuilder::finalizeFragmentOutputColor(GrGLSLShaderVar& outp
utColor) { |
53 outputColor.setLayoutQualifier("location = 0"); | 53 outputColor.setLayoutQualifier("location = 0, index = 0"); |
54 } | 54 } |
55 | 55 |
56 void GrVkPipelineStateBuilder::finalizeFragmentSecondaryColor(GrGLSLShaderVar& o
utputColor) { | 56 void GrVkPipelineStateBuilder::finalizeFragmentSecondaryColor(GrGLSLShaderVar& o
utputColor) { |
57 outputColor.setLayoutQualifier("location = 1"); | 57 outputColor.setLayoutQualifier("location = 0, index = 1"); |
58 } | 58 } |
59 | 59 |
60 VkShaderStageFlags visibility_to_vk_stage_flags(uint32_t visibility) { | 60 VkShaderStageFlags visibility_to_vk_stage_flags(uint32_t visibility) { |
61 VkShaderStageFlags flags = 0; | 61 VkShaderStageFlags flags = 0; |
62 | 62 |
63 if (visibility & kVertex_GrShaderFlag) { | 63 if (visibility & kVertex_GrShaderFlag) { |
64 flags |= VK_SHADER_STAGE_VERTEX_BIT; | 64 flags |= VK_SHADER_STAGE_VERTEX_BIT; |
65 } | 65 } |
66 if (visibility & kGeometry_GrShaderFlag) { | 66 if (visibility & kGeometry_GrShaderFlag) { |
67 flags |= VK_SHADER_STAGE_GEOMETRY_BIT; | 67 flags |= VK_SHADER_STAGE_GEOMETRY_BIT; |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 shaderc_compilation_result_t result = nullptr; | 102 shaderc_compilation_result_t result = nullptr; |
103 | 103 |
104 if (gpu->vkCaps().canUseGLSLForShaderModule()) { | 104 if (gpu->vkCaps().canUseGLSLForShaderModule()) { |
105 moduleCreateInfo.codeSize = strlen(shaderString.c_str()); | 105 moduleCreateInfo.codeSize = strlen(shaderString.c_str()); |
106 moduleCreateInfo.pCode = (const uint32_t*)shaderString.c_str(); | 106 moduleCreateInfo.pCode = (const uint32_t*)shaderString.c_str(); |
107 } else { | 107 } else { |
108 | 108 |
109 shaderc_compiler_t compiler = gpu->shadercCompiler(); | 109 shaderc_compiler_t compiler = gpu->shadercCompiler(); |
110 | 110 |
111 shaderc_compile_options_t options = shaderc_compile_options_initialize()
; | 111 shaderc_compile_options_t options = shaderc_compile_options_initialize()
; |
112 shaderc_compile_options_set_forced_version_profile(options, 140, shaderc
_profile_none); | |
113 | 112 |
114 shaderc_shader_kind shadercStage = vk_shader_stage_to_shaderc_kind(stage
); | 113 shaderc_shader_kind shadercStage = vk_shader_stage_to_shaderc_kind(stage
); |
115 result = shaderc_compile_into_spv(compiler, | 114 result = shaderc_compile_into_spv(compiler, |
116 shaderString.c_str(), | 115 shaderString.c_str(), |
117 strlen(shaderString.c_str()), | 116 strlen(shaderString.c_str()), |
118 shadercStage, | 117 shadercStage, |
119 "shader", | 118 "shader", |
120 "main", | 119 "main", |
121 options); | 120 options); |
122 shaderc_compile_options_release(options); | 121 shaderc_compile_options_release(options); |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
295 dsLayout, | 294 dsLayout, |
296 fUniformHandles, | 295 fUniformHandles, |
297 fUniformHandler.fUniforms, | 296 fUniformHandler.fUniforms, |
298 fUniformHandler.fCurrentVertexUBOOffset, | 297 fUniformHandler.fCurrentVertexUBOOffset, |
299 fUniformHandler.fCurrentFragmentUBOOffset, | 298 fUniformHandler.fCurrentFragmentUBOOffset, |
300 numSamplers, | 299 numSamplers, |
301 fGeometryProcessor, | 300 fGeometryProcessor, |
302 fXferProcessor, | 301 fXferProcessor, |
303 fFragmentProcessors); | 302 fFragmentProcessors); |
304 } | 303 } |
OLD | NEW |