1
0
mirror of https://github.com/doitsujin/dxvk.git synced 2025-03-02 04:29:14 +01:00

[spirv] Add method to retrieve literal string from instruction

This commit is contained in:
Philip Rebohle 2019-11-19 12:49:07 +01:00
parent 8252d1ccd5
commit 5a2fd7c71b
No known key found for this signature in database
GPG Key ID: C8CC613427A31C99

View File

@ -54,23 +54,35 @@ namespace dxvk {
* take 64-bit arguments which require more than one DWORD. * take 64-bit arguments which require more than one DWORD.
* Arguments start at index 1. Calling this method with an * Arguments start at index 1. Calling this method with an
* argument ID of 0 will return the opcode token. * argument ID of 0 will return the opcode token.
* \param [in] id Argument index, starting at 1 * \param [in] idx Argument index, starting at 1
* \returns The argument value * \returns The argument value
*/ */
uint32_t arg(uint32_t id) const { uint32_t arg(uint32_t idx) const {
const uint32_t index = m_offset + id; const uint32_t index = m_offset + idx;
return index < m_length ? m_code[index] : 0; return index < m_length ? m_code[index] : 0;
} }
/**
* \brief Argument string
*
* Retrieves a pointer to a UTF-8-encoded string.
* \param [in] idx Argument index, starting at 1
* \returns Pointer to the literal string
*/
const char* chr(uint32_t idx) const {
const uint32_t index = m_offset + idx;
return index < m_length ? reinterpret_cast<const char*>(&m_code[index]) : nullptr;
}
/** /**
* \brief Changes the value of an argument * \brief Changes the value of an argument
* *
* \param [in] id Argument index, starting at 1 * \param [in] idx Argument index, starting at 1
* \param [in] word New argument word * \param [in] word New argument word
*/ */
void setArg(uint32_t id, uint32_t word) const { void setArg(uint32_t idx, uint32_t word) const {
if (m_offset + id < m_length) if (m_offset + idx < m_length)
m_code[m_offset + id] = word; m_code[m_offset + idx] = word;
} }
private: private: