[dxvk] Added ID counter for SPIR-V code generation

This commit is contained in:
Philip Rebohle 2017-10-16 19:52:54 +02:00
parent 8728e6e101
commit aebe359509
3 changed files with 42 additions and 7 deletions

View File

@ -5,6 +5,7 @@
#include "dxvk_include.h"
#include "./spirv/dxvk_spirv_code_buffer.h"
#include "./spirv/dxvk_spirv_id_counter.h"
namespace dxvk {

View File

@ -26,13 +26,15 @@ namespace dxvk {
void DxvkSpirvCodeBuffer::append(const DxvkSpirvCodeBuffer& other) {
const size_t size = m_code.size();
m_code.resize(size + other.m_code.size());
uint32_t* dst = this->m_code.data();
const uint32_t* src = other.m_code.data();
std::memcpy(dst + size, src, sizeof(uint32_t) * size);
if (other.size() != 0) {
const size_t size = m_code.size();
m_code.resize(size + other.m_code.size());
uint32_t* dst = this->m_code.data();
const uint32_t* src = other.m_code.data();
std::memcpy(dst + size, src, sizeof(uint32_t) * size);
}
}

View File

@ -0,0 +1,32 @@
#pragma once
#include "../dxvk_include.h"
namespace dxvk {
/**
* \brief SPIR-V ID counter
*
* Allocates IDs, starting at zero. This is meant
* to be used to allocate unique IDs during code
* generation.
*/
class DxvkSpirvIdCounter {
public:
uint32_t nexId() {
return m_id++;
}
uint32_t numIds() const {
return m_id;
}
private:
uint32_t m_id = 0;
};
}