This repository has been archived by the owner on Nov 16, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 129
webgl: fix issues on Android devices #149
Merged
Merged
Changes from 14 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
d9db2e6
webgl: make vertex attrib 'textureCoord' optional
fs-eire 9b2fc9a
webgl: dump shader source in debug mode
fs-eire df667d0
webgl: check shader status after compile
fs-eire e1b2f6e
add 2 test cases that failed on Android
fs-eire c23be3c
simplify ProgramInfo
fs-eire 9171cc0
requires explicit uniform declaration
fs-eire 98404a7
support GLSL ES 3.0
fs-eire 85d0286
add karma config for android
fs-eire 1132daf
enable check for GL_BLEND
fs-eire a6e4a84
add one android test case for blend disabled
fs-eire 7a4f2a3
update test whitelist
fs-eire a15335d
Merge branch 'master' into android
hariharans29 5f75676
Merge branch 'master' into android
fs-eire eea43c7
Merge branch 'master' into android
fs-eire 1c7cdc9
Merge branch 'master' into android
hariharans29 9834526
fix flag naming: isFloat32DownloadSupported
fs-eire File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,59 +1,54 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT license. | ||
|
||
const INLINE_FUNC_DEF_REGEX: RegExp = | ||
/@inline[\s\n\r]+(\w+)[\s\n\r]+([0-9a-zA-Z_]+)\s*\(([^)]*)\)\s*{(([^}]|[\n\r])*)}/gm; | ||
const FUNC_CALL_REGEX = '(\\w+)?\\s+([_0-9a-zA-Z]+)\\s+=\\s+__FUNC__\\((.*)\\)\\s*;'; | ||
/** | ||
* GLSL preprocessor class responsible for resolving @inline directives | ||
* GLSL preprocessor responsible for resolving @inline directives | ||
*/ | ||
export class GlslFunctionInliner { | ||
// tslint:disable-next-line:variable-name | ||
static readonly InlineFuncDefRegex: RegExp = | ||
/@inline[\s\n\r]+(\w+)[\s\n\r]+([0-9a-zA-Z_]+)\s*\(([^)]*)\)\s*{(([^}]|[\n\r])*)}/gm; | ||
// tslint:disable-next-line:variable-name | ||
static readonly FuncCallRegex = '(\\w+)?\\s+([_0-9a-zA-Z]+)\\s+=\\s+__FUNC__\\((.*)\\)\\s*;'; | ||
|
||
inline(script: string) { | ||
const inlineDefs: {[name: string]: {params: Array<{type: string, name: string}|null>, body: string}} = {}; | ||
let match; | ||
while ((match = GlslFunctionInliner.InlineFuncDefRegex.exec(script)) !== null) { | ||
const params = match[3] | ||
.split(',') | ||
.map(s => { | ||
const tokens = s.trim().split(' '); | ||
if (tokens && tokens.length === 2) { | ||
return {type: tokens[0], name: tokens[1]}; | ||
} | ||
return null; | ||
}) | ||
.filter(v => v !== null); | ||
inlineDefs[match[2]] = {params, body: match[4]}; | ||
} | ||
for (const name in inlineDefs) { | ||
const regexString = GlslFunctionInliner.FuncCallRegex.replace('__FUNC__', name); | ||
const regex = new RegExp(regexString, 'gm'); | ||
while ((match = regex.exec(script)) !== null) { | ||
const type = match[1]; | ||
const variable = match[2]; | ||
const params = match[3].split(','); | ||
const declLine = (type) ? `${type} ${variable};` : ''; | ||
let newBody: string = inlineDefs[name].body; | ||
let paramRedecLine = ''; | ||
inlineDefs[name].params.forEach((v, i) => { | ||
if (v) { | ||
paramRedecLine += `${v.type} ${v.name} = ${params[i]};\n`; | ||
} | ||
}); | ||
newBody = `${paramRedecLine}\n ${newBody}`; | ||
newBody = newBody.replace('return', `${variable} = `); | ||
const replacement = ` | ||
${declLine} | ||
{ | ||
${newBody} | ||
export function replaceInlines(script: string): string { | ||
const inlineDefs: {[name: string]: {params: Array<{type: string, name: string}|null>, body: string}} = {}; | ||
let match; | ||
while ((match = INLINE_FUNC_DEF_REGEX.exec(script)) !== null) { | ||
const params = match[3] | ||
.split(',') | ||
.map(s => { | ||
const tokens = s.trim().split(' '); | ||
if (tokens && tokens.length === 2) { | ||
return {type: tokens[0], name: tokens[1]}; | ||
} | ||
return null; | ||
}) | ||
.filter(v => v !== null); | ||
inlineDefs[match[2]] = {params, body: match[4]}; | ||
} | ||
for (const name in inlineDefs) { | ||
const regexString = FUNC_CALL_REGEX.replace('__FUNC__', name); | ||
const regex = new RegExp(regexString, 'gm'); | ||
while ((match = regex.exec(script)) !== null) { | ||
const type = match[1]; | ||
const variable = match[2]; | ||
const params = match[3].split(','); | ||
const declLine = (type) ? `${type} ${variable};` : ''; | ||
let newBody: string = inlineDefs[name].body; | ||
let paramRedecLine = ''; | ||
inlineDefs[name].params.forEach((v, i) => { | ||
if (v) { | ||
paramRedecLine += `${v.type} ${v.name} = ${params[i]};\n`; | ||
} | ||
`; | ||
script = script.replace(match[0], replacement); | ||
}); | ||
newBody = `${paramRedecLine}\n ${newBody}`; | ||
newBody = newBody.replace('return', `${variable} = `); | ||
const replacement = ` | ||
${declLine} | ||
{ | ||
${newBody} | ||
} | ||
`; | ||
script = script.replace(match[0], replacement); | ||
} | ||
script = script.replace(GlslFunctionInliner.InlineFuncDefRegex, ''); | ||
return script; | ||
} | ||
script = script.replace(INLINE_FUNC_DEF_REGEX, ''); | ||
return script; | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this because this was the default value previously ? I mean there is no data to choose this value right ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is because it's the previous default value.