mirror of
https://github.com/doitsujin/dxvk.git
synced 2025-01-18 02:52:10 +01:00
[dxvk] Added ID counter for SPIR-V code generation
This commit is contained in:
parent
8728e6e101
commit
aebe359509
@ -5,6 +5,7 @@
|
||||
#include "dxvk_include.h"
|
||||
|
||||
#include "./spirv/dxvk_spirv_code_buffer.h"
|
||||
#include "./spirv/dxvk_spirv_id_counter.h"
|
||||
|
||||
namespace dxvk {
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
32
src/dxvk/spirv/dxvk_spirv_id_counter.h
Normal file
32
src/dxvk/spirv/dxvk_spirv_id_counter.h
Normal 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;
|
||||
|
||||
};
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user