[D3D12] DXBC size and checksum
This commit is contained in:
parent
945ced4996
commit
1dc98d9133
|
@ -30,7 +30,7 @@ void DxbcShaderTranslator::Reset() {
|
||||||
std::vector<uint8_t> DxbcShaderTranslator::CompleteTranslation() {
|
std::vector<uint8_t> DxbcShaderTranslator::CompleteTranslation() {
|
||||||
shader_object_.clear();
|
shader_object_.clear();
|
||||||
|
|
||||||
// Shader object header.
|
// Write the shader object header.
|
||||||
shader_object_.push_back('CBXD');
|
shader_object_.push_back('CBXD');
|
||||||
// Reserve space for the checksum.
|
// Reserve space for the checksum.
|
||||||
for (uint32_t i = 0; i < 4; ++i) {
|
for (uint32_t i = 0; i < 4; ++i) {
|
||||||
|
@ -42,12 +42,19 @@ std::vector<uint8_t> DxbcShaderTranslator::CompleteTranslation() {
|
||||||
// 5 chunks - RDEF, ISGN, OSGN, SHEX, STAT.
|
// 5 chunks - RDEF, ISGN, OSGN, SHEX, STAT.
|
||||||
shader_object_.push_back(5);
|
shader_object_.push_back(5);
|
||||||
|
|
||||||
// Copy bytes out.
|
// Fill the remaining fields of the header and copy bytes out.
|
||||||
// TODO(Triang3l): avoid copy?
|
uint32_t shader_object_size =
|
||||||
|
uint32_t(shader_object_.size() * sizeof(uint32_t));
|
||||||
|
shader_object_[6] = shader_object_size;
|
||||||
|
// The checksum includes the size field, so it must be the last.
|
||||||
|
CalculateDXBCChecksum(reinterpret_cast<unsigned char*>(shader_object_.data()),
|
||||||
|
shader_object_size,
|
||||||
|
reinterpret_cast<unsigned int*>(&shader_object_[1]));
|
||||||
|
// TODO(Triang3l): Avoid copy?
|
||||||
std::vector<uint8_t> shader_object_bytes;
|
std::vector<uint8_t> shader_object_bytes;
|
||||||
shader_object_bytes.resize(shader_object_.size() * sizeof(uint32_t));
|
shader_object_bytes.resize(shader_object_size);
|
||||||
std::memcpy(shader_object_bytes.data(), shader_object_.data(),
|
std::memcpy(shader_object_bytes.data(), shader_object_.data(),
|
||||||
shader_object_bytes.size());
|
shader_object_size);
|
||||||
return shader_object_bytes;
|
return shader_object_bytes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue