early-access version 3012

This commit is contained in:
pineappleEA 2022-10-10 02:05:13 +02:00
parent 6834d23fab
commit b16ace6ba4
14 changed files with 140 additions and 169 deletions

View file

@ -1,7 +1,7 @@
yuzu emulator early access yuzu emulator early access
============= =============
This is the source code for early-access 3011. This is the source code for early-access 3012.
## Legal Notice ## Legal Notice

View file

@ -277,8 +277,9 @@ struct CallbackStatus {
BodyColorStatus color_status{}; BodyColorStatus color_status{};
BatteryStatus battery_status{}; BatteryStatus battery_status{};
VibrationStatus vibration_status{}; VibrationStatus vibration_status{};
CameraStatus camera_status{}; CameraFormat camera_status{CameraFormat::None};
NfcStatus nfc_status{}; NfcState nfc_status{NfcState::Unknown};
std::vector<u8> raw_data{};
}; };
// Triggered once every input change // Triggered once every input change

View file

@ -277,7 +277,10 @@ Common::Input::CameraStatus TransformToCamera(const Common::Input::CallbackStatu
Common::Input::CameraStatus camera{}; Common::Input::CameraStatus camera{};
switch (callback.type) { switch (callback.type) {
case Common::Input::InputType::IrSensor: case Common::Input::InputType::IrSensor:
camera = callback.camera_status; camera = {
.format = callback.camera_status,
.data = callback.raw_data,
};
break; break;
default: default:
LOG_ERROR(Input, "Conversion from type {} to camera not implemented", callback.type); LOG_ERROR(Input, "Conversion from type {} to camera not implemented", callback.type);
@ -291,7 +294,10 @@ Common::Input::NfcStatus TransformToNfc(const Common::Input::CallbackStatus& cal
Common::Input::NfcStatus nfc{}; Common::Input::NfcStatus nfc{};
switch (callback.type) { switch (callback.type) {
case Common::Input::InputType::Nfc: case Common::Input::InputType::Nfc:
return callback.nfc_status; nfc = {
.state = callback.nfc_status,
.data = callback.raw_data,
};
break; break;
default: default:
LOG_ERROR(Input, "Conversion from type {} to NFC not implemented", callback.type); LOG_ERROR(Input, "Conversion from type {} to NFC not implemented", callback.type);

View file

@ -691,9 +691,12 @@ public:
} }
void OnChange() { void OnChange() {
const auto camera_status = GetStatus();
const Common::Input::CallbackStatus status{ const Common::Input::CallbackStatus status{
.type = Common::Input::InputType::IrSensor, .type = Common::Input::InputType::IrSensor,
.camera_status = GetStatus(), .camera_status = camera_status.format,
.raw_data = camera_status.data,
}; };
TriggerOnChange(status); TriggerOnChange(status);
@ -732,9 +735,12 @@ public:
} }
void OnChange() { void OnChange() {
const auto nfc_status = GetStatus();
const Common::Input::CallbackStatus status{ const Common::Input::CallbackStatus status{
.type = Common::Input::InputType::Nfc, .type = Common::Input::InputType::Nfc,
.nfc_status = GetStatus(), .nfc_status = nfc_status.state,
.raw_data = nfc_status.data,
}; };
TriggerOnChange(status); TriggerOnChange(status);

View file

@ -117,10 +117,12 @@ void Maxwell3D::InitializeRegisterDefaults() {
shadow_state = regs; shadow_state = regs;
mme_inline[MAXWELL3D_REG_INDEX(draw.end)] = true; inline_draw[MAXWELL3D_REG_INDEX(draw.end)] = true;
mme_inline[MAXWELL3D_REG_INDEX(draw.begin)] = true; inline_draw[MAXWELL3D_REG_INDEX(draw.begin)] = true;
mme_inline[MAXWELL3D_REG_INDEX(vertex_buffer.count)] = true; inline_draw[MAXWELL3D_REG_INDEX(vertex_buffer.first)] = true;
mme_inline[MAXWELL3D_REG_INDEX(index_buffer.count)] = true; inline_draw[MAXWELL3D_REG_INDEX(vertex_buffer.count)] = true;
inline_draw[MAXWELL3D_REG_INDEX(index_buffer.first)] = true;
inline_draw[MAXWELL3D_REG_INDEX(index_buffer.count)] = true;
} }
void Maxwell3D::ProcessMacro(u32 method, const u32* base_start, u32 amount, bool is_last_call) { void Maxwell3D::ProcessMacro(u32 method, const u32* base_start, u32 amount, bool is_last_call) {
@ -208,25 +210,21 @@ void Maxwell3D::ProcessMethodCall(u32 method, u32 argument, u32 nonshadow_argume
return ProcessCBBind(3); return ProcessCBBind(3);
case MAXWELL3D_REG_INDEX(bind_groups[4].raw_config): case MAXWELL3D_REG_INDEX(bind_groups[4].raw_config):
return ProcessCBBind(4); return ProcessCBBind(4);
case MAXWELL3D_REG_INDEX(draw.end):
return DrawArrays();
case MAXWELL3D_REG_INDEX(index_buffer32_first): case MAXWELL3D_REG_INDEX(index_buffer32_first):
regs.index_buffer.count = regs.index_buffer32_first.count; regs.index_buffer.count = regs.index_buffer32_first.count;
regs.index_buffer.first = regs.index_buffer32_first.first; regs.index_buffer.first = regs.index_buffer32_first.first;
dirty.flags[VideoCommon::Dirty::IndexBuffer] = true; dirty.flags[VideoCommon::Dirty::IndexBuffer] = true;
return DrawArrays(); return FlushInlineDraw();
case MAXWELL3D_REG_INDEX(index_buffer16_first): case MAXWELL3D_REG_INDEX(index_buffer16_first):
regs.index_buffer.count = regs.index_buffer16_first.count; regs.index_buffer.count = regs.index_buffer16_first.count;
regs.index_buffer.first = regs.index_buffer16_first.first; regs.index_buffer.first = regs.index_buffer16_first.first;
dirty.flags[VideoCommon::Dirty::IndexBuffer] = true; dirty.flags[VideoCommon::Dirty::IndexBuffer] = true;
return DrawArrays(); return FlushInlineDraw();
case MAXWELL3D_REG_INDEX(index_buffer8_first): case MAXWELL3D_REG_INDEX(index_buffer8_first):
regs.index_buffer.count = regs.index_buffer8_first.count; regs.index_buffer.count = regs.index_buffer8_first.count;
regs.index_buffer.first = regs.index_buffer8_first.first; regs.index_buffer.first = regs.index_buffer8_first.first;
dirty.flags[VideoCommon::Dirty::IndexBuffer] = true; dirty.flags[VideoCommon::Dirty::IndexBuffer] = true;
// a macro calls this one over and over, should it increase instancing? return FlushInlineDraw();
// Used by Hades and likely other Vulkan games.
return DrawArrays();
case MAXWELL3D_REG_INDEX(topology_override): case MAXWELL3D_REG_INDEX(topology_override):
use_topology_override = true; use_topology_override = true;
return; return;
@ -261,14 +259,14 @@ void Maxwell3D::CallMacroMethod(u32 method, const std::vector<u32>& parameters)
// Execute the current macro. // Execute the current macro.
macro_engine->Execute(macro_positions[entry], parameters); macro_engine->Execute(macro_positions[entry], parameters);
if (mme_draw.current_mode != MMEDrawMode::Undefined) { if (draw_state.current_mode != DrawMode::Undefined) {
FlushMMEInlineDraw(); FlushInlineDraw();
} }
} }
void Maxwell3D::CallMethod(u32 method, u32 method_argument, bool is_last_call) { void Maxwell3D::CallMethod(u32 method, u32 method_argument, bool is_last_call) {
// It is an error to write to a register other than the current macro's ARG register before it // It is an error to write to a register other than the current macro's ARG register before
// has finished execution. // it has finished execution.
if (executing_macro != 0) { if (executing_macro != 0) {
ASSERT(method == executing_macro + 1); ASSERT(method == executing_macro + 1);
} }
@ -283,9 +281,39 @@ void Maxwell3D::CallMethod(u32 method, u32 method_argument, bool is_last_call) {
ASSERT_MSG(method < Regs::NUM_REGS, ASSERT_MSG(method < Regs::NUM_REGS,
"Invalid Maxwell3D register, increase the size of the Regs structure"); "Invalid Maxwell3D register, increase the size of the Regs structure");
const u32 argument = ProcessShadowRam(method, method_argument); if (inline_draw[method]) {
ProcessDirtyRegisters(method, argument); regs.reg_array[method] = method_argument;
ProcessMethodCall(method, argument, method_argument, is_last_call); switch (method) {
case MAXWELL3D_REG_INDEX(vertex_buffer.count):
case MAXWELL3D_REG_INDEX(index_buffer.count): {
const DrawMode expected_mode = method == MAXWELL3D_REG_INDEX(vertex_buffer.count)
? DrawMode::Array
: DrawMode::Indexed;
StepInstance(expected_mode, method_argument);
break;
}
case MAXWELL3D_REG_INDEX(draw.begin):
draw_state.instance_mode =
(regs.draw.instance_id == Maxwell3D::Regs::Draw::InstanceId::Subsequent) ||
(regs.draw.instance_id == Maxwell3D::Regs::Draw::InstanceId::Unchanged);
draw_state.gl_begin_consume = true;
break;
case MAXWELL3D_REG_INDEX(draw.end):
draw_state.gl_end_count++;
break;
case MAXWELL3D_REG_INDEX(vertex_buffer.first):
case MAXWELL3D_REG_INDEX(index_buffer.first):
break;
}
} else {
if (draw_state.current_mode != DrawMode::Undefined) {
FlushInlineDraw();
}
const u32 argument = ProcessShadowRam(method, method_argument);
ProcessDirtyRegisters(method, argument);
ProcessMethodCall(method, argument, method_argument, is_last_call);
}
} }
void Maxwell3D::CallMultiMethod(u32 method, const u32* base_start, u32 amount, void Maxwell3D::CallMultiMethod(u32 method, const u32* base_start, u32 amount,
@ -326,55 +354,30 @@ void Maxwell3D::CallMultiMethod(u32 method, const u32* base_start, u32 amount,
} }
} }
void Maxwell3D::StepInstance(const MMEDrawMode expected_mode, const u32 count) { void Maxwell3D::StepInstance(const DrawMode expected_mode, const u32 count) {
if (mme_draw.current_mode == MMEDrawMode::Undefined) { if (draw_state.current_mode == DrawMode::Undefined) {
if (mme_draw.gl_begin_consume) { if (draw_state.gl_begin_consume) {
mme_draw.current_mode = expected_mode; draw_state.current_mode = expected_mode;
mme_draw.current_count = count; draw_state.current_count = count;
mme_draw.instance_count = 1; draw_state.instance_count = 1;
mme_draw.gl_begin_consume = false; draw_state.gl_begin_consume = false;
mme_draw.gl_end_count = 0; draw_state.gl_end_count = 0;
} }
return; return;
} else { } else {
if (mme_draw.current_mode == expected_mode && count == mme_draw.current_count && if (draw_state.current_mode == expected_mode && count == draw_state.current_count &&
mme_draw.instance_mode && mme_draw.gl_begin_consume) { draw_state.instance_mode && draw_state.gl_begin_consume) {
mme_draw.instance_count++; draw_state.instance_count++;
mme_draw.gl_begin_consume = false; draw_state.gl_begin_consume = false;
return; return;
} else { } else {
FlushMMEInlineDraw(); FlushInlineDraw();
} }
} }
// Tail call in case it needs to retry. // Tail call in case it needs to retry.
StepInstance(expected_mode, count); StepInstance(expected_mode, count);
} }
void Maxwell3D::CallMethodFromMME(u32 method, u32 method_argument) {
if (mme_inline[method]) {
regs.reg_array[method] = method_argument;
if (method == MAXWELL3D_REG_INDEX(vertex_buffer.count) ||
method == MAXWELL3D_REG_INDEX(index_buffer.count)) {
const MMEDrawMode expected_mode = method == MAXWELL3D_REG_INDEX(vertex_buffer.count)
? MMEDrawMode::Array
: MMEDrawMode::Indexed;
StepInstance(expected_mode, method_argument);
} else if (method == MAXWELL3D_REG_INDEX(draw.begin)) {
mme_draw.instance_mode =
(regs.draw.instance_id == Maxwell3D::Regs::Draw::InstanceId::Subsequent) ||
(regs.draw.instance_id == Maxwell3D::Regs::Draw::InstanceId::Unchanged);
mme_draw.gl_begin_consume = true;
} else {
mme_draw.gl_end_count++;
}
} else {
if (mme_draw.current_mode != MMEDrawMode::Undefined) {
FlushMMEInlineDraw();
}
CallMethod(method, method_argument, true);
}
}
void Maxwell3D::ProcessTopologyOverride() { void Maxwell3D::ProcessTopologyOverride() {
using PrimitiveTopology = Maxwell3D::Regs::PrimitiveTopology; using PrimitiveTopology = Maxwell3D::Regs::PrimitiveTopology;
using PrimitiveTopologyOverride = Maxwell3D::Regs::PrimitiveTopologyOverride; using PrimitiveTopologyOverride = Maxwell3D::Regs::PrimitiveTopologyOverride;
@ -404,11 +407,12 @@ void Maxwell3D::ProcessTopologyOverride() {
} }
} }
void Maxwell3D::FlushMMEInlineDraw() { void Maxwell3D::FlushInlineDraw() {
LOG_TRACE(HW_GPU, "called, topology={}, count={}", regs.draw.topology.Value(), LOG_TRACE(HW_GPU, "called, topology={}, count={}", regs.draw.topology.Value(),
regs.vertex_buffer.count); regs.vertex_buffer.count);
ASSERT_MSG(!(regs.index_buffer.count && regs.vertex_buffer.count), "Both indexed and direct?"); ASSERT_MSG(!(regs.index_buffer.count && regs.vertex_buffer.count), "Both indexed and direct?");
ASSERT(mme_draw.instance_count == mme_draw.gl_end_count); ASSERT(draw_state.instance_count == draw_state.gl_end_count);
// Both instance configuration registers can not be set at the same time. // Both instance configuration registers can not be set at the same time.
ASSERT_MSG(regs.draw.instance_id == Maxwell3D::Regs::Draw::InstanceId::First || ASSERT_MSG(regs.draw.instance_id == Maxwell3D::Regs::Draw::InstanceId::First ||
@ -417,9 +421,9 @@ void Maxwell3D::FlushMMEInlineDraw() {
ProcessTopologyOverride(); ProcessTopologyOverride();
const bool is_indexed = mme_draw.current_mode == MMEDrawMode::Indexed; const bool is_indexed = draw_state.current_mode == DrawMode::Indexed;
if (ShouldExecute()) { if (ShouldExecute()) {
rasterizer->Draw(is_indexed, true); rasterizer->Draw(is_indexed);
} }
// TODO(bunnei): Below, we reset vertex count so that we can use these registers to determine if // TODO(bunnei): Below, we reset vertex count so that we can use these registers to determine if
@ -431,12 +435,12 @@ void Maxwell3D::FlushMMEInlineDraw() {
} else { } else {
regs.vertex_buffer.count = 0; regs.vertex_buffer.count = 0;
} }
mme_draw.current_mode = MMEDrawMode::Undefined; draw_state.current_mode = DrawMode::Undefined;
mme_draw.current_count = 0; draw_state.current_count = 0;
mme_draw.instance_count = 0; draw_state.instance_count = 0;
mme_draw.instance_mode = false; draw_state.instance_mode = false;
mme_draw.gl_begin_consume = false; draw_state.gl_begin_consume = false;
mme_draw.gl_end_count = 0; draw_state.gl_end_count = 0;
} }
void Maxwell3D::ProcessMacroUpload(u32 data) { void Maxwell3D::ProcessMacroUpload(u32 data) {
@ -576,42 +580,6 @@ void Maxwell3D::ProcessSyncPoint() {
} }
} }
void Maxwell3D::DrawArrays() {
LOG_TRACE(HW_GPU, "called, topology={}, count={}", regs.draw.topology.Value(),
regs.vertex_buffer.count);
ASSERT_MSG(!(regs.index_buffer.count && regs.vertex_buffer.count), "Both indexed and direct?");
// Both instance configuration registers can not be set at the same time.
ASSERT_MSG(regs.draw.instance_id == Maxwell3D::Regs::Draw::InstanceId::First ||
regs.draw.instance_id != Maxwell3D::Regs::Draw::InstanceId::Unchanged,
"Illegal combination of instancing parameters");
ProcessTopologyOverride();
if (regs.draw.instance_id == Maxwell3D::Regs::Draw::InstanceId::Subsequent) {
// Increment the current instance *before* drawing.
state.current_instance++;
} else if (regs.draw.instance_id != Maxwell3D::Regs::Draw::InstanceId::Unchanged) {
// Reset the current instance to 0.
state.current_instance = 0;
}
const bool is_indexed{regs.index_buffer.count && !regs.vertex_buffer.count};
if (ShouldExecute()) {
rasterizer->Draw(is_indexed, false);
}
// TODO(bunnei): Below, we reset vertex count so that we can use these registers to determine if
// the game is trying to draw indexed or direct mode. This needs to be verified on HW still -
// it's possible that it is incorrect and that there is some other register used to specify the
// drawing mode.
if (is_indexed) {
regs.index_buffer.count = 0;
} else {
regs.vertex_buffer.count = 0;
}
}
std::optional<u64> Maxwell3D::GetQueryResult() { std::optional<u64> Maxwell3D::GetQueryResult() {
switch (regs.report_semaphore.query.report) { switch (regs.report_semaphore.query.report) {
case Regs::ReportSemaphore::Report::Payload: case Regs::ReportSemaphore::Report::Payload:

View file

@ -3050,8 +3050,6 @@ public:
}; };
std::array<ShaderStageInfo, Regs::MaxShaderStage> shader_stages; std::array<ShaderStageInfo, Regs::MaxShaderStage> shader_stages;
u32 current_instance = 0; ///< Current instance to be used to simulate instanced rendering.
}; };
State state{}; State state{};
@ -3066,10 +3064,7 @@ public:
void CallMultiMethod(u32 method, const u32* base_start, u32 amount, void CallMultiMethod(u32 method, const u32* base_start, u32 amount,
u32 methods_pending) override; u32 methods_pending) override;
/// Write the value to the register identified by method. void FlushInlineDraw();
void CallMethodFromMME(u32 method, u32 method_argument);
void FlushMMEInlineDraw();
bool ShouldExecute() const { bool ShouldExecute() const {
return execute_on; return execute_on;
@ -3083,20 +3078,20 @@ public:
return *rasterizer; return *rasterizer;
} }
enum class MMEDrawMode : u32 { enum class DrawMode : u32 {
Undefined, Undefined,
Array, Array,
Indexed, Indexed,
}; };
struct MMEDrawState { struct DrawState {
MMEDrawMode current_mode{MMEDrawMode::Undefined}; DrawMode current_mode{DrawMode::Undefined};
u32 current_count{}; u32 current_count{};
u32 instance_count{}; u32 instance_count{};
bool instance_mode{}; bool instance_mode{};
bool gl_begin_consume{}; bool gl_begin_consume{};
u32 gl_end_count{}; u32 gl_end_count{};
} mme_draw; } draw_state;
struct DirtyState { struct DirtyState {
using Flags = std::bitset<std::numeric_limits<u8>::max()>; using Flags = std::bitset<std::numeric_limits<u8>::max()>;
@ -3166,14 +3161,11 @@ private:
/// Handles a write to the CB_BIND register. /// Handles a write to the CB_BIND register.
void ProcessCBBind(size_t stage_index); void ProcessCBBind(size_t stage_index);
/// Handles a write to the VERTEX_END_GL register, triggering a draw.
void DrawArrays();
/// Handles use of topology overrides (e.g., to avoid using a topology assigned from a macro) /// Handles use of topology overrides (e.g., to avoid using a topology assigned from a macro)
void ProcessTopologyOverride(); void ProcessTopologyOverride();
// Handles a instance drawcall from MME // Handles a instance drawcall from MME
void StepInstance(MMEDrawMode expected_mode, u32 count); void StepInstance(DrawMode expected_mode, u32 count);
/// Returns a query's value or an empty object if the value will be deferred through a cache. /// Returns a query's value or an empty object if the value will be deferred through a cache.
std::optional<u64> GetQueryResult(); std::optional<u64> GetQueryResult();
@ -3186,7 +3178,7 @@ private:
/// Start offsets of each macro in macro_memory /// Start offsets of each macro in macro_memory
std::array<u32, 0x80> macro_positions{}; std::array<u32, 0x80> macro_positions{};
std::array<bool, Regs::NUM_REGS> mme_inline{}; std::array<bool, Regs::NUM_REGS> inline_draw{};
/// Macro method that is currently being executed / being fed parameters. /// Macro method that is currently being executed / being fed parameters.
u32 executing_macro = 0; u32 executing_macro = 0;

View file

@ -22,17 +22,17 @@ void HLE_771BB18C62444DA0(Engines::Maxwell3D& maxwell3d, const std::vector<u32>&
maxwell3d.regs.draw.topology.Assign( maxwell3d.regs.draw.topology.Assign(
static_cast<Tegra::Engines::Maxwell3D::Regs::PrimitiveTopology>(parameters[0] & 0x3ffffff)); static_cast<Tegra::Engines::Maxwell3D::Regs::PrimitiveTopology>(parameters[0] & 0x3ffffff));
maxwell3d.regs.global_base_instance_index = parameters[5]; maxwell3d.regs.global_base_instance_index = parameters[5];
maxwell3d.mme_draw.instance_count = instance_count; maxwell3d.draw_state.instance_count = instance_count;
maxwell3d.regs.global_base_vertex_index = parameters[3]; maxwell3d.regs.global_base_vertex_index = parameters[3];
maxwell3d.regs.index_buffer.count = parameters[1]; maxwell3d.regs.index_buffer.count = parameters[1];
maxwell3d.regs.index_buffer.first = parameters[4]; maxwell3d.regs.index_buffer.first = parameters[4];
if (maxwell3d.ShouldExecute()) { if (maxwell3d.ShouldExecute()) {
maxwell3d.Rasterizer().Draw(true, true); maxwell3d.Rasterizer().Draw(true);
} }
maxwell3d.regs.index_buffer.count = 0; maxwell3d.regs.index_buffer.count = 0;
maxwell3d.mme_draw.instance_count = 0; maxwell3d.draw_state.instance_count = 0;
maxwell3d.mme_draw.current_mode = Engines::Maxwell3D::MMEDrawMode::Undefined; maxwell3d.draw_state.current_mode = Engines::Maxwell3D::DrawMode::Undefined;
} }
void HLE_0D61FC9FAAC9FCAD(Engines::Maxwell3D& maxwell3d, const std::vector<u32>& parameters) { void HLE_0D61FC9FAAC9FCAD(Engines::Maxwell3D& maxwell3d, const std::vector<u32>& parameters) {
@ -43,14 +43,14 @@ void HLE_0D61FC9FAAC9FCAD(Engines::Maxwell3D& maxwell3d, const std::vector<u32>&
maxwell3d.regs.global_base_instance_index = parameters[4]; maxwell3d.regs.global_base_instance_index = parameters[4];
maxwell3d.regs.draw.topology.Assign( maxwell3d.regs.draw.topology.Assign(
static_cast<Tegra::Engines::Maxwell3D::Regs::PrimitiveTopology>(parameters[0])); static_cast<Tegra::Engines::Maxwell3D::Regs::PrimitiveTopology>(parameters[0]));
maxwell3d.mme_draw.instance_count = count; maxwell3d.draw_state.instance_count = count;
if (maxwell3d.ShouldExecute()) { if (maxwell3d.ShouldExecute()) {
maxwell3d.Rasterizer().Draw(false, true); maxwell3d.Rasterizer().Draw(false);
} }
maxwell3d.regs.vertex_buffer.count = 0; maxwell3d.regs.vertex_buffer.count = 0;
maxwell3d.mme_draw.instance_count = 0; maxwell3d.draw_state.instance_count = 0;
maxwell3d.mme_draw.current_mode = Engines::Maxwell3D::MMEDrawMode::Undefined; maxwell3d.draw_state.current_mode = Engines::Maxwell3D::DrawMode::Undefined;
} }
void HLE_0217920100488FF7(Engines::Maxwell3D& maxwell3d, const std::vector<u32>& parameters) { void HLE_0217920100488FF7(Engines::Maxwell3D& maxwell3d, const std::vector<u32>& parameters) {
@ -63,39 +63,39 @@ void HLE_0217920100488FF7(Engines::Maxwell3D& maxwell3d, const std::vector<u32>&
maxwell3d.dirty.flags[VideoCommon::Dirty::IndexBuffer] = true; maxwell3d.dirty.flags[VideoCommon::Dirty::IndexBuffer] = true;
maxwell3d.regs.global_base_vertex_index = element_base; maxwell3d.regs.global_base_vertex_index = element_base;
maxwell3d.regs.global_base_instance_index = base_instance; maxwell3d.regs.global_base_instance_index = base_instance;
maxwell3d.mme_draw.instance_count = instance_count; maxwell3d.draw_state.instance_count = instance_count;
maxwell3d.CallMethodFromMME(0x8e3, 0x640); maxwell3d.CallMethod(0x8e3, 0x640, true);
maxwell3d.CallMethodFromMME(0x8e4, element_base); maxwell3d.CallMethod(0x8e4, element_base, true);
maxwell3d.CallMethodFromMME(0x8e5, base_instance); maxwell3d.CallMethod(0x8e5, base_instance, true);
maxwell3d.regs.draw.topology.Assign( maxwell3d.regs.draw.topology.Assign(
static_cast<Tegra::Engines::Maxwell3D::Regs::PrimitiveTopology>(parameters[0])); static_cast<Tegra::Engines::Maxwell3D::Regs::PrimitiveTopology>(parameters[0]));
if (maxwell3d.ShouldExecute()) { if (maxwell3d.ShouldExecute()) {
maxwell3d.Rasterizer().Draw(true, true); maxwell3d.Rasterizer().Draw(true);
} }
maxwell3d.regs.vertex_id_base = 0x0; maxwell3d.regs.vertex_id_base = 0x0; // vertex id base?
maxwell3d.regs.index_buffer.count = 0; maxwell3d.regs.index_buffer.count = 0;
maxwell3d.regs.global_base_vertex_index = 0x0; maxwell3d.regs.global_base_vertex_index = 0x0;
maxwell3d.regs.global_base_instance_index = 0x0; maxwell3d.regs.global_base_instance_index = 0x0;
maxwell3d.mme_draw.instance_count = 0; maxwell3d.draw_state.instance_count = 0;
maxwell3d.CallMethodFromMME(0x8e3, 0x640); maxwell3d.CallMethod(0x8e3, 0x640, true);
maxwell3d.CallMethodFromMME(0x8e4, 0x0); maxwell3d.CallMethod(0x8e4, 0x0, true);
maxwell3d.CallMethodFromMME(0x8e5, 0x0); maxwell3d.CallMethod(0x8e5, 0x0, true);
maxwell3d.mme_draw.current_mode = Engines::Maxwell3D::MMEDrawMode::Undefined; maxwell3d.draw_state.current_mode = Engines::Maxwell3D::DrawMode::Undefined;
} }
// Multidraw Indirect // Multidraw Indirect
void HLE_3F5E74B9C9A50164(Engines::Maxwell3D& maxwell3d, const std::vector<u32>& parameters) { void HLE_3F5E74B9C9A50164(Engines::Maxwell3D& maxwell3d, const std::vector<u32>& parameters) {
SCOPE_EXIT({ SCOPE_EXIT({
// Clean everything. // Clean everything.
maxwell3d.regs.vertex_id_base = 0x0; maxwell3d.regs.vertex_id_base = 0x0; // vertex id base?
maxwell3d.regs.index_buffer.count = 0; maxwell3d.regs.index_buffer.count = 0;
maxwell3d.regs.global_base_vertex_index = 0x0; maxwell3d.regs.global_base_vertex_index = 0x0;
maxwell3d.regs.global_base_instance_index = 0x0; maxwell3d.regs.global_base_instance_index = 0x0;
maxwell3d.mme_draw.instance_count = 0; maxwell3d.draw_state.instance_count = 0;
maxwell3d.CallMethodFromMME(0x8e3, 0x640); maxwell3d.CallMethod(0x8e3, 0x640, true);
maxwell3d.CallMethodFromMME(0x8e4, 0x0); maxwell3d.CallMethod(0x8e4, 0x0, true);
maxwell3d.CallMethodFromMME(0x8e5, 0x0); maxwell3d.CallMethod(0x8e5, 0x0, true);
maxwell3d.mme_draw.current_mode = Engines::Maxwell3D::MMEDrawMode::Undefined; maxwell3d.draw_state.current_mode = Engines::Maxwell3D::DrawMode::Undefined;
maxwell3d.dirty.flags[VideoCommon::Dirty::IndexBuffer] = true; maxwell3d.dirty.flags[VideoCommon::Dirty::IndexBuffer] = true;
}); });
const u32 start_indirect = parameters[0]; const u32 start_indirect = parameters[0];
@ -127,15 +127,15 @@ void HLE_3F5E74B9C9A50164(Engines::Maxwell3D& maxwell3d, const std::vector<u32>&
maxwell3d.regs.index_buffer.count = num_vertices; maxwell3d.regs.index_buffer.count = num_vertices;
maxwell3d.regs.global_base_vertex_index = base_vertex; maxwell3d.regs.global_base_vertex_index = base_vertex;
maxwell3d.regs.global_base_instance_index = base_instance; maxwell3d.regs.global_base_instance_index = base_instance;
maxwell3d.mme_draw.instance_count = instance_count; maxwell3d.draw_state.instance_count = instance_count;
maxwell3d.CallMethodFromMME(0x8e3, 0x640); maxwell3d.CallMethod(0x8e3, 0x640, true);
maxwell3d.CallMethodFromMME(0x8e4, base_vertex); maxwell3d.CallMethod(0x8e4, base_vertex, true);
maxwell3d.CallMethodFromMME(0x8e5, base_instance); maxwell3d.CallMethod(0x8e5, base_instance, true);
maxwell3d.dirty.flags[VideoCommon::Dirty::IndexBuffer] = true; maxwell3d.dirty.flags[VideoCommon::Dirty::IndexBuffer] = true;
if (maxwell3d.ShouldExecute()) { if (maxwell3d.ShouldExecute()) {
maxwell3d.Rasterizer().Draw(true, true); maxwell3d.Rasterizer().Draw(true);
} }
maxwell3d.mme_draw.current_mode = Engines::Maxwell3D::MMEDrawMode::Undefined; maxwell3d.draw_state.current_mode = Engines::Maxwell3D::DrawMode::Undefined;
} }
} }

View file

@ -335,7 +335,7 @@ void MacroInterpreterImpl::SetMethodAddress(u32 address) {
} }
void MacroInterpreterImpl::Send(u32 value) { void MacroInterpreterImpl::Send(u32 value) {
maxwell3d.CallMethodFromMME(method_address.address, value); maxwell3d.CallMethod(method_address.address, value, true);
// Increment the method address by the method increment. // Increment the method address by the method increment.
method_address.address.Assign(method_address.address.Value() + method_address.address.Assign(method_address.address.Value() +
method_address.increment.Value()); method_address.increment.Value());

View file

@ -346,7 +346,7 @@ void MacroJITx64Impl::Compile_Read(Macro::Opcode opcode) {
} }
void Send(Engines::Maxwell3D* maxwell3d, Macro::MethodAddress method_address, u32 value) { void Send(Engines::Maxwell3D* maxwell3d, Macro::MethodAddress method_address, u32 value) {
maxwell3d->CallMethodFromMME(method_address.address, value); maxwell3d->CallMethod(method_address.address, value, true);
} }
void MacroJITx64Impl::Compile_Send(Xbyak::Reg32 value) { void MacroJITx64Impl::Compile_Send(Xbyak::Reg32 value) {

View file

@ -40,7 +40,7 @@ public:
virtual ~RasterizerInterface() = default; virtual ~RasterizerInterface() = default;
/// Dispatches a draw invocation /// Dispatches a draw invocation
virtual void Draw(bool is_indexed, bool is_instanced) = 0; virtual void Draw(bool is_indexed) = 0;
/// Clear the current framebuffer /// Clear the current framebuffer
virtual void Clear() = 0; virtual void Clear() = 0;

View file

@ -205,7 +205,7 @@ void RasterizerOpenGL::Clear() {
++num_queued_commands; ++num_queued_commands;
} }
void RasterizerOpenGL::Draw(bool is_indexed, bool is_instanced) { void RasterizerOpenGL::Draw(bool is_indexed) {
MICROPROFILE_SCOPE(OpenGL_Drawing); MICROPROFILE_SCOPE(OpenGL_Drawing);
SCOPE_EXIT({ gpu.TickWork(); }); SCOPE_EXIT({ gpu.TickWork(); });
@ -228,8 +228,7 @@ void RasterizerOpenGL::Draw(bool is_indexed, bool is_instanced) {
BeginTransformFeedback(pipeline, primitive_mode); BeginTransformFeedback(pipeline, primitive_mode);
const GLuint base_instance = static_cast<GLuint>(maxwell3d->regs.global_base_instance_index); const GLuint base_instance = static_cast<GLuint>(maxwell3d->regs.global_base_instance_index);
const GLsizei num_instances = const GLsizei num_instances = maxwell3d->draw_state.instance_count;
static_cast<GLsizei>(is_instanced ? maxwell3d->mme_draw.instance_count : 1);
if (is_indexed) { if (is_indexed) {
const GLint base_vertex = static_cast<GLint>(maxwell3d->regs.global_base_vertex_index); const GLint base_vertex = static_cast<GLint>(maxwell3d->regs.global_base_vertex_index);
const GLsizei num_vertices = static_cast<GLsizei>(maxwell3d->regs.index_buffer.count); const GLsizei num_vertices = static_cast<GLsizei>(maxwell3d->regs.index_buffer.count);

View file

@ -68,7 +68,7 @@ public:
StateTracker& state_tracker_); StateTracker& state_tracker_);
~RasterizerOpenGL() override; ~RasterizerOpenGL() override;
void Draw(bool is_indexed, bool is_instanced) override; void Draw(bool is_indexed) override;
void Clear() override; void Clear() override;
void DispatchCompute() override; void DispatchCompute() override;
void ResetCounter(VideoCore::QueryType type) override; void ResetCounter(VideoCore::QueryType type) override;

View file

@ -127,11 +127,10 @@ VkRect2D GetScissorState(const Maxwell& regs, size_t index, u32 up_scale = 1, u3
return scissor; return scissor;
} }
DrawParams MakeDrawParams(const Maxwell& regs, u32 num_instances, bool is_instanced, DrawParams MakeDrawParams(const Maxwell& regs, u32 num_instances, bool is_indexed) {
bool is_indexed) {
DrawParams params{ DrawParams params{
.base_instance = regs.global_base_instance_index, .base_instance = regs.global_base_instance_index,
.num_instances = is_instanced ? num_instances : 1, .num_instances = num_instances,
.base_vertex = is_indexed ? regs.global_base_vertex_index : regs.vertex_buffer.first, .base_vertex = is_indexed ? regs.global_base_vertex_index : regs.vertex_buffer.first,
.num_vertices = is_indexed ? regs.index_buffer.count : regs.vertex_buffer.count, .num_vertices = is_indexed ? regs.index_buffer.count : regs.vertex_buffer.count,
.first_index = is_indexed ? regs.index_buffer.first : 0, .first_index = is_indexed ? regs.index_buffer.first : 0,
@ -177,7 +176,7 @@ RasterizerVulkan::RasterizerVulkan(Core::Frontend::EmuWindow& emu_window_, Tegra
RasterizerVulkan::~RasterizerVulkan() = default; RasterizerVulkan::~RasterizerVulkan() = default;
void RasterizerVulkan::Draw(bool is_indexed, bool is_instanced) { void RasterizerVulkan::Draw(bool is_indexed) {
MICROPROFILE_SCOPE(Vulkan_Drawing); MICROPROFILE_SCOPE(Vulkan_Drawing);
SCOPE_EXIT({ gpu.TickWork(); }); SCOPE_EXIT({ gpu.TickWork(); });
@ -199,8 +198,8 @@ void RasterizerVulkan::Draw(bool is_indexed, bool is_instanced) {
UpdateDynamicStates(); UpdateDynamicStates();
const auto& regs{maxwell3d->regs}; const auto& regs{maxwell3d->regs};
const u32 num_instances{maxwell3d->mme_draw.instance_count}; const u32 num_instances{maxwell3d->draw_state.instance_count};
const DrawParams draw_params{MakeDrawParams(regs, num_instances, is_instanced, is_indexed)}; const DrawParams draw_params{MakeDrawParams(regs, num_instances, is_indexed)};
scheduler.Record([draw_params](vk::CommandBuffer cmdbuf) { scheduler.Record([draw_params](vk::CommandBuffer cmdbuf) {
if (draw_params.is_indexed) { if (draw_params.is_indexed) {
cmdbuf.DrawIndexed(draw_params.num_vertices, draw_params.num_instances, cmdbuf.DrawIndexed(draw_params.num_vertices, draw_params.num_instances,

View file

@ -64,7 +64,7 @@ public:
StateTracker& state_tracker_, Scheduler& scheduler_); StateTracker& state_tracker_, Scheduler& scheduler_);
~RasterizerVulkan() override; ~RasterizerVulkan() override;
void Draw(bool is_indexed, bool is_instanced) override; void Draw(bool is_indexed) override;
void Clear() override; void Clear() override;
void DispatchCompute() override; void DispatchCompute() override;
void ResetCounter(VideoCore::QueryType type) override; void ResetCounter(VideoCore::QueryType type) override;