[D3D12] DXBC string append

This commit is contained in:
Triang3l 2018-08-27 16:53:59 +03:00
parent 1dc98d9133
commit 285de2a521
2 changed files with 17 additions and 0 deletions

View File

@ -14,6 +14,8 @@
#include "third_party/dxbc/DXBCChecksum.h" #include "third_party/dxbc/DXBCChecksum.h"
#include "third_party/dxbc/d3d12TokenizedProgramFormat.hpp" #include "third_party/dxbc/d3d12TokenizedProgramFormat.hpp"
#include "xenia/base/math.h"
namespace xe { namespace xe {
namespace gpu { namespace gpu {
using namespace ucode; using namespace ucode;
@ -58,5 +60,17 @@ std::vector<uint8_t> DxbcShaderTranslator::CompleteTranslation() {
return shader_object_bytes; return shader_object_bytes;
} }
uint32_t DxbcShaderTranslator::AppendString(std::vector<uint32_t>& dest,
const char* source) {
size_t size = std::strlen(source) + 1;
size_t size_aligned = xe::align(size_aligned, sizeof(uint32_t));
size_t dest_pos = dest.size();
dest.resize(dest_pos + size_aligned / sizeof(uint32_t));
std::memcpy(&dest[dest_pos], source, size);
std::memset(reinterpret_cast<uint8_t*>(&dest[dest_pos]) + size, 0xAB,
size_aligned - size);
return uint32_t(size_aligned);
}
} // namespace gpu } // namespace gpu
} // namespace xe } // namespace xe

View File

@ -29,6 +29,9 @@ class DxbcShaderTranslator : public ShaderTranslator {
std::vector<uint8_t> CompleteTranslation() override; std::vector<uint8_t> CompleteTranslation() override;
private: private:
// Appends a string to a DWORD stream, returns the DWORD-aligned length.
static uint32_t AppendString(std::vector<uint32_t>& dest, const char* source);
// Executable instructions - generated during translation. // Executable instructions - generated during translation.
std::vector<uint32_t> shader_code_; std::vector<uint32_t> shader_code_;
// Complete shader object, with all the needed chunks and dcl_ instructions - // Complete shader object, with all the needed chunks and dcl_ instructions -