Advertisement
Guest User

Untitled

a guest
Mar 30th, 2014
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. bool NXDeviceShader::Set(int cb, string constantName, void* value)
  2. {
  3. NXShaderVariable* variable = GetVariableByName(constantName);
  4.  
  5. if (variable == nullptr)
  6. return false;
  7.  
  8. D3D11_MAPPED_SUBRESOURCE resource;
  9. resource.pData = nullptr; resource.DepthPitch = 0; resource.RowPitch = 0;
  10.  
  11. if (FAILED(Core::NXGPU::Map(ConstantBuffers[cb].Data, 0, D3D11_MAP_WRITE_DISCARD, 0, &resource)))
  12. return false;
  13.  
  14. memcpy((unsigned char*) resource.pData + variable->Description.StartOffset, value, variable->Description.Size);
  15.  
  16. Core::NXGPU::Unmap(ConstantBuffers[cb].Data, 0);
  17.  
  18. variable = nullptr;
  19.  
  20. SetConstantBuffer(cb, ConstantBuffers[cb].Data);
  21.  
  22. return true;
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement