MCPcopy Create free account
hub / github.com/PixarAnimationStudios/OpenUSD / _CreateShaderProgram

Method _CreateShaderProgram

pxr/imaging/hgi/unitTestHelper.cpp:88–132  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

86}
87
88bool
89HgiPipelineCreationTestDriver::_CreateShaderProgram()
90{
91 HgiShaderFunctionDesc vertDesc;
92 vertDesc.debugName = TfToken("Vertex");
93 vertDesc.shaderStage = HgiShaderStageVertex;
94 HgiShaderFunctionAddStageInput(
95 &vertDesc, "position", "vec4", "position");
96 HgiShaderFunctionAddStageInput(
97 &vertDesc, "uvIn", "vec2");
98 HgiShaderFunctionAddStageOutput(
99 &vertDesc, "gl_Position", "vec4", "position");
100 HgiShaderFunctionAddStageOutput(
101 &vertDesc, "uvOut", "vec2");
102
103 HgiShaderFunctionDesc fragDesc;
104 fragDesc.debugName = TfToken("Fragment");
105 fragDesc.shaderStage = HgiShaderStageFragment;
106 HgiShaderFunctionAddStageInput(
107 &fragDesc, "uvOut", "vec2");
108 HgiShaderFunctionAddStageOutput(
109 &fragDesc, "hd_FragColor", "vec4", "color");
110
111 vertDesc.shaderCode = glslfx_vertShaderStr.c_str();
112 HgiShaderFunctionHandle vertFn = _hgi->CreateShaderFunction(vertDesc);
113
114 fragDesc.shaderCode = glslfx_fragShaderStr.c_str();
115 HgiShaderFunctionHandle fragFn = _hgi->CreateShaderFunction(fragDesc);
116
117 HgiShaderProgramDesc programDesc;
118 programDesc.debugName = TfToken("FullscreenTriangle").GetString();
119 programDesc.shaderFunctions.push_back(std::move(vertFn));
120 programDesc.shaderFunctions.push_back(std::move(fragFn));
121 _shaderProgram = _hgi->CreateShaderProgram(programDesc);
122
123 if (!_shaderProgram->IsValid() || !vertFn->IsValid() ||
124 !fragFn->IsValid()) {
125 TF_CODING_ERROR("Failed to create shader program");
126 _PrintCompileErrors();
127 _DestroyShaderProgram();
128 return false;
129 }
130
131 return true;
132}
133
134bool
135HgiPipelineCreationTestDriver::_CreatePipeline()

Callers

nothing calls this directly

Calls 9

push_backMethod · 0.80
TfTokenClass · 0.50
c_strMethod · 0.45
CreateShaderFunctionMethod · 0.45
GetStringMethod · 0.45
CreateShaderProgramMethod · 0.45
IsValidMethod · 0.45

Tested by

no test coverage detected