MCPcopy Create free account
hub / github.com/TheRealMJP/DeferredTexturing / Initialize

Method Initialize

SampleFramework12/v1.00/Graphics/Skybox.cpp:260–341  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

258}
259
260void Skybox::Initialize()
261{
262 // Load the shaders
263 const std::wstring shaderPath = SampleFrameworkDir() + L"Shaders\\Skybox.hlsl";
264 vertexShader = CompileFromFile(shaderPath.c_str(), "SkyboxVS", ShaderType::Vertex, ShaderProfile::SM51);
265 pixelShader = CompileFromFile(shaderPath.c_str(), "SkyboxPS", ShaderType::Pixel, ShaderProfile::SM51);
266
267 {
268 // Make a root signature
269 D3D12_DESCRIPTOR_RANGE srvRanges[1] = { };
270 srvRanges[0].RangeType = D3D12_DESCRIPTOR_RANGE_TYPE_SRV;
271 srvRanges[0].NumDescriptors = 1;
272 srvRanges[0].BaseShaderRegister = 0;
273 srvRanges[0].RegisterSpace = 0;
274 srvRanges[0].OffsetInDescriptorsFromTableStart = D3D12_DESCRIPTOR_RANGE_OFFSET_APPEND;
275
276 D3D12_ROOT_PARAMETER rootParameters[3] = { };
277 rootParameters[0].ParameterType = D3D12_ROOT_PARAMETER_TYPE_DESCRIPTOR_TABLE;
278 rootParameters[0].ShaderVisibility = D3D12_SHADER_VISIBILITY_PIXEL;
279 rootParameters[0].DescriptorTable.pDescriptorRanges = srvRanges;
280 rootParameters[0].DescriptorTable.NumDescriptorRanges = 1;
281
282 rootParameters[1].ParameterType = D3D12_ROOT_PARAMETER_TYPE_CBV;
283 rootParameters[1].ShaderVisibility = D3D12_SHADER_VISIBILITY_VERTEX;
284 rootParameters[1].Descriptor.RegisterSpace = 0;
285 rootParameters[1].Descriptor.ShaderRegister = 0;
286
287 rootParameters[2].ParameterType = D3D12_ROOT_PARAMETER_TYPE_CBV;
288 rootParameters[2].ShaderVisibility = D3D12_SHADER_VISIBILITY_PIXEL;
289 rootParameters[2].Descriptor.RegisterSpace = 0;
290 rootParameters[2].Descriptor.ShaderRegister = 0;
291
292 D3D12_STATIC_SAMPLER_DESC staticSamplers[1] = { };
293 staticSamplers[0] = DX12::GetStaticSamplerState(SamplerState::LinearClamp);
294
295 D3D12_ROOT_SIGNATURE_DESC rootSignatureDesc = { };
296 rootSignatureDesc.NumParameters = ArraySize_(rootParameters);
297 rootSignatureDesc.pParameters = rootParameters;
298 rootSignatureDesc.NumStaticSamplers = 1;
299 rootSignatureDesc.pStaticSamplers = staticSamplers;
300 rootSignatureDesc.Flags = D3D12_ROOT_SIGNATURE_FLAG_ALLOW_INPUT_ASSEMBLER_INPUT_LAYOUT;
301
302 DX12::CreateRootSignature(&rootSignature, rootSignatureDesc);
303 }
304
305 // Create and initialize the vertex and index buffers
306 Float3 verts[NumVertices] =
307 {
308 Float3(-1.0f, 1.0f, 1.0f),
309 Float3(1.0f, 1.0f, 1.0f),
310 Float3(1.0f, -1.0f, 1.0f),
311 Float3(-1.0f, -1.0f, 1.0f),
312 Float3(1.0f, 1.0f, -1.0f),
313 Float3(-1.0f, 1.0f, -1.0f),
314 Float3(-1.0f, -1.0f, -1.0f),
315 Float3(1.0f, -1.0f, -1.0f),
316 };
317

Callers

nothing calls this directly

Calls 6

SampleFrameworkDirFunction · 0.85
CompileFromFileFunction · 0.85
GetStaticSamplerStateFunction · 0.85
CreateRootSignatureFunction · 0.85
Float3Class · 0.85
c_strMethod · 0.80

Tested by

no test coverage detected