Skip to content

Commit

Permalink
[dxvk] Add function to set bind mask bit to a given value
Browse files Browse the repository at this point in the history
  • Loading branch information
doitsujin committed Aug 26, 2019
1 parent e7b7192 commit d2d19b0
Showing 1 changed file with 20 additions and 12 deletions.
32 changes: 20 additions & 12 deletions src/dxvk/dxvk_bind_mask.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,35 +36,43 @@ namespace dxvk {
}

/**
* \brief Marks a binding as active
* \brief Changes a single binding
*
* \param [in] slot The binding ID
* \param [in] value New binding state
* \returns \c true if the state has changed
*/
bool set(uint32_t slot) {
bool set(uint32_t slot, bool value) {
const uint32_t intId = slot / BitCount;
const uint32_t bitId = slot % BitCount;
const uint32_t bitMask = 1u << bitId;

const uint32_t prev = m_slots[intId];
m_slots[intId] = prev | bitMask;
return (prev & bitMask) == 0;
const uint32_t next = value
? prev | bitMask
: prev & ~bitMask;
m_slots[intId] = next;
return prev != next;
}


/**
* \brief Marks a binding as active
*
* \param [in] slot The binding ID
* \returns \c true if the state has changed
*/
bool set(uint32_t slot) {
return set(slot, true);
}

/**
* \brief Marks a binding as inactive
*
* \param [in] slot The binding ID
* \returns \c true if the state has changed
*/
bool clr(uint32_t slot) {
const uint32_t intId = slot / BitCount;
const uint32_t bitId = slot % BitCount;
const uint32_t bitMask = 1u << bitId;

const uint32_t prev = m_slots[intId];
m_slots[intId] = prev & ~bitMask;
return (prev & bitMask) != 0;
return set(slot, false);
}

/**
Expand Down

0 comments on commit d2d19b0

Please sign in to comment.