Fix OpenGL sampler and copy semantics
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
#include "fixtures/RHITestFixture.h"
|
||||
#include "XCEngine/RHI/RHISampler.h"
|
||||
#include "XCEngine/RHI/OpenGL/OpenGLSampler.h"
|
||||
#include <glad/glad.h>
|
||||
|
||||
using namespace XCEngine::RHI;
|
||||
|
||||
@@ -75,3 +77,51 @@ TEST_P(RHITestFixture, Sampler_GetNativeHandle) {
|
||||
sampler->Shutdown();
|
||||
delete sampler;
|
||||
}
|
||||
|
||||
TEST_P(RHITestFixture, Sampler_OpenGLHonorsSamplerDesc) {
|
||||
if (GetBackendType() != RHIType::OpenGL) {
|
||||
GTEST_SKIP() << "OpenGL-specific sampler parameter verification";
|
||||
}
|
||||
|
||||
SamplerDesc desc = {};
|
||||
desc.filter = static_cast<uint32_t>(FilterMode::ComparisonAnisotropic);
|
||||
desc.addressU = static_cast<uint32_t>(TextureAddressMode::Clamp);
|
||||
desc.addressV = static_cast<uint32_t>(TextureAddressMode::Mirror);
|
||||
desc.addressW = static_cast<uint32_t>(TextureAddressMode::Border);
|
||||
desc.maxAnisotropy = 8;
|
||||
desc.comparisonFunc = static_cast<uint32_t>(ComparisonFunc::GreaterEqual);
|
||||
desc.minLod = 1.0f;
|
||||
desc.maxLod = 4.0f;
|
||||
|
||||
RHISampler* sampler = GetDevice()->CreateSampler(desc);
|
||||
ASSERT_NE(sampler, nullptr);
|
||||
|
||||
const GLuint samplerId = static_cast<OpenGLSampler*>(sampler)->GetID();
|
||||
|
||||
GLint value = 0;
|
||||
glGetSamplerParameteriv(samplerId, GL_TEXTURE_WRAP_S, &value);
|
||||
EXPECT_EQ(value, GL_CLAMP_TO_EDGE);
|
||||
glGetSamplerParameteriv(samplerId, GL_TEXTURE_WRAP_T, &value);
|
||||
EXPECT_EQ(value, GL_MIRRORED_REPEAT);
|
||||
glGetSamplerParameteriv(samplerId, GL_TEXTURE_WRAP_R, &value);
|
||||
EXPECT_EQ(value, GL_CLAMP_TO_BORDER);
|
||||
glGetSamplerParameteriv(samplerId, GL_TEXTURE_MIN_FILTER, &value);
|
||||
EXPECT_EQ(value, GL_LINEAR_MIPMAP_LINEAR);
|
||||
glGetSamplerParameteriv(samplerId, GL_TEXTURE_MAG_FILTER, &value);
|
||||
EXPECT_EQ(value, GL_LINEAR);
|
||||
glGetSamplerParameteriv(samplerId, GL_TEXTURE_COMPARE_MODE, &value);
|
||||
EXPECT_EQ(value, GL_COMPARE_REF_TO_TEXTURE);
|
||||
glGetSamplerParameteriv(samplerId, GL_TEXTURE_COMPARE_FUNC, &value);
|
||||
EXPECT_EQ(value, GL_GEQUAL);
|
||||
|
||||
GLfloat floatValue = 0.0f;
|
||||
glGetSamplerParameterfv(samplerId, GL_TEXTURE_MAX_ANISOTROPY, &floatValue);
|
||||
EXPECT_GE(floatValue, 8.0f);
|
||||
glGetSamplerParameterfv(samplerId, GL_TEXTURE_MIN_LOD, &floatValue);
|
||||
EXPECT_FLOAT_EQ(floatValue, 1.0f);
|
||||
glGetSamplerParameterfv(samplerId, GL_TEXTURE_MAX_LOD, &floatValue);
|
||||
EXPECT_FLOAT_EQ(floatValue, 4.0f);
|
||||
|
||||
sampler->Shutdown();
|
||||
delete sampler;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user