Revert "Program border color once per dsh"

Signed-off-by: Maciej Plewka <maciej.plewka@intel.com>
This commit is contained in:
Maciej Plewka
2021-05-17 10:08:54 +00:00
committed by Compute-Runtime-Automation
parent 1557cd21e0
commit 159404f38e
19 changed files with 117 additions and 133 deletions

View File

@@ -33,7 +33,7 @@ HWTEST_F(CommandEncodeStatesTest, GivenCommandStreamWhenEncodeCopySamplerStateTh
}
using BindlessCommandEncodeStatesTest = Test<MemManagerFixture>;
HWTEST_F(BindlessCommandEncodeStatesTest, GivenBindlessEnabledWhenCopySamplerStateThenBorderSetCorrectly) {
HWTEST_F(BindlessCommandEncodeStatesTest, GivenBindlessEnabledWhenBorderColorWithoutAlphaThenBorderColorPtrReturned) {
using SAMPLER_BORDER_COLOR_STATE = typename FamilyType::SAMPLER_BORDER_COLOR_STATE;
DebugManagerStateRestore restorer;
DebugManager.flags.UseBindlessMode.set(1);
@@ -41,34 +41,99 @@ HWTEST_F(BindlessCommandEncodeStatesTest, GivenBindlessEnabledWhenCopySamplerSta
uint32_t numSamplers = 1;
pDevice->getExecutionEnvironment()->rootDeviceEnvironments[pDevice->getRootDeviceIndex()]->createBindlessHeapsHelper(pDevice->getMemoryManager(), pDevice->getNumAvailableDevices() > 1, pDevice->getRootDeviceIndex());
uint32_t borderColorSize = 0;
uint32_t borderColorSize = 0x40;
SAMPLER_BORDER_COLOR_STATE samplerState;
samplerState.init();
auto dsh = pDevice->getBindlessHeapsHelper()->getHeap(BindlessHeapsHelper::BindlesHeapType::GLOBAL_DSH);
EncodeStates<FamilyType>::copySamplerState(dsh, borderColorSize, numSamplers, 0, &samplerState, pDevice->getBindlessHeapsHelper());
auto expectedValue = pDevice->getBindlessHeapsHelper()->getBorderColorOffset();
auto expectedValue = pDevice->getBindlessHeapsHelper()->getDefaultBorderColorOffset();
auto pSmplr = reinterpret_cast<SAMPLER_STATE *>(dsh->getGraphicsAllocation()->getUnderlyingBuffer());
EXPECT_EQ(pSmplr->getIndirectStatePointer(), expectedValue);
}
HWTEST_F(BindlessCommandEncodeStatesTest, GivenBindlessEnabledWhenCopySamplerStateCalledTwiceThenTheSameIndirectPointerIsSet) {
using SAMPLER_STATE = typename FamilyType::SAMPLER_STATE;
using INTERFACE_DESCRIPTOR_DATA = typename FamilyType::INTERFACE_DESCRIPTOR_DATA;
HWTEST_F(BindlessCommandEncodeStatesTest, GivenBindlessEnabledWhenBorderColorWithAlphaThenBorderColorPtrOffseted) {
using SAMPLER_BORDER_COLOR_STATE = typename FamilyType::SAMPLER_BORDER_COLOR_STATE;
DebugManagerStateRestore restorer;
DebugManager.flags.UseBindlessMode.set(1);
using SAMPLER_STATE = typename FamilyType::SAMPLER_STATE;
uint32_t numSamplers = 1;
pDevice->getExecutionEnvironment()->rootDeviceEnvironments[pDevice->getRootDeviceIndex()]->createBindlessHeapsHelper(pDevice->getMemoryManager(), pDevice->getNumAvailableDevices() > 1, pDevice->getRootDeviceIndex());
SAMPLER_STATE samplerState;
uint32_t borderColorSize = 0x40;
SAMPLER_BORDER_COLOR_STATE samplerState;
samplerState.init();
samplerState.setBorderColorAlpha(1.0);
auto dsh = pDevice->getBindlessHeapsHelper()->getHeap(BindlessHeapsHelper::BindlesHeapType::GLOBAL_DSH);
EncodeStates<FamilyType>::copySamplerState(dsh, 0, numSamplers, 0, &samplerState, pDevice->getBindlessHeapsHelper());
EncodeStates<FamilyType>::copySamplerState(dsh, 0, numSamplers, 0, &samplerState, pDevice->getBindlessHeapsHelper());
EncodeStates<FamilyType>::copySamplerState(dsh, borderColorSize, numSamplers, 0, &samplerState, pDevice->getBindlessHeapsHelper());
auto expectedValue = pDevice->getBindlessHeapsHelper()->getAlphaBorderColorOffset();
auto pSmplr1 = reinterpret_cast<SAMPLER_STATE *>(dsh->getGraphicsAllocation()->getUnderlyingBuffer());
auto pSmplr2 = reinterpret_cast<SAMPLER_STATE *>(ptrOffset(dsh->getGraphicsAllocation()->getUnderlyingBuffer(), static_cast<uint32_t>(alignUp(sizeof(samplerState), EncodeStates<FamilyType>::alignIndirectStatePointer))));
EXPECT_EQ(pSmplr1->getIndirectStatePointer(), pSmplr2->getIndirectStatePointer());
auto pSmplr = reinterpret_cast<SAMPLER_STATE *>(dsh->getGraphicsAllocation()->getUnderlyingBuffer());
EXPECT_EQ(pSmplr->getIndirectStatePointer(), expectedValue);
}
HWTEST_F(BindlessCommandEncodeStatesTest, GivenBindlessEnabledWhenBorderColorsRedChanelIsNotZeroThenExceptionThrown) {
using SAMPLER_BORDER_COLOR_STATE = typename FamilyType::SAMPLER_BORDER_COLOR_STATE;
DebugManagerStateRestore restorer;
DebugManager.flags.UseBindlessMode.set(1);
using SAMPLER_STATE = typename FamilyType::SAMPLER_STATE;
uint32_t numSamplers = 1;
pDevice->getExecutionEnvironment()->rootDeviceEnvironments[pDevice->getRootDeviceIndex()]->createBindlessHeapsHelper(pDevice->getMemoryManager(), pDevice->getNumAvailableDevices() > 1, pDevice->getRootDeviceIndex());
uint32_t borderColorSize = 0x40;
SAMPLER_BORDER_COLOR_STATE samplerState;
samplerState.init();
samplerState.setBorderColorRed(0.5);
auto dsh = pDevice->getBindlessHeapsHelper()->getHeap(BindlessHeapsHelper::BindlesHeapType::GLOBAL_DSH);
EXPECT_THROW(EncodeStates<FamilyType>::copySamplerState(dsh, borderColorSize, numSamplers, 0, &samplerState, pDevice->getBindlessHeapsHelper()), std::exception);
}
HWTEST_F(BindlessCommandEncodeStatesTest, GivenBindlessEnabledWhenBorderColorsGreenChanelIsNotZeroThenExceptionThrown) {
using SAMPLER_BORDER_COLOR_STATE = typename FamilyType::SAMPLER_BORDER_COLOR_STATE;
DebugManagerStateRestore restorer;
DebugManager.flags.UseBindlessMode.set(1);
using SAMPLER_STATE = typename FamilyType::SAMPLER_STATE;
uint32_t numSamplers = 1;
pDevice->getExecutionEnvironment()->rootDeviceEnvironments[pDevice->getRootDeviceIndex()]->createBindlessHeapsHelper(pDevice->getMemoryManager(), pDevice->getNumAvailableDevices() > 1, pDevice->getRootDeviceIndex());
uint32_t borderColorSize = 0x40;
SAMPLER_BORDER_COLOR_STATE samplerState;
samplerState.init();
samplerState.setBorderColorGreen(0.5);
auto dsh = pDevice->getBindlessHeapsHelper()->getHeap(BindlessHeapsHelper::BindlesHeapType::GLOBAL_DSH);
EXPECT_THROW(EncodeStates<FamilyType>::copySamplerState(dsh, borderColorSize, numSamplers, 0, &samplerState, pDevice->getBindlessHeapsHelper()), std::exception);
}
HWTEST_F(BindlessCommandEncodeStatesTest, GivenBindlessEnabledWhenBorderColorsBlueChanelIsNotZeroThenExceptionThrown) {
using SAMPLER_BORDER_COLOR_STATE = typename FamilyType::SAMPLER_BORDER_COLOR_STATE;
DebugManagerStateRestore restorer;
DebugManager.flags.UseBindlessMode.set(1);
using SAMPLER_STATE = typename FamilyType::SAMPLER_STATE;
uint32_t numSamplers = 1;
pDevice->getExecutionEnvironment()->rootDeviceEnvironments[pDevice->getRootDeviceIndex()]->createBindlessHeapsHelper(pDevice->getMemoryManager(), pDevice->getNumAvailableDevices() > 1, pDevice->getRootDeviceIndex());
uint32_t borderColorSize = 0x40;
SAMPLER_BORDER_COLOR_STATE samplerState;
samplerState.init();
samplerState.setBorderColorBlue(0.5);
auto dsh = pDevice->getBindlessHeapsHelper()->getHeap(BindlessHeapsHelper::BindlesHeapType::GLOBAL_DSH);
EXPECT_THROW(EncodeStates<FamilyType>::copySamplerState(dsh, borderColorSize, numSamplers, 0, &samplerState, pDevice->getBindlessHeapsHelper()), std::exception);
}
HWTEST_F(BindlessCommandEncodeStatesTest, GivenBindlessEnabledWhenBorderColorsAlphaChanelIsNotZeroOrOneThenExceptionThrown) {
using SAMPLER_BORDER_COLOR_STATE = typename FamilyType::SAMPLER_BORDER_COLOR_STATE;
DebugManagerStateRestore restorer;
DebugManager.flags.UseBindlessMode.set(1);
using SAMPLER_STATE = typename FamilyType::SAMPLER_STATE;
uint32_t numSamplers = 1;
pDevice->getExecutionEnvironment()->rootDeviceEnvironments[pDevice->getRootDeviceIndex()]->createBindlessHeapsHelper(pDevice->getMemoryManager(), pDevice->getNumAvailableDevices() > 1, pDevice->getRootDeviceIndex());
uint32_t borderColorSize = 0x40;
SAMPLER_BORDER_COLOR_STATE samplerState;
samplerState.init();
samplerState.setBorderColorAlpha(0.5);
auto dsh = pDevice->getBindlessHeapsHelper()->getHeap(BindlessHeapsHelper::BindlesHeapType::GLOBAL_DSH);
EXPECT_THROW(EncodeStates<FamilyType>::copySamplerState(dsh, borderColorSize, numSamplers, 0, &samplerState, pDevice->getBindlessHeapsHelper()), std::exception);
}
HWTEST_F(CommandEncodeStatesTest, givenCreatedSurfaceStateBufferWhenAllocationProvidedThenUseAllocationAsInput) {