MCPcopy Create free account
hub / github.com/GPUOpen-Effects/GeometryFX / RenderMesh

Method RenderMesh

framework/d3d11/amd_sdk/src/HelperFunctions.cpp:281–348  ·  view source on GitHub ↗

-------------------------------------------------------------------------------------- Allows the app to render individual meshes of an sdkmesh and override the primitive topology (useful for tessellated rendering of SDK meshes ) --------------------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

279// and override the primitive topology (useful for tessellated rendering of SDK meshes )
280//--------------------------------------------------------------------------------------
281void AMD::RenderMesh( CDXUTSDKMesh* pDXUTMesh, UINT uMesh, D3D11_PRIMITIVE_TOPOLOGY PrimType,
282 UINT uDiffuseSlot, UINT uNormalSlot, UINT uSpecularSlot )
283{
284#define MAX_D3D11_VERTEX_STREAMS D3D11_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT
285
286 assert( NULL != pDXUTMesh );
287
288 SDKMESH_MESH* pMesh = pDXUTMesh->GetMesh( uMesh );
289
290 UINT Strides[MAX_D3D11_VERTEX_STREAMS];
291 UINT Offsets[MAX_D3D11_VERTEX_STREAMS];
292 ID3D11Buffer* pVB[MAX_D3D11_VERTEX_STREAMS];
293
294 if (pMesh->NumVertexBuffers > MAX_D3D11_VERTEX_STREAMS)
295 {
296 return;
297 }
298
299 for (UINT64 i = 0; i < pMesh->NumVertexBuffers; i++)
300 {
301 pVB[i] = pDXUTMesh->GetVB11( uMesh, (UINT)i );
302 Strides[i] = pDXUTMesh->GetVertexStride( uMesh, (UINT)i );
303 Offsets[i] = 0;
304 }
305
306 ID3D11Buffer* pIB = pDXUTMesh->GetIB11( pMesh->IndexBuffer );
307 DXGI_FORMAT ibFormat = pDXUTMesh->GetIBFormat11( pMesh->IndexBuffer );
308
309 DXUTGetD3D11DeviceContext()->IASetVertexBuffers( 0, pMesh->NumVertexBuffers, pVB, Strides, Offsets );
310 DXUTGetD3D11DeviceContext()->IASetIndexBuffer( pIB, ibFormat, 0 );
311
312 SDKMESH_SUBSET* pSubset = NULL;
313 SDKMESH_MATERIAL* pMat = NULL;
314
315 for (UINT uSubset = 0; uSubset < pMesh->NumSubsets; uSubset++)
316 {
317 pSubset = pDXUTMesh->GetSubset( uMesh, uSubset );
318
319 if (D3D11_PRIMITIVE_TOPOLOGY_UNDEFINED == PrimType)
320 {
321 PrimType = pDXUTMesh->GetPrimitiveType11( (SDKMESH_PRIMITIVE_TYPE)pSubset->PrimitiveType );
322 }
323
324 DXUTGetD3D11DeviceContext()->IASetPrimitiveTopology( PrimType );
325
326 pMat = pDXUTMesh->GetMaterial( pSubset->MaterialID );
327 if (uDiffuseSlot != INVALID_SAMPLER_SLOT && !IsErrorResource( pMat->pDiffuseRV11 ))
328 {
329 DXUTGetD3D11DeviceContext()->PSSetShaderResources( uDiffuseSlot, 1, &pMat->pDiffuseRV11 );
330 }
331
332 if (uNormalSlot != INVALID_SAMPLER_SLOT && !IsErrorResource( pMat->pNormalRV11 ))
333 {
334 DXUTGetD3D11DeviceContext()->PSSetShaderResources( uNormalSlot, 1, &pMat->pNormalRV11 );
335 }
336
337 if (uSpecularSlot != INVALID_SAMPLER_SLOT && !IsErrorResource( pMat->pSpecularRV11 ))
338 {

Callers

nothing calls this directly

Calls 9

IsErrorResourceFunction · 0.85
GetVB11Method · 0.80
GetVertexStrideMethod · 0.80
GetIB11Method · 0.80
GetIBFormat11Method · 0.80
GetSubsetMethod · 0.80
GetPrimitiveType11Method · 0.80
GetMaterialMethod · 0.80
GetMeshMethod · 0.45

Tested by

no test coverage detected