mirror of
https://github.com/intel/compute-runtime.git
synced 2025-12-25 13:33:02 +08:00
fix: align up surface size in surface state
don't abort when surface size is not aligned underlying memory size is always aligned Signed-off-by: Mateusz Jablonski <mateusz.jablonski@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
f928d695e7
commit
ce059e7fe3
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2020-2022 Intel Corporation
|
||||
* Copyright (C) 2020-2023 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -404,10 +404,10 @@ inline void EncodeStoreMMIO<Family>::encode(MI_STORE_REGISTER_MEM *cmdBuffer, ui
|
||||
template <typename Family>
|
||||
void EncodeSurfaceState<Family>::encodeBuffer(EncodeSurfaceStateArgs &args) {
|
||||
auto surfaceState = reinterpret_cast<R_SURFACE_STATE *>(args.outMemory);
|
||||
UNRECOVERABLE_IF(!isAligned<getSurfaceBaseAddressAlignment()>(args.size));
|
||||
auto bufferSize = alignUp(args.size, getSurfaceBaseAddressAlignment());
|
||||
|
||||
SURFACE_STATE_BUFFER_LENGTH length = {0};
|
||||
length.Length = static_cast<uint32_t>(args.size - 1);
|
||||
length.Length = static_cast<uint32_t>(bufferSize - 1);
|
||||
|
||||
surfaceState->setWidth(length.SurfaceState.Width + 1);
|
||||
surfaceState->setHeight(length.SurfaceState.Height + 1);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2020-2022 Intel Corporation
|
||||
* Copyright (C) 2020-2023 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -19,9 +19,30 @@
|
||||
#include "shared/test/common/mocks/mock_execution_environment.h"
|
||||
#include "shared/test/common/test_macros/hw_test.h"
|
||||
|
||||
#include "encode_surface_state_args.h"
|
||||
|
||||
using namespace NEO;
|
||||
using CommandEncoderTests = ::testing::Test;
|
||||
|
||||
HWTEST_F(CommandEncoderTests, givenMisalignedSizeWhenProgrammingSurfaceStateForBufferThenAlignedSizeIsProgrammed) {
|
||||
using RENDER_SURFACE_STATE = typename FamilyType::RENDER_SURFACE_STATE;
|
||||
|
||||
RENDER_SURFACE_STATE renderSurfaceState{};
|
||||
MockExecutionEnvironment executionEnvironment{};
|
||||
|
||||
auto misalignedSize = 1u;
|
||||
auto alignedSize = 4u;
|
||||
|
||||
NEO::EncodeSurfaceStateArgs args{};
|
||||
args.outMemory = &renderSurfaceState;
|
||||
args.gmmHelper = executionEnvironment.rootDeviceEnvironments[0]->getGmmHelper();
|
||||
args.size = misalignedSize;
|
||||
|
||||
EncodeSurfaceState<FamilyType>::encodeBuffer(args);
|
||||
|
||||
EXPECT_EQ(alignedSize, renderSurfaceState.getWidth());
|
||||
}
|
||||
|
||||
HWTEST_F(CommandEncoderTests, givenImmDataWriteWhenProgrammingMiFlushDwThenSetAllRequiredFields) {
|
||||
using MI_FLUSH_DW = typename FamilyType::MI_FLUSH_DW;
|
||||
uint8_t buffer[2 * sizeof(MI_FLUSH_DW)] = {};
|
||||
|
||||
Reference in New Issue
Block a user