Implement ReadCbufValue and ReadTextureType hades callbacks

Used for bindless and BRX instruction emulation.
This commit is contained in:
Billy Laws 2022-10-09 13:50:19 +01:00
parent 2163f8cde6
commit 4c2db0ba01
3 changed files with 35 additions and 5 deletions

View File

@ -184,11 +184,17 @@ namespace skyline::gpu::interconnect::maxwell3d {
if (!packedState.shaderHashes[i]) if (!packedState.shaderHashes[i])
continue; continue;
auto program{ctx.gpu.shader.ParseGraphicsShader(packedState.postVtgShaderAttributeSkipMask, auto program{ctx.gpu.shader.ParseGraphicsShader(
ConvertCompilerShaderStage(static_cast<PipelineStage>(i)), packedState.postVtgShaderAttributeSkipMask,
shaderBinaries[i].binary, shaderBinaries[i].baseOffset, ConvertCompilerShaderStage(static_cast<PipelineStage>(i)),
packedState.bindlessTextureConstantBufferSlotSelect, shaderBinaries[i].binary, shaderBinaries[i].baseOffset,
[](int, int){ return 0; }, [](u32){return Shader::TextureType::Color2D;})}; packedState.bindlessTextureConstantBufferSlotSelect,
[&](u32 index, u32 offset) {
size_t shaderStage{i > 0 ? (i - 1) : 0};
return constantBuffers[shaderStage][index].Read<int>(ctx.executor, offset);
}, [&](u32 index) {
return textures.GetTextureType(ctx, index);
})};
if (i == stageIdx(PipelineStage::Vertex) && packedState.shaderHashes[stageIdx(PipelineStage::VertexCullBeforeFetch)]) { if (i == stageIdx(PipelineStage::Vertex) && packedState.shaderHashes[stageIdx(PipelineStage::VertexCullBeforeFetch)]) {
ignoreVertexCullBeforeFetch = true; ignoreVertexCullBeforeFetch = true;
programs[i] = ctx.gpu.shader.CombineVertexShaders(programs[stageIdx(PipelineStage::VertexCullBeforeFetch)], program, shaderBinaries[i].binary); programs[i] = ctx.gpu.shader.CombineVertexShaders(programs[stageIdx(PipelineStage::VertexCullBeforeFetch)], program, shaderBinaries[i].binary);

View File

@ -318,4 +318,27 @@ namespace skyline::gpu::interconnect::maxwell3d {
textureHeaderCache[index] = {textureHeader, texture.get(), ctx.executor.executionNumber}; textureHeaderCache[index] = {textureHeader, texture.get(), ctx.executor.executionNumber};
return texture.get(); return texture.get();
} }
Shader::TextureType Textures::GetTextureType(InterconnectContext &ctx, u32 index) {
auto textureHeaders{texturePool.UpdateGet(ctx).textureHeaders};
switch (textureHeaders[index].textureType) {
case TextureImageControl::TextureType::e1D:
return Shader::TextureType::Color1D;
case TextureImageControl::TextureType::e1DArray:
return Shader::TextureType::ColorArray1D;
case TextureImageControl::TextureType::e1DBuffer:
return Shader::TextureType::Buffer;
case TextureImageControl::TextureType::e2DNoMipmap:
case TextureImageControl::TextureType::e2D:
return Shader::TextureType::Color2D;
case TextureImageControl::TextureType::e2DArray:
return Shader::TextureType::ColorArray2D;
case TextureImageControl::TextureType::e3D:
return Shader::TextureType::Color3D;
case TextureImageControl::TextureType::eCube:
return Shader::TextureType::ColorCube;
case TextureImageControl::TextureType::eCubeArray:
return Shader::TextureType::ColorArrayCube;
}
}
} }

View File

@ -4,6 +4,7 @@
#pragma once #pragma once
#include <tsl/robin_map.h> #include <tsl/robin_map.h>
#include <shader_compiler/runtime_info.h>
#include "common.h" #include "common.h"
#include "tic.h" #include "tic.h"