Skip to content

Commit

Permalink
bp: Use LastBound for dynamic state values
Browse files Browse the repository at this point in the history
  • Loading branch information
spencer-lunarg committed Jan 6, 2025
1 parent c2573b9 commit d519be1
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 18 deletions.
12 changes: 2 additions & 10 deletions layers/best_practices/bp_drawdispatch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -225,17 +225,9 @@ bool BestPractices::ValidateIndexBufferArm(const bp_state::CommandBuffer& cb_sta
if (!ib_mem_state) return skip;

const void* ib_mem = ib_mem_state->p_driver_data;
bool primitive_restart_enable = false;

const auto* pipeline_state = cb_state.GetCurrentPipeline(VK_PIPELINE_BIND_POINT_GRAPHICS);
if (pipeline_state && !pipeline_state->IsDynamic(CB_DYNAMIC_STATE_PRIMITIVE_RESTART_ENABLE)) {
const auto* ia_state = pipeline_state->InputAssemblyState();
if (ia_state) {
primitive_restart_enable = ia_state->primitiveRestartEnable == VK_TRUE;
}
} else {
primitive_restart_enable = cb_state.dynamic_state_value.primitive_restart_enable;
}
const auto& last_bound_state = cb_state.lastBound[ConvertToLvlBindPoint(VK_PIPELINE_BIND_POINT_GRAPHICS)];
const bool primitive_restart_enable = last_bound_state.IsPrimitiveRestartEnable();

// no point checking index buffer if the memory is nonexistant/unmapped, or if there is no graphics pipeline bound to this CB
if (ib_mem) {
Expand Down
21 changes: 17 additions & 4 deletions layers/state_tracker/pipeline_state.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* Copyright (c) 2015-2024 The Khronos Group Inc.
* Copyright (c) 2015-2024 Valve Corporation
* Copyright (c) 2015-2024 LunarG, Inc.
* Copyright (C) 2015-2024 Google Inc.
/* Copyright (c) 2015-2025 The Khronos Group Inc.
* Copyright (c) 2015-2025 Valve Corporation
* Copyright (c) 2015-2025 LunarG, Inc.
* Copyright (C) 2015-2025 Google Inc.
* Modifications Copyright (C) 2020 Advanced Micro Devices, Inc. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
Expand Down Expand Up @@ -1188,6 +1188,19 @@ bool LastBound::IsViewportWScalingEnable() const {
return false;
}

bool LastBound::IsPrimitiveRestartEnable() const {
if (!pipeline_state || pipeline_state->IsDynamic(CB_DYNAMIC_STATE_PRIMITIVE_RESTART_ENABLE)) {
if (cb_state.IsDynamicStateSet(CB_DYNAMIC_STATE_PRIMITIVE_RESTART_ENABLE)) {
return cb_state.dynamic_state_value.primitive_restart_enable;
}
} else {
if (auto ia_state = pipeline_state->InputAssemblyState()) {
return ia_state->primitiveRestartEnable == VK_TRUE;
}
}
return false;
}

VkCoverageModulationModeNV LastBound::GetCoverageModulationMode() const {
if (!pipeline_state || pipeline_state->IsDynamic(CB_DYNAMIC_STATE_COVERAGE_MODULATION_MODE_NV)) {
if (cb_state.IsDynamicStateSet(CB_DYNAMIC_STATE_COVERAGE_MODULATION_MODE_NV)) {
Expand Down
9 changes: 5 additions & 4 deletions layers/state_tracker/pipeline_state.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* Copyright (c) 2015-2024 The Khronos Group Inc.
* Copyright (c) 2015-2024 Valve Corporation
* Copyright (c) 2015-2024 LunarG, Inc.
* Copyright (C) 2015-2024 Google Inc.
/* Copyright (c) 2015-2025 The Khronos Group Inc.
* Copyright (c) 2015-2025 Valve Corporation
* Copyright (c) 2015-2025 LunarG, Inc.
* Copyright (C) 2015-2025 Google Inc.
* Modifications Copyright (C) 2020 Advanced Micro Devices, Inc. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
Expand Down Expand Up @@ -732,6 +732,7 @@ struct LastBound {
bool IsStippledLineEnable() const;
bool IsShadingRateImageEnable() const;
bool IsViewportWScalingEnable() const;
bool IsPrimitiveRestartEnable() const;
VkCoverageModulationModeNV GetCoverageModulationMode() const;

bool ValidShaderObjectCombination(const VkPipelineBindPoint bind_point, const DeviceFeatures &device_features) const;
Expand Down

0 comments on commit d519be1

Please sign in to comment.