MCPcopy Create free account
hub / github.com/FlaxEngine/FlaxEngine / Bind

Method Bind

Source/Engine/Graphics/Materials/GUIMaterialShader.cpp:30–77  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

28 });
29
30void GUIMaterialShader::Bind(BindParameters& params)
31{
32 // Prepare
33 auto context = params.GPUContext;
34 Span<byte> cb(_cbData.Get(), _cbData.Count());
35 ASSERT_LOW_LAYER(cb.Length() >= sizeof(GUIMaterialShaderData));
36 auto materialData = reinterpret_cast<GUIMaterialShaderData*>(cb.Get());
37 cb = cb.Slice(sizeof(GUIMaterialShaderData));
38 int32 srv = 0;
39 auto customData = (Render2D::CustomData*)params.CustomData;
40 const auto ps = customData->UseDepthBuffer ? _cache.Depth : _cache.NoDepth;
41
42 // Setup parameters
43 MaterialParameter::BindMeta bindMeta;
44 bindMeta.Context = context;
45 bindMeta.Constants = cb;
46 bindMeta.Input = nullptr;
47 bindMeta.Buffers = nullptr;
48 bindMeta.CanSampleDepth = false;
49 bindMeta.CanSampleGBuffer = false;
50 MaterialParams::Bind(params.ParamsLink, bindMeta);
51
52 // Setup material constants
53 {
54 Matrix::Transpose(customData->ViewProjection, materialData->ViewProjectionMatrix);
55 Matrix::Transpose(Matrix::Identity, materialData->WorldMatrix);
56 Matrix::Transpose(Matrix::Identity, materialData->ViewMatrix);
57 materialData->ViewPos = Float3::Zero;
58 materialData->ViewFar = 0.0f;
59 materialData->ViewDir = Float3::Forward;
60 materialData->TimeParam = params.Time;
61 materialData->ScaledTimeParam = params.ScaledTime;
62 materialData->ViewInfo = Float4::Zero;
63 auto& viewport = Render2D::GetViewport();
64 materialData->ScreenSize = Float4(viewport.Width, viewport.Height, 1.0f / viewport.Width, 1.0f / viewport.Height);
65 materialData->ViewSize = Float4(customData->ViewSize.X, customData->ViewSize.Y, 1.0f / customData->ViewSize.X, 1.0f / customData->ViewSize.Y);
66 }
67
68 // Bind constants
69 if (_cb)
70 {
71 context->UpdateCB(_cb, _cbData.Get());
72 context->BindCB(0, _cb);
73 }
74
75 // Bind pipeline
76 context->SetState(ps);
77}
78
79void GUIMaterialShader::Unload()
80{

Callers

nothing calls this directly

Calls 11

BindFunction · 0.85
GetViewportFunction · 0.85
Float4Class · 0.85
SliceMethod · 0.80
TransposeFunction · 0.50
GetMethod · 0.45
CountMethod · 0.45
LengthMethod · 0.45
UpdateCBMethod · 0.45
BindCBMethod · 0.45
SetStateMethod · 0.45

Tested by

no test coverage detected