[spirv] Add method to allocate new ID from code buffer.

This commit is contained in:
Philip Rebohle 2019-11-19 12:12:05 +01:00
parent 014798161c
commit 9f88249b91
No known key found for this signature in database
GPG Key ID: C8CC613427A31C99
2 changed files with 20 additions and 1 deletions

View File

@ -40,6 +40,16 @@ namespace dxvk {
}
uint32_t SpirvCodeBuffer::allocId() {
constexpr size_t BoundIdsOffset = 3;
if (m_code.size() <= BoundIdsOffset)
return 0;
return m_code[BoundIdsOffset]++;
}
void SpirvCodeBuffer::append(const SpirvCodeBuffer& other) {
if (other.size() != 0) {
const size_t size = m_code.size();

View File

@ -76,6 +76,15 @@ namespace dxvk {
return SpirvInstructionIterator(nullptr, 0, 0);
}
/**
* \brief Allocates a new ID
*
* Returns a new valid ID and increments the
* maximum ID count stored in the header.
* \returns The new SPIR-V ID
*/
uint32_t allocId();
/**
* \brief Merges two code buffers
*
@ -101,7 +110,7 @@ namespace dxvk {
* \param [in] wordCount Number of words
*/
void putIns(spv::Op opCode, uint16_t wordCount);
/**
* \brief Appends a 32-bit integer to the buffer
* \param [in] value The number to add