MCPcopy Create free account
hub / github.com/android/ndk-samples / createGraphicsPipeline

Method createGraphicsPipeline

hello-vulkan/app/src/main/cpp/hellovk.h:1103–1230  ·  view source on GitHub ↗

* Creates a graphics pipeline loading a simple vertex and fragment shader, both * with 'main' set as entrypoint A list of standard parameters are provided: * - The vertex input coming from the application is set to empty - we are * hardcoding the triangle in the vertex shader. * - The input assembly is configured to draw triangle lists * - We intend to draw onto the whole screen, so the sc

Source from the content-addressed store, hash-verified

1101 * in order to render a rotated scene when the device has been rotated.
1102 */
1103void HelloVK::createGraphicsPipeline() {
1104 auto vertShaderCode =
1105 LoadBinaryFileToVector("shaders/shader.vert.spv", assetManager);
1106 auto fragShaderCode =
1107 LoadBinaryFileToVector("shaders/shader.frag.spv", assetManager);
1108
1109 VkShaderModule vertShaderModule = createShaderModule(vertShaderCode);
1110 VkShaderModule fragShaderModule = createShaderModule(fragShaderCode);
1111
1112 VkPipelineShaderStageCreateInfo vertShaderStageInfo{};
1113 vertShaderStageInfo.sType =
1114 VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO;
1115 vertShaderStageInfo.stage = VK_SHADER_STAGE_VERTEX_BIT;
1116 vertShaderStageInfo.module = vertShaderModule;
1117 vertShaderStageInfo.pName = "main";
1118
1119 VkPipelineShaderStageCreateInfo fragShaderStageInfo{};
1120 fragShaderStageInfo.sType =
1121 VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO;
1122 fragShaderStageInfo.stage = VK_SHADER_STAGE_FRAGMENT_BIT;
1123 fragShaderStageInfo.module = fragShaderModule;
1124 fragShaderStageInfo.pName = "main";
1125
1126 VkPipelineShaderStageCreateInfo shaderStages[] = {vertShaderStageInfo,
1127 fragShaderStageInfo};
1128
1129 VkPipelineVertexInputStateCreateInfo vertexInputInfo{};
1130 vertexInputInfo.sType =
1131 VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO;
1132 vertexInputInfo.vertexBindingDescriptionCount = 0;
1133 vertexInputInfo.pVertexBindingDescriptions = nullptr;
1134 vertexInputInfo.vertexAttributeDescriptionCount = 0;
1135 vertexInputInfo.pVertexAttributeDescriptions = nullptr;
1136
1137 VkPipelineInputAssemblyStateCreateInfo inputAssembly{};
1138 inputAssembly.sType =
1139 VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO;
1140 inputAssembly.topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST;
1141 inputAssembly.primitiveRestartEnable = VK_FALSE;
1142
1143 VkPipelineViewportStateCreateInfo viewportState{};
1144 viewportState.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO;
1145 viewportState.viewportCount = 1;
1146 viewportState.scissorCount = 1;
1147
1148 VkPipelineRasterizationStateCreateInfo rasterizer{};
1149 rasterizer.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO;
1150 rasterizer.depthClampEnable = VK_FALSE;
1151 rasterizer.rasterizerDiscardEnable = VK_FALSE;
1152 rasterizer.polygonMode = VK_POLYGON_MODE_FILL;
1153 rasterizer.lineWidth = 1.0f;
1154
1155 rasterizer.cullMode = VK_CULL_MODE_BACK_BIT;
1156 rasterizer.frontFace = VK_FRONT_FACE_CLOCKWISE;
1157
1158 rasterizer.depthBiasEnable = VK_FALSE;
1159 rasterizer.depthBiasConstantFactor = 0.0f;
1160 rasterizer.depthBiasClamp = 0.0f;

Callers

nothing calls this directly

Calls 2

LoadBinaryFileToVectorFunction · 0.85
dataMethod · 0.80

Tested by

no test coverage detected