1
0
mirror of https://github.com/EduApps-CDG/OpenDX synced 2024-12-30 09:45:37 +01:00

[dxbc] Implemented type conversion instructions

This commit is contained in:
Philip Rebohle 2017-12-19 18:12:18 +01:00
parent 95bc4b5826
commit 5415b685de
9 changed files with 130 additions and 11 deletions

View File

@ -1272,7 +1272,8 @@ namespace dxvk {
if (m_state.om.depthStencilView != nullptr) if (m_state.om.depthStencilView != nullptr)
attachments.setDepthTarget(m_state.om.depthStencilView->GetDXVKImageView()); attachments.setDepthTarget(m_state.om.depthStencilView->GetDXVKImageView());
framebuffer = m_device->createFramebuffer(attachments); if (attachments.hasAttachments())
framebuffer = m_device->createFramebuffer(attachments);
} }
// Bind the framebuffer object to the context // Bind the framebuffer object to the context

View File

@ -338,8 +338,8 @@ namespace dxvk {
viewInfo.type = VK_IMAGE_VIEW_TYPE_2D_ARRAY; viewInfo.type = VK_IMAGE_VIEW_TYPE_2D_ARRAY;
viewInfo.minLevel = 0; viewInfo.minLevel = 0;
viewInfo.numLevels = 1; viewInfo.numLevels = 1;
viewInfo.minLayer = desc.Texture2DArray.FirstArraySlice; viewInfo.minLayer = desc.Texture2DMSArray.FirstArraySlice;
viewInfo.numLayers = desc.Texture2DArray.ArraySize; viewInfo.numLayers = desc.Texture2DMSArray.ArraySize;
break; break;
default: default:
@ -432,8 +432,8 @@ namespace dxvk {
viewInfo.type = VK_IMAGE_VIEW_TYPE_2D_ARRAY; viewInfo.type = VK_IMAGE_VIEW_TYPE_2D_ARRAY;
viewInfo.minLevel = 0; viewInfo.minLevel = 0;
viewInfo.numLevels = 1; viewInfo.numLevels = 1;
viewInfo.minLayer = desc.Texture2DArray.FirstArraySlice; viewInfo.minLayer = desc.Texture2DMSArray.FirstArraySlice;
viewInfo.numLayers = desc.Texture2DArray.ArraySize; viewInfo.numLayers = desc.Texture2DMSArray.ArraySize;
break; break;
default: default:

View File

@ -809,6 +809,28 @@ namespace dxvk {
src.at(0).id, src.at(1).id); src.at(0).id, src.at(1).id);
break; break;
///////////////////////////
// Conversion instructions
case DxbcOpcode::ItoF:
dst.id = m_module.opConvertStoF(
typeId, src.at(0).id);
break;
case DxbcOpcode::UtoF:
dst.id = m_module.opConvertUtoF(
typeId, src.at(0).id);
break;
case DxbcOpcode::FtoI:
dst.id = m_module.opConvertFtoS(
typeId, src.at(0).id);
break;
case DxbcOpcode::FtoU:
dst.id = m_module.opConvertFtoU(
typeId, src.at(0).id);
break;
default: default:
Logger::warn(str::format( Logger::warn(str::format(
"DxbcCompiler: Unhandled instruction: ", "DxbcCompiler: Unhandled instruction: ",

View File

@ -99,9 +99,15 @@ namespace dxvk {
/* Frc */ /* Frc */
{ }, { },
/* FtoI */ /* FtoI */
{ }, { 2, DxbcInstClass::VectorAlu, {
{ DxbcOperandKind::DstReg, DxbcScalarType::Sint32 },
{ DxbcOperandKind::SrcReg, DxbcScalarType::Float32 },
} },
/* FtoU */ /* FtoU */
{ }, { 2, DxbcInstClass::VectorAlu, {
{ DxbcOperandKind::DstReg, DxbcScalarType::Uint32 },
{ DxbcOperandKind::SrcReg, DxbcScalarType::Float32 },
} },
/* Ge */ /* Ge */
{ 3, DxbcInstClass::VectorCmp, { { 3, DxbcInstClass::VectorCmp, {
{ DxbcOperandKind::DstReg, DxbcScalarType::Uint32 }, { DxbcOperandKind::DstReg, DxbcScalarType::Uint32 },
@ -178,7 +184,10 @@ namespace dxvk {
/* IShr */ /* IShr */
{ }, { },
/* ItoF */ /* ItoF */
{ }, { 2, DxbcInstClass::VectorAlu, {
{ DxbcOperandKind::DstReg, DxbcScalarType::Float32 },
{ DxbcOperandKind::SrcReg, DxbcScalarType::Sint32 },
} },
/* Label */ /* Label */
{ }, { },
/* Ld */ /* Ld */
@ -334,7 +343,10 @@ namespace dxvk {
/* UShr */ /* UShr */
{ }, { },
/* UtoF */ /* UtoF */
{ }, { 2, DxbcInstClass::VectorAlu, {
{ DxbcOperandKind::DstReg, DxbcScalarType::Float32 },
{ DxbcOperandKind::SrcReg, DxbcScalarType::Uint32 },
} },
/* Xor */ /* Xor */
{ 3, DxbcInstClass::VectorAlu, { { 3, DxbcInstClass::VectorAlu, {
{ DxbcOperandKind::DstReg, DxbcScalarType::Uint32 }, { DxbcOperandKind::DstReg, DxbcScalarType::Uint32 },

View File

@ -22,7 +22,7 @@ namespace dxvk {
// Create swap chain for the surface // Create swap chain for the surface
DxvkSwapchainProperties swapchainProperties; DxvkSwapchainProperties swapchainProperties;
swapchainProperties.preferredSurfaceFormat = this->pickFormat(bufferFormat); swapchainProperties.preferredSurfaceFormat = this->pickFormat(bufferFormat);
swapchainProperties.preferredPresentMode = VK_PRESENT_MODE_FIFO_KHR; swapchainProperties.preferredPresentMode = VK_PRESENT_MODE_IMMEDIATE_KHR;
swapchainProperties.preferredBufferSize.width = bufferWidth; swapchainProperties.preferredBufferSize.width = bufferWidth;
swapchainProperties.preferredBufferSize.height = bufferHeight; swapchainProperties.preferredBufferSize.height = bufferHeight;
@ -266,7 +266,7 @@ namespace dxvk {
DXGI_FORMAT bufferFormat) { DXGI_FORMAT bufferFormat) {
DxvkSwapchainProperties swapchainProperties; DxvkSwapchainProperties swapchainProperties;
swapchainProperties.preferredSurfaceFormat = this->pickFormat(bufferFormat); swapchainProperties.preferredSurfaceFormat = this->pickFormat(bufferFormat);
swapchainProperties.preferredPresentMode = VK_PRESENT_MODE_FIFO_KHR; swapchainProperties.preferredPresentMode = VK_PRESENT_MODE_IMMEDIATE_KHR;
swapchainProperties.preferredBufferSize.width = bufferWidth; swapchainProperties.preferredBufferSize.width = bufferWidth;
swapchainProperties.preferredBufferSize.height = bufferHeight; swapchainProperties.preferredBufferSize.height = bufferHeight;

View File

@ -53,6 +53,16 @@ namespace dxvk {
} }
bool DxvkRenderTargets::hasAttachments() const {
bool result = m_depthTarget != nullptr;
for (uint32_t i = 0; (i < MaxNumRenderTargets) && !result; i++)
result |= m_colorTargets.at(i) != nullptr;
return result;
}
DxvkFramebufferSize DxvkRenderTargets::renderTargetSize( DxvkFramebufferSize DxvkRenderTargets::renderTargetSize(
const Rc<DxvkImageView>& renderTarget) const { const Rc<DxvkImageView>& renderTarget) const {
auto extent = renderTarget->image()->info().extent; auto extent = renderTarget->image()->info().extent;

View File

@ -94,6 +94,12 @@ namespace dxvk {
*/ */
DxvkFramebufferSize getImageSize() const; DxvkFramebufferSize getImageSize() const;
/**
* \brief Checks whether any attachments are defined
* \returns \c false if no attachments are defined
*/
bool hasAttachments() const;
private: private:
std::array<Rc<DxvkImageView>, MaxNumRenderTargets> m_colorTargets; std::array<Rc<DxvkImageView>, MaxNumRenderTargets> m_colorTargets;

View File

@ -641,6 +641,58 @@ namespace dxvk {
} }
uint32_t SpirvModule::opConvertFtoS(
uint32_t resultType,
uint32_t operand) {
uint32_t resultId = this->allocateId();
m_code.putIns (spv::OpConvertFToS, 4);
m_code.putWord(resultType);
m_code.putWord(resultId);
m_code.putWord(operand);
return resultId;
}
uint32_t SpirvModule::opConvertFtoU(
uint32_t resultType,
uint32_t operand) {
uint32_t resultId = this->allocateId();
m_code.putIns (spv::OpConvertFToU, 4);
m_code.putWord(resultType);
m_code.putWord(resultId);
m_code.putWord(operand);
return resultId;
}
uint32_t SpirvModule::opConvertStoF(
uint32_t resultType,
uint32_t operand) {
uint32_t resultId = this->allocateId();
m_code.putIns (spv::OpConvertSToF, 4);
m_code.putWord(resultType);
m_code.putWord(resultId);
m_code.putWord(operand);
return resultId;
}
uint32_t SpirvModule::opConvertUtoF(
uint32_t resultType,
uint32_t operand) {
uint32_t resultId = this->allocateId();
m_code.putIns (spv::OpConvertUToF, 4);
m_code.putWord(resultType);
m_code.putWord(resultId);
m_code.putWord(operand);
return resultId;
}
uint32_t SpirvModule::opNot( uint32_t SpirvModule::opNot(
uint32_t resultType, uint32_t resultType,
uint32_t operand) { uint32_t operand) {

View File

@ -236,6 +236,22 @@ namespace dxvk {
uint32_t operand1, uint32_t operand1,
uint32_t operand2); uint32_t operand2);
uint32_t opConvertFtoS(
uint32_t resultType,
uint32_t operand);
uint32_t opConvertFtoU(
uint32_t resultType,
uint32_t operand);
uint32_t opConvertStoF(
uint32_t resultType,
uint32_t operand);
uint32_t opConvertUtoF(
uint32_t resultType,
uint32_t operand);
uint32_t opNot( uint32_t opNot(
uint32_t resultType, uint32_t resultType,
uint32_t operand); uint32_t operand);