Browse Source
Merge pull request #8858 from vonchenplus/mipmap
Merge pull request #8858 from vonchenplus/mipmap
video_core: Generate mipmap texture by drawingnce_cpp
committed by
GitHub
29 changed files with 259 additions and 8 deletions
-
1src/shader_recompiler/CMakeLists.txt
-
3src/shader_recompiler/backend/glasm/emit_glasm.cpp
-
4src/shader_recompiler/backend/glasm/emit_glasm_context_get_set.cpp
-
1src/shader_recompiler/backend/glasm/emit_glasm_instructions.h
-
4src/shader_recompiler/backend/glsl/emit_glsl_context_get_set.cpp
-
1src/shader_recompiler/backend/glsl/emit_glsl_instructions.h
-
3src/shader_recompiler/backend/glsl/glsl_emit_context.cpp
-
4src/shader_recompiler/backend/spirv/emit_spirv.h
-
12src/shader_recompiler/backend/spirv/emit_spirv_context_get_set.cpp
-
1src/shader_recompiler/backend/spirv/emit_spirv_instructions.h
-
31src/shader_recompiler/backend/spirv/spirv_emit_context.cpp
-
4src/shader_recompiler/backend/spirv/spirv_emit_context.h
-
2src/shader_recompiler/environment.h
-
8src/shader_recompiler/frontend/ir/ir_emitter.cpp
-
3src/shader_recompiler/frontend/ir/ir_emitter.h
-
1src/shader_recompiler/frontend/ir/opcodes.inc
-
2src/shader_recompiler/frontend/maxwell/translate_program.cpp
-
1src/shader_recompiler/ir_opt/passes.h
-
77src/shader_recompiler/ir_opt/position_pass.cpp
-
1src/shader_recompiler/shader_info.h
-
11src/video_core/renderer_opengl/gl_graphics_pipeline.cpp
-
10src/video_core/renderer_opengl/gl_rasterizer.cpp
-
2src/video_core/renderer_opengl/gl_shader_cache.cpp
-
10src/video_core/renderer_vulkan/pipeline_helper.h
-
24src/video_core/renderer_vulkan/vk_graphics_pipeline.cpp
-
4src/video_core/renderer_vulkan/vk_graphics_pipeline.h
-
16src/video_core/renderer_vulkan/vk_rasterizer.cpp
-
17src/video_core/shader_environment.cpp
-
9src/video_core/shader_environment.h
@ -0,0 +1,77 @@ |
|||||
|
// SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project
|
||||
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
|
||||
|
#include <boost/container/small_vector.hpp>
|
||||
|
|
||||
|
#include "shader_recompiler/frontend/ir/basic_block.h"
|
||||
|
#include "shader_recompiler/frontend/ir/ir_emitter.h"
|
||||
|
#include "shader_recompiler/frontend/ir/value.h"
|
||||
|
#include "shader_recompiler/ir_opt/passes.h"
|
||||
|
|
||||
|
namespace Shader::Optimization { |
||||
|
|
||||
|
namespace { |
||||
|
struct PositionInst { |
||||
|
IR::Inst* inst; |
||||
|
IR::Block* block; |
||||
|
IR::Attribute attr; |
||||
|
}; |
||||
|
using PositionInstVector = boost::container::small_vector<PositionInst, 24>; |
||||
|
} // Anonymous namespace
|
||||
|
|
||||
|
void PositionPass(Environment& env, IR::Program& program) { |
||||
|
if (env.ShaderStage() != Stage::VertexB || env.ReadViewportTransformState()) { |
||||
|
return; |
||||
|
} |
||||
|
|
||||
|
Info& info{program.info}; |
||||
|
info.uses_render_area = true; |
||||
|
|
||||
|
PositionInstVector to_replace; |
||||
|
for (IR::Block* const block : program.post_order_blocks) { |
||||
|
for (IR::Inst& inst : block->Instructions()) { |
||||
|
switch (inst.GetOpcode()) { |
||||
|
case IR::Opcode::SetAttribute: { |
||||
|
const IR::Attribute attr{inst.Arg(0).Attribute()}; |
||||
|
switch (attr) { |
||||
|
case IR::Attribute::PositionX: |
||||
|
case IR::Attribute::PositionY: { |
||||
|
to_replace.push_back(PositionInst{.inst = &inst, .block = block, .attr = attr}); |
||||
|
break; |
||||
|
} |
||||
|
default: |
||||
|
break; |
||||
|
} |
||||
|
break; |
||||
|
} |
||||
|
default: |
||||
|
break; |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
for (PositionInst& position_inst : to_replace) { |
||||
|
IR::IREmitter ir{*position_inst.block, |
||||
|
IR::Block::InstructionList::s_iterator_to(*position_inst.inst)}; |
||||
|
const IR::F32 value(position_inst.inst->Arg(1)); |
||||
|
const IR::F32F64 scale(ir.Imm32(2.f)); |
||||
|
const IR::F32 negative_one{ir.Imm32(-1.f)}; |
||||
|
switch (position_inst.attr) { |
||||
|
case IR::Attribute::PositionX: { |
||||
|
position_inst.inst->SetArg( |
||||
|
1, |
||||
|
ir.FPFma(value, ir.FPMul(ir.FPRecip(ir.RenderAreaWidth()), scale), negative_one)); |
||||
|
break; |
||||
|
} |
||||
|
case IR::Attribute::PositionY: { |
||||
|
position_inst.inst->SetArg( |
||||
|
1, |
||||
|
ir.FPFma(value, ir.FPMul(ir.FPRecip(ir.RenderAreaHeight()), scale), negative_one)); |
||||
|
break; |
||||
|
} |
||||
|
default: |
||||
|
break; |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} // namespace Shader::Optimization
|
||||
Write
Preview
Loading…
Cancel
Save
Reference in new issue