Merge pull request #165 from aliPMPAINT/old-state
Test for ShaderResources
This commit is contained in:
commit
2834519307
1 changed files with 57 additions and 0 deletions
57
test/TestShaderResources.cpp
Normal file
57
test/TestShaderResources.cpp
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
#include "gtest/gtest.h"
|
||||
|
||||
#include "kompute/Kompute.hpp"
|
||||
|
||||
static const std::string shaderString = (R"(
|
||||
#version 450
|
||||
|
||||
layout (local_size_x = 1) in;
|
||||
|
||||
// The input tensors bind index is relative to index in parameter passed
|
||||
layout(set = 0, binding = 0) buffer bina { float tina[]; };
|
||||
layout(set = 0, binding = 1) buffer binb { float tinb[]; };
|
||||
layout(set = 0, binding = 2) buffer bout { float tout[]; };
|
||||
|
||||
void main() {
|
||||
uint index = gl_GlobalInvocationID.x;
|
||||
|
||||
int i = 1;
|
||||
|
||||
while(i < 200) {
|
||||
tout[index] += tina[index] * tinb[index];
|
||||
i++;
|
||||
}
|
||||
}
|
||||
)");
|
||||
|
||||
void compileShaderWithGivenResources(const std::string shaderString, const TBuiltInResource resources) {
|
||||
kp::Shader::compile_source(shaderString, std::string("main"), std::vector<std::pair<std::string,std::string>>({}), resources);
|
||||
}
|
||||
|
||||
|
||||
|
||||
TEST(TestShaderResources, TestNoMaxLight)
|
||||
{
|
||||
TBuiltInResource noMaxLightResources = kp::defaultResource;
|
||||
noMaxLightResources.maxLights=0;
|
||||
|
||||
EXPECT_NO_THROW(compileShaderWithGivenResources(shaderString, noMaxLightResources));
|
||||
}
|
||||
|
||||
|
||||
TEST(TestShaderResources, TestSmallComputeWorkGroupSizeX)
|
||||
{
|
||||
TBuiltInResource smallComputeWorkGroupSizeXResources = kp::defaultResource;
|
||||
smallComputeWorkGroupSizeXResources.maxComputeWorkGroupSizeX=0;
|
||||
|
||||
ASSERT_THROW(compileShaderWithGivenResources(shaderString, smallComputeWorkGroupSizeXResources), std::runtime_error);
|
||||
}
|
||||
|
||||
|
||||
TEST(TestShaderResources, TestNoWhileLoopLimit)
|
||||
{
|
||||
TBuiltInResource noWhileLoopLimitResources = kp::defaultResource;
|
||||
noWhileLoopLimitResources.limits.whileLoops=0;
|
||||
|
||||
ASSERT_THROW(compileShaderWithGivenResources(shaderString, noWhileLoopLimitResources), std::runtime_error);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue