mirror of
https://github.com/doitsujin/dxvk.git
synced 2025-01-31 14:52:11 +01:00
54ed8f0bb0
Co-authored-by: Philip Rebohle <philip.rebohle@tu-dortmund.de> Co-authored-by: Robin Kertels <robin.kertels@gmail.com> Co-authored-by: pchome <pchome@users.noreply.github.com> Co-authored-by: Christopher Egert <cme3000@gmail.com> Co-authored-by: Derek Lesho <dereklesho52@Gmail.com> Co-authored-by: Luis Cáceres <lacaceres97@gmail.com> Co-authored-by: Nelson Chen <crazysim@gmail.com> Co-authored-by: Edmondo Tommasina <edmondo.tommasina@gmail.com> Co-authored-by: Riesi <riesi@opentrash.com> Co-authored-by: gbMichelle <gbmichelle.dev@gmail.com>
60 lines
1021 B
C++
60 lines
1021 B
C++
#pragma once
|
|
|
|
#include "dxso_include.h"
|
|
|
|
#include "../dxbc/dxbc_tag.h"
|
|
|
|
#include <cstdint>
|
|
|
|
namespace dxvk {
|
|
|
|
/**
|
|
* \brief DXSO (d3d9) bytecode reader
|
|
*
|
|
* Holds references to the shader byte code and
|
|
* provides methods to read
|
|
*/
|
|
class DxsoReader {
|
|
|
|
public:
|
|
|
|
DxsoReader(const char* data)
|
|
: DxsoReader(data, 0) { }
|
|
|
|
size_t pos() {
|
|
return m_pos;
|
|
}
|
|
|
|
auto readu32() { return this->readNum<uint32_t> (); }
|
|
auto readf32() { return this->readNum<float> (); }
|
|
|
|
DxbcTag readTag();
|
|
|
|
void read(void* dst, size_t n);
|
|
|
|
void skip(size_t n);
|
|
|
|
void store(std::ostream&& stream, size_t size) const;
|
|
|
|
const char* currentPtr() {
|
|
return m_data + m_pos;
|
|
}
|
|
|
|
private:
|
|
|
|
DxsoReader(const char* data, size_t pos)
|
|
: m_data(data), m_pos(pos) { }
|
|
|
|
const char* m_data = nullptr;
|
|
size_t m_pos = 0;
|
|
|
|
template<typename T>
|
|
T readNum() {
|
|
T result;
|
|
this->read(&result, sizeof(result));
|
|
return result;
|
|
}
|
|
|
|
};
|
|
|
|
} |