| 122 | |
| 123 | |
| 124 | void DiffuseRenderer::Draw(const DiffuseDrawParams* params, ID3D11Buffer* positions, ID3D11Buffer* velocities, ID3D11Buffer* indices, int numParticles) |
| 125 | { |
| 126 | using namespace DirectX; |
| 127 | |
| 128 | ID3D11DeviceContext* deviceContext = m_deviceContext; |
| 129 | |
| 130 | // update constant buffer |
| 131 | { |
| 132 | D3D11_MAPPED_SUBRESOURCE mappedResource = { 0 }; |
| 133 | if (S_OK == deviceContext->Map(m_constantBuffer, 0u, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource)) |
| 134 | { |
| 135 | DiffuseShaderConst cParams; |
| 136 | |
| 137 | cParams.modelViewProjection = (float4x4&)(XMMatrixMultiply(XMMatrixMultiply(params->model, params->view), params->projection)); |
| 138 | cParams.modelView = (float4x4&)XMMatrixMultiply(params->model, params->view); |
| 139 | cParams.projection = (float4x4&)params->projection; |
| 140 | |
| 141 | cParams.motionBlurScale = params->motionScale; |
| 142 | cParams.diffuseRadius = params->diffuseRadius; |
| 143 | cParams.diffuseScale = params->diffuseScale; |
| 144 | cParams.spotMin = params->spotMin; |
| 145 | cParams.spotMax = params->spotMax; |
| 146 | |
| 147 | cParams.lightTransform = (float4x4&)params->lightTransform; |
| 148 | cParams.lightPos = params->lightPos; |
| 149 | cParams.lightDir = params->lightDir; |
| 150 | cParams.color = params->color; |
| 151 | |
| 152 | |
| 153 | memcpy(cParams.shadowTaps, params->shadowTaps, sizeof(cParams.shadowTaps)); |
| 154 | |
| 155 | memcpy(mappedResource.pData, &cParams, sizeof(DiffuseShaderConst)); |
| 156 | |
| 157 | deviceContext->Unmap(m_constantBuffer, 0u); |
| 158 | } |
| 159 | } |
| 160 | |
| 161 | deviceContext->VSSetShader(m_diffuseVS, nullptr, 0u); |
| 162 | deviceContext->GSSetShader(m_diffuseGS, nullptr, 0u); |
| 163 | deviceContext->PSSetShader(m_diffusePS, nullptr, 0u); |
| 164 | |
| 165 | if (params->shadowMap) |
| 166 | { |
| 167 | ShadowMap* shadowMap = (ShadowMap*)params->shadowMap; |
| 168 | |
| 169 | ID3D11ShaderResourceView* ppSRV[1] = { shadowMap->m_depthSrv.Get() }; |
| 170 | deviceContext->PSSetShaderResources(0, 1, ppSRV); |
| 171 | ID3D11SamplerState* ppSS[1] = { shadowMap->m_linearSampler.Get() }; |
| 172 | deviceContext->PSSetSamplers(0, 1, ppSS); |
| 173 | } |
| 174 | |
| 175 | deviceContext->IASetInputLayout(m_inputLayout); |
| 176 | deviceContext->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_POINTLIST); |
| 177 | |
| 178 | deviceContext->VSSetConstantBuffers(0, 1, &m_constantBuffer); |
| 179 | deviceContext->GSSetConstantBuffers(0, 1, &m_constantBuffer); |
| 180 | deviceContext->PSSetConstantBuffers(0, 1, &m_constantBuffer); |
| 181 |
nothing calls this directly
no outgoing calls
no test coverage detected