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

Method _CreateShaderProgram

pxr/imaging/hdSt/unitTestHelper.cpp:490–556  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

488"}\n";
489
490void
491HdSt_TextureTestDriver::_CreateShaderProgram()
492{
493 if (_pipeline) {
494 _hgi->DestroyGraphicsPipeline(&_pipeline);
495 }
496 if (_shaderProgram) {
497 _DestroyShaderProgram();
498 }
499
500 HgiShaderFunctionDesc vertDesc;
501 vertDesc.debugName = TfToken("Vertex");
502 vertDesc.shaderStage = HgiShaderStageVertex;
503 HgiShaderFunctionAddStageInput(
504 &vertDesc, "position", "vec4", "position");
505 HgiShaderFunctionAddStageInput(
506 &vertDesc, "uvIn", "vec2");
507 HgiShaderFunctionAddStageOutput(
508 &vertDesc, "gl_Position", "vec4", "position");
509 HgiShaderFunctionAddStageOutput(
510 &vertDesc, "uvOut", "vec2");
511
512 HgiShaderFunctionDesc fragDesc;
513 fragDesc.debugName = TfToken("Fragment");
514 fragDesc.shaderStage = HgiShaderStageFragment;
515 HgiShaderFunctionAddStageInput(
516 &fragDesc, "uvOut", "vec2");
517 HgiShaderFunctionAddTexture(
518 &fragDesc, "colorIn");
519 HgiShaderFunctionAddStageOutput(
520 &fragDesc, "hd_FragColor", "vec4", "color");
521 HgiShaderFunctionAddConstantParam(
522 &fragDesc, "screenSize", "vec2");
523
524 std::istringstream vertShaderStream(vertShaderStr);
525 std::istringstream fragShaderStream(fragShaderStr);
526 const HioGlslfx vsGlslfx = HioGlslfx(vertShaderStream);
527 const HioGlslfx fsGlslfx = HioGlslfx(fragShaderStream);
528
529 // Setup the vertex shader
530 std::string vsCode;
531 vsCode += vsGlslfx.GetSource(TfToken("VertexPassthrough"));
532 TF_VERIFY(!vsCode.empty());
533 vertDesc.shaderCode = vsCode.c_str();
534 HgiShaderFunctionHandle vertFn = _hgi->CreateShaderFunction(vertDesc);
535
536 // Setup the fragment shader
537 std::string fsCode;
538 fsCode += fsGlslfx.GetSource(TfToken("FullscreenTexture"));
539 TF_VERIFY(!fsCode.empty());
540 fragDesc.shaderCode = fsCode.c_str();
541 HgiShaderFunctionHandle fragFn = _hgi->CreateShaderFunction(fragDesc);
542
543 // Setup the shader program
544 HgiShaderProgramDesc programDesc;
545 programDesc.debugName = TfToken("FullscreenTriangle").GetString();
546 programDesc.shaderFunctions.push_back(std::move(vertFn));
547 programDesc.shaderFunctions.push_back(std::move(fragFn));

Callers

nothing calls this directly

Calls 15

push_backMethod · 0.80
HioGlslfxClass · 0.70
TfTokenClass · 0.50
GetSourceMethod · 0.45
emptyMethod · 0.45
c_strMethod · 0.45
CreateShaderFunctionMethod · 0.45

Tested by

no test coverage detected