mirror of
https://github.com/yuzu-emu/yuzu-mainline.git
synced 2024-12-25 02:55:31 +00:00
gl_rasterizer: Minor code changes
This commit is contained in:
parent
04cdecb7a1
commit
954fc02fdd
|
@ -998,17 +998,17 @@ TextureBufferUsage RasterizerOpenGL::SetupDrawTextures(Maxwell::ShaderStage stag
|
||||||
|
|
||||||
for (u32 bindpoint = 0; bindpoint < entries.size(); ++bindpoint) {
|
for (u32 bindpoint = 0; bindpoint < entries.size(); ++bindpoint) {
|
||||||
const auto& entry = entries[bindpoint];
|
const auto& entry = entries[bindpoint];
|
||||||
Tegra::Texture::FullTextureInfo texture;
|
const auto texture = [&]() {
|
||||||
if (entry.IsBindless()) {
|
if (!entry.IsBindless()) {
|
||||||
|
return maxwell3d.GetStageTexture(stage, entry.GetOffset());
|
||||||
|
}
|
||||||
const auto cbuf = entry.GetBindlessCBuf();
|
const auto cbuf = entry.GetBindlessCBuf();
|
||||||
Tegra::Texture::TextureHandle tex_handle;
|
Tegra::Texture::TextureHandle tex_handle;
|
||||||
tex_handle.raw = maxwell3d.AccessConstBuffer32(stage, cbuf.first, cbuf.second);
|
tex_handle.raw = maxwell3d.AccessConstBuffer32(stage, cbuf.first, cbuf.second);
|
||||||
texture = maxwell3d.GetTextureInfo(tex_handle, entry.GetOffset());
|
return maxwell3d.GetTextureInfo(tex_handle, entry.GetOffset());
|
||||||
} else {
|
}();
|
||||||
texture = maxwell3d.GetStageTexture(stage, entry.GetOffset());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (SetupTexture(shader, base_bindings.sampler + bindpoint, texture, entry)) {
|
if (SetupTexture(base_bindings.sampler + bindpoint, texture, entry)) {
|
||||||
texture_buffer_usage.set(bindpoint);
|
texture_buffer_usage.set(bindpoint);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1016,8 +1016,7 @@ TextureBufferUsage RasterizerOpenGL::SetupDrawTextures(Maxwell::ShaderStage stag
|
||||||
return texture_buffer_usage;
|
return texture_buffer_usage;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool RasterizerOpenGL::SetupTexture(const Shader& shader, u32 binding,
|
bool RasterizerOpenGL::SetupTexture(u32 binding, const Tegra::Texture::FullTextureInfo& texture,
|
||||||
const Tegra::Texture::FullTextureInfo& texture,
|
|
||||||
const GLShader::SamplerEntry& entry) {
|
const GLShader::SamplerEntry& entry) {
|
||||||
state.samplers[binding] = sampler_cache.GetSampler(texture.tsc);
|
state.samplers[binding] = sampler_cache.GetSampler(texture.tsc);
|
||||||
|
|
||||||
|
@ -1044,22 +1043,30 @@ void RasterizerOpenGL::SetupComputeImages(const Shader& shader) {
|
||||||
const auto& entries = shader->GetShaderEntries().images;
|
const auto& entries = shader->GetShaderEntries().images;
|
||||||
for (u32 bindpoint = 0; bindpoint < entries.size(); ++bindpoint) {
|
for (u32 bindpoint = 0; bindpoint < entries.size(); ++bindpoint) {
|
||||||
const auto& entry = entries[bindpoint];
|
const auto& entry = entries[bindpoint];
|
||||||
const auto texture = [&]() {
|
const auto tic = [&]() {
|
||||||
if (!entry.IsBindless()) {
|
if (!entry.IsBindless()) {
|
||||||
return compute.GetTexture(entry.GetOffset());
|
return compute.GetTexture(entry.GetOffset()).tic;
|
||||||
}
|
}
|
||||||
const auto cbuf = entry.GetBindlessCBuf();
|
const auto cbuf = entry.GetBindlessCBuf();
|
||||||
Tegra::Texture::TextureHandle tex_handle;
|
Tegra::Texture::TextureHandle tex_handle;
|
||||||
tex_handle.raw = compute.AccessConstBuffer32(cbuf.first, cbuf.second);
|
tex_handle.raw = compute.AccessConstBuffer32(cbuf.first, cbuf.second);
|
||||||
return compute.GetTextureInfo(tex_handle, entry.GetOffset());
|
return compute.GetTextureInfo(tex_handle, entry.GetOffset()).tic;
|
||||||
}();
|
}();
|
||||||
const auto view = texture_cache.GetImageSurface(texture.tic, entry);
|
SetupImage(bindpoint, tic, entry);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void RasterizerOpenGL::SetupImage(u32 binding, const Tegra::Texture::TICEntry& tic,
|
||||||
|
const GLShader::ImageEntry& entry) {
|
||||||
|
const auto view = texture_cache.GetImageSurface(tic, entry);
|
||||||
if (!view) {
|
if (!view) {
|
||||||
state.images[bindpoint] = 0;
|
state.images[binding] = 0;
|
||||||
continue;
|
return;
|
||||||
}
|
}
|
||||||
state.images[bindpoint] = view->GetTexture();
|
if (!tic.IsBuffer()) {
|
||||||
|
view->ApplySwizzle(tic.x_source, tic.y_source, tic.z_source, tic.w_source);
|
||||||
}
|
}
|
||||||
|
state.images[binding] = view->GetTexture();
|
||||||
}
|
}
|
||||||
|
|
||||||
void RasterizerOpenGL::SyncViewport(OpenGLState& current_state) {
|
void RasterizerOpenGL::SyncViewport(OpenGLState& current_state) {
|
||||||
|
|
|
@ -142,12 +142,16 @@ private:
|
||||||
const Shader& shader, BaseBindings base_bindings);
|
const Shader& shader, BaseBindings base_bindings);
|
||||||
|
|
||||||
/// Configures a texture. Returns true when the texture is a texture buffer.
|
/// Configures a texture. Returns true when the texture is a texture buffer.
|
||||||
bool SetupTexture(const Shader& shader, u32 binding,
|
bool SetupTexture(u32 binding, const Tegra::Texture::FullTextureInfo& texture,
|
||||||
const Tegra::Texture::FullTextureInfo& texture,
|
|
||||||
const GLShader::SamplerEntry& entry);
|
const GLShader::SamplerEntry& entry);
|
||||||
|
|
||||||
|
/// Configures images in a compute shader.
|
||||||
void SetupComputeImages(const Shader& shader);
|
void SetupComputeImages(const Shader& shader);
|
||||||
|
|
||||||
|
/// Configures an image.
|
||||||
|
void SetupImage(u32 binding, const Tegra::Texture::TICEntry& tic,
|
||||||
|
const GLShader::ImageEntry& entry);
|
||||||
|
|
||||||
/// Syncs the viewport and depth range to match the guest state
|
/// Syncs the viewport and depth range to match the guest state
|
||||||
void SyncViewport(OpenGLState& current_state);
|
void SyncViewport(OpenGLState& current_state);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue