From df50c42df593b4dc8741fe3be5b700f4fd8591f4 Mon Sep 17 00:00:00 2001 From: Eugene Cheah Date: Sat, 23 Jan 2016 18:40:38 +0800 Subject: [PATCH] Fallback mode handling --- demo/index.html | 26 -------------------------- folder-structure.md | 4 ++++ src/gpu.js | 29 +++++++++++++++++++++++------ 3 files changed, 27 insertions(+), 32 deletions(-) delete mode 100644 demo/index.html diff --git a/demo/index.html b/demo/index.html deleted file mode 100644 index 7deeb693..00000000 --- a/demo/index.html +++ /dev/null @@ -1,26 +0,0 @@ - - - - - Test Case A - - - - - - diff --git a/folder-structure.md b/folder-structure.md index 469235f1..e6bf132b 100644 --- a/folder-structure.md +++ b/folder-structure.md @@ -3,3 +3,7 @@ + demo : demo HTML files + lib : External library JS files + src : The source javascript ++ test + + lib : the QUnit library + + html : the QUnit html page + + src : The unit test source code diff --git a/src/gpu.js b/src/gpu.js index bd301ddd..da3d7dc7 100644 --- a/src/gpu.js +++ b/src/gpu.js @@ -2,9 +2,16 @@ /// /// The parameter object contains the following sub parameters /// -/// + thread (default: [1024]) -/// + block (default: [1]) -/// + mode (default: null) +/// +---------+---------------+---------------------------------------------------------------------------+ +/// | Name | Default value | Description | +/// +---------+---------------+---------------------------------------------------------------------------+ +/// | thread | [1024] | Thread dimension array | +/// | block | [1] | Block dimension array | +/// | mode | null | The CPU / GPU configuration mode, "auto" / null. Has the following modes. | +/// | | | + null / "auto" : Attempts to build GPU mode, else fallbacks | +/// | | | + "gpu" : Attempts to build GPU mode, else fallbacks | +/// | | | + "cpu" : Forces JS fallback mode only | +/// +---------+---------------+---------------------------------------------------------------------------+ /// /// @param inputFunction The calling to perform the conversion /// @param paramObj The parameter configuration object @@ -30,13 +37,23 @@ var GPU = function(kernal, paramObj) { // var thread = paramObj.thread || [1024]; var block = paramObj.block || [1]; + var mode = paramObj.mode && paramObj.mode.toLowerCase(); // // Attempts to do the webclgl conversion, returns if success // - var ret = GPU_jsToWebclgl(kernal, thread, block, paramObj); - if(ret != null) { - return ret; + var ret = null; + + if( mode == null || mode == "gpu" ) { + // Attempts to do the conversion to webclgl + if( (ret = GPU_jsToWebclgl(kernal, thread, block, paramObj)) != null) { + return ret; + } + + // GPU only mode failed, return null + if( mode == "gpu" ) { + return null; + } } //