[dxbc] Implemented SampleInfo instruction

This commit is contained in:
Philip Rebohle 2018-02-04 19:30:39 +01:00
parent 76d48fcdf5
commit 54108726d5
No known key found for this signature in database
GPG Key ID: C8CC613427A31C99
6 changed files with 69 additions and 3 deletions

View File

@ -88,6 +88,9 @@ namespace dxvk {
case DxbcInstClass::TextureQuery:
return this->emitTextureQuery(ins);
case DxbcInstClass::TextureQueryMs:
return this->emitTextureQueryMs(ins);
case DxbcInstClass::TextureFetch:
return this->emitTextureFetch(ins);
@ -2280,6 +2283,25 @@ namespace dxvk {
}
void DxbcCompiler::emitTextureQueryMs(const DxbcShaderInstruction& ins) {
// sampleinfo has two operands:
// (dst0) The destination register
// (src0) Resource to query
// TODO Check if resource is bound
DxbcRegisterValue sampleCount = emitQueryTextureSamples(ins.src[0]);
if (ins.controls.resinfoType != DxbcResinfoType::Uint) {
sampleCount.type.ctype = DxbcScalarType::Float32;
sampleCount.type.ccount = 1;
sampleCount.id = m_module.opConvertUtoF(
getVectorTypeId(sampleCount.type),
sampleCount.id);
}
emitRegisterStore(ins.dst[0], sampleCount);
}
void DxbcCompiler::emitTextureFetch(const DxbcShaderInstruction& ins) {
// ld has three operands:
// (dst0) The destination register
@ -2502,9 +2524,11 @@ namespace dxvk {
DxbcRegisterValue result;
result.type.ctype = m_textures.at(textureId).sampledType;
result.type.ccount = 4;
switch (ins.op) {
// Simple image gather operation
case DxbcOpcode::Gather4: {
case DxbcOpcode::Gather4:
case DxbcOpcode::Gather4Po: {
result.id = m_module.opImageGather(
getVectorTypeId(result.type), sampledImageId, coord.id,
m_module.constu32(samplerReg.swizzle[0]),
@ -2512,7 +2536,8 @@ namespace dxvk {
} break;
// Depth-compare operation
case DxbcOpcode::Gather4C: {
case DxbcOpcode::Gather4C:
case DxbcOpcode::Gather4PoC: {
result.id = m_module.opImageDrefGather(
getVectorTypeId(result.type), sampledImageId, coord.id,
referenceValue.id, imageOperands);
@ -3924,6 +3949,20 @@ namespace dxvk {
}
DxbcRegisterValue DxbcCompiler::emitQueryTextureSamples(
const DxbcRegister& resource) {
const DxbcBufferInfo info = getBufferInfo(resource);
DxbcRegisterValue result;
result.type.ctype = DxbcScalarType::Uint32;
result.type.ccount = 1;
result.id = m_module.opImageQuerySamples(
getVectorTypeId(result.type),
m_module.opLoad(info.typeId, info.varId));
return result;
}
DxbcRegisterValue DxbcCompiler::emitQueryTextureSize(
const DxbcRegister& resource,
DxbcRegisterValue lod) {

View File

@ -524,6 +524,9 @@ namespace dxvk {
void emitTextureQuery(
const DxbcShaderInstruction& ins);
void emitTextureQueryMs(
const DxbcShaderInstruction& ins);
void emitTextureFetch(
const DxbcShaderInstruction& ins);
@ -703,6 +706,9 @@ namespace dxvk {
DxbcRegisterValue emitQueryTextureLods(
const DxbcRegister& resource);
DxbcRegisterValue emitQueryTextureSamples(
const DxbcRegister& resource);
DxbcRegisterValue emitQueryTextureSize(
const DxbcRegister& resource,
DxbcRegisterValue lod);

View File

@ -547,7 +547,10 @@ namespace dxvk {
/* SamplePos */
{ },
/* SampleInfo */
{ },
{ 2, DxbcInstClass::TextureQueryMs, {
{ DxbcOperandKind::DstReg, DxbcScalarType::Uint32 },
{ DxbcOperandKind::SrcReg, DxbcScalarType::Float32 },
} },
/* Reserved1 */
{ },
/* HsDecls */

View File

@ -42,6 +42,7 @@ namespace dxvk {
BufferStore, ///< Structured or raw buffer store
ConvertFloat16, ///< 16-bit float packing/unpacking
TextureQuery, ///< Texture query instruction
TextureQueryMs, ///< Multisample texture query
TextureFetch, ///< Texture fetch instruction
TextureGather, ///< Texture gather instruction
TextureSample, ///< Texture sampling instruction

View File

@ -2400,6 +2400,19 @@ namespace dxvk {
}
uint32_t SpirvModule::opImageQuerySamples(
uint32_t resultType,
uint32_t image) {
uint32_t resultId = this->allocateId();
m_code.putIns (spv::OpImageQuerySamples, 4);
m_code.putWord(resultType);
m_code.putWord(resultId);
m_code.putWord(image);
return resultId;
}
uint32_t SpirvModule::opImageFetch(
uint32_t resultType,
uint32_t image,

View File

@ -840,6 +840,10 @@ namespace dxvk {
uint32_t resultType,
uint32_t image);
uint32_t opImageQuerySamples(
uint32_t resultType,
uint32_t image);
uint32_t opImageFetch(
uint32_t resultType,
uint32_t image,