2018-02-20 01:04:37 +00:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
2018-03-19 03:23:05 +00:00
|
|
|
const make = require('../make')
|
|
|
|
const random = require('../random')
|
|
|
|
|
|
|
|
class webgl extends make {
|
|
|
|
static get internalFormat () {
|
|
|
|
return {
|
|
|
|
'RGB': {format: 'RGB', type: ['UNSIGNED_BYTE', 'UNSIGNED_SHORT_5_6_5']},
|
|
|
|
'RGBA': {format: 'RGBA', type: ['UNSIGNED_BYTE', 'UNSIGNED_SHORT_4_4_4_4', 'UNSIGNED_SHORT_5_5_5_1']},
|
|
|
|
'LUMINANCE_ALPHA': {format: 'LUMINANCE_ALPHA', type: ['UNSIGNED_BYTE']},
|
|
|
|
'LUMINANCE': {format: 'LUMINANCE', type: ['UNSIGNED_BYTE']},
|
|
|
|
'ALPHA': {format: 'ALPHA', type: ['UNSIGNED_BYTE']},
|
|
|
|
'R8': {format: 'RED', type: ['UNSIGNED_BYTE']},
|
|
|
|
'R16F': {format: 'RED', type: ['HALF_FLOAT', 'FLOAT']},
|
|
|
|
'R32F': {format: 'RED', type: ['FLOAT']},
|
|
|
|
'R8UI': {format: 'RED_INTEGER', type: ['UNSIGNED_BYTE']},
|
|
|
|
'RG8': {format: 'RG', type: ['UNSIGNED_BYTE']},
|
|
|
|
'RG16F': {format: 'RG', type: ['HALF_FLOAT', 'FLOAT']},
|
|
|
|
'RG32F': {format: 'RG', type: ['FLOAT']},
|
|
|
|
'RG8UI': {format: 'RG_INTEGER', type: ['UNSIGNED_BYTE']},
|
|
|
|
'RGB8': {format: 'RGB', type: ['UNSIGNED_BYTE']},
|
|
|
|
'SRGB8': {format: 'RGB', type: ['UNSIGNED_BYTE']},
|
|
|
|
'RGB565': {format: 'RGB', type: ['RGB', 'UNSIGNED_BYTE', 'UNSIGNED_SHORT_5_6_5']},
|
|
|
|
'R11F_G11F_B10F': {format: 'RGB', type: ['UNSIGNED_INT_10F_11F_11F_REV', 'HALF_FLOAT', 'FLOAT']},
|
|
|
|
'RGB9_E5': {format: 'RGB', type: ['HALF_FLOAT', 'FLOAT']},
|
|
|
|
'RGB16F': {format: 'RGB', type: ['HALF_FLOAT', 'FLOAT']},
|
|
|
|
'RGB32F': {format: 'RGB', type: ['FLOAT']},
|
|
|
|
'RGB8UI': {format: 'RGB_INTEGER', type: ['UNSIGNED_BYTE']},
|
|
|
|
'RGBA8': {format: 'RGBA', type: ['UNSIGNED_BYTE']},
|
|
|
|
'SRGB8_ALPHA8': {format: 'RGBA', type: ['UNSIGNED_BYTE']},
|
|
|
|
'RGB5_A1': {format: 'RGBA', type: ['UNSIGNED_BYTE', 'UNSIGNED_SHORT_5_5_5_1']},
|
|
|
|
'RGB10_A2': {format: 'RGBA', type: ['UNSIGNED_INT_2_10_10_10_REV']},
|
|
|
|
'RGBA4': {format: 'RGBA', type: ['UNSIGNED_BYTE', 'UNSIGNED_SHORT_4_4_4_4']},
|
|
|
|
'RGBA16F': {format: 'RGBA', type: ['HALF_FLOAT', 'FLOAT']},
|
|
|
|
'RGBA32F': {format: 'RGBA', type: ['FLOAT']},
|
|
|
|
'RGBA8UI': {format: 'RGBA_INTEGER', type: ['UNSIGNED_BYTE']}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static WebGLFormat () {
|
|
|
|
let internalformat = random.item(Object.keys(this.internalFormat))
|
|
|
|
let format = this.internalFormat[internalformat].format
|
|
|
|
let type = random.item(this.internalFormat[internalformat].type)
|
2018-02-22 05:59:27 +00:00
|
|
|
return [internalformat, format, type]
|
2018-03-19 03:23:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static textureSources () {
|
2018-02-20 02:06:17 +00:00
|
|
|
let sources = [
|
2018-02-20 01:45:45 +00:00
|
|
|
'HTMLCanvasElement',
|
|
|
|
'HTMLImageElement',
|
|
|
|
'HTMLVideoElement',
|
2018-02-21 09:19:32 +00:00
|
|
|
'ImageData'
|
2018-02-20 01:45:45 +00:00
|
|
|
]
|
|
|
|
return random.item(sources)
|
2018-03-19 03:23:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static parseUniforms (shader) {
|
2018-02-20 02:06:17 +00:00
|
|
|
let names = []
|
|
|
|
let result = shader.match(/uniform .* (\w+)(?=;)/gm)
|
2018-02-20 02:05:42 +00:00
|
|
|
if (result) {
|
2018-02-21 09:19:32 +00:00
|
|
|
result.forEach((v) => names.push(v.split(' ').pop()))
|
2018-02-20 02:05:42 +00:00
|
|
|
}
|
|
|
|
return names
|
2018-03-19 03:23:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static parseAttributes (shader) {
|
2018-02-20 02:06:17 +00:00
|
|
|
let names = []
|
|
|
|
let result = shader.match(/attribute .* (\w+)(?=;)/gm)
|
2018-02-20 02:05:42 +00:00
|
|
|
if (result) {
|
2018-02-21 09:19:32 +00:00
|
|
|
result.forEach((v) => names.push(v.split(' ').pop()))
|
2018-02-20 02:05:42 +00:00
|
|
|
}
|
|
|
|
return names
|
2018-03-19 03:23:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static parseFrag (shader) {
|
2018-02-23 05:44:11 +00:00
|
|
|
return shader.match(/(gl_Frag[^[ =]+)/gm)
|
2018-03-19 03:23:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static randomBitmask () {
|
2018-02-21 09:21:03 +00:00
|
|
|
return parseInt((random.subset([1, 0], 8).join('')))
|
2018-03-19 03:23:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static randomBufferTarget (isWebGL2) {
|
2018-02-21 09:19:32 +00:00
|
|
|
let target = [
|
|
|
|
'ARRAY_BUFFER',
|
|
|
|
'ELEMENT_ARRAY_BUFFER'
|
|
|
|
]
|
2018-02-21 09:21:03 +00:00
|
|
|
if (isWebGL2) {
|
2018-02-22 05:59:27 +00:00
|
|
|
target.extend([
|
2018-02-21 09:19:32 +00:00
|
|
|
'COPY_READ_BUFFER',
|
|
|
|
'COPY_WRITE_BUFFER',
|
|
|
|
'TRANSFORM_FEEDBACK_BUFFER',
|
|
|
|
'UNIFORM_BUFFER',
|
|
|
|
'PIXEL_PACK_BUFFER',
|
|
|
|
'PIXEL_UNPACK_BUFFER'
|
|
|
|
])
|
|
|
|
}
|
|
|
|
return random.item(target)
|
2018-03-19 03:23:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static randomTexParameter (isWebGL2) {
|
2018-02-21 09:19:32 +00:00
|
|
|
let pname = [
|
|
|
|
'TEXTURE_MAG_FILTER',
|
|
|
|
'TEXTURE_MIN_FILTER',
|
|
|
|
'TEXTURE_WRAP_S',
|
|
|
|
'TEXTURE_WRAP_T'
|
|
|
|
]
|
|
|
|
if (isWebGL2) {
|
|
|
|
pname.extend([
|
|
|
|
'TEXTURE_BASE_LEVEL',
|
|
|
|
'TEXTURE_COMPARE_FUNC',
|
|
|
|
'TEXTURE_COMPARE_MODE',
|
|
|
|
'TEXTURE_MAX_LEVEL',
|
|
|
|
'TEXTURE_MAX_LOD',
|
|
|
|
'TEXTURE_MIN_LOD',
|
|
|
|
'TEXTURE_WRAP_R'
|
|
|
|
])
|
|
|
|
}
|
|
|
|
return random.item(pname)
|
2018-03-19 03:23:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static randomTexParameterValue (isWebGL2) {
|
2018-02-21 09:21:03 +00:00
|
|
|
let pnameparam = {
|
2018-02-21 09:19:32 +00:00
|
|
|
'TEXTURE_MAG_FILTER': [
|
|
|
|
'LINEAR',
|
|
|
|
'NEAREST'
|
|
|
|
],
|
|
|
|
'TEXTURE_MIN_FILTER': [
|
|
|
|
'LINEAR',
|
|
|
|
'NEAREST',
|
|
|
|
'NEAREST_MIPMAP_NEAREST',
|
|
|
|
'LINEAR_MIPMAP_NEAREST',
|
|
|
|
'NEAREST_MIPMAP_LINEA',
|
|
|
|
'LINEAR_MIPMAP_LINEAR'
|
|
|
|
],
|
|
|
|
'TEXTURE_WRAP_S': [
|
|
|
|
'REPEAT',
|
|
|
|
'CLAMP_TO_EDGE',
|
|
|
|
'MIRRORED_REPEAT'
|
|
|
|
],
|
|
|
|
'TEXTURE_WRAP_T': [
|
|
|
|
'REPEAT',
|
|
|
|
'CLAMP_TO_EDGE',
|
|
|
|
'MIRRORED_REPEAT'
|
2018-02-21 09:21:03 +00:00
|
|
|
]
|
2018-02-21 09:19:32 +00:00
|
|
|
}
|
|
|
|
if (isWebGL2) {
|
2018-02-21 09:21:03 +00:00
|
|
|
pnameparam = Object.assign(
|
|
|
|
pnameparam,
|
2018-02-21 09:19:32 +00:00
|
|
|
{
|
|
|
|
'TEXTURE_BASE_LEVEL': [
|
|
|
|
make.number.any()
|
|
|
|
],
|
|
|
|
'TEXTURE_COMPARE_FUNC': [
|
|
|
|
'LEQUAL',
|
|
|
|
'GEQUAL',
|
|
|
|
'LESS',
|
|
|
|
'GREATER',
|
|
|
|
'EQUAL',
|
|
|
|
'NOTEQUAL',
|
|
|
|
'ALWAYS',
|
|
|
|
'NEVER'
|
|
|
|
],
|
|
|
|
'TEXTURE_COMPARE_MODE': [
|
|
|
|
'NONE',
|
|
|
|
'COMPARE_REF_TO_TEXTURE'
|
|
|
|
],
|
|
|
|
'TEXTURE_MAX_LEVEL': [
|
|
|
|
make.number.any()
|
|
|
|
],
|
|
|
|
'TEXTURE_MAX_LOD': [
|
|
|
|
make.number.float()
|
|
|
|
],
|
|
|
|
'TEXTURE_MIN_LOD': [
|
|
|
|
make.number.float()
|
|
|
|
],
|
|
|
|
'TEXTURE_WRAP_R': [
|
|
|
|
'REPEAT',
|
|
|
|
'CLAMP_TO_EDGE',
|
|
|
|
'MIRRORED_REPEAT'
|
|
|
|
]
|
|
|
|
}
|
|
|
|
)
|
|
|
|
}
|
2018-02-21 09:21:03 +00:00
|
|
|
let pname = random.item(Object.keys(pnameparam))
|
|
|
|
let param = random.item(pnameparam[pname])
|
2018-02-21 09:19:32 +00:00
|
|
|
return [pname, param]
|
2018-03-19 03:23:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static randomBlendMode (isWebGL2) {
|
2018-02-21 09:19:32 +00:00
|
|
|
let mode = [
|
|
|
|
'FUNC_ADD',
|
|
|
|
'FUNC_SUBTRACT',
|
2018-02-21 09:21:03 +00:00
|
|
|
'FUNC_REVERSE_SUBTRACT'
|
2018-02-21 09:19:32 +00:00
|
|
|
]
|
|
|
|
if (isWebGL2) {
|
2018-02-22 05:59:27 +00:00
|
|
|
mode.extend([
|
2018-02-21 09:19:32 +00:00
|
|
|
'MIN',
|
|
|
|
'MAX'
|
|
|
|
])
|
|
|
|
}
|
|
|
|
return random.item(mode)
|
2018-03-19 03:23:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static randomBlendFactor (isWebGL2) {
|
2018-02-21 09:19:32 +00:00
|
|
|
let factor = [
|
|
|
|
'ZERO',
|
|
|
|
'ONE',
|
|
|
|
'SRC_COLOR',
|
|
|
|
'ONE_MINUS_SRC_COLOR',
|
|
|
|
'DST_COLOR',
|
|
|
|
'ONE_MINUS_DST_COLOR',
|
|
|
|
'SRC_ALPHA',
|
|
|
|
'ONE_MINUS_SRC_ALPHA',
|
|
|
|
'DST_ALPHA',
|
|
|
|
'ONE_MINUS_DST_ALPHA',
|
|
|
|
'CONSTANT_COLOR',
|
|
|
|
'ONE_MINUS_CONSTANT_COLOR',
|
|
|
|
'CONSTANT_ALPHA',
|
|
|
|
'ONE_MINUS_CONSTANT_ALPHA',
|
|
|
|
'SRC_ALPHA_SATURATE'
|
|
|
|
]
|
2018-02-21 09:21:03 +00:00
|
|
|
return random.item(factor)
|
2018-03-19 03:23:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static randomFace (isWebGL2) {
|
2018-02-21 09:19:32 +00:00
|
|
|
let mode = [
|
|
|
|
'FRONT',
|
|
|
|
'BACK',
|
|
|
|
'FRONT_AND_BACK'
|
|
|
|
]
|
|
|
|
return random.item(mode)
|
2018-03-19 03:23:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static randomTexImage2DTarget (isWebGL2) {
|
2018-02-21 09:19:32 +00:00
|
|
|
let target = [
|
|
|
|
'TEXTURE_2D',
|
|
|
|
'TEXTURE_CUBE_MAP_POSITIVE_X',
|
|
|
|
'TEXTURE_CUBE_MAP_NEGATIVE_X',
|
|
|
|
'TEXTURE_CUBE_MAP_POSITIVE_Y',
|
|
|
|
'TEXTURE_CUBE_MAP_NEGATIVE_Y',
|
|
|
|
'TEXTURE_CUBE_MAP_POSITIVE_Z',
|
|
|
|
'TEXTURE_CUBE_MAP_NEGATIVE_Z'
|
|
|
|
]
|
|
|
|
return random.item(target)
|
2018-03-19 03:23:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static randomTextureTarget (isWebGL2) {
|
2018-02-21 09:19:32 +00:00
|
|
|
let target = [
|
|
|
|
'TEXTURE_2D',
|
|
|
|
'TEXTURE_CUBE_MAP'
|
|
|
|
]
|
|
|
|
if (isWebGL2) {
|
|
|
|
target.extend([
|
|
|
|
'TEXTURE_3D',
|
|
|
|
'TEXTURE_2D_ARRAY'
|
|
|
|
])
|
|
|
|
}
|
|
|
|
return random.item(target)
|
2018-03-19 03:23:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static randomFunc (isWebGL2) {
|
2018-02-21 09:19:32 +00:00
|
|
|
let func = [
|
|
|
|
'NEVER',
|
|
|
|
'LESS',
|
|
|
|
'EQUAL',
|
|
|
|
'LEQUAL',
|
|
|
|
'GREATER',
|
|
|
|
'NOTEQUAL',
|
|
|
|
'GEQUAL',
|
|
|
|
'ALWAYS'
|
|
|
|
]
|
|
|
|
return random.item(func)
|
2018-03-19 03:23:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static randomCap (isWebGL2) {
|
2018-02-21 09:19:32 +00:00
|
|
|
let cap = [
|
|
|
|
'BLEND',
|
|
|
|
'CULL_FACE',
|
|
|
|
'DEPTH_TEST',
|
|
|
|
'DITHER',
|
|
|
|
'POLYGON_OFFSET_FILL',
|
|
|
|
'SAMPLE_ALPHA_TO_COVERAGE',
|
|
|
|
'SAMPLE_COVERAGE',
|
|
|
|
'SCISSOR_TEST',
|
|
|
|
'STENCIL_TEST'
|
|
|
|
]
|
|
|
|
if (isWebGL2) {
|
2018-02-22 05:59:27 +00:00
|
|
|
cap.extend([
|
2018-02-21 09:19:32 +00:00
|
|
|
'RASTERIZER_DISCARD'
|
|
|
|
])
|
|
|
|
}
|
|
|
|
return random.item(cap)
|
2018-03-19 03:23:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static randomPrimitive (isWebGL2) {
|
2018-02-21 09:19:32 +00:00
|
|
|
let mode = [
|
|
|
|
'POINTS',
|
|
|
|
'LINE_STRIP',
|
|
|
|
'LINE_LOOP',
|
|
|
|
'LINES',
|
|
|
|
'TRIANGLE_STRIP',
|
|
|
|
'TRIANGLE_FAN',
|
|
|
|
'TRIANGLES'
|
|
|
|
]
|
|
|
|
return random.item(mode)
|
2018-03-19 03:23:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static randomTextureAttachment (isWebGL2) {
|
2018-02-21 09:19:32 +00:00
|
|
|
let attachment = [
|
|
|
|
'COLOR_ATTACHMENT0',
|
|
|
|
'DEPTH_ATTACHMENT',
|
|
|
|
'STENCIL_ATTACHMENT',
|
2018-02-21 09:21:03 +00:00
|
|
|
'DEPTH_STENCIL_ATTACHMENT'
|
2018-02-21 09:19:32 +00:00
|
|
|
]
|
|
|
|
if (isWebGL2) {
|
2018-02-22 05:59:27 +00:00
|
|
|
attachment.extend([
|
2018-02-21 09:19:32 +00:00
|
|
|
'COLOR_ATTACHMENT' + random.range(0, 15)
|
|
|
|
])
|
|
|
|
}
|
|
|
|
return random.item(attachment)
|
2018-03-19 03:23:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static randomAttachmentQuery (isWebGL2) {
|
2018-02-21 09:19:32 +00:00
|
|
|
let pname = [
|
|
|
|
'FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE',
|
|
|
|
'FRAMEBUFFER_ATTACHMENT_OBJECT_NAME',
|
|
|
|
'FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL',
|
|
|
|
'FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE'
|
|
|
|
]
|
|
|
|
if (isWebGL2) {
|
2018-02-22 05:59:27 +00:00
|
|
|
pname.extend([
|
2018-02-21 09:19:32 +00:00
|
|
|
'FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE',
|
|
|
|
'FRAMEBUFFER_ATTACHMENT_BLUE_SIZE',
|
|
|
|
'FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING',
|
|
|
|
'FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE',
|
|
|
|
'FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE',
|
|
|
|
'FRAMEBUFFER_ATTACHMENT_GREEN_SIZE',
|
|
|
|
'FRAMEBUFFER_ATTACHMENT_RED_SIZE',
|
|
|
|
'FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE',
|
|
|
|
'FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER'
|
|
|
|
])
|
|
|
|
}
|
2018-02-22 05:59:27 +00:00
|
|
|
return random.item(pname)
|
2018-03-19 03:23:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static randomShaderPrecision (isWebGL2) {
|
2018-02-21 09:19:32 +00:00
|
|
|
let precisiontype = [
|
|
|
|
'LOW_FLOAT',
|
|
|
|
'MEDIUM_FLOAT',
|
|
|
|
'HIGH_FLOAT',
|
|
|
|
'LOW_INT',
|
|
|
|
'MEDIUM_INT',
|
|
|
|
'HIGH_INT'
|
|
|
|
]
|
|
|
|
return random.item(precisiontype)
|
2018-03-19 03:23:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static randomStencilRefParameter (isWebGL2) {
|
2018-02-21 09:19:32 +00:00
|
|
|
let param = [
|
|
|
|
'STENCIL_FUNC',
|
|
|
|
'STENCIL_VALUE_MASK',
|
|
|
|
'STENCIL_REF',
|
|
|
|
'STENCIL_BACK_FUNC',
|
|
|
|
'STENCIL_BACK_VALUE_MASK',
|
|
|
|
'STENCIL_BACK_REF',
|
|
|
|
'STENCIL_BITS'
|
|
|
|
]
|
|
|
|
return random.item(param)
|
2018-03-19 03:23:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static randomStencilMaskParameter (isWebGL2) {
|
2018-02-21 09:19:32 +00:00
|
|
|
let param = [
|
|
|
|
'STENCIL_WRITEMASK',
|
|
|
|
'STENCIL_BACK_WRITEMASK',
|
|
|
|
'STENCIL_BITS'
|
|
|
|
]
|
|
|
|
return random.item(param)
|
2018-03-19 03:23:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static randomVertexAttribParameter (isWebGL2) {
|
2018-02-21 09:19:32 +00:00
|
|
|
let pname = [
|
|
|
|
'VERTEX_ATTRIB_ARRAY_BUFFER_BINDING',
|
|
|
|
'VERTEX_ATTRIB_ARRAY_ENABLED',
|
|
|
|
'VERTEX_ATTRIB_ARRAY_SIZE',
|
|
|
|
'VERTEX_ATTRIB_ARRAY_STRIDE',
|
|
|
|
'VERTEX_ATTRIB_ARRAY_TYPE',
|
|
|
|
'VERTEX_ATTRIB_ARRAY_NORMALIZED',
|
|
|
|
'CURRENT_VERTEX_ATTRIB'
|
|
|
|
]
|
|
|
|
if (isWebGL2) {
|
|
|
|
pname.extend([
|
|
|
|
'VERTEX_ATTRIB_ARRAY_INTEGER',
|
|
|
|
'VERTEX_ATTRIB_ARRAY_DIVISOR',
|
|
|
|
'VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE'
|
|
|
|
])
|
|
|
|
}
|
2018-02-22 05:59:27 +00:00
|
|
|
return random.item(pname)
|
2018-03-19 03:23:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static randomHint (isWebGL2) {
|
2018-02-21 09:19:32 +00:00
|
|
|
let target = [
|
|
|
|
'GENERATE_MIPMAP_HINT'
|
|
|
|
]
|
|
|
|
if (isWebGL2) {
|
|
|
|
target.extend([
|
|
|
|
'FRAGMENT_SHADER_DERIVATIVE_HINT'
|
|
|
|
])
|
|
|
|
}
|
|
|
|
return random.item(target)
|
2018-03-19 03:23:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static randomHintMode (isWebGL2) {
|
2018-02-21 09:19:32 +00:00
|
|
|
let mode = [
|
|
|
|
'FASTEST',
|
|
|
|
'NICEST',
|
|
|
|
'DONT_CARE'
|
|
|
|
]
|
|
|
|
return random.item(mode)
|
2018-03-19 03:23:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static randomPixelStorage (isWebGL2) {
|
2018-02-21 09:19:32 +00:00
|
|
|
let pname = {
|
2018-02-22 05:59:27 +00:00
|
|
|
'PACK_ALIGNMENT': random.item([1, 2, 4, 8]),
|
|
|
|
'UNPACK_ALIGNMENT': random.item([1, 2, 4, 8]),
|
2018-02-21 09:19:32 +00:00
|
|
|
'UNPACK_FLIP_Y_WEBGL': random.bool(),
|
|
|
|
'UNPACK_PREMULTIPLY_ALPHA_WEBGL': random.bool(),
|
|
|
|
'UNPACK_COLORSPACE_CONVERSION_WEBGL': random.item([0, 0x9244])
|
|
|
|
}
|
|
|
|
if (isWebGL2) {
|
|
|
|
Object.assign(
|
|
|
|
pname,
|
|
|
|
{
|
|
|
|
'PACK_ROW_LENGTH': make.number.any(),
|
2018-02-21 09:21:03 +00:00
|
|
|
'PACK_SKIP_PIXELS': make.number.any(),
|
|
|
|
'PACK_SKIP_ROWS': make.number.any(),
|
|
|
|
'UNPACK_ROW_LENGTH': make.number.any(),
|
|
|
|
'UNPACK_IMAGE_HEIGHT': make.number.any(),
|
|
|
|
'UNPACK_SKIP_PIXELS': make.number.any(),
|
|
|
|
'UNPACK_SKIP_ROWS': make.number.any(),
|
|
|
|
'UNPACK_SKIP_IMAGES': make.number.any()
|
2018-02-21 09:19:32 +00:00
|
|
|
}
|
|
|
|
)
|
|
|
|
}
|
2018-02-21 09:21:03 +00:00
|
|
|
let name = random.item(Object.keys(pname))
|
2018-02-21 09:19:32 +00:00
|
|
|
return [name, pname[name]]
|
2018-03-19 03:23:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static randomStencilAction (isWebGL2) {
|
2018-02-21 09:19:32 +00:00
|
|
|
let action = [
|
|
|
|
'KEEP',
|
|
|
|
'ZERO',
|
|
|
|
'REPLACE',
|
|
|
|
'INCR',
|
|
|
|
'INCR_WRAP',
|
|
|
|
'DECR',
|
|
|
|
'DECR_WRAP',
|
|
|
|
'INVERT'
|
|
|
|
]
|
2018-02-21 09:21:03 +00:00
|
|
|
return random.item(action)
|
2018-03-19 03:23:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static randomQueryTarget (isWebGL2) {
|
2018-02-21 09:19:32 +00:00
|
|
|
let target = [
|
|
|
|
'ANY_SAMPLES_PASSED',
|
|
|
|
'ANY_SAMPLES_PASSED_CONSERVATIVE',
|
|
|
|
'TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN'
|
|
|
|
]
|
|
|
|
return random.item(target)
|
2018-03-19 03:23:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static randomQueryPname (isWebGL2) {
|
2018-02-21 09:19:32 +00:00
|
|
|
let pname = [
|
|
|
|
'CURRENT_QUERY',
|
|
|
|
'QUERY_RESULT',
|
|
|
|
'QUERY_RESULT_AVAILABLE'
|
|
|
|
]
|
|
|
|
return random.item(pname)
|
2018-03-19 03:23:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static randomSamplerParameter (isWebGL2) {
|
2018-02-21 09:19:32 +00:00
|
|
|
let pname = [
|
|
|
|
'TEXTURE_MAG_FILTER',
|
|
|
|
'TEXTURE_MIN_FILTER',
|
|
|
|
'TEXTURE_WRAP_S',
|
|
|
|
'TEXTURE_WRAP_T',
|
|
|
|
'TEXTURE_BASE_LEVEL',
|
|
|
|
'TEXTURE_COMPARE_FUNC',
|
|
|
|
'TEXTURE_COMPARE_MODE',
|
|
|
|
'TEXTURE_MAX_LEVEL',
|
|
|
|
'TEXTURE_WRAP_R',
|
|
|
|
'TEXTURE_MAX_LOD',
|
|
|
|
'TEXTURE_MIN_LOD',
|
|
|
|
'TEXTURE_MAX_ANISOTROPY_EXT'
|
|
|
|
]
|
|
|
|
return random.item(pname)
|
2018-03-19 03:23:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static randomSyncParameter (isWebGL2) {
|
2018-02-21 09:19:32 +00:00
|
|
|
let pname = [
|
|
|
|
'OBJECT_TYPE',
|
|
|
|
'SYNC_STATUS',
|
|
|
|
'SYNC_CONDITION',
|
|
|
|
'SYNC_FLAGS'
|
|
|
|
]
|
|
|
|
return random.item(pname)
|
2018-03-19 03:23:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static randomClearBuffer (isWebGL2) {
|
2018-02-21 09:19:32 +00:00
|
|
|
let buffer = [
|
|
|
|
'COLOR',
|
|
|
|
'DEPTH',
|
|
|
|
'STENCIL',
|
|
|
|
'DEPTH_STENCIL'
|
|
|
|
]
|
|
|
|
return random.item(buffer)
|
2018-03-19 03:23:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static randomBindBufferTarget (isWebGL2) {
|
2018-02-21 09:19:32 +00:00
|
|
|
let target = [
|
|
|
|
'TRANSFORM_FEEDBACK_BUFFER',
|
|
|
|
'UNIFORM_BUFFER'
|
|
|
|
]
|
|
|
|
return random.item(target)
|
2018-03-19 03:23:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static randomIndexedParameterTarget (isWebGL2) {
|
2018-02-21 09:19:32 +00:00
|
|
|
let target = [
|
|
|
|
'TRANSFORM_FEEDBACK_BUFFER_BINDING',
|
|
|
|
'TRANSFORM_FEEDBACK_BUFFER_SIZE',
|
|
|
|
'TRANSFORM_FEEDBACK_BUFFER_START',
|
|
|
|
'UNIFORM_BUFFER_BINDING',
|
|
|
|
'UNIFORM_BUFFER_SIZE',
|
|
|
|
'UNIFORM_BUFFER_START'
|
|
|
|
]
|
|
|
|
return random.item(target)
|
2018-03-19 03:23:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static randomUniformParameter (isWebGL2) {
|
2018-02-21 09:19:32 +00:00
|
|
|
let pname = [
|
|
|
|
'UNIFORM_TYPE',
|
|
|
|
'UNIFORM_SIZE',
|
|
|
|
'UNIFORM_BLOCK_INDEX',
|
|
|
|
'UNIFORM_OFFSET',
|
|
|
|
'UNIFORM_ARRAY_STRIDE',
|
|
|
|
'UNIFORM_MATRIX_STRIDE',
|
2018-02-21 09:21:03 +00:00
|
|
|
'UNIFORM_IS_ROW_MAJOR'
|
2018-02-21 09:19:32 +00:00
|
|
|
]
|
|
|
|
return random.item(pname)
|
2018-03-19 03:23:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static randomUniformBlockParameter (isWebGL2) {
|
2018-02-21 09:19:32 +00:00
|
|
|
let pname = [
|
|
|
|
'UNIFORM_BLOCK_BINDING',
|
|
|
|
'UNIFORM_BLOCK_DATA_SIZE',
|
|
|
|
'UNIFORM_BLOCK_ACTIVE_UNIFORMS',
|
|
|
|
'UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES',
|
|
|
|
'UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER',
|
|
|
|
'UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER'
|
|
|
|
]
|
|
|
|
return random.item(pname)
|
2018-03-19 03:23:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static randomPixelDatatype (isWebGL2) {
|
2018-02-21 09:19:32 +00:00
|
|
|
let type = [
|
|
|
|
'UNSIGNED_BYTE',
|
|
|
|
'UNSIGNED_SHORT',
|
|
|
|
'UNSIGNED_SHORT_5_6_5',
|
|
|
|
'UNSIGNED_SHORT_4_4_4_4',
|
|
|
|
'UNSIGNED_SHORT_5_5_5_1',
|
|
|
|
'UNSIGNED_INT',
|
|
|
|
'FLOAT'
|
|
|
|
]
|
|
|
|
return random.item(type)
|
2018-03-19 03:23:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static randomBufferUsage (isWebGL2) {
|
2018-02-21 09:19:32 +00:00
|
|
|
let usage = [
|
|
|
|
'STATIC_DRAW',
|
|
|
|
'DYNAMIC_DRAW',
|
|
|
|
'STREAM_DRAW'
|
|
|
|
]
|
2018-02-21 09:21:03 +00:00
|
|
|
if (isWebGL2) {
|
2018-02-22 05:59:27 +00:00
|
|
|
usage.extend([
|
2018-02-21 09:19:32 +00:00
|
|
|
'STATIC_READ',
|
|
|
|
'DYNAMIC_READ',
|
|
|
|
'STREAM_READ',
|
|
|
|
'STATIC_COPY',
|
|
|
|
'DYNAMIC_COPY',
|
2018-02-21 09:21:03 +00:00
|
|
|
'STREAM_COPY'
|
2018-02-21 09:19:32 +00:00
|
|
|
])
|
|
|
|
}
|
|
|
|
return random.item(usage)
|
2018-02-20 01:16:37 +00:00
|
|
|
}
|
|
|
|
}
|
2018-03-19 03:23:05 +00:00
|
|
|
|
|
|
|
module.exports = webgl
|