1
0
mirror of https://github.com/doitsujin/dxvk.git synced 2025-02-20 19:54:19 +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)
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

View File

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

View File

@ -809,6 +809,28 @@ namespace dxvk {
src.at(0).id, src.at(1).id);
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:
Logger::warn(str::format(
"DxbcCompiler: Unhandled instruction: ",

View File

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

View File

@ -22,7 +22,7 @@ namespace dxvk {
// Create swap chain for the surface
DxvkSwapchainProperties swapchainProperties;
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.height = bufferHeight;
@ -266,7 +266,7 @@ namespace dxvk {
DXGI_FORMAT bufferFormat) {
DxvkSwapchainProperties swapchainProperties;
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.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(
const Rc<DxvkImageView>& renderTarget) const {
auto extent = renderTarget->image()->info().extent;

View File

@ -94,6 +94,12 @@ namespace dxvk {
*/
DxvkFramebufferSize getImageSize() const;
/**
* \brief Checks whether any attachments are defined
* \returns \c false if no attachments are defined
*/
bool hasAttachments() const;
private:
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 resultType,
uint32_t operand) {

View File

@ -236,6 +236,22 @@ namespace dxvk {
uint32_t operand1,
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 resultType,
uint32_t operand);