Пример #1
0
void SimpleRWLock::UnLock() {
  UINT64 oldVal = itsLock;
  HT_ASSERT(oldVal != Free);
  if ((oldVal & NoWriterBitMask) == 0) {
    itsLock = Free;
  } else {
    while (!CAS64(&itsLock, oldVal, oldVal+1)) {
      oldVal = itsLock;
      HT_ASSERT(oldVal != Free);
      HT_ASSERT((oldVal & NoWriterBitMask) != 0);
    }
  }
}
Пример #2
0
void SimpleRWLock::LockForRead() {
  UINT64 oldVal = itsLock;
  while (((oldVal & NoWriterBitMask) == 0) ||
         !CAS64(&itsLock, oldVal, oldVal-1)) {
    oldVal = itsLock;
  }
  HT_ASSERT(((oldVal-1) & NoWriterBitMask) != 0);
}
Пример #3
0
	void BufferLayout::Init(void* shaderBlob) {
		ID3DBlob* shader = static_cast<ID3DBlob*>(shaderBlob);

		std::vector<D3D11_INPUT_ELEMENT_DESC> elementDescs;

		u32 lastBuffer = -1;

		for (u32 i = 0; i < m_Attributes.size(); i++) {
			D3D11_INPUT_ELEMENT_DESC current       = {};
			current.SemanticName                   = m_Attributes[i].semanticName.GetData();

			if (m_Attributes[i].type == DataType::MATRIX4) {
				for (int k = 0; k < 4; k++) {
					current.SemanticIndex          = k;
					current.Format                 = DXGI_FORMAT_R32G32B32A32_FLOAT;
					current.InputSlot              = m_Attributes[i].bufferId;
					current.InputSlotClass         = m_Attributes[i].instancing ? D3D11_INPUT_PER_INSTANCE_DATA : D3D11_INPUT_PER_VERTEX_DATA;
					current.InstanceDataStepRate   = m_Attributes[i].instancing ? 1 : 0;
					if (lastBuffer                != m_Attributes[i].bufferId) {
						lastBuffer                 = m_Attributes[i].bufferId;
						current.AlignedByteOffset  = 0;
					}
					else {
						current.AlignedByteOffset  = D3D11_APPEND_ALIGNED_ELEMENT;
					}
					elementDescs.push_back(current);
				}
			}
			else {
				current.SemanticIndex = 0;
				if (static_cast<DXGI_FORMAT>(m_Attributes[i].type) == DXGI_FORMAT_R32_FLOAT) {
					switch (m_Attributes[i].count) {
					case 1:
						current.Format = DXGI_FORMAT_R32_FLOAT;
						break;
					case 2:
						current.Format = DXGI_FORMAT_R32G32_FLOAT;
						break;
					case 3:
						current.Format = DXGI_FORMAT_R32G32B32_FLOAT;
						break;
					case 4:
						current.Format = DXGI_FORMAT_R32G32B32A32_FLOAT;
						break;
					default:
						HT_ASSERT(false, "[BufferLayout] Attribute count not supported.");
					}
				}
				else {
					current.Format             = static_cast<DXGI_FORMAT>(m_Attributes[i].type);
				}

				current.InputSlot              = m_Attributes[i].bufferId;
				current.InputSlotClass         = m_Attributes[i].instancing ? D3D11_INPUT_PER_INSTANCE_DATA : D3D11_INPUT_PER_VERTEX_DATA;
				current.InstanceDataStepRate   = m_Attributes[i].instancing ? 1 : 0;
				if (lastBuffer                != m_Attributes[i].bufferId) {
					lastBuffer                 = m_Attributes[i].bufferId;
					current.AlignedByteOffset  = 0;
				}
				else {
					current.AlignedByteOffset  = D3D11_APPEND_ALIGNED_ELEMENT;
				}
				elementDescs.push_back(current);
			}
		}

		DX(HT_DXDEVICE->CreateInputLayout(&elementDescs[0], elementDescs.size(), shader->GetBufferPointer(), shader->GetBufferSize(), &m_InputLayout));
	}
Пример #4
0
void SimpleLock::UnLock() {
  HT_ASSERT(itsLock != Free);
  itsLock = Free;
}