MCPcopy Create free account
hub / github.com/KhronosGroup/OpenCL-CTS / CreateGLTexture2DArrayMultisample

Function CreateGLTexture2DArrayMultisample

test_common/gl/helpers.cpp:1301–1564  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1299}
1300
1301void * CreateGLTexture2DArrayMultisample(size_t width, size_t height,
1302 size_t total_layers, size_t samples,
1303 GLenum target, GLenum glFormat, GLenum internalFormat, GLenum glType,
1304 ExplicitType type, GLuint *outTextureID, int *outError,
1305 bool allocateMem, MTdata d, bool fixedSampleLocations)
1306{
1307 // This function creates a multisample texture and renders into each sample
1308 // using a GLSL shader
1309
1310 // Check if the renderer supports enough samples
1311 GLint max_samples = get_gl_max_samples(target, internalFormat);
1312
1313 if (max_samples < (GLint)samples)
1314 log_error("GL error: requested samples (%zu) exceeds renderer max "
1315 "samples (%d)\n",
1316 samples, max_samples);
1317
1318 // Setup the GLSL program
1319 const GLchar *vertex_source =
1320 "#version 140\n"
1321 "in vec4 att0;\n"
1322 "void main (void) {\n"
1323 " gl_Position = vec4(att0.xy,0.0,1.0);\n"
1324 "}\n";
1325
1326 const GLchar *fragmentSource =
1327 "#version 140\n"
1328 "out %s out0;\n"
1329 "uniform %s colorVal;\n"
1330 "uniform float depthVal;\n"
1331 "void main (void) {\n"
1332 " out0 = %s(colorVal);\n"
1333 " gl_FragDepth = depthVal;\n"
1334 "}\n";
1335
1336 GLchar fragmentShader[256];
1337 sprintf(fragmentShader, fragmentSource, get_gl_vector_type(internalFormat), get_gl_data_type(internalFormat), get_gl_vector_type(internalFormat));
1338 const GLchar *fragment_source = &fragmentShader[0];
1339
1340 glShaderWrapper vertex_shader = glCreateShader(GL_VERTEX_SHADER);
1341 glShaderSource(vertex_shader, 1, &vertex_source, NULL);
1342 glCompileShader(vertex_shader);
1343 CHECK_GL_ERROR()
1344
1345 glShaderWrapper fragment_shader = glCreateShader(GL_FRAGMENT_SHADER);
1346 glShaderSource(fragment_shader, 1, &fragment_source, NULL);
1347 glCompileShader(fragment_shader);
1348 CHECK_GL_ERROR()
1349
1350 glProgramWrapper prog = glCreateProgram();
1351 glAttachShader(prog, vertex_shader);
1352 glAttachShader(prog, fragment_shader);
1353 CHECK_GL_ERROR()
1354
1355 glBindAttribLocation(prog, 0, "att0");
1356 glLinkProgram(prog);
1357 CHECK_GL_ERROR()
1358

Callers 2

test_image_format_readFunction · 0.85

Calls 7

get_gl_max_samplesFunction · 0.85
get_gl_vector_typeFunction · 0.85
get_gl_data_typeFunction · 0.85
get_explicit_type_sizeFunction · 0.85
convert_float_to_halfFunction · 0.85
GetGLFormatNameFunction · 0.70

Tested by 2

test_image_format_readFunction · 0.68