| 100 | |
| 101 | |
| 102 | bool FillAndSetConstants( Tr2ConstantBufferAL& buffer, const void* const data, const size_t dataSize, unsigned constantTypeMask, const unsigned registerIndex, Tr2RenderContext& renderContext ) |
| 103 | { |
| 104 | if( constantTypeMask == 0 ) |
| 105 | { |
| 106 | return true; |
| 107 | } |
| 108 | if( !buffer.IsValid() || dataSize > buffer.GetSize() ) |
| 109 | { |
| 110 | USE_MAIN_THREAD_RENDER_CONTEXT(); |
| 111 | CR_RETURN_VAL( buffer.Create( (unsigned int)dataSize, renderContext ), false ); |
| 112 | } |
| 113 | |
| 114 | void* mapped = nullptr; |
| 115 | if( !SUCCEEDED( buffer.Lock( &mapped, renderContext ) ) || !mapped ) |
| 116 | { |
| 117 | return false; |
| 118 | } |
| 119 | |
| 120 | memcpy( mapped, data, std::min( (uint32_t)dataSize, buffer.GetSize() ) ); |
| 121 | buffer.Unlock( renderContext ); |
| 122 | |
| 123 | SetConstants( buffer, constantTypeMask, registerIndex, renderContext ); |
| 124 | |
| 125 | return true; |
| 126 | } |
| 127 | |
| 128 | void SetConstants( Tr2ConstantBufferAL& buffer, unsigned constantTypeMask, const unsigned registerIndex, Tr2RenderContext& renderContext ) |
| 129 | { |