Merge mozilla-central to fx-team

This commit is contained in:
Carsten "Tomcat" Book 2016-04-27 13:56:49 +02:00
Родитель efa3e84b16 05d6ba16fa
Коммит bfa6750d68
4153 изменённых файлов: 197977 добавлений и 52660 удалений

Просмотреть файл

@ -702,7 +702,7 @@ TextAttrsMgr::TextDecorValue::
bool isForegroundColor = false;
textReset->GetDecorationColor(mColor, isForegroundColor);
if (isForegroundColor)
mColor = aFrame->StyleContext()->GetTextFillColor();
mColor = aFrame->StyleColor()->mColor;
mLine = textReset->mTextDecorationLine &
(NS_STYLE_TEXT_DECORATION_LINE_UNDERLINE |

Просмотреть файл

@ -5440,7 +5440,7 @@ function handleLinkClick(event, href, linkNode) {
linkNode) {
let referrerAttrValue = Services.netUtils.parseAttributePolicyString(linkNode.
getAttribute("referrerpolicy"));
if (referrerAttrValue != Ci.nsIHttpChannel.REFERRER_POLICY_DEFAULT) {
if (referrerAttrValue != Ci.nsIHttpChannel.REFERRER_POLICY_UNSET) {
referrerPolicy = referrerAttrValue;
}
}

Просмотреть файл

@ -128,7 +128,7 @@ var handleContentContextMenu = function (event) {
if (Services.prefs.getBoolPref("network.http.enablePerElementReferrer")) {
let referrerAttrValue = Services.netUtils.parseAttributePolicyString(event.target.
getAttribute("referrerpolicy"));
if (referrerAttrValue !== Ci.nsIHttpChannel.REFERRER_POLICY_DEFAULT) {
if (referrerAttrValue !== Ci.nsIHttpChannel.REFERRER_POLICY_UNSET) {
referrerPolicy = referrerAttrValue;
}
}
@ -419,7 +419,7 @@ var ClickEventHandler = {
node) {
let referrerAttrValue = Services.netUtils.parseAttributePolicyString(node.
getAttribute("referrerpolicy"));
if (referrerAttrValue !== Ci.nsIHttpChannel.REFERRER_POLICY_DEFAULT) {
if (referrerAttrValue !== Ci.nsIHttpChannel.REFERRER_POLICY_UNSET) {
referrerPolicy = referrerAttrValue;
}
}

Просмотреть файл

@ -3,7 +3,7 @@
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
<!ENTITY window.title "Block Lists">
<!ENTITY window.width "50em">
<!ENTITY window.width "55em">
<!ENTITY treehead.list.label "List">
<!ENTITY windowClose.key "w">

Просмотреть файл

@ -76,12 +76,6 @@ leak:processInternalEntity
# Bug 1187421 - With e10s, NSS does not always free the error stack. m1.
leak:nss_ClearErrorStack
# Bug 1122045 - Leaks in MessageLoop::MessageLoop()
leak:MessageLoop::MessageLoop
# This may not actually be related to MessageLoop.
leak:base::WaitableEvent::TimedWait
leak:MessageLoop::PostTask_Helper
# Bug 1189430 - DNS leaks in mochitest-chrome.
leak:nsDNSService::AsyncResolveExtended
leak:_GetAddrInfo_Portable

Просмотреть файл

@ -520,7 +520,7 @@ function testGetterSetterObject() {
is(propNonEnums[0].querySelector(".name").getAttribute("value"), "get",
"Should have the right property name for 'get'.");
is(propNonEnums[0].querySelector(".value").getAttribute("value"),
"test/myVar.prop()",
"get prop()",
"Should have the right property value for 'get'.");
ok(propNonEnums[0].querySelector(".value").className.includes("token-other"),
"Should have the right token class for 'get'.");
@ -528,7 +528,7 @@ function testGetterSetterObject() {
is(propNonEnums[1].querySelector(".name").getAttribute("value"), "set",
"Should have the right property name for 'set'.");
is(propNonEnums[1].querySelector(".value").getAttribute("value"),
"test/myVar.prop(val)",
"set prop(val)",
"Should have the right property value for 'set'.");
ok(propNonEnums[1].querySelector(".value").className.includes("token-other"),
"Should have the right token class for 'set'.");

Просмотреть файл

@ -259,6 +259,10 @@ TabSources.prototype = {
* @returns Boolean
*/
_isMinifiedURL: function (aURL) {
if (!aURL) {
return false;
}
try {
let url = new URL(aURL);
let pathname = url.pathname;

Просмотреть файл

@ -387,8 +387,8 @@ AudioChannelService::GetState(nsPIDOMWindowOuter* aWindow, uint32_t aAudioChanne
// TODO : distiguish between suspend and mute, it would be done in bug1242874.
*aMuted = *aMuted || window->GetMediaSuspended() || window->GetAudioMuted();
nsCOMPtr<nsPIDOMWindowOuter> win = window->GetScriptableParent();
if (window == win) {
nsCOMPtr<nsPIDOMWindowOuter> win = window->GetScriptableParentOrNull();
if (!win) {
break;
}

Просмотреть файл

@ -3658,8 +3658,8 @@ nsPIDOMWindowInner::CreatePerformanceObjectIfNeeded()
// If we are dealing with an iframe, we will need the parent's performance
// object (so we can add the iframe as a resource of that page).
nsPerformance* parentPerformance = nullptr;
nsCOMPtr<nsPIDOMWindowOuter> parentWindow = GetScriptableParent();
if (GetOuterWindow() != parentWindow) {
nsCOMPtr<nsPIDOMWindowOuter> parentWindow = GetScriptableParentOrNull();
if (parentWindow) {
nsPIDOMWindowInner* parentInnerWindow = nullptr;
if (parentWindow) {
parentInnerWindow = parentWindow->GetCurrentInnerWindow();
@ -3878,6 +3878,19 @@ nsGlobalWindow::GetScriptableParent()
return parent.get();
}
/**
* Behavies identically to GetScriptableParent extept that it returns null
* if GetScriptableParent would return this window.
*/
nsPIDOMWindowOuter*
nsGlobalWindow::GetScriptableParentOrNull()
{
FORWARD_TO_OUTER(GetScriptableParentOrNull, (), nullptr);
nsPIDOMWindowOuter* parent = GetScriptableParent();
return (Cast(parent) == this) ? nullptr : parent;
}
/**
* nsPIDOMWindow::GetParent (when called from C++) is just a wrapper around
* GetRealParent.

Просмотреть файл

@ -896,6 +896,7 @@ public:
already_AddRefed<nsPIDOMWindowOuter> GetParent(mozilla::ErrorResult& aError);
already_AddRefed<nsPIDOMWindowOuter> GetParent() override;
nsPIDOMWindowOuter* GetScriptableParent() override;
nsPIDOMWindowOuter* GetScriptableParentOrNull() override;
mozilla::dom::Element* GetFrameElementOuter();
mozilla::dom::Element* GetFrameElement(mozilla::ErrorResult& aError);
already_AddRefed<nsIDOMElement> GetFrameElement() override;

Просмотреть файл

@ -1657,6 +1657,167 @@ nsINode::GetNextElementSibling() const
return nullptr;
}
static already_AddRefed<nsINode>
GetNodeFromNodeOrString(const OwningNodeOrString& aNode,
nsIDocument* aDocument)
{
if (aNode.IsNode()) {
nsCOMPtr<nsINode> node = aNode.GetAsNode();
return node.forget();
}
if (aNode.IsString()){
RefPtr<nsTextNode> textNode =
aDocument->CreateTextNode(aNode.GetAsString());
return textNode.forget();
}
MOZ_CRASH("Impossible type");
}
/**
* Implement the algorithm specified at
* https://dom.spec.whatwg.org/#converting-nodes-into-a-node for |prepend()|,
* |append()|, |before()|, |after()|, and |replaceWith()| APIs.
*/
static already_AddRefed<nsINode>
ConvertNodesOrStringsIntoNode(const Sequence<OwningNodeOrString>& aNodes,
nsIDocument* aDocument,
ErrorResult& aRv)
{
if (aNodes.Length() == 1) {
return GetNodeFromNodeOrString(aNodes[0], aDocument);
}
nsCOMPtr<nsINode> fragment = aDocument->CreateDocumentFragment();
for (const auto& node : aNodes) {
nsCOMPtr<nsINode> childNode = GetNodeFromNodeOrString(node, aDocument);
fragment->AppendChild(*childNode, aRv);
if (aRv.Failed()) {
return nullptr;
}
}
return fragment.forget();
}
static void
InsertNodesIntoHashset(const Sequence<OwningNodeOrString>& aNodes,
nsTHashtable<nsPtrHashKey<nsINode>>& aHashset)
{
for (const auto& node : aNodes) {
if (node.IsNode()) {
aHashset.PutEntry(node.GetAsNode());
}
}
}
static nsINode*
FindViablePreviousSibling(const nsINode& aNode,
const Sequence<OwningNodeOrString>& aNodes)
{
nsTHashtable<nsPtrHashKey<nsINode>> nodeSet(16);
InsertNodesIntoHashset(aNodes, nodeSet);
nsINode* viablePreviousSibling = nullptr;
for (nsINode* sibling = aNode.GetPreviousSibling(); sibling;
sibling = sibling->GetPreviousSibling()) {
if (!nodeSet.Contains(sibling)) {
viablePreviousSibling = sibling;
break;
}
}
return viablePreviousSibling;
}
static nsINode*
FindViableNextSibling(const nsINode& aNode,
const Sequence<OwningNodeOrString>& aNodes)
{
nsTHashtable<nsPtrHashKey<nsINode>> nodeSet(16);
InsertNodesIntoHashset(aNodes, nodeSet);
nsINode* viableNextSibling = nullptr;
for (nsINode* sibling = aNode.GetNextSibling(); sibling;
sibling = sibling->GetNextSibling()) {
if (!nodeSet.Contains(sibling)) {
viableNextSibling = sibling;
break;
}
}
return viableNextSibling;
}
void
nsINode::Before(const Sequence<OwningNodeOrString>& aNodes,
ErrorResult& aRv)
{
nsCOMPtr<nsINode> parent = GetParentNode();
if (!parent) {
return;
}
nsINode* viablePreviousSibling = FindViablePreviousSibling(*this, aNodes);
nsCOMPtr<nsINode> node =
ConvertNodesOrStringsIntoNode(aNodes, OwnerDoc(), aRv);
if (aRv.Failed()) {
return;
}
viablePreviousSibling = viablePreviousSibling ?
viablePreviousSibling->GetNextSibling() : parent->GetFirstChild();
parent->InsertBefore(*node, viablePreviousSibling, aRv);
}
void
nsINode::After(const Sequence<OwningNodeOrString>& aNodes,
ErrorResult& aRv)
{
nsCOMPtr<nsINode> parent = GetParentNode();
if (!parent) {
return;
}
nsINode* viableNextSibling = FindViableNextSibling(*this, aNodes);
nsCOMPtr<nsINode> node =
ConvertNodesOrStringsIntoNode(aNodes, OwnerDoc(), aRv);
if (aRv.Failed()) {
return;
}
parent->InsertBefore(*node, viableNextSibling, aRv);
}
void
nsINode::ReplaceWith(const Sequence<OwningNodeOrString>& aNodes,
ErrorResult& aRv)
{
nsCOMPtr<nsINode> parent = GetParentNode();
if (!parent) {
return;
}
nsINode* viableNextSibling = FindViableNextSibling(*this, aNodes);
nsCOMPtr<nsINode> node =
ConvertNodesOrStringsIntoNode(aNodes, OwnerDoc(), aRv);
if (aRv.Failed()) {
return;
}
if (parent == GetParentNode()) {
parent->ReplaceChild(*node, *this, aRv);
} else {
parent->InsertBefore(*node, viableNextSibling, aRv);
}
}
void
nsINode::Remove()
{
@ -1700,6 +1861,32 @@ nsINode::GetLastElementChild() const
return nullptr;
}
void
nsINode::Prepend(const Sequence<OwningNodeOrString>& aNodes,
ErrorResult& aRv)
{
nsCOMPtr<nsINode> node =
ConvertNodesOrStringsIntoNode(aNodes, OwnerDoc(), aRv);
if (aRv.Failed()) {
return;
}
InsertBefore(*node, mFirstChild, aRv);
}
void
nsINode::Append(const Sequence<OwningNodeOrString>& aNodes,
ErrorResult& aRv)
{
nsCOMPtr<nsINode> node =
ConvertNodesOrStringsIntoNode(aNodes, OwnerDoc(), aRv);
if (aRv.Failed()) {
return;
}
AppendChild(*node, aRv);
}
void
nsINode::doRemoveChildAt(uint32_t aIndex, bool aNotify,
nsIContent* aKid, nsAttrAndChildArray& aChildArray)

Просмотреть файл

@ -76,6 +76,8 @@ class DOMRectReadOnly;
class Element;
class EventHandlerNonNull;
template<typename T> class Optional;
class OwningNodeOrString;
template<typename> class Sequence;
class Text;
class TextOrElementOrDocument;
struct DOMPointInit;
@ -268,9 +270,13 @@ public:
typedef mozilla::dom::DOMPointInit DOMPointInit;
typedef mozilla::dom::DOMQuad DOMQuad;
typedef mozilla::dom::DOMRectReadOnly DOMRectReadOnly;
typedef mozilla::dom::OwningNodeOrString OwningNodeOrString;
typedef mozilla::dom::TextOrElementOrDocument TextOrElementOrDocument;
typedef mozilla::ErrorResult ErrorResult;
template<class T>
using Sequence = mozilla::dom::Sequence<T>;
NS_DECLARE_STATIC_IID_ACCESSOR(NS_INODE_IID)
// Among the sub-classes that inherit (directly or indirectly) from nsINode,
@ -1795,6 +1801,11 @@ public:
// ChildNode methods
mozilla::dom::Element* GetPreviousElementSibling() const;
mozilla::dom::Element* GetNextElementSibling() const;
void Before(const Sequence<OwningNodeOrString>& aNodes, ErrorResult& aRv);
void After(const Sequence<OwningNodeOrString>& aNodes, ErrorResult& aRv);
void ReplaceWith(const Sequence<OwningNodeOrString>& aNodes,
ErrorResult& aRv);
/**
* Remove this node from its parent, if any.
*/
@ -1804,6 +1815,9 @@ public:
mozilla::dom::Element* GetFirstElementChild() const;
mozilla::dom::Element* GetLastElementChild() const;
void Prepend(const Sequence<OwningNodeOrString>& aNodes, ErrorResult& aRv);
void Append(const Sequence<OwningNodeOrString>& aNodes, ErrorResult& aRv);
void GetBoxQuads(const BoxQuadOptions& aOptions,
nsTArray<RefPtr<DOMQuad> >& aResult,
mozilla::ErrorResult& aRv);

Просмотреть файл

@ -118,6 +118,12 @@ public:
virtual nsPIDOMWindowOuter* GetScriptableParent() = 0;
virtual already_AddRefed<nsPIWindowRoot> GetTopWindowRoot() = 0;
/**
* Behavies identically to GetScriptableParent extept that it returns null
* if GetScriptableParent would return this window.
*/
virtual nsPIDOMWindowOuter* GetScriptableParentOrNull() = 0;
// Inner windows only.
virtual nsresult RegisterIdleObserver(nsIIdleObserver* aIdleObserver) = 0;
virtual nsresult UnregisterIdleObserver(nsIIdleObserver* aIdleObserver) = 0;

Просмотреть файл

@ -23,7 +23,8 @@ window.addEventListener("message", function(event) {
* to do checkIndividualResults and resetState
*/
function doXHR(aUrl, onSuccess, onFail) {
var xhr = new XMLHttpRequest();
// The server is at http[s]://example.com so we need cross-origin XHR.
var xhr = new XMLHttpRequest({mozSystem: true});
xhr.responseType = "json";
xhr.onload = function () {
onSuccess(xhr);
@ -31,7 +32,7 @@ function doXHR(aUrl, onSuccess, onFail) {
xhr.onerror = function () {
onFail(xhr);
};
xhr.open('GET', aUrl, true);
xhr.open('GET', "http" + aUrl, true);
xhr.send(null);
}
@ -69,6 +70,8 @@ var tests = (function() {
// enable referrer attribute
yield SpecialPowers.pushPrefEnv({"set": [['network.http.enablePerElementReferrer', true]]}, advance);
yield SpecialPowers.pushPrefEnv({"set": [['security.mixed_content.block_active_content', false]]}, advance);
yield SpecialPowers.pushPermissions([{'type': 'systemXHR', 'allow': true, 'context': document}], advance);
var iframe = document.getElementById("testframe");
@ -87,7 +90,8 @@ var tests = (function() {
searchParams.append(l, tests[i][l]);
}
}
yield iframe.src = SJS + searchParams.toString();
var schemeFrom = tests[i].SCHEME_FROM || "http";
yield iframe.src = schemeFrom + SJS + searchParams.toString();
yield checkIndividualResults(tests[i].DESC, tests[i].RESULT, tests[i].NAME);
};
};

Просмотреть файл

@ -16,17 +16,21 @@ const IMG_BYTES = atob(
"iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12" +
"P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==");
function createTestUrl(aPolicy, aAction, aName, aType) {
return "http://" + BASE_URL +
function createTestUrl(aPolicy, aAction, aName, aType, aSchemeFrom, aSchemeTo) {
var schemeTo = aSchemeTo || "http";
var schemeFrom = aSchemeFrom || "http";
return schemeTo + "://" + BASE_URL +
"ACTION=" + aAction + "&" +
"policy=" + aPolicy + "&" +
"NAME=" + aName + "&" +
"type=" + aType;
"type=" + aType + "&" +
"SCHEME_FROM=" + schemeFrom;
}
// test page using iframe referrer attribute
// if aParams are set this creates a test where the iframe url is a redirect
function createIframeTestPageUsingRefferer(aMetaPolicy, aAttributePolicy, aNewAttributePolicy, aName, aParams, aChangingMethod) {
function createIframeTestPageUsingRefferer(aMetaPolicy, aAttributePolicy, aNewAttributePolicy, aName, aParams,
aSchemeFrom, aSchemeTo, aChangingMethod) {
var metaString = "";
if (aMetaPolicy) {
metaString = `<meta name="referrer" content="${aMetaPolicy}">`;
@ -44,7 +48,7 @@ function createIframeTestPageUsingRefferer(aMetaPolicy, aAttributePolicy, aNewAt
aParams.append("ACTION", "redirectIframe");
iframeUrl = "http://" + CROSS_ORIGIN + aParams.toString();
} else {
iframeUrl = createTestUrl(aAttributePolicy, "test", aName, "iframe");
iframeUrl = createTestUrl(aAttributePolicy, "test", aName, "iframe", aSchemeFrom, aSchemeTo);
}
return `<!DOCTYPE HTML>
@ -67,20 +71,20 @@ function createIframeTestPageUsingRefferer(aMetaPolicy, aAttributePolicy, aNewAt
</html>`;
}
function buildAnchorString(aMetaPolicy, aReferrerPolicy, aName, aRelString){
function buildAnchorString(aMetaPolicy, aReferrerPolicy, aName, aRelString, aSchemeFrom, aSchemeTo){
if (aReferrerPolicy) {
return `<a href="${createTestUrl(aReferrerPolicy, 'test', aName, 'link')}" referrerpolicy="${aReferrerPolicy}" id="link" ${aRelString}>${aReferrerPolicy}</a>`;
return `<a href="${createTestUrl(aReferrerPolicy, 'test', aName, 'link', aSchemeFrom, aSchemeTo)}" referrerpolicy="${aReferrerPolicy}" id="link" ${aRelString}>${aReferrerPolicy}</a>`;
}
return `<a href="${createTestUrl(aMetaPolicy, 'test', aName, 'link')}" id="link" ${aRelString}>link</a>`;
return `<a href="${createTestUrl(aMetaPolicy, 'test', aName, 'link', aSchemeFrom, aSchemeTo)}" id="link" ${aRelString}>link</a>`;
}
function buildAreaString(aMetaPolicy, aReferrerPolicy, aName, aRelString){
function buildAreaString(aMetaPolicy, aReferrerPolicy, aName, aRelString, aSchemeFrom, aSchemeTo){
var result = `<img src="file_mozfiledataurl_img.jpg" alt="image" usemap="#imageMap">`;
result += `<map name="imageMap">`;
if (aReferrerPolicy) {
result += `<area shape="circle" coords="1,1,1" href="${createTestUrl(aReferrerPolicy, 'test', aName, 'link')}" alt="theArea" referrerpolicy="${aReferrerPolicy}" id="link" ${aRelString}>`;
result += `<area shape="circle" coords="1,1,1" href="${createTestUrl(aReferrerPolicy, 'test', aName, 'link', aSchemeFrom, aSchemeTo)}" alt="theArea" referrerpolicy="${aReferrerPolicy}" id="link" ${aRelString}>`;
} else {
result += `<area shape="circle" coords="1,1,1" href="${createTestUrl(aMetaPolicy, 'test', aName, 'link')}" alt="theArea" id="link" ${aRelString}>`;
result += `<area shape="circle" coords="1,1,1" href="${createTestUrl(aMetaPolicy, 'test', aName, 'link', aSchemeFrom, aSchemeTo)}" alt="theArea" id="link" ${aRelString}>`;
}
result += `</map>`;
@ -88,7 +92,7 @@ function buildAreaString(aMetaPolicy, aReferrerPolicy, aName, aRelString){
}
// test page using anchor or area referrer attribute
function createAETestPageUsingRefferer(aMetaPolicy, aAttributePolicy, aNewAttributePolicy, aName, aRel, aStringBuilder, aChangingMethod) {
function createAETestPageUsingRefferer(aMetaPolicy, aAttributePolicy, aNewAttributePolicy, aName, aRel, aStringBuilder, aSchemeFrom, aSchemeTo, aChangingMethod) {
var metaString = "";
if (aMetaPolicy) {
metaString = `<head><meta name="referrer" content="${aMetaPolicy}"></head>`;
@ -103,7 +107,7 @@ function createAETestPageUsingRefferer(aMetaPolicy, aAttributePolicy, aNewAttrib
if (aRel) {
relString = `rel="noreferrer"`;
}
var elementString = aStringBuilder(aMetaPolicy, aAttributePolicy, aName, relString);
var elementString = aStringBuilder(aMetaPolicy, aAttributePolicy, aName, relString, aSchemeFrom, aSchemeTo);
return `<!DOCTYPE HTML>
<html>
@ -151,6 +155,8 @@ function createRedirectImgTestCase(aParams, aAttributePolicy) {
function handleRequest(request, response) {
var params = new URLSearchParams(request.queryString);
var action = params.get("ACTION");
var schemeFrom = params.get("SCHEME_FROM") || "http";
var schemeTo = params.get("SCHEME_TO") || "http";
if (action === "resetState") {
setSharedState(SHARED_KEY, "{}");
@ -201,7 +207,7 @@ function handleRequest(request, response) {
var referrer = request.getHeader("Referer");
if (referrer.indexOf("referrer_testserver") > 0) {
referrerLevel = "full";
} else if (referrer.indexOf("http://mochi.test:8888") == 0) {
} else if (referrer.indexOf(schemeFrom + "://example.com") == 0) {
referrerLevel = "origin";
} else {
// this is never supposed to happen
@ -250,8 +256,8 @@ function handleRequest(request, response) {
// anchor & area
var _getPage = createAETestPageUsingRefferer.bind(null, metaPolicy, attributePolicy, newAttributePolicy, name, rel);
var _getAnchorPage = _getPage.bind(null, buildAnchorString);
var _getAreaPage = _getPage.bind(null, buildAreaString);
var _getAnchorPage = _getPage.bind(null, buildAnchorString, schemeFrom, schemeTo);
var _getAreaPage = _getPage.bind(null, buildAreaString, schemeFrom, schemeTo);
// aMetaPolicy, aAttributePolicy, aNewAttributePolicy, aName, aChangingMethod, aStringBuilder
if (action === "generate-anchor-policy-test") {
@ -280,7 +286,8 @@ function handleRequest(request, response) {
}
// iframe
_getPage = createIframeTestPageUsingRefferer.bind(null, metaPolicy, attributePolicy, newAttributePolicy, name, "");
_getPage = createIframeTestPageUsingRefferer.bind(null, metaPolicy, attributePolicy, newAttributePolicy, name, "",
schemeFrom, schemeTo);
// aMetaPolicy, aAttributePolicy, aNewAttributePolicy, aName, aChangingMethod
if (action === "generate-iframe-policy-test") {
@ -302,7 +309,8 @@ function handleRequest(request, response) {
return;
}
if (action === "generate-iframe-redirect-policy-test") {
response.write(createIframeTestPageUsingRefferer(metaPolicy, attributePolicy, newAttributePolicy, name, params));
response.write(createIframeTestPageUsingRefferer(metaPolicy, attributePolicy, newAttributePolicy, name, params,
schemeFrom, schemeTo));
return;
}

Просмотреть файл

@ -14,8 +14,8 @@
<script type="application/javascript;version=1.8">
const SJS = "/tests/dom/base/test/referrer_testserver.sjs?";
const PARAMS = ["ATTRIBUTE_POLICY", "NEW_ATTRIBUTE_POLICY", "META_POLICY", "REL"];
const SJS = "://example.com/tests/dom/base/test/referrer_testserver.sjs?";
const PARAMS = ["ATTRIBUTE_POLICY", "NEW_ATTRIBUTE_POLICY", "META_POLICY", "REL", "SCHEME_FROM", "SCHEME_TO"];
const testCases = [
{ACTION: ["generate-anchor-policy-test", "generate-area-policy-test"],
@ -39,6 +39,28 @@
META_POLICY: 'no-referrer',
DESC: "no-referrer in meta",
RESULT: 'none'},
// Test if element attr would override meta referr policy.
// 1. Downgrade.
{ATTRIBUTE_POLICY: 'no-referrer-when-downgrade',
NAME: 'origin-in-meta-downgrade-in-attr',
META_POLICY: 'origin',
DESC: 'origin in meta downgrade in attr',
SCHEME_FROM: 'https',
SCHEME_TO: 'http',
RESULT: 'none'},
// 2. No downgrade.
{ATTRIBUTE_POLICY: 'no-referrer-when-downgrade',
NAME: 'origin-in-meta-downgrade-in-attr',
META_POLICY: 'origin',
DESC: 'origin in meta downgrade in attr',
SCHEME_FROM: 'https',
SCHEME_TO: 'https',
RESULT: 'full'},
// End of element attr overriding test..
{ATTRIBUTE_POLICY: 'origin',
NAME: 'origin-with-no-meta',
META_POLICY: '',

Просмотреть файл

@ -15,7 +15,7 @@
<script type="application/javascript;version=1.8">
const SJS = "/tests/dom/base/test/referrer_testserver.sjs?";
const SJS = "://example.com/tests/dom/base/test/referrer_testserver.sjs?";
const PARAMS = ["ATTRIBUTE_POLICY", "NEW_ATTRIBUTE_POLICY", "META_POLICY", "REL"];
const testCases = [

Просмотреть файл

@ -14,19 +14,24 @@
<script type="application/javascript;version=1.8">
const SJS = "/tests/dom/base/test/referrer_testserver.sjs?";
const PARAMS = ["ATTRIBUTE_POLICY", "NEW_ATTRIBUTE_POLICY", "META_POLICY", "REL"];
const SJS = "://example.com/tests/dom/base/test/referrer_testserver.sjs?";
const PARAMS = ["ATTRIBUTE_POLICY", "NEW_ATTRIBUTE_POLICY", "META_POLICY", "REL", , "SCHEME_FROM", "SCHEME_TO"];
const testCases = [
{ACTION: ["generate-anchor-policy-test", "generate-area-policy-test"],
TESTS: [
// setting invalid refer values -> we expect either full referrer (default)
// or whatever is specified in the meta referrer policy
// Note that for those test cases which require cross-origin test, we use different
// scheme to result in cross-origin request.
{ATTRIBUTE_POLICY: 'origin-when-cross-origin',
NAME: 'origin-when-cross-origin-with-no-meta',
META_POLICY: '',
SCHEME_FROM: 'https',
SCHEME_TO: 'http',
DESC: "origin-when-cross-origin (anchor) with no meta",
RESULT: 'full'},
RESULT: 'origin'},
{ATTRIBUTE_POLICY: 'default',
NAME: 'default-with-no-meta',
META_POLICY: '',
@ -40,16 +45,22 @@
{ATTRIBUTE_POLICY: 'origin-when-cross-origin',
NAME: 'origin-when-cross-origin-with-no-referrer-in-meta',
META_POLICY: 'no-referrer',
SCHEME_FROM: 'https',
SCHEME_TO: 'http',
DESC: "origin-when-cross-origin (anchor) with no-referrer in meta",
RESULT: 'none'},
RESULT: 'origin'},
{ATTRIBUTE_POLICY: 'origin-when-cross-origin',
NAME: 'origin-when-cross-origin-with-unsafe-url-in-meta',
META_POLICY: 'unsafe-url',
SCHEME_FROM: 'https',
SCHEME_TO: 'http',
DESC: "origin-when-cross-origin (anchor) with unsafe-url in meta",
RESULT: 'full'},
RESULT: 'origin'},
{ATTRIBUTE_POLICY: 'origin-when-cross-origin',
NAME: 'origin-when-cross-origin-with-origin-in-meta',
META_POLICY: 'origin',
SCHEME_FROM: 'https',
SCHEME_TO: 'http',
DESC: "origin-when-cross-origin (anchor) with origin in meta",
RESULT: 'origin'}]}
];

Просмотреть файл

@ -14,7 +14,7 @@
<script type="application/javascript;version=1.8">
const SJS = "/tests/dom/base/test/referrer_testserver.sjs?";
const SJS = "://example.com/tests/dom/base/test/referrer_testserver.sjs?";
const PARAMS = ["ATTRIBUTE_POLICY", "NEW_ATTRIBUTE_POLICY", "META_POLICY", "REL"];
const testCases = [

Просмотреть файл

@ -15,7 +15,7 @@
<script type="application/javascript;version=1.7">
const SJS = "/tests/dom/base/test/referrer_testserver.sjs?";
const SJS = "://example.com/tests/dom/base/test/referrer_testserver.sjs?";
const PARAMS = ["ATTRIBUTE_POLICY", "NEW_ATTRIBUTE_POLICY", "META_POLICY"];
const testCases = [

Просмотреть файл

@ -14,7 +14,7 @@
<script type="application/javascript;version=1.7">
const SJS = "/tests/dom/base/test/referrer_testserver.sjs?";
const SJS = "://example.com/tests/dom/base/test/referrer_testserver.sjs?";
const PARAMS = ["ATTRIBUTE_POLICY", "NEW_ATTRIBUTE_POLICY", "META_POLICY"];
const testCases = [

Просмотреть файл

@ -14,19 +14,24 @@
<script type="application/javascript;version=1.7">
const SJS = "/tests/dom/base/test/referrer_testserver.sjs?";
const PARAMS = ["ATTRIBUTE_POLICY", "NEW_ATTRIBUTE_POLICY", "META_POLICY"];
const SJS = "://example.com/tests/dom/base/test/referrer_testserver.sjs?";
const PARAMS = ["ATTRIBUTE_POLICY", "NEW_ATTRIBUTE_POLICY", "META_POLICY", "SCHEME_FROM", "SCHEME_TO"];
const testCases = [
{ACTION: ["generate-iframe-policy-test"],
TESTS: [
// setting invalid refer values -> we expect either full referrer (default)
// or whatever is specified in the meta referrer policy
// Note that for those test cases which require cross-origin test, we use different
// scheme to result in cross-origin request.
{ATTRIBUTE_POLICY: 'origin-when-cross-origin',
NAME: 'origin-when-cross-origin-with-no-meta',
META_POLICY: '',
DESC: "origin-when-cross-origin (iframe) with no meta",
RESULT: 'full'},
SCHEME_FROM: 'https',
SCHEME_TO: 'http',
RESULT: 'origin'},
{ATTRIBUTE_POLICY: 'default',
NAME: 'default-with-no-meta',
META_POLICY: '',
@ -41,16 +46,22 @@
NAME: 'origin-when-cross-origin-with-no-referrer-in-meta',
META_POLICY: 'no-referrer',
DESC: "origin-when-cross-origin (iframe) with no-referrer in meta",
RESULT: 'none'},
SCHEME_FROM: 'https',
SCHEME_TO: 'http',
RESULT: 'origin'},
{ATTRIBUTE_POLICY: 'origin-when-cross-origin',
NAME: 'origin-when-cross-origin-with-unsafe-url-in-meta',
META_POLICY: 'unsafe-url',
DESC: "origin-when-cross-origin (iframe) with unsafe-url in meta",
RESULT: 'full'},
SCHEME_FROM: 'https',
SCHEME_TO: 'http',
RESULT: 'origin'},
{ATTRIBUTE_POLICY: 'origin-when-cross-origin',
NAME: 'origin-when-cross-origin-with-origin-in-meta',
META_POLICY: 'origin',
DESC: "origin-when-cross-origin (iframe) with origin in meta",
SCHEME_FROM: 'https',
SCHEME_TO: 'http',
RESULT: 'origin'},
{NAME: 'origin-in-meta',
META_POLICY: 'origin',

Просмотреть файл

@ -13,7 +13,7 @@
<script type="application/javascript;version=1.8">
const SJS = "/tests/dom/base/test/referrer_testserver.sjs?";
const SJS = "://example.com/tests/dom/base/test/referrer_testserver.sjs?";
const PARAMS = ["ATTRIBUTE_POLICY", "NEW_ATTRIBUTE_POLICY", "META_POLICY"];
const testCases = [

Просмотреть файл

@ -11,8 +11,9 @@ TEST_DIRS += ['compiledtest']
MOCHITEST_MANIFESTS += [
'test/crossorigin/mochitest.ini',
'test/mochitest-subsuite-webgl.ini',
'test/mochitest.ini',
'test/webgl-conf/generated-mochitest.ini',
'test/webgl-mochitest/mochitest.ini',
]
MOCHITEST_CHROME_MANIFESTS += ['test/chrome/chrome.ini']

Просмотреть файл

@ -1,847 +0,0 @@
# This is a GENERATED FILE. Do not edit it directly.
# Regenerated it by using `python generate-wrappers-and-manifest.py`.
# Mark skipped tests in mochitest-errata.ini.
# Mark failing tests in mochi-single.html.
[DEFAULT]
subsuite = webgl
skip-if = os == 'b2g' || ((os == 'linux') && (buildapp == 'b2g')) || ((os == 'linux') && (buildapp == 'mulet'))
support-files = webgl-conformance/../webgl-mochitest/driver-info.js
webgl-conformance/always-fail.html
webgl-conformance/conformance/00_readme.txt
webgl-conformance/conformance/00_test_list.txt
webgl-conformance/conformance/LICENSE_CHROMIUM
webgl-conformance/conformance/attribs/00_test_list.txt
webgl-conformance/conformance/attribs/gl-enable-vertex-attrib.html
webgl-conformance/conformance/attribs/gl-vertex-attrib-zero-issues.html
webgl-conformance/conformance/attribs/gl-vertex-attrib.html
webgl-conformance/conformance/attribs/gl-vertexattribpointer-offsets.html
webgl-conformance/conformance/attribs/gl-vertexattribpointer.html
webgl-conformance/conformance/buffers/00_test_list.txt
webgl-conformance/conformance/buffers/buffer-bind-test.html
webgl-conformance/conformance/buffers/buffer-data-array-buffer.html
webgl-conformance/conformance/buffers/index-validation-copies-indices.html
webgl-conformance/conformance/buffers/index-validation-crash-with-buffer-sub-data.html
webgl-conformance/conformance/buffers/index-validation-verifies-too-many-indices.html
webgl-conformance/conformance/buffers/index-validation-with-resized-buffer.html
webgl-conformance/conformance/buffers/index-validation.html
webgl-conformance/conformance/canvas/00_test_list.txt
webgl-conformance/conformance/canvas/buffer-offscreen-test.html
webgl-conformance/conformance/canvas/buffer-preserve-test.html
webgl-conformance/conformance/canvas/canvas-test.html
webgl-conformance/conformance/canvas/canvas-zero-size.html
webgl-conformance/conformance/canvas/drawingbuffer-static-canvas-test.html
webgl-conformance/conformance/canvas/drawingbuffer-test.html
webgl-conformance/conformance/canvas/viewport-unchanged-upon-resize.html
webgl-conformance/conformance/context/00_test_list.txt
webgl-conformance/conformance/context/constants.html
webgl-conformance/conformance/context/context-attribute-preserve-drawing-buffer.html
webgl-conformance/conformance/context/context-attributes-alpha-depth-stencil-antialias.html
webgl-conformance/conformance/context/context-lost-restored.html
webgl-conformance/conformance/context/context-lost.html
webgl-conformance/conformance/context/context-type-test.html
webgl-conformance/conformance/context/incorrect-context-object-behaviour.html
webgl-conformance/conformance/context/methods.html
webgl-conformance/conformance/context/premultiplyalpha-test.html
webgl-conformance/conformance/context/resource-sharing-test.html
webgl-conformance/conformance/extensions/00_test_list.txt
webgl-conformance/conformance/extensions/ext-sRGB.html
webgl-conformance/conformance/extensions/ext-shader-texture-lod.html
webgl-conformance/conformance/extensions/ext-texture-filter-anisotropic.html
webgl-conformance/conformance/extensions/oes-standard-derivatives.html
webgl-conformance/conformance/extensions/oes-texture-float.html
webgl-conformance/conformance/extensions/oes-vertex-array-object.html
webgl-conformance/conformance/extensions/webgl-compressed-texture-etc1.html
webgl-conformance/conformance/extensions/webgl-compressed-texture-s3tc.html
webgl-conformance/conformance/extensions/webgl-debug-renderer-info.html
webgl-conformance/conformance/extensions/webgl-debug-shaders.html
webgl-conformance/conformance/extensions/webgl-depth-texture.html
webgl-conformance/conformance/glsl/00_test_list.txt
webgl-conformance/conformance/glsl/functions/00_test_list.txt
webgl-conformance/conformance/glsl/functions/glsl-function-abs.html
webgl-conformance/conformance/glsl/functions/glsl-function-acos.html
webgl-conformance/conformance/glsl/functions/glsl-function-asin.html
webgl-conformance/conformance/glsl/functions/glsl-function-atan-xy.html
webgl-conformance/conformance/glsl/functions/glsl-function-atan.html
webgl-conformance/conformance/glsl/functions/glsl-function-ceil.html
webgl-conformance/conformance/glsl/functions/glsl-function-clamp-float.html
webgl-conformance/conformance/glsl/functions/glsl-function-clamp-gentype.html
webgl-conformance/conformance/glsl/functions/glsl-function-cos.html
webgl-conformance/conformance/glsl/functions/glsl-function-cross.html
webgl-conformance/conformance/glsl/functions/glsl-function-distance.html
webgl-conformance/conformance/glsl/functions/glsl-function-dot.html
webgl-conformance/conformance/glsl/functions/glsl-function-faceforward.html
webgl-conformance/conformance/glsl/functions/glsl-function-floor.html
webgl-conformance/conformance/glsl/functions/glsl-function-fract.html
webgl-conformance/conformance/glsl/functions/glsl-function-length.html
webgl-conformance/conformance/glsl/functions/glsl-function-lessThan.html
webgl-conformance/conformance/glsl/functions/glsl-function-max-float.html
webgl-conformance/conformance/glsl/functions/glsl-function-max-gentype.html
webgl-conformance/conformance/glsl/functions/glsl-function-min-float.html
webgl-conformance/conformance/glsl/functions/glsl-function-min-gentype.html
webgl-conformance/conformance/glsl/functions/glsl-function-mix-float.html
webgl-conformance/conformance/glsl/functions/glsl-function-mix-gentype.html
webgl-conformance/conformance/glsl/functions/glsl-function-mod-float.html
webgl-conformance/conformance/glsl/functions/glsl-function-mod-gentype.html
webgl-conformance/conformance/glsl/functions/glsl-function-normalize.html
webgl-conformance/conformance/glsl/functions/glsl-function-reflect.html
webgl-conformance/conformance/glsl/functions/glsl-function-refract.html
webgl-conformance/conformance/glsl/functions/glsl-function-sign.html
webgl-conformance/conformance/glsl/functions/glsl-function-sin.html
webgl-conformance/conformance/glsl/functions/glsl-function-smoothstep-float.html
webgl-conformance/conformance/glsl/functions/glsl-function-smoothstep-gentype.html
webgl-conformance/conformance/glsl/functions/glsl-function-step-float.html
webgl-conformance/conformance/glsl/functions/glsl-function-step-gentype.html
webgl-conformance/conformance/glsl/functions/glsl-function.html
webgl-conformance/conformance/glsl/implicit/00_test_list.txt
webgl-conformance/conformance/glsl/implicit/add_int_float.vert.html
webgl-conformance/conformance/glsl/implicit/add_int_mat2.vert.html
webgl-conformance/conformance/glsl/implicit/add_int_mat3.vert.html
webgl-conformance/conformance/glsl/implicit/add_int_mat4.vert.html
webgl-conformance/conformance/glsl/implicit/add_int_vec2.vert.html
webgl-conformance/conformance/glsl/implicit/add_int_vec3.vert.html
webgl-conformance/conformance/glsl/implicit/add_int_vec4.vert.html
webgl-conformance/conformance/glsl/implicit/add_ivec2_vec2.vert.html
webgl-conformance/conformance/glsl/implicit/add_ivec3_vec3.vert.html
webgl-conformance/conformance/glsl/implicit/add_ivec4_vec4.vert.html
webgl-conformance/conformance/glsl/implicit/assign_int_to_float.vert.html
webgl-conformance/conformance/glsl/implicit/assign_ivec2_to_vec2.vert.html
webgl-conformance/conformance/glsl/implicit/assign_ivec3_to_vec3.vert.html
webgl-conformance/conformance/glsl/implicit/assign_ivec4_to_vec4.vert.html
webgl-conformance/conformance/glsl/implicit/construct_struct.vert.html
webgl-conformance/conformance/glsl/implicit/divide_int_float.vert.html
webgl-conformance/conformance/glsl/implicit/divide_int_mat2.vert.html
webgl-conformance/conformance/glsl/implicit/divide_int_mat3.vert.html
webgl-conformance/conformance/glsl/implicit/divide_int_mat4.vert.html
webgl-conformance/conformance/glsl/implicit/divide_int_vec2.vert.html
webgl-conformance/conformance/glsl/implicit/divide_int_vec3.vert.html
webgl-conformance/conformance/glsl/implicit/divide_int_vec4.vert.html
webgl-conformance/conformance/glsl/implicit/divide_ivec2_vec2.vert.html
webgl-conformance/conformance/glsl/implicit/divide_ivec3_vec3.vert.html
webgl-conformance/conformance/glsl/implicit/divide_ivec4_vec4.vert.html
webgl-conformance/conformance/glsl/implicit/equal_int_float.vert.html
webgl-conformance/conformance/glsl/implicit/equal_ivec2_vec2.vert.html
webgl-conformance/conformance/glsl/implicit/equal_ivec3_vec3.vert.html
webgl-conformance/conformance/glsl/implicit/equal_ivec4_vec4.vert.html
webgl-conformance/conformance/glsl/implicit/function_int_float.vert.html
webgl-conformance/conformance/glsl/implicit/function_ivec2_vec2.vert.html
webgl-conformance/conformance/glsl/implicit/function_ivec3_vec3.vert.html
webgl-conformance/conformance/glsl/implicit/function_ivec4_vec4.vert.html
webgl-conformance/conformance/glsl/implicit/greater_than.vert.html
webgl-conformance/conformance/glsl/implicit/greater_than_equal.vert.html
webgl-conformance/conformance/glsl/implicit/less_than.vert.html
webgl-conformance/conformance/glsl/implicit/less_than_equal.vert.html
webgl-conformance/conformance/glsl/implicit/multiply_int_float.vert.html
webgl-conformance/conformance/glsl/implicit/multiply_int_mat2.vert.html
webgl-conformance/conformance/glsl/implicit/multiply_int_mat3.vert.html
webgl-conformance/conformance/glsl/implicit/multiply_int_mat4.vert.html
webgl-conformance/conformance/glsl/implicit/multiply_int_vec2.vert.html
webgl-conformance/conformance/glsl/implicit/multiply_int_vec3.vert.html
webgl-conformance/conformance/glsl/implicit/multiply_int_vec4.vert.html
webgl-conformance/conformance/glsl/implicit/multiply_ivec2_vec2.vert.html
webgl-conformance/conformance/glsl/implicit/multiply_ivec3_vec3.vert.html
webgl-conformance/conformance/glsl/implicit/multiply_ivec4_vec4.vert.html
webgl-conformance/conformance/glsl/implicit/not_equal_int_float.vert.html
webgl-conformance/conformance/glsl/implicit/not_equal_ivec2_vec2.vert.html
webgl-conformance/conformance/glsl/implicit/not_equal_ivec3_vec3.vert.html
webgl-conformance/conformance/glsl/implicit/not_equal_ivec4_vec4.vert.html
webgl-conformance/conformance/glsl/implicit/subtract_int_float.vert.html
webgl-conformance/conformance/glsl/implicit/subtract_int_mat2.vert.html
webgl-conformance/conformance/glsl/implicit/subtract_int_mat3.vert.html
webgl-conformance/conformance/glsl/implicit/subtract_int_mat4.vert.html
webgl-conformance/conformance/glsl/implicit/subtract_int_vec2.vert.html
webgl-conformance/conformance/glsl/implicit/subtract_int_vec3.vert.html
webgl-conformance/conformance/glsl/implicit/subtract_int_vec4.vert.html
webgl-conformance/conformance/glsl/implicit/subtract_ivec2_vec2.vert.html
webgl-conformance/conformance/glsl/implicit/subtract_ivec3_vec3.vert.html
webgl-conformance/conformance/glsl/implicit/subtract_ivec4_vec4.vert.html
webgl-conformance/conformance/glsl/implicit/ternary_int_float.vert.html
webgl-conformance/conformance/glsl/implicit/ternary_ivec2_vec2.vert.html
webgl-conformance/conformance/glsl/implicit/ternary_ivec3_vec3.vert.html
webgl-conformance/conformance/glsl/implicit/ternary_ivec4_vec4.vert.html
webgl-conformance/conformance/glsl/matrices/00_test_list.txt
webgl-conformance/conformance/glsl/matrices/glsl-mat4-to-mat3.html
webgl-conformance/conformance/glsl/misc/00_test_list.txt
webgl-conformance/conformance/glsl/misc/attrib-location-length-limits.html
webgl-conformance/conformance/glsl/misc/embedded-struct-definitions-forbidden.html
webgl-conformance/conformance/glsl/misc/glsl-2types-of-textures-on-same-unit.html
webgl-conformance/conformance/glsl/misc/glsl-function-nodes.html
webgl-conformance/conformance/glsl/misc/glsl-long-variable-names.html
webgl-conformance/conformance/glsl/misc/glsl-vertex-branch.html
webgl-conformance/conformance/glsl/misc/include.vs
webgl-conformance/conformance/glsl/misc/non-ascii-comments.vert.html
webgl-conformance/conformance/glsl/misc/non-ascii.vert.html
webgl-conformance/conformance/glsl/misc/re-compile-re-link.html
webgl-conformance/conformance/glsl/misc/shader-with-256-character-identifier.frag.html
webgl-conformance/conformance/glsl/misc/shader-with-257-character-identifier.frag.html
webgl-conformance/conformance/glsl/misc/shader-with-_webgl-identifier.vert.html
webgl-conformance/conformance/glsl/misc/shader-with-arbitrary-indexing.frag.html
webgl-conformance/conformance/glsl/misc/shader-with-arbitrary-indexing.vert.html
webgl-conformance/conformance/glsl/misc/shader-with-attrib-array.vert.html
webgl-conformance/conformance/glsl/misc/shader-with-attrib-struct.vert.html
webgl-conformance/conformance/glsl/misc/shader-with-clipvertex.vert.html
webgl-conformance/conformance/glsl/misc/shader-with-comma-assignment.html
webgl-conformance/conformance/glsl/misc/shader-with-comma-conditional-assignment.html
webgl-conformance/conformance/glsl/misc/shader-with-conditional-scoping.html
webgl-conformance/conformance/glsl/misc/shader-with-default-precision.frag.html
webgl-conformance/conformance/glsl/misc/shader-with-default-precision.vert.html
webgl-conformance/conformance/glsl/misc/shader-with-define-line-continuation.frag.html
webgl-conformance/conformance/glsl/misc/shader-with-dfdx-no-ext.frag.html
webgl-conformance/conformance/glsl/misc/shader-with-dfdx.frag.html
webgl-conformance/conformance/glsl/misc/shader-with-do-scoping.html
webgl-conformance/conformance/glsl/misc/shader-with-error-directive.html
webgl-conformance/conformance/glsl/misc/shader-with-explicit-int-cast.vert.html
webgl-conformance/conformance/glsl/misc/shader-with-float-return-value.frag.html
webgl-conformance/conformance/glsl/misc/shader-with-for-loop.html
webgl-conformance/conformance/glsl/misc/shader-with-for-scoping.html
webgl-conformance/conformance/glsl/misc/shader-with-frag-depth.frag.html
webgl-conformance/conformance/glsl/misc/shader-with-function-recursion.frag.html
webgl-conformance/conformance/glsl/misc/shader-with-function-scoped-struct.html
webgl-conformance/conformance/glsl/misc/shader-with-functional-scoping.html
webgl-conformance/conformance/glsl/misc/shader-with-glcolor.vert.html
webgl-conformance/conformance/glsl/misc/shader-with-gles-1.frag.html
webgl-conformance/conformance/glsl/misc/shader-with-gles-symbol.frag.html
webgl-conformance/conformance/glsl/misc/shader-with-glprojectionmatrix.vert.html
webgl-conformance/conformance/glsl/misc/shader-with-hex-int-constant-macro.html
webgl-conformance/conformance/glsl/misc/shader-with-implicit-vec3-to-vec4-cast.vert.html
webgl-conformance/conformance/glsl/misc/shader-with-include.vert.html
webgl-conformance/conformance/glsl/misc/shader-with-int-return-value.frag.html
webgl-conformance/conformance/glsl/misc/shader-with-invalid-identifier.frag.html
webgl-conformance/conformance/glsl/misc/shader-with-ivec2-return-value.frag.html
webgl-conformance/conformance/glsl/misc/shader-with-ivec3-return-value.frag.html
webgl-conformance/conformance/glsl/misc/shader-with-ivec4-return-value.frag.html
webgl-conformance/conformance/glsl/misc/shader-with-limited-indexing.frag.html
webgl-conformance/conformance/glsl/misc/shader-with-line-directive.html
webgl-conformance/conformance/glsl/misc/shader-with-long-line.html
webgl-conformance/conformance/glsl/misc/shader-with-non-ascii-error.frag.html
webgl-conformance/conformance/glsl/misc/shader-with-precision.frag.html
webgl-conformance/conformance/glsl/misc/shader-with-quoted-error.frag.html
webgl-conformance/conformance/glsl/misc/shader-with-undefined-preprocessor-symbol.frag.html
webgl-conformance/conformance/glsl/misc/shader-with-uniform-in-loop-condition.vert.html
webgl-conformance/conformance/glsl/misc/shader-with-vec2-return-value.frag.html
webgl-conformance/conformance/glsl/misc/shader-with-vec3-return-value.frag.html
webgl-conformance/conformance/glsl/misc/shader-with-vec4-return-value.frag.html
webgl-conformance/conformance/glsl/misc/shader-with-vec4-vec3-vec4-conditional.html
webgl-conformance/conformance/glsl/misc/shader-with-version-100.frag.html
webgl-conformance/conformance/glsl/misc/shader-with-version-100.vert.html
webgl-conformance/conformance/glsl/misc/shader-with-version-120.vert.html
webgl-conformance/conformance/glsl/misc/shader-with-version-130.vert.html
webgl-conformance/conformance/glsl/misc/shader-with-webgl-identifier.vert.html
webgl-conformance/conformance/glsl/misc/shader-without-precision.frag.html
webgl-conformance/conformance/glsl/misc/shared.html
webgl-conformance/conformance/glsl/misc/struct-nesting-exceeds-maximum.html
webgl-conformance/conformance/glsl/misc/struct-nesting-under-maximum.html
webgl-conformance/conformance/glsl/misc/uniform-location-length-limits.html
webgl-conformance/conformance/glsl/reserved/00_test_list.txt
webgl-conformance/conformance/glsl/reserved/_webgl_field.vert.html
webgl-conformance/conformance/glsl/reserved/_webgl_function.vert.html
webgl-conformance/conformance/glsl/reserved/_webgl_struct.vert.html
webgl-conformance/conformance/glsl/reserved/_webgl_variable.vert.html
webgl-conformance/conformance/glsl/reserved/webgl_field.vert.html
webgl-conformance/conformance/glsl/reserved/webgl_function.vert.html
webgl-conformance/conformance/glsl/reserved/webgl_struct.vert.html
webgl-conformance/conformance/glsl/reserved/webgl_variable.vert.html
webgl-conformance/conformance/glsl/samplers/00_test_list.txt
webgl-conformance/conformance/glsl/samplers/glsl-function-texture2d-bias.html
webgl-conformance/conformance/glsl/samplers/glsl-function-texture2dlod.html
webgl-conformance/conformance/glsl/samplers/glsl-function-texture2dproj.html
webgl-conformance/conformance/glsl/variables/00_test_list.txt
webgl-conformance/conformance/glsl/variables/gl-fragcoord.html
webgl-conformance/conformance/glsl/variables/gl-frontfacing.html
webgl-conformance/conformance/glsl/variables/gl-pointcoord.html
webgl-conformance/conformance/limits/00_test_list.txt
webgl-conformance/conformance/limits/gl-max-texture-dimensions.html
webgl-conformance/conformance/limits/gl-min-attribs.html
webgl-conformance/conformance/limits/gl-min-textures.html
webgl-conformance/conformance/limits/gl-min-uniforms.html
webgl-conformance/conformance/misc/00_test_list.txt
webgl-conformance/conformance/misc/bad-arguments-test.html
webgl-conformance/conformance/misc/delayed-drawing.html
webgl-conformance/conformance/misc/error-reporting.html
webgl-conformance/conformance/misc/functions-returning-strings.html
webgl-conformance/conformance/misc/instanceof-test.html
webgl-conformance/conformance/misc/invalid-passed-params.html
webgl-conformance/conformance/misc/is-object.html
webgl-conformance/conformance/misc/null-object-behaviour.html
webgl-conformance/conformance/misc/object-deletion-behaviour.html
webgl-conformance/conformance/misc/shader-precision-format.html
webgl-conformance/conformance/misc/type-conversion-test.html
webgl-conformance/conformance/misc/uninitialized-test.html
webgl-conformance/conformance/misc/webgl-specific.html
webgl-conformance/conformance/more/00_test_list.txt
webgl-conformance/conformance/more/README.md
webgl-conformance/conformance/more/all_tests.html
webgl-conformance/conformance/more/all_tests_linkonly.html
webgl-conformance/conformance/more/all_tests_sequential.html
webgl-conformance/conformance/more/conformance/argGenerators-A.js
webgl-conformance/conformance/more/conformance/argGenerators-B1.js
webgl-conformance/conformance/more/conformance/argGenerators-B2.js
webgl-conformance/conformance/more/conformance/argGenerators-B3.js
webgl-conformance/conformance/more/conformance/argGenerators-B4.js
webgl-conformance/conformance/more/conformance/argGenerators-C.js
webgl-conformance/conformance/more/conformance/argGenerators-D_G.js
webgl-conformance/conformance/more/conformance/argGenerators-G_I.js
webgl-conformance/conformance/more/conformance/argGenerators-L_S.js
webgl-conformance/conformance/more/conformance/argGenerators-S_V.js
webgl-conformance/conformance/more/conformance/badArgsArityLessThanArgc.html
webgl-conformance/conformance/more/conformance/constants.html
webgl-conformance/conformance/more/conformance/fuzzTheAPI.html
webgl-conformance/conformance/more/conformance/getContext.html
webgl-conformance/conformance/more/conformance/methods.html
webgl-conformance/conformance/more/conformance/quickCheckAPI-A.html
webgl-conformance/conformance/more/conformance/quickCheckAPI-B1.html
webgl-conformance/conformance/more/conformance/quickCheckAPI-B2.html
webgl-conformance/conformance/more/conformance/quickCheckAPI-B3.html
webgl-conformance/conformance/more/conformance/quickCheckAPI-B4.html
webgl-conformance/conformance/more/conformance/quickCheckAPI-C.html
webgl-conformance/conformance/more/conformance/quickCheckAPI-D_G.html
webgl-conformance/conformance/more/conformance/quickCheckAPI-G_I.html
webgl-conformance/conformance/more/conformance/quickCheckAPI-L_S.html
webgl-conformance/conformance/more/conformance/quickCheckAPI-S_V.html
webgl-conformance/conformance/more/conformance/quickCheckAPI.js
webgl-conformance/conformance/more/conformance/quickCheckAPIBadArgs.html
webgl-conformance/conformance/more/conformance/webGLArrays.html
webgl-conformance/conformance/more/demos/opengl_web.html
webgl-conformance/conformance/more/demos/video.html
webgl-conformance/conformance/more/functions/bindBuffer.html
webgl-conformance/conformance/more/functions/bindBufferBadArgs.html
webgl-conformance/conformance/more/functions/bindFramebufferLeaveNonZero.html
webgl-conformance/conformance/more/functions/bufferData.html
webgl-conformance/conformance/more/functions/bufferDataBadArgs.html
webgl-conformance/conformance/more/functions/bufferSubData.html
webgl-conformance/conformance/more/functions/bufferSubDataBadArgs.html
webgl-conformance/conformance/more/functions/copyTexImage2D.html
webgl-conformance/conformance/more/functions/copyTexImage2DBadArgs.html
webgl-conformance/conformance/more/functions/copyTexSubImage2D.html
webgl-conformance/conformance/more/functions/copyTexSubImage2DBadArgs.html
webgl-conformance/conformance/more/functions/deleteBufferBadArgs.html
webgl-conformance/conformance/more/functions/drawArrays.html
webgl-conformance/conformance/more/functions/drawArraysOutOfBounds.html
webgl-conformance/conformance/more/functions/drawElements.html
webgl-conformance/conformance/more/functions/drawElementsBadArgs.html
webgl-conformance/conformance/more/functions/isTests.html
webgl-conformance/conformance/more/functions/readPixels.html
webgl-conformance/conformance/more/functions/readPixelsBadArgs.html
webgl-conformance/conformance/more/functions/texImage2D.html
webgl-conformance/conformance/more/functions/texImage2DBadArgs.html
webgl-conformance/conformance/more/functions/texImage2DHTML.html
webgl-conformance/conformance/more/functions/texImage2DHTMLBadArgs.html
webgl-conformance/conformance/more/functions/texSubImage2D.html
webgl-conformance/conformance/more/functions/texSubImage2DBadArgs.html
webgl-conformance/conformance/more/functions/texSubImage2DHTML.html
webgl-conformance/conformance/more/functions/texSubImage2DHTMLBadArgs.html
webgl-conformance/conformance/more/functions/uniformMatrix.html
webgl-conformance/conformance/more/functions/uniformMatrixBadArgs.html
webgl-conformance/conformance/more/functions/uniformf.html
webgl-conformance/conformance/more/functions/uniformfArrayLen1.html
webgl-conformance/conformance/more/functions/uniformfBadArgs.html
webgl-conformance/conformance/more/functions/uniformi.html
webgl-conformance/conformance/more/functions/uniformiBadArgs.html
webgl-conformance/conformance/more/functions/vertexAttrib.html
webgl-conformance/conformance/more/functions/vertexAttribBadArgs.html
webgl-conformance/conformance/more/functions/vertexAttribPointer.html
webgl-conformance/conformance/more/functions/vertexAttribPointerBadArgs.html
webgl-conformance/conformance/more/glsl/arrayOutOfBounds.html
webgl-conformance/conformance/more/glsl/longLoops.html
webgl-conformance/conformance/more/glsl/uniformOutOfBounds.html
webgl-conformance/conformance/more/glsl/unusedAttribsUniforms.html
webgl-conformance/conformance/more/index.html
webgl-conformance/conformance/more/performance/CPUvsGPU.html
webgl-conformance/conformance/more/performance/bandwidth.html
webgl-conformance/conformance/more/performance/jsGCPause.html
webgl-conformance/conformance/more/performance/jsMatrixMult.html
webgl-conformance/conformance/more/performance/jsToGLOverhead.html
webgl-conformance/conformance/more/unit.css
webgl-conformance/conformance/more/unit.js
webgl-conformance/conformance/more/util.js
webgl-conformance/conformance/programs/00_test_list.txt
webgl-conformance/conformance/programs/get-active-test.html
webgl-conformance/conformance/programs/gl-bind-attrib-location-test.html
webgl-conformance/conformance/programs/gl-get-active-attribute.html
webgl-conformance/conformance/programs/gl-get-active-uniform.html
webgl-conformance/conformance/programs/gl-getshadersource.html
webgl-conformance/conformance/programs/gl-shader-test.html
webgl-conformance/conformance/programs/invalid-UTF-16.html
webgl-conformance/conformance/programs/program-test.html
webgl-conformance/conformance/reading/00_test_list.txt
webgl-conformance/conformance/reading/read-pixels-pack-alignment.html
webgl-conformance/conformance/reading/read-pixels-test.html
webgl-conformance/conformance/renderbuffers/00_test_list.txt
webgl-conformance/conformance/renderbuffers/framebuffer-object-attachment.html
webgl-conformance/conformance/renderbuffers/framebuffer-test.html
webgl-conformance/conformance/renderbuffers/renderbuffer-initialization.html
webgl-conformance/conformance/rendering/00_test_list.txt
webgl-conformance/conformance/rendering/draw-arrays-out-of-bounds.html
webgl-conformance/conformance/rendering/draw-elements-out-of-bounds.html
webgl-conformance/conformance/rendering/gl-clear.html
webgl-conformance/conformance/rendering/gl-drawelements.html
webgl-conformance/conformance/rendering/gl-scissor-test.html
webgl-conformance/conformance/rendering/line-loop-tri-fan.html
webgl-conformance/conformance/rendering/more-than-65536-indices.html
webgl-conformance/conformance/rendering/point-size.html
webgl-conformance/conformance/rendering/triangle.html
webgl-conformance/conformance/resources/3x3.png
webgl-conformance/conformance/resources/blue-1x1.jpg
webgl-conformance/conformance/resources/boolUniformShader.vert
webgl-conformance/conformance/resources/bug-32888-texture.png
webgl-conformance/conformance/resources/floatUniformShader.vert
webgl-conformance/conformance/resources/fragmentShader.frag
webgl-conformance/conformance/resources/glsl-conformance-test.js
webgl-conformance/conformance/resources/glsl-feature-tests.css
webgl-conformance/conformance/resources/glsl-generator.js
webgl-conformance/conformance/resources/gray-ramp-256-with-128-alpha.png
webgl-conformance/conformance/resources/gray-ramp-256.png
webgl-conformance/conformance/resources/gray-ramp-default-gamma.png
webgl-conformance/conformance/resources/gray-ramp-gamma0.1.png
webgl-conformance/conformance/resources/gray-ramp-gamma1.0.png
webgl-conformance/conformance/resources/gray-ramp-gamma2.0.png
webgl-conformance/conformance/resources/gray-ramp-gamma4.0.png
webgl-conformance/conformance/resources/gray-ramp-gamma9.0.png
webgl-conformance/conformance/resources/gray-ramp.png
webgl-conformance/conformance/resources/green-2x2-16bit.png
webgl-conformance/conformance/resources/intArrayUniformShader.vert
webgl-conformance/conformance/resources/intUniformShader.vert
webgl-conformance/conformance/resources/matUniformShader.vert
webgl-conformance/conformance/resources/noopUniformShader.frag
webgl-conformance/conformance/resources/noopUniformShader.vert
webgl-conformance/conformance/resources/npot-video.mp4
webgl-conformance/conformance/resources/npot-video.theora.ogv
webgl-conformance/conformance/resources/npot-video.webmvp8.webm
webgl-conformance/conformance/resources/pnglib.js
webgl-conformance/conformance/resources/red-green.mp4
webgl-conformance/conformance/resources/red-green.png
webgl-conformance/conformance/resources/red-green.theora.ogv
webgl-conformance/conformance/resources/red-green.webmvp8.webm
webgl-conformance/conformance/resources/red-indexed.png
webgl-conformance/conformance/resources/samplerUniformShader.frag
webgl-conformance/conformance/resources/small-square-with-cie-rgb-profile.png
webgl-conformance/conformance/resources/small-square-with-colormatch-profile.png
webgl-conformance/conformance/resources/small-square-with-colorspin-profile.jpg
webgl-conformance/conformance/resources/small-square-with-colorspin-profile.png
webgl-conformance/conformance/resources/small-square-with-e-srgb-profile.png
webgl-conformance/conformance/resources/small-square-with-smpte-c-profile.png
webgl-conformance/conformance/resources/small-square-with-srgb-iec61966-2.1-profile.png
webgl-conformance/conformance/resources/structUniformShader.vert
webgl-conformance/conformance/resources/vertexShader.vert
webgl-conformance/conformance/resources/webgl-test-utils.js
webgl-conformance/conformance/resources/webgl-test.js
webgl-conformance/conformance/resources/zero-alpha.png
webgl-conformance/conformance/state/00_test_list.txt
webgl-conformance/conformance/state/gl-enable-enum-test.html
webgl-conformance/conformance/state/gl-enum-tests.html
webgl-conformance/conformance/state/gl-get-calls.html
webgl-conformance/conformance/state/gl-geterror.html
webgl-conformance/conformance/state/gl-getstring.html
webgl-conformance/conformance/state/gl-object-get-calls.html
webgl-conformance/conformance/textures/00_test_list.txt
webgl-conformance/conformance/textures/compressed-tex-image.html
webgl-conformance/conformance/textures/copy-tex-image-and-sub-image-2d.html
webgl-conformance/conformance/textures/gl-pixelstorei.html
webgl-conformance/conformance/textures/gl-teximage.html
webgl-conformance/conformance/textures/origin-clean-conformance.html
webgl-conformance/conformance/textures/tex-image-and-sub-image-2d-with-array-buffer-view.html
webgl-conformance/conformance/textures/tex-image-and-sub-image-2d-with-canvas.html
webgl-conformance/conformance/textures/tex-image-and-sub-image-2d-with-image-data.html
webgl-conformance/conformance/textures/tex-image-and-sub-image-2d-with-image.html
webgl-conformance/conformance/textures/tex-image-and-sub-image-2d-with-video.html
webgl-conformance/conformance/textures/tex-image-and-uniform-binding-bugs.html
webgl-conformance/conformance/textures/tex-image-with-format-and-type.html
webgl-conformance/conformance/textures/tex-image-with-invalid-data.html
webgl-conformance/conformance/textures/tex-input-validation.html
webgl-conformance/conformance/textures/tex-sub-image-2d-bad-args.html
webgl-conformance/conformance/textures/tex-sub-image-2d.html
webgl-conformance/conformance/textures/texparameter-test.html
webgl-conformance/conformance/textures/texture-active-bind-2.html
webgl-conformance/conformance/textures/texture-active-bind.html
webgl-conformance/conformance/textures/texture-clear.html
webgl-conformance/conformance/textures/texture-complete.html
webgl-conformance/conformance/textures/texture-formats-test.html
webgl-conformance/conformance/textures/texture-mips.html
webgl-conformance/conformance/textures/texture-npot-video.html
webgl-conformance/conformance/textures/texture-npot.html
webgl-conformance/conformance/textures/texture-size-cube-maps.html
webgl-conformance/conformance/textures/texture-size.html
webgl-conformance/conformance/textures/texture-transparent-pixels-initialized.html
webgl-conformance/conformance/typedarrays/00_test_list.txt
webgl-conformance/conformance/typedarrays/array-buffer-crash.html
webgl-conformance/conformance/typedarrays/array-buffer-view-crash.html
webgl-conformance/conformance/typedarrays/array-unit-tests.html
webgl-conformance/conformance/uniforms/00_test_list.txt
webgl-conformance/conformance/uniforms/gl-uniform-arrays.html
webgl-conformance/conformance/uniforms/gl-uniform-bool.html
webgl-conformance/conformance/uniforms/gl-uniformmatrix4fv.html
webgl-conformance/conformance/uniforms/gl-unknown-uniform.html
webgl-conformance/conformance/uniforms/null-uniform-location.html
webgl-conformance/conformance/uniforms/uniform-location.html
webgl-conformance/conformance/uniforms/uniform-samplers-test.html
webgl-conformance/iframe-autoresize.js
webgl-conformance/mochi-single.html
webgl-conformance/resources/cors-util.js
webgl-conformance/resources/desktop-gl-constants.js
webgl-conformance/resources/js-test-pre.js
webgl-conformance/resources/js-test-style.css
webgl-conformance/resources/opengl_logo.jpg
webgl-conformance/resources/thunderbird-logo-64x64.png
webgl-conformance/resources/webgl-logo.png
webgl-conformance/resources/webgl-test-harness.js
[webgl-conformance/_wrappers/test_always-fail.html]
[webgl-conformance/_wrappers/test_conformance__attribs__gl-enable-vertex-attrib.html]
[webgl-conformance/_wrappers/test_conformance__attribs__gl-vertex-attrib-zero-issues.html]
[webgl-conformance/_wrappers/test_conformance__attribs__gl-vertex-attrib.html]
[webgl-conformance/_wrappers/test_conformance__attribs__gl-vertexattribpointer-offsets.html]
[webgl-conformance/_wrappers/test_conformance__attribs__gl-vertexattribpointer.html]
[webgl-conformance/_wrappers/test_conformance__buffers__buffer-bind-test.html]
[webgl-conformance/_wrappers/test_conformance__buffers__buffer-data-array-buffer.html]
[webgl-conformance/_wrappers/test_conformance__buffers__index-validation-copies-indices.html]
[webgl-conformance/_wrappers/test_conformance__buffers__index-validation-crash-with-buffer-sub-data.html]
[webgl-conformance/_wrappers/test_conformance__buffers__index-validation-verifies-too-many-indices.html]
[webgl-conformance/_wrappers/test_conformance__buffers__index-validation-with-resized-buffer.html]
[webgl-conformance/_wrappers/test_conformance__buffers__index-validation.html]
[webgl-conformance/_wrappers/test_conformance__canvas__buffer-offscreen-test.html]
skip-if = os == 'android'
[webgl-conformance/_wrappers/test_conformance__canvas__buffer-preserve-test.html]
[webgl-conformance/_wrappers/test_conformance__canvas__canvas-test.html]
[webgl-conformance/_wrappers/test_conformance__canvas__canvas-zero-size.html]
[webgl-conformance/_wrappers/test_conformance__canvas__drawingbuffer-static-canvas-test.html]
skip-if = os == 'mac'
[webgl-conformance/_wrappers/test_conformance__canvas__drawingbuffer-test.html]
[webgl-conformance/_wrappers/test_conformance__canvas__viewport-unchanged-upon-resize.html]
skip-if = os == 'mac'
[webgl-conformance/_wrappers/test_conformance__context__constants.html]
[webgl-conformance/_wrappers/test_conformance__context__context-attributes-alpha-depth-stencil-antialias.html]
skip-if = (os == 'b2g')
[webgl-conformance/_wrappers/test_conformance__context__context-lost-restored.html]
[webgl-conformance/_wrappers/test_conformance__context__context-lost.html]
[webgl-conformance/_wrappers/test_conformance__context__context-type-test.html]
[webgl-conformance/_wrappers/test_conformance__context__incorrect-context-object-behaviour.html]
[webgl-conformance/_wrappers/test_conformance__context__methods.html]
[webgl-conformance/_wrappers/test_conformance__context__premultiplyalpha-test.html]
[webgl-conformance/_wrappers/test_conformance__context__resource-sharing-test.html]
[webgl-conformance/_wrappers/test_conformance__extensions__oes-standard-derivatives.html]
[webgl-conformance/_wrappers/test_conformance__extensions__ext-texture-filter-anisotropic.html]
[webgl-conformance/_wrappers/test_conformance__extensions__oes-texture-float.html]
skip-if = (os == 'linux')
[webgl-conformance/_wrappers/test_conformance__extensions__oes-vertex-array-object.html]
[webgl-conformance/_wrappers/test_conformance__extensions__webgl-debug-renderer-info.html]
[webgl-conformance/_wrappers/test_conformance__extensions__webgl-debug-shaders.html]
[webgl-conformance/_wrappers/test_conformance__extensions__webgl-compressed-texture-etc1.html]
[webgl-conformance/_wrappers/test_conformance__extensions__webgl-compressed-texture-s3tc.html]
[webgl-conformance/_wrappers/test_conformance__extensions__ext-sRGB.html]
[webgl-conformance/_wrappers/test_conformance__extensions__ext-shader-texture-lod.html]
[webgl-conformance/_wrappers/test_conformance__glsl__functions__glsl-function.html]
[webgl-conformance/_wrappers/test_conformance__glsl__functions__glsl-function-abs.html]
[webgl-conformance/_wrappers/test_conformance__glsl__functions__glsl-function-acos.html]
[webgl-conformance/_wrappers/test_conformance__glsl__functions__glsl-function-asin.html]
[webgl-conformance/_wrappers/test_conformance__glsl__functions__glsl-function-atan.html]
[webgl-conformance/_wrappers/test_conformance__glsl__functions__glsl-function-atan-xy.html]
[webgl-conformance/_wrappers/test_conformance__glsl__functions__glsl-function-ceil.html]
[webgl-conformance/_wrappers/test_conformance__glsl__functions__glsl-function-clamp-float.html]
[webgl-conformance/_wrappers/test_conformance__glsl__functions__glsl-function-clamp-gentype.html]
[webgl-conformance/_wrappers/test_conformance__glsl__functions__glsl-function-cos.html]
[webgl-conformance/_wrappers/test_conformance__glsl__functions__glsl-function-cross.html]
[webgl-conformance/_wrappers/test_conformance__glsl__functions__glsl-function-distance.html]
[webgl-conformance/_wrappers/test_conformance__glsl__functions__glsl-function-dot.html]
[webgl-conformance/_wrappers/test_conformance__glsl__functions__glsl-function-faceforward.html]
[webgl-conformance/_wrappers/test_conformance__glsl__functions__glsl-function-floor.html]
[webgl-conformance/_wrappers/test_conformance__glsl__functions__glsl-function-fract.html]
[webgl-conformance/_wrappers/test_conformance__glsl__functions__glsl-function-length.html]
[webgl-conformance/_wrappers/test_conformance__glsl__functions__glsl-function-max-float.html]
[webgl-conformance/_wrappers/test_conformance__glsl__functions__glsl-function-max-gentype.html]
[webgl-conformance/_wrappers/test_conformance__glsl__functions__glsl-function-min-float.html]
[webgl-conformance/_wrappers/test_conformance__glsl__functions__glsl-function-min-gentype.html]
[webgl-conformance/_wrappers/test_conformance__glsl__functions__glsl-function-mix-float.html]
[webgl-conformance/_wrappers/test_conformance__glsl__functions__glsl-function-mix-gentype.html]
[webgl-conformance/_wrappers/test_conformance__glsl__functions__glsl-function-mod-float.html]
[webgl-conformance/_wrappers/test_conformance__glsl__functions__glsl-function-mod-gentype.html]
[webgl-conformance/_wrappers/test_conformance__glsl__functions__glsl-function-normalize.html]
[webgl-conformance/_wrappers/test_conformance__glsl__functions__glsl-function-reflect.html]
[webgl-conformance/_wrappers/test_conformance__glsl__functions__glsl-function-sign.html]
[webgl-conformance/_wrappers/test_conformance__glsl__functions__glsl-function-sin.html]
[webgl-conformance/_wrappers/test_conformance__glsl__functions__glsl-function-step-float.html]
[webgl-conformance/_wrappers/test_conformance__glsl__functions__glsl-function-step-gentype.html]
[webgl-conformance/_wrappers/test_conformance__glsl__functions__glsl-function-smoothstep-float.html]
[webgl-conformance/_wrappers/test_conformance__glsl__functions__glsl-function-smoothstep-gentype.html]
[webgl-conformance/_wrappers/test_conformance__glsl__implicit__add_int_float.vert.html]
[webgl-conformance/_wrappers/test_conformance__glsl__implicit__add_int_mat2.vert.html]
[webgl-conformance/_wrappers/test_conformance__glsl__implicit__add_int_mat3.vert.html]
[webgl-conformance/_wrappers/test_conformance__glsl__implicit__add_int_mat4.vert.html]
[webgl-conformance/_wrappers/test_conformance__glsl__implicit__add_int_vec2.vert.html]
[webgl-conformance/_wrappers/test_conformance__glsl__implicit__add_int_vec3.vert.html]
[webgl-conformance/_wrappers/test_conformance__glsl__implicit__add_int_vec4.vert.html]
[webgl-conformance/_wrappers/test_conformance__glsl__implicit__add_ivec2_vec2.vert.html]
[webgl-conformance/_wrappers/test_conformance__glsl__implicit__add_ivec3_vec3.vert.html]
[webgl-conformance/_wrappers/test_conformance__glsl__implicit__add_ivec4_vec4.vert.html]
[webgl-conformance/_wrappers/test_conformance__glsl__implicit__assign_int_to_float.vert.html]
[webgl-conformance/_wrappers/test_conformance__glsl__implicit__assign_ivec2_to_vec2.vert.html]
[webgl-conformance/_wrappers/test_conformance__glsl__implicit__assign_ivec3_to_vec3.vert.html]
[webgl-conformance/_wrappers/test_conformance__glsl__implicit__assign_ivec4_to_vec4.vert.html]
[webgl-conformance/_wrappers/test_conformance__glsl__implicit__construct_struct.vert.html]
[webgl-conformance/_wrappers/test_conformance__glsl__implicit__divide_int_float.vert.html]
[webgl-conformance/_wrappers/test_conformance__glsl__implicit__divide_int_mat2.vert.html]
[webgl-conformance/_wrappers/test_conformance__glsl__implicit__divide_int_mat3.vert.html]
[webgl-conformance/_wrappers/test_conformance__glsl__implicit__divide_int_mat4.vert.html]
[webgl-conformance/_wrappers/test_conformance__glsl__implicit__divide_int_vec2.vert.html]
[webgl-conformance/_wrappers/test_conformance__glsl__implicit__divide_int_vec3.vert.html]
[webgl-conformance/_wrappers/test_conformance__glsl__implicit__divide_int_vec4.vert.html]
[webgl-conformance/_wrappers/test_conformance__glsl__implicit__divide_ivec2_vec2.vert.html]
[webgl-conformance/_wrappers/test_conformance__glsl__implicit__divide_ivec3_vec3.vert.html]
[webgl-conformance/_wrappers/test_conformance__glsl__implicit__divide_ivec4_vec4.vert.html]
[webgl-conformance/_wrappers/test_conformance__glsl__implicit__equal_int_float.vert.html]
[webgl-conformance/_wrappers/test_conformance__glsl__implicit__equal_ivec2_vec2.vert.html]
[webgl-conformance/_wrappers/test_conformance__glsl__implicit__equal_ivec3_vec3.vert.html]
[webgl-conformance/_wrappers/test_conformance__glsl__implicit__equal_ivec4_vec4.vert.html]
[webgl-conformance/_wrappers/test_conformance__glsl__implicit__function_int_float.vert.html]
[webgl-conformance/_wrappers/test_conformance__glsl__implicit__function_ivec2_vec2.vert.html]
[webgl-conformance/_wrappers/test_conformance__glsl__implicit__function_ivec3_vec3.vert.html]
[webgl-conformance/_wrappers/test_conformance__glsl__implicit__function_ivec4_vec4.vert.html]
[webgl-conformance/_wrappers/test_conformance__glsl__implicit__greater_than.vert.html]
[webgl-conformance/_wrappers/test_conformance__glsl__implicit__greater_than_equal.vert.html]
[webgl-conformance/_wrappers/test_conformance__glsl__implicit__less_than.vert.html]
[webgl-conformance/_wrappers/test_conformance__glsl__implicit__less_than_equal.vert.html]
[webgl-conformance/_wrappers/test_conformance__glsl__implicit__multiply_int_float.vert.html]
[webgl-conformance/_wrappers/test_conformance__glsl__implicit__multiply_int_mat2.vert.html]
[webgl-conformance/_wrappers/test_conformance__glsl__implicit__multiply_int_mat3.vert.html]
[webgl-conformance/_wrappers/test_conformance__glsl__implicit__multiply_int_mat4.vert.html]
[webgl-conformance/_wrappers/test_conformance__glsl__implicit__multiply_int_vec2.vert.html]
[webgl-conformance/_wrappers/test_conformance__glsl__implicit__multiply_int_vec3.vert.html]
[webgl-conformance/_wrappers/test_conformance__glsl__implicit__multiply_int_vec4.vert.html]
[webgl-conformance/_wrappers/test_conformance__glsl__implicit__multiply_ivec2_vec2.vert.html]
[webgl-conformance/_wrappers/test_conformance__glsl__implicit__multiply_ivec3_vec3.vert.html]
[webgl-conformance/_wrappers/test_conformance__glsl__implicit__multiply_ivec4_vec4.vert.html]
[webgl-conformance/_wrappers/test_conformance__glsl__implicit__not_equal_int_float.vert.html]
[webgl-conformance/_wrappers/test_conformance__glsl__implicit__not_equal_ivec2_vec2.vert.html]
[webgl-conformance/_wrappers/test_conformance__glsl__implicit__not_equal_ivec3_vec3.vert.html]
[webgl-conformance/_wrappers/test_conformance__glsl__implicit__not_equal_ivec4_vec4.vert.html]
[webgl-conformance/_wrappers/test_conformance__glsl__implicit__subtract_int_float.vert.html]
[webgl-conformance/_wrappers/test_conformance__glsl__implicit__subtract_int_mat2.vert.html]
[webgl-conformance/_wrappers/test_conformance__glsl__implicit__subtract_int_mat3.vert.html]
[webgl-conformance/_wrappers/test_conformance__glsl__implicit__subtract_int_mat4.vert.html]
[webgl-conformance/_wrappers/test_conformance__glsl__implicit__subtract_int_vec2.vert.html]
[webgl-conformance/_wrappers/test_conformance__glsl__implicit__subtract_int_vec3.vert.html]
[webgl-conformance/_wrappers/test_conformance__glsl__implicit__subtract_int_vec4.vert.html]
[webgl-conformance/_wrappers/test_conformance__glsl__implicit__subtract_ivec2_vec2.vert.html]
[webgl-conformance/_wrappers/test_conformance__glsl__implicit__subtract_ivec3_vec3.vert.html]
[webgl-conformance/_wrappers/test_conformance__glsl__implicit__subtract_ivec4_vec4.vert.html]
[webgl-conformance/_wrappers/test_conformance__glsl__implicit__ternary_int_float.vert.html]
[webgl-conformance/_wrappers/test_conformance__glsl__implicit__ternary_ivec2_vec2.vert.html]
[webgl-conformance/_wrappers/test_conformance__glsl__implicit__ternary_ivec3_vec3.vert.html]
[webgl-conformance/_wrappers/test_conformance__glsl__implicit__ternary_ivec4_vec4.vert.html]
[webgl-conformance/_wrappers/test_conformance__glsl__misc__attrib-location-length-limits.html]
[webgl-conformance/_wrappers/test_conformance__glsl__misc__embedded-struct-definitions-forbidden.html]
[webgl-conformance/_wrappers/test_conformance__glsl__misc__glsl-function-nodes.html]
[webgl-conformance/_wrappers/test_conformance__glsl__misc__glsl-long-variable-names.html]
[webgl-conformance/_wrappers/test_conformance__glsl__misc__non-ascii-comments.vert.html]
[webgl-conformance/_wrappers/test_conformance__glsl__misc__non-ascii.vert.html]
[webgl-conformance/_wrappers/test_conformance__glsl__misc__shader-with-256-character-identifier.frag.html]
[webgl-conformance/_wrappers/test_conformance__glsl__misc__shader-with-257-character-identifier.frag.html]
[webgl-conformance/_wrappers/test_conformance__glsl__misc__shader-with-_webgl-identifier.vert.html]
[webgl-conformance/_wrappers/test_conformance__glsl__misc__shader-with-arbitrary-indexing.frag.html]
[webgl-conformance/_wrappers/test_conformance__glsl__misc__shader-with-arbitrary-indexing.vert.html]
[webgl-conformance/_wrappers/test_conformance__glsl__misc__shader-with-attrib-array.vert.html]
[webgl-conformance/_wrappers/test_conformance__glsl__misc__shader-with-attrib-struct.vert.html]
[webgl-conformance/_wrappers/test_conformance__glsl__misc__shader-with-clipvertex.vert.html]
[webgl-conformance/_wrappers/test_conformance__glsl__misc__shader-with-default-precision.frag.html]
[webgl-conformance/_wrappers/test_conformance__glsl__misc__shader-with-default-precision.vert.html]
[webgl-conformance/_wrappers/test_conformance__glsl__misc__shader-with-define-line-continuation.frag.html]
[webgl-conformance/_wrappers/test_conformance__glsl__misc__shader-with-dfdx-no-ext.frag.html]
[webgl-conformance/_wrappers/test_conformance__glsl__misc__shader-with-dfdx.frag.html]
[webgl-conformance/_wrappers/test_conformance__glsl__misc__shader-with-error-directive.html]
[webgl-conformance/_wrappers/test_conformance__glsl__misc__shader-with-explicit-int-cast.vert.html]
[webgl-conformance/_wrappers/test_conformance__glsl__misc__shader-with-float-return-value.frag.html]
[webgl-conformance/_wrappers/test_conformance__glsl__misc__shader-with-frag-depth.frag.html]
[webgl-conformance/_wrappers/test_conformance__glsl__misc__shader-with-function-recursion.frag.html]
[webgl-conformance/_wrappers/test_conformance__glsl__misc__shader-with-glcolor.vert.html]
[webgl-conformance/_wrappers/test_conformance__glsl__misc__shader-with-gles-1.frag.html]
[webgl-conformance/_wrappers/test_conformance__glsl__misc__shader-with-gles-symbol.frag.html]
[webgl-conformance/_wrappers/test_conformance__glsl__misc__shader-with-glprojectionmatrix.vert.html]
[webgl-conformance/_wrappers/test_conformance__glsl__misc__shader-with-implicit-vec3-to-vec4-cast.vert.html]
[webgl-conformance/_wrappers/test_conformance__glsl__misc__shader-with-include.vert.html]
[webgl-conformance/_wrappers/test_conformance__glsl__misc__shader-with-int-return-value.frag.html]
[webgl-conformance/_wrappers/test_conformance__glsl__misc__shader-with-invalid-identifier.frag.html]
[webgl-conformance/_wrappers/test_conformance__glsl__misc__shader-with-ivec2-return-value.frag.html]
[webgl-conformance/_wrappers/test_conformance__glsl__misc__shader-with-ivec3-return-value.frag.html]
[webgl-conformance/_wrappers/test_conformance__glsl__misc__shader-with-ivec4-return-value.frag.html]
[webgl-conformance/_wrappers/test_conformance__glsl__misc__shader-with-limited-indexing.frag.html]
[webgl-conformance/_wrappers/test_conformance__glsl__misc__shader-with-long-line.html]
[webgl-conformance/_wrappers/test_conformance__glsl__misc__shader-with-non-ascii-error.frag.html]
[webgl-conformance/_wrappers/test_conformance__glsl__misc__shader-with-precision.frag.html]
[webgl-conformance/_wrappers/test_conformance__glsl__misc__shader-with-quoted-error.frag.html]
[webgl-conformance/_wrappers/test_conformance__glsl__misc__shader-with-undefined-preprocessor-symbol.frag.html]
[webgl-conformance/_wrappers/test_conformance__glsl__misc__shader-with-uniform-in-loop-condition.vert.html]
[webgl-conformance/_wrappers/test_conformance__glsl__misc__shader-with-vec2-return-value.frag.html]
[webgl-conformance/_wrappers/test_conformance__glsl__misc__shader-with-vec3-return-value.frag.html]
[webgl-conformance/_wrappers/test_conformance__glsl__misc__shader-with-vec4-return-value.frag.html]
[webgl-conformance/_wrappers/test_conformance__glsl__misc__shader-with-version-100.frag.html]
[webgl-conformance/_wrappers/test_conformance__glsl__misc__shader-with-version-100.vert.html]
[webgl-conformance/_wrappers/test_conformance__glsl__misc__shader-with-version-120.vert.html]
[webgl-conformance/_wrappers/test_conformance__glsl__misc__shader-with-version-130.vert.html]
[webgl-conformance/_wrappers/test_conformance__glsl__misc__shader-with-webgl-identifier.vert.html]
[webgl-conformance/_wrappers/test_conformance__glsl__misc__shader-without-precision.frag.html]
[webgl-conformance/_wrappers/test_conformance__glsl__misc__shared.html]
[webgl-conformance/_wrappers/test_conformance__glsl__misc__struct-nesting-exceeds-maximum.html]
[webgl-conformance/_wrappers/test_conformance__glsl__misc__struct-nesting-under-maximum.html]
[webgl-conformance/_wrappers/test_conformance__glsl__misc__uniform-location-length-limits.html]
[webgl-conformance/_wrappers/test_conformance__glsl__reserved___webgl_field.vert.html]
[webgl-conformance/_wrappers/test_conformance__glsl__reserved___webgl_function.vert.html]
[webgl-conformance/_wrappers/test_conformance__glsl__reserved___webgl_struct.vert.html]
[webgl-conformance/_wrappers/test_conformance__glsl__reserved___webgl_variable.vert.html]
[webgl-conformance/_wrappers/test_conformance__glsl__reserved__webgl_field.vert.html]
[webgl-conformance/_wrappers/test_conformance__glsl__reserved__webgl_function.vert.html]
[webgl-conformance/_wrappers/test_conformance__glsl__reserved__webgl_struct.vert.html]
[webgl-conformance/_wrappers/test_conformance__glsl__reserved__webgl_variable.vert.html]
[webgl-conformance/_wrappers/test_conformance__glsl__variables__gl-fragcoord.html]
[webgl-conformance/_wrappers/test_conformance__glsl__variables__gl-frontfacing.html]
[webgl-conformance/_wrappers/test_conformance__glsl__variables__gl-pointcoord.html]
[webgl-conformance/_wrappers/test_conformance__limits__gl-min-attribs.html]
[webgl-conformance/_wrappers/test_conformance__limits__gl-max-texture-dimensions.html]
[webgl-conformance/_wrappers/test_conformance__limits__gl-min-textures.html]
skip-if = (os == 'linux')
[webgl-conformance/_wrappers/test_conformance__limits__gl-min-uniforms.html]
[webgl-conformance/_wrappers/test_conformance__misc__bad-arguments-test.html]
[webgl-conformance/_wrappers/test_conformance__misc__error-reporting.html]
[webgl-conformance/_wrappers/test_conformance__misc__instanceof-test.html]
[webgl-conformance/_wrappers/test_conformance__misc__invalid-passed-params.html]
skip-if = (os == 'android') || (os == 'b2g') || (os == 'linux')
[webgl-conformance/_wrappers/test_conformance__misc__is-object.html]
[webgl-conformance/_wrappers/test_conformance__misc__null-object-behaviour.html]
[webgl-conformance/_wrappers/test_conformance__misc__functions-returning-strings.html]
[webgl-conformance/_wrappers/test_conformance__misc__object-deletion-behaviour.html]
[webgl-conformance/_wrappers/test_conformance__misc__shader-precision-format.html]
[webgl-conformance/_wrappers/test_conformance__misc__type-conversion-test.html]
skip-if = (os == 'android') || (os == 'b2g') || (os == 'linux')
[webgl-conformance/_wrappers/test_conformance__misc__uninitialized-test.html]
skip-if = os == 'android'
[webgl-conformance/_wrappers/test_conformance__misc__webgl-specific.html]
[webgl-conformance/_wrappers/test_conformance__programs__get-active-test.html]
[webgl-conformance/_wrappers/test_conformance__programs__gl-bind-attrib-location-test.html]
[webgl-conformance/_wrappers/test_conformance__programs__gl-get-active-attribute.html]
[webgl-conformance/_wrappers/test_conformance__programs__gl-get-active-uniform.html]
[webgl-conformance/_wrappers/test_conformance__programs__gl-getshadersource.html]
[webgl-conformance/_wrappers/test_conformance__programs__gl-shader-test.html]
[webgl-conformance/_wrappers/test_conformance__programs__invalid-UTF-16.html]
[webgl-conformance/_wrappers/test_conformance__programs__program-test.html]
[webgl-conformance/_wrappers/test_conformance__reading__read-pixels-pack-alignment.html]
[webgl-conformance/_wrappers/test_conformance__reading__read-pixels-test.html]
skip-if = (os == 'android') || (os == 'b2g') || (os == 'linux')
[webgl-conformance/_wrappers/test_conformance__renderbuffers__framebuffer-object-attachment.html]
skip-if = os == 'android'
[webgl-conformance/_wrappers/test_conformance__renderbuffers__framebuffer-test.html]
[webgl-conformance/_wrappers/test_conformance__renderbuffers__renderbuffer-initialization.html]
[webgl-conformance/_wrappers/test_conformance__rendering__draw-arrays-out-of-bounds.html]
[webgl-conformance/_wrappers/test_conformance__rendering__draw-elements-out-of-bounds.html]
[webgl-conformance/_wrappers/test_conformance__rendering__gl-clear.html]
[webgl-conformance/_wrappers/test_conformance__rendering__gl-drawelements.html]
[webgl-conformance/_wrappers/test_conformance__rendering__gl-scissor-test.html]
[webgl-conformance/_wrappers/test_conformance__rendering__more-than-65536-indices.html]
[webgl-conformance/_wrappers/test_conformance__rendering__point-size.html]
[webgl-conformance/_wrappers/test_conformance__rendering__triangle.html]
[webgl-conformance/_wrappers/test_conformance__rendering__line-loop-tri-fan.html]
[webgl-conformance/_wrappers/test_conformance__state__gl-enable-enum-test.html]
[webgl-conformance/_wrappers/test_conformance__state__gl-enum-tests.html]
[webgl-conformance/_wrappers/test_conformance__state__gl-get-calls.html]
[webgl-conformance/_wrappers/test_conformance__state__gl-geterror.html]
[webgl-conformance/_wrappers/test_conformance__state__gl-getstring.html]
[webgl-conformance/_wrappers/test_conformance__state__gl-object-get-calls.html]
[webgl-conformance/_wrappers/test_conformance__textures__compressed-tex-image.html]
[webgl-conformance/_wrappers/test_conformance__textures__copy-tex-image-and-sub-image-2d.html]
[webgl-conformance/_wrappers/test_conformance__textures__gl-pixelstorei.html]
[webgl-conformance/_wrappers/test_conformance__textures__gl-teximage.html]
skip-if = (os == 'android') || (os == 'b2g') || (os == 'linux')
[webgl-conformance/_wrappers/test_conformance__textures__origin-clean-conformance.html]
[webgl-conformance/_wrappers/test_conformance__textures__tex-image-and-sub-image-2d-with-array-buffer-view.html]
[webgl-conformance/_wrappers/test_conformance__textures__tex-image-and-sub-image-2d-with-canvas.html]
[webgl-conformance/_wrappers/test_conformance__textures__tex-image-and-sub-image-2d-with-image-data.html]
[webgl-conformance/_wrappers/test_conformance__textures__tex-image-and-sub-image-2d-with-image.html]
[webgl-conformance/_wrappers/test_conformance__textures__tex-image-and-sub-image-2d-with-video.html]
skip-if = (os == 'android') || (os == 'b2g') || (os == 'linux') || (os == 'win')
[webgl-conformance/_wrappers/test_conformance__textures__tex-image-and-uniform-binding-bugs.html]
skip-if = (os == 'b2g')
[webgl-conformance/_wrappers/test_conformance__textures__tex-image-with-format-and-type.html]
skip-if = (os == 'android') || (os == 'b2g') || (os == 'linux')
[webgl-conformance/_wrappers/test_conformance__textures__tex-image-with-invalid-data.html]
[webgl-conformance/_wrappers/test_conformance__textures__tex-input-validation.html]
skip-if = (os == 'android') || (os == 'b2g') || (os == 'linux')
[webgl-conformance/_wrappers/test_conformance__textures__tex-sub-image-2d-bad-args.html]
[webgl-conformance/_wrappers/test_conformance__textures__tex-sub-image-2d.html]
[webgl-conformance/_wrappers/test_conformance__textures__texparameter-test.html]
[webgl-conformance/_wrappers/test_conformance__textures__texture-active-bind-2.html]
[webgl-conformance/_wrappers/test_conformance__textures__texture-active-bind.html]
[webgl-conformance/_wrappers/test_conformance__textures__texture-complete.html]
[webgl-conformance/_wrappers/test_conformance__textures__texture-formats-test.html]
[webgl-conformance/_wrappers/test_conformance__textures__texture-mips.html]
skip-if = (os == 'linux')
[webgl-conformance/_wrappers/test_conformance__textures__texture-npot-video.html]
skip-if = (os == 'android') || (os == 'win')
[webgl-conformance/_wrappers/test_conformance__textures__texture-npot.html]
skip-if = os == 'android'
[webgl-conformance/_wrappers/test_conformance__textures__texture-size.html]
skip-if = os == 'android'
[webgl-conformance/_wrappers/test_conformance__textures__texture-size-cube-maps.html]
skip-if = (os == 'android') || (os == 'linux')
[webgl-conformance/_wrappers/test_conformance__textures__texture-transparent-pixels-initialized.html]
[webgl-conformance/_wrappers/test_conformance__typedarrays__array-buffer-crash.html]
[webgl-conformance/_wrappers/test_conformance__typedarrays__array-buffer-view-crash.html]
[webgl-conformance/_wrappers/test_conformance__typedarrays__array-unit-tests.html]
[webgl-conformance/_wrappers/test_conformance__uniforms__gl-uniform-arrays.html]
[webgl-conformance/_wrappers/test_conformance__uniforms__gl-uniform-bool.html]
[webgl-conformance/_wrappers/test_conformance__uniforms__gl-uniformmatrix4fv.html]
[webgl-conformance/_wrappers/test_conformance__uniforms__gl-unknown-uniform.html]
[webgl-conformance/_wrappers/test_conformance__uniforms__null-uniform-location.html]
[webgl-conformance/_wrappers/test_conformance__uniforms__uniform-location.html]
[webgl-conformance/_wrappers/test_conformance__uniforms__uniform-samplers-test.html]
[webgl-conformance/_wrappers/test_conformance__more__conformance__constants.html]
[webgl-conformance/_wrappers/test_conformance__more__conformance__getContext.html]
[webgl-conformance/_wrappers/test_conformance__more__conformance__methods.html]
[webgl-conformance/_wrappers/test_conformance__more__conformance__quickCheckAPI-A.html]
[webgl-conformance/_wrappers/test_conformance__more__conformance__quickCheckAPI-B1.html]
[webgl-conformance/_wrappers/test_conformance__more__conformance__quickCheckAPI-B2.html]
[webgl-conformance/_wrappers/test_conformance__more__conformance__quickCheckAPI-B3.html]
[webgl-conformance/_wrappers/test_conformance__more__conformance__quickCheckAPI-B4.html]
[webgl-conformance/_wrappers/test_conformance__more__conformance__quickCheckAPI-C.html]
[webgl-conformance/_wrappers/test_conformance__more__conformance__quickCheckAPI-D_G.html]
[webgl-conformance/_wrappers/test_conformance__more__conformance__quickCheckAPI-G_I.html]
[webgl-conformance/_wrappers/test_conformance__more__conformance__quickCheckAPI-L_S.html]
[webgl-conformance/_wrappers/test_conformance__more__conformance__quickCheckAPI-S_V.html]
[webgl-conformance/_wrappers/test_conformance__more__conformance__webGLArrays.html]
[webgl-conformance/_wrappers/test_conformance__more__functions__bindBuffer.html]
[webgl-conformance/_wrappers/test_conformance__more__functions__bindBufferBadArgs.html]
[webgl-conformance/_wrappers/test_conformance__more__functions__bindFramebufferLeaveNonZero.html]
[webgl-conformance/_wrappers/test_conformance__more__functions__bufferData.html]
[webgl-conformance/_wrappers/test_conformance__more__functions__bufferDataBadArgs.html]
[webgl-conformance/_wrappers/test_conformance__more__functions__bufferSubData.html]
[webgl-conformance/_wrappers/test_conformance__more__functions__bufferSubDataBadArgs.html]
[webgl-conformance/_wrappers/test_conformance__more__functions__copyTexImage2D.html]
[webgl-conformance/_wrappers/test_conformance__more__functions__copyTexImage2DBadArgs.html]
[webgl-conformance/_wrappers/test_conformance__more__functions__copyTexSubImage2D.html]
[webgl-conformance/_wrappers/test_conformance__more__functions__copyTexSubImage2DBadArgs.html]
[webgl-conformance/_wrappers/test_conformance__more__functions__deleteBufferBadArgs.html]
[webgl-conformance/_wrappers/test_conformance__more__functions__drawArrays.html]
[webgl-conformance/_wrappers/test_conformance__more__functions__drawArraysOutOfBounds.html]
[webgl-conformance/_wrappers/test_conformance__more__functions__drawElements.html]
[webgl-conformance/_wrappers/test_conformance__more__functions__drawElementsBadArgs.html]
[webgl-conformance/_wrappers/test_conformance__more__functions__isTests.html]
[webgl-conformance/_wrappers/test_conformance__more__functions__readPixels.html]
[webgl-conformance/_wrappers/test_conformance__more__functions__readPixelsBadArgs.html]
[webgl-conformance/_wrappers/test_conformance__more__functions__texImage2D.html]
[webgl-conformance/_wrappers/test_conformance__more__functions__texImage2DBadArgs.html]
[webgl-conformance/_wrappers/test_conformance__more__functions__texImage2DHTML.html]
[webgl-conformance/_wrappers/test_conformance__more__functions__texImage2DHTMLBadArgs.html]
[webgl-conformance/_wrappers/test_conformance__more__functions__texSubImage2D.html]
[webgl-conformance/_wrappers/test_conformance__more__functions__texSubImage2DBadArgs.html]
[webgl-conformance/_wrappers/test_conformance__more__functions__texSubImage2DHTML.html]
[webgl-conformance/_wrappers/test_conformance__more__functions__texSubImage2DHTMLBadArgs.html]
[webgl-conformance/_wrappers/test_conformance__more__functions__uniformf.html]
[webgl-conformance/_wrappers/test_conformance__more__functions__uniformfBadArgs.html]
[webgl-conformance/_wrappers/test_conformance__more__functions__uniformfArrayLen1.html]
[webgl-conformance/_wrappers/test_conformance__more__functions__uniformi.html]
[webgl-conformance/_wrappers/test_conformance__more__functions__uniformiBadArgs.html]
[webgl-conformance/_wrappers/test_conformance__more__functions__uniformMatrix.html]
[webgl-conformance/_wrappers/test_conformance__more__functions__uniformMatrixBadArgs.html]
[webgl-conformance/_wrappers/test_conformance__more__functions__vertexAttrib.html]
[webgl-conformance/_wrappers/test_conformance__more__functions__vertexAttribBadArgs.html]
[webgl-conformance/_wrappers/test_conformance__more__functions__vertexAttribPointer.html]
[webgl-conformance/_wrappers/test_conformance__more__functions__vertexAttribPointerBadArgs.html]
[webgl-conformance/_wrappers/test_conformance__more__glsl__arrayOutOfBounds.html]
[webgl-conformance/_wrappers/test_conformance__more__glsl__uniformOutOfBounds.html]

Просмотреть файл

@ -0,0 +1,20 @@
<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8'>
<link rel='stylesheet' href='checkout/resources/js-test-style.css'/>
<script src='checkout/resources/js-test-pre.js'></script>
</head>
<body>
<div id='description'></div>
<div id='console'></div>
<script>
description('Deliberately fail so as to test our harness.');
testFailed('The harness should expect and handle this failure.');
finishTest();
</script>
</body>
</html>

Просмотреть файл

@ -0,0 +1,6 @@
// files that end in .txt list other tests
// other lines are assumed to be .html files
conformance/00_test_list.txt
conformance/more/00_test_list.txt

Просмотреть файл

@ -0,0 +1,132 @@
Rules for Claiming a Conformant WebGL Implementation
====================================================
The WebGL API is a web standard, and many web browser implementers
deliver their browser on multiple operating systems (OSs). WebGL
implementations also typically rely on the presence of an OpenGL or
OpenGL ES implementation on the OS. It can be appreciated that a WebGL
implementation therefore has many dependencies. This document attempts
to clarify to potential implementers the rules the Khronos Group uses
to judge whether a particular WebGL implementation is conformant.
There are two primary reasons to submit conformance results:
A) A web browser implementer desires to certify their WebGL
implementation as conformant.
B) A GPU manufacturer delivering an embedded system including web
browser with WebGL support desires to certify their WebGL
implementation as conformant.
Each of these situations carries different constraints, so the
conformance rules are phrased differently for each. Typically, a web
browser implementer aims to certify that the WebGL "layer" is correct.
A GPU vendor typically aims to certify that a given device is
physically capable of passing the tests.
A newly-developed WebGL implementation should not support the "webgl"
HTML Canvas context type by default in a shipping version of the
product until reaching conformance. It is acceptable to give end users
an option to turn on WebGL support in a non-conformant implementation
as long as the documentation for that option clearly indicates that
the implementation is not yet conformant and may have compatibility
issues. It is suggested that the Canvas context type
"experimental-webgl" may be supported by default in such
implementations.
A WebGL implementation might reach conformance, but a subsequent
graphics driver release on a particular OS might introduce a
regression causing failures of one or more of the WebGL conformance
tests. In this situation it is not required to revoke support for the
"webgl" HTML Canvas context type. The WebGL implementer should work
with the GPU vendor to ensure the driver regression is fixed. A
situation like this would, however, prevent the WebGL implementer from
conforming to a subsequent version of the test suite.
(A) Conformance Rules for a Web Browser Implementer
===================================================
1. Conformance on a particular operating system
On a given OS, a WebGL implementation will be considered to conform to
a particular version of the conformance suite if the suite passes with
no test failures on at least two GPUs, each from a different
vendor. If the OS only supports a GPU from one vendor, the two-GPU
requirement is dropped.
2. Conformance across multiple operating systems
A WebGL implementation will be considered to conform to a particular
version of the conformance suite if it passes rule (1) on all of the
OSs on which the WebGL implementation is intended to be supported.
3. Conformance as the web browser is upgraded
WebGL conformance results submitted for an earlier version of the
browser carry forward to later versions of the browser, unless the
WebGL implementation changes substantially enough that it is expected
that conformance may have been affected. In that case, the browser
implementer should submit new conformance results.
4. Conformance as the operating system is upgraded
If a new version is released of one of the OSs on which a WebGL
implementation is intended to run, then WebGL conformance results
submitted for earlier versions of that OS carry forward. Future
conformance results must be submitted against the new version of the
OS. If it is anticipated that the older OS version will be supported
for some time, then future conformance results must be submitted
separately for both the old and new versions of the OS.
(B) Conformance Rules for a GPU Vendor
======================================
A GPU vendor submitting conformance results for a WebGL implementation
typically does so because the device containing the GPU includes a
built-in web browser. In this case the following rules apply:
1. Conformance results must be submitted for each GPU and operating
system combination to be certified. It is not required to submit
results for different devices containing the same GPU and running the
same operating system.
2. Conformance results may be submitted up to three months in advance
of the product reaching initial shipment.
3. Conformance results carry forward for a given GPU as the operating
system and graphics driver are upgraded, unless there is an
expectation that conformance may have been affected. In that case, the
GPU vendor should submit new conformance results.
Discussion
==========
A WebGL implementation intended to ship on three OSs may reach
conformance on two of them, but due to graphics driver bugs, may be
unable to reach conformance on the third. In this situation the
implementation is not yet considered to be conformant.
An existing WebGL implementation which conformed to an earlier version
of the test suite is not required to remove support for the "webgl"
HTML Canvas context type while in the process of conforming to a later
version of the test suite. However, the implementer must not advertise
conformance to the later version until it has been reached. It is
acceptable for the implementer to advertise details of their
conformance, for example number or percentage of passing or failing
tests, or names of passing or failing tests.
A GPU vendor might submit conformance results in order to use the
WebGL logo in a marketing campaign. In this situation, results may be
submitted in advance of the product becoming available through sales
channels, per the rules above.
The WebGL API has strict security requirements. Even one failing test
may indicate a serious security issue in the WebGL implementation. For
this reason, no exceptions for failing conformance tests will be
granted.
The Khronos Group determines whether a particular WebGL implementation
is conformant based on the implementer's conformance suite
submissions, on multiple OSs and on multiple GPUs as necessary, using
the rules above. An implementer shall not judge their own
implementation conformant simply by applying the above rules.

Просмотреть файл

@ -0,0 +1,77 @@
Welcome to the WebGL Conformance Test Suite
===========================================
Note: Before adding a new test or editing an existing test
[please read these guidelines](test-guidelines.md).
This is the WebGL conformance test suite. You can find a the current "live"
version at [https://www.khronos.org/registry/webgl/sdk/tests/webgl-conformance-tests.html](https://www.khronos.org/registry/webgl/sdk/tests/webgl-conformance-tests.html)
NOTE TO USERS: Unless you are a WebGL implementor, there is no need to submit
a conformance result using this process. Should you discover bugs in your
browser's WebGL implementation, either via this test suite or otherwise,
please report them through your browser vendor's bug tracking system.
FOR WEBGL IMPLEMENTORS: Please follow the instructions below to create
a formal conformance submission.
1. Open webgl-conformance-tests.html in your target browser
2. Press the "run tests" button
3. At the end of the run, press "display text summary"
4. Verify that the User Agent and WebGL renderer strings identify your browser and target correctly.
5. Copy the contents of the text summary (starting with "WebGL Conformance Test Results") and send via email to
webgl_conformance_submissions@khronos.org
Please see CONFORMANCE_RULES.txt in this directory for guidelines
about what constitutes a conformant WebGL implementation.
Usage Notes:
------------
There are various URL options you can pass in.
run: Set to 1 to start the tests automatically
Example: webgl-conformance-tests.html?run=1
version: Set to the version of the harness you wish to run. Tests
at this version or below will be run
Example: webgl-conformance-tests.html?version=1.3.2
minVersion: Set to the minimum version of each test to include. Only tests
at this version or above will be included.
Example: webgl-conformance-tests.html?minVersion=1.3.2
fast: Only run tests not marked with --slow
Example: webgl-conformance-tests.html?fast=true
skip: Comma separated list of regular expressions of which tests to skip.
Example: webgl-conformance-tests.html?skip=glsl,.*destruction\.html
include: Comma separated list of regular expressions of which tests to include.
Example: webgl-conformance-tests.html?include=glsl,.*destruction\.html
frames: The number of iframes to use to run tests in parallel.
Example: webgl-conformance-tests.html?frames=8
Note the tests are not required to run with anything other than frames = 1.
History
-------
- 2011/02/24: Version 1.0.0
- 2012/02/23: Version 1.0.1
- 2012/03/20: Version 1.0.2
- 2013/02/14: Version 1.0.3
- 2013/10/11: Version 2.0.0 (beta)

Просмотреть файл

@ -0,0 +1,18 @@
attribs/00_test_list.txt
buffers/00_test_list.txt
canvas/00_test_list.txt
context/00_test_list.txt
extensions/00_test_list.txt
glsl/00_test_list.txt
limits/00_test_list.txt
misc/00_test_list.txt
--min-version 1.0.2 ogles/00_test_list.txt
programs/00_test_list.txt
reading/00_test_list.txt
renderbuffers/00_test_list.txt
rendering/00_test_list.txt
state/00_test_list.txt
textures/00_test_list.txt
typedarrays/00_test_list.txt
uniforms/00_test_list.txt

Просмотреть файл

@ -0,0 +1,10 @@
--min-version 1.0.3 gl-bindAttribLocation-aliasing.html
--min-version 1.0.3 gl-bindAttribLocation-matrix.html
--min-version 1.0.2 gl-disabled-vertex-attrib.html
gl-enable-vertex-attrib.html
--min-version 1.0.3 gl-matrix-attributes.html
gl-vertex-attrib.html
gl-vertexattribpointer.html
gl-vertexattribpointer-offsets.html
--min-version 1.0.2 gl-vertex-attrib-render.html
gl-vertex-attrib-zero-issues.html

Просмотреть файл

@ -0,0 +1,90 @@
<!--
/*
** Copyright (c) 2014 The Khronos Group Inc.
**
** Permission is hereby granted, free of charge, to any person obtaining a
** copy of this software and/or associated documentation files (the
** "Materials"), to deal in the Materials without restriction, including
** without limitation the rights to use, copy, modify, merge, publish,
** distribute, sublicense, and/or sell copies of the Materials, and to
** permit persons to whom the Materials are furnished to do so, subject to
** the following conditions:
**
** The above copyright notice and this permission notice shall be included
** in all copies or substantial portions of the Materials.
**
** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
*/
-->
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<link rel="stylesheet" href="../../resources/js-test-style.css"/>
<script src="../../resources/js-test-pre.js"></script>
<script src="../resources/webgl-test-utils.js"></script>
<title>bindAttribLocation with aliasing</title>
</head>
<body>
<div id="description"></div>
<div id="console"></div>
<canvas id="canvas" width="8" height="8" style="width: 8px; height: 8px;"></canvas>
<script id="vertexShader" type="text/something-not-javascript">
precision mediump float;
attribute $(type_1) a_1;
attribute $(type_2) a_2;
void main() {
gl_Position = $(gl_Position_1) + $(gl_Position_2);
}
</script>
<script>
"use strict";
description("This test verifies combinations of valid, active attribute types cannot be bound to the same location with bindAttribLocation.");
var wtu = WebGLTestUtils;
var canvas = document.getElementById("canvas");
var gl = wtu.create3DContext(canvas, {antialias: false});
var glFragmentShader = wtu.setupSimpleColorFragmentShader(gl);
var typeInfo = [
{ type: 'float', asVec4: 'vec4(0.0, $(var), 0.0, 1.0)' },
{ type: 'vec2', asVec4: 'vec4($(var), 0.0, 1.0)' },
{ type: 'vec3', asVec4: 'vec4($(var), 1.0)' },
{ type: 'vec4', asVec4: '$(var)' },
];
var maxAttributes = gl.getParameter(gl.MAX_VERTEX_ATTRIBS);
// Test all type combinations of a_1 and a_2.
typeInfo.forEach(function(typeInfo1) {
typeInfo.forEach(function(typeInfo2) {
debug('attribute_1: ' + typeInfo1.type + ' attribute_2: ' + typeInfo2.type);
var replaceParams = {
type_1: typeInfo1.type,
type_2: typeInfo2.type,
gl_Position_1: wtu.replaceParams(typeInfo1.asVec4, {var: 'a_1'}),
gl_Position_2: wtu.replaceParams(typeInfo2.asVec4, {var: 'a_2'})
};
var strVertexShader = wtu.replaceParams(wtu.getScript('vertexShader'), replaceParams);
var glVertexShader = wtu.loadShader(gl, strVertexShader, gl.VERTEX_SHADER);
assertMsg(glVertexShader != null, "Vertex shader compiled successfully.");
// Bind both a_1 and a_2 to the same position and verify the link fails.
// Do so for all valid positions available.
for (var l = 0; l < maxAttributes; l++) {
var glProgram = gl.createProgram();
gl.bindAttribLocation(glProgram, l, 'a_1');
gl.bindAttribLocation(glProgram, l, 'a_2');
gl.attachShader(glProgram, glVertexShader);
gl.attachShader(glProgram, glFragmentShader);
gl.linkProgram(glProgram);
assertMsg(!gl.getProgramParameter(glProgram, gl.LINK_STATUS), "Link should fail when both types are aliased to location " + l);
}
});
});
var successfullyParsed = true;
</script>
<script src="../../resources/js-test-post.js"></script>
</body>
</html>

Просмотреть файл

@ -0,0 +1,119 @@
<!--
/*
** Copyright (c) 2014 The Khronos Group Inc.
**
** Permission is hereby granted, free of charge, to any person obtaining a
** copy of this software and/or associated documentation files (the
** "Materials"), to deal in the Materials without restriction, including
** without limitation the rights to use, copy, modify, merge, publish,
** distribute, sublicense, and/or sell copies of the Materials, and to
** permit persons to whom the Materials are furnished to do so, subject to
** the following conditions:
**
** The above copyright notice and this permission notice shall be included
** in all copies or substantial portions of the Materials.
**
** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
*/
-->
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<link rel="stylesheet" href="../../resources/js-test-style.css"/>
<script src="../../resources/js-test-pre.js"></script>
<script src="../resources/webgl-test-utils.js"></script>
<title>WebGL bindAttribLocation with Matrix Attributes Conformance Test</title>
</head>
<body>
<div id="description"></div>
<div id="console"></div>
<canvas id="canvas" width="8" height="8" style="width: 8px; height: 8px;"></canvas>
<script>
"use strict";
description("This test verifies that vectors placed via bindAttribLocation right after matricies will fail if there is insufficient room for the matrix.");
var wtu = WebGLTestUtils;
var canvas = document.getElementById("canvas");
var gl = wtu.create3DContext(canvas, {antialias: false});
// Make sure we have room for at least a mat4.
var maxAttributes = gl.getParameter(gl.MAX_VERTEX_ATTRIBS);
debug('MAX_VERTEX_ATTRIBUTES is ' + maxAttributes);
shouldBeGreaterThanOrEqual('maxAttributes', '4');
var glFragmentShader = wtu.setupSimpleColorFragmentShader(gl);
// Given a matrix dimension, load a vertex shader with a matrix of that dimension
// and a vector. Ensure that both the vector and matrix are active attributes.
// Return the compiled vertex shader.
function loadVertexShader(numMatrixDimensions) {
var strVertexShader =
'attribute mat' + numMatrixDimensions + ' matrix;\n' +
'attribute vec' + numMatrixDimensions + ' vector;\n' +
'void main(void) { gl_Position = vec4(vector*matrix';
// Ensure the vec4 has the correct number of dimensions in order to be assignable
// to gl_Position.
for (var ii = numMatrixDimensions; ii < 4; ++ii) {
strVertexShader += ",0.0";
}
strVertexShader += ");}\n";
return wtu.loadShader(gl, strVertexShader, gl.VERTEX_SHADER);
}
// Given a vertex shader, matrix location and vector location, create and link
// a program with glFragmentShader and a vertex shader returned by loadVertexShader
// attached. Bind the matrix to matrixLocation and the vector to vectorLocation.
// Return whether the link was successful.
function createAndLinkProgram(glVertexShader, matrixLocation, vectorLocation) {
var glProgram = gl.createProgram();
gl.bindAttribLocation(glProgram, matrixLocation, 'matrix');
gl.bindAttribLocation(glProgram, vectorLocation, 'vector');
gl.attachShader(glProgram, glVertexShader);
gl.attachShader(glProgram, glFragmentShader);
gl.linkProgram(glProgram);
return gl.getProgramParameter(glProgram, gl.LINK_STATUS);
}
// For each matrix dimension (mat2, mat3 and mat4)
for (var mm = 2; mm <= 4; ++mm) {
debug('Testing ' + mm + ' dimensional matrices');
var glVertexShader = loadVertexShader(mm);
// Per the WebGL spec: "LinkProgram will fail if the attribute bindings assigned
// by bindAttribLocation do not leave enough space to assign a location for an
// active matrix attribute which requires multiple contiguous generic attributes."
// We will test this by placing the vector after the matrix attribute such that there
// is not enough room for the matrix. Vertify the link operation fails.
// Run the test for each available attribute slot. Go to maxAttributes-mm to leave enough room
// for the matrix itself. Leave another slot open for the vector following the matrix.
for (var pp = 0; pp <= maxAttributes - mm - 1; ++pp) {
// For each matrix dimension, bind the vector right after the matrix such that we leave
// insufficient room for the matrix. Verify doing this will fail the link operation.
for (var ll = 0; ll < mm; ++ll) {
var vectorLocation = pp + ll;
assertMsg(!createAndLinkProgram(glVertexShader, /*matrixLocation*/pp, vectorLocation),
"Matrix with location " + pp + " and vector with location " + vectorLocation + " should not link.");
}
// Ensure that once we have left enough room for the matrix, the program links successfully.
var vectorLocation = pp + ll;
assertMsg(createAndLinkProgram(glVertexShader, /*matrixLocation*/pp, vectorLocation),
"Matrix with location " + pp + " and vector with location " + vectorLocation + " should link.");
debug('');
}
debug('');
}
var successfullyParsed = true;
</script>
<script src="../../resources/js-test-post.js"></script>
</body>
</html>

Просмотреть файл

@ -0,0 +1,100 @@
<!--
/*
** Copyright (c) 2012 The Khronos Group Inc.
**
** Permission is hereby granted, free of charge, to any person obtaining a
** copy of this software and/or associated documentation files (the
** "Materials"), to deal in the Materials without restriction, including
** without limitation the rights to use, copy, modify, merge, publish,
** distribute, sublicense, and/or sell copies of the Materials, and to
** permit persons to whom the Materials are furnished to do so, subject to
** the following conditions:
**
** The above copyright notice and this permission notice shall be included
** in all copies or substantial portions of the Materials.
**
** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
*/
-->
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>WebGL Disabled Vertex Attrib Test</title>
<link rel="stylesheet" href="../../resources/js-test-style.css"/>
<script src="../../resources/js-test-pre.js"></script>
<script src="../resources/webgl-test-utils.js"> </script>
</head>
<body>
<canvas id="example" width="50" height="50">
</canvas>
<div id="description"></div>
<div id="console"></div>
<script id="vshader" type="x-shader/x-vertex">
attribute vec4 a_position;
attribute vec4 a_color;
varying vec4 v_color;
bool isCorrectColor(vec4 v) {
return v.x == 0.0 && v.y == 0.0 && v.z == 0.0 && v.w == 1.0;
}
void main() {
gl_Position = a_position;
v_color = isCorrectColor(a_color) ? vec4(0, 1, 0, 1) : vec4(1, 0, 0, 1);
}
</script>
<script id="fshader" type="x-shader/x-fragment">
precision mediump float;
varying vec4 v_color;
void main() {
gl_FragColor = v_color;
}
</script>
<script>
"use strict";
var wtu = WebGLTestUtils;
description();
var gl = wtu.create3DContext("example");
var numVertexAttribs = gl.getParameter(gl.MAX_VERTEX_ATTRIBS);
for (var ii = 0; ii < numVertexAttribs; ++ii) {
var colorLocation = (ii + 1) % numVertexAttribs;
var positionLocation = colorLocation ? 0 : 1;
if (positionLocation != 0) {
// We need to create a new 3d context for testing attrib 0
// since we've already effected attrib 0 on other tests.
gl = wtu.create3DContext();
}
debug("testing attrib: " + colorLocation);
var program = wtu.setupProgram(
gl,
['vshader', 'fshader'],
['a_position', 'a_color'],
[positionLocation, colorLocation]);
var gridRes = 1;
wtu.setupIndexedQuad(gl, gridRes, positionLocation);
wtu.clearAndDrawIndexedQuad(gl, gridRes);
wtu.checkCanvas(gl, [0, 255, 0, 255], "should be green");
}
wtu.glErrorShouldBe(gl, gl.NO_ERROR, "should be no errors");
var successfullyParsed = true;
</script>
<script src="../../resources/js-test-post.js"></script>
</body>
</html>

Просмотреть файл

@ -0,0 +1,82 @@
<!--
/*
** Copyright (c) 2012 The Khronos Group Inc.
**
** Permission is hereby granted, free of charge, to any person obtaining a
** copy of this software and/or associated documentation files (the
** "Materials"), to deal in the Materials without restriction, including
** without limitation the rights to use, copy, modify, merge, publish,
** distribute, sublicense, and/or sell copies of the Materials, and to
** permit persons to whom the Materials are furnished to do so, subject to
** the following conditions:
**
** The above copyright notice and this permission notice shall be included
** in all copies or substantial portions of the Materials.
**
** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
*/
-->
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>WebGL Enable Vertex Attrib Test</title>
<link rel="stylesheet" href="../../resources/js-test-style.css"/>
<script src="../../resources/js-test-pre.js"></script>
<script src="../resources/webgl-test-utils.js"> </script>
</head>
<body>
<canvas id="example" width="50" height="50">
</canvas>
<div id="description"></div>
<div id="console"></div>
<script id="vshader" type="x-shader/x-vertex">
attribute vec4 vPosition;
void main()
{
gl_Position = vPosition;
}
</script>
<script id="fshader" type="x-shader/x-fragment">
void main()
{
gl_FragColor = vec4(1.0,0.0,0.0,1.0);
}
</script>
<script>
"use strict";
description("tests that turning on attribs that have no buffer bound fails to draw");
var wtu = WebGLTestUtils;
var gl = wtu.create3DContext("example");
var program = wtu.setupProgram(gl, ["vshader", "fshader"], ["vPosition"]);
var vertexObject = gl.createBuffer();
gl.bindBuffer(gl.ARRAY_BUFFER, vertexObject);
gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([ 0,0.5,0, -0.5,-0.5,0, 0.5,-0.5,0 ]), gl.STATIC_DRAW);
gl.enableVertexAttribArray(0);
gl.vertexAttribPointer(0, 3, gl.FLOAT, false, 0, 0);
gl.enableVertexAttribArray(3);
wtu.glErrorShouldBe(gl, gl.NO_ERROR);
gl.drawArrays(gl.TRIANGLES, 0, 3);
wtu.glErrorShouldBe(gl, gl.INVALID_OPERATION);
var successfullyParsed = true;
</script>
<script src="../../resources/js-test-post.js"></script>
</body>
</html>

Просмотреть файл

@ -0,0 +1,157 @@
<!--
/*
** Copyright (c) 2014 The Khronos Group Inc.
**
** Permission is hereby granted, free of charge, to any person obtaining a
** copy of this software and/or associated documentation files (the
** "Materials"), to deal in the Materials without restriction, including
** without limitation the rights to use, copy, modify, merge, publish,
** distribute, sublicense, and/or sell copies of the Materials, and to
** permit persons to whom the Materials are furnished to do so, subject to
** the following conditions:
**
** The above copyright notice and this permission notice shall be included
** in all copies or substantial portions of the Materials.
**
** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
*/
-->
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<link rel="stylesheet" href="../../resources/js-test-style.css"/>
<script src="../../resources/js-test-pre.js"></script>
<script src="../resources/webgl-test-utils.js"></script>
<title>WebGL Matrix Attribute Conformance Test</title>
</head>
<body>
<div id="description"></div>
<div id="console"></div>
<canvas id="canvas" width="8" height="8" style="width: 8px; height: 8px;"></canvas>
<script>
"use strict";
description("This tests ensures that matrix attribute locations do not clash with other shader attributes.");
var wtu = WebGLTestUtils;
var canvas = document.getElementById("canvas");
var gl = wtu.create3DContext(canvas, {antialias: false});
// Make sure we have room for at least a mat4.
var maxAttributes = gl.getParameter(gl.MAX_VERTEX_ATTRIBS);
debug('MAX_VERTEX_ATTRIBUTES is ' + maxAttributes);
shouldBeGreaterThanOrEqual('maxAttributes', '4');
var glFragmentShader = wtu.setupSimpleColorFragmentShader(gl);
// prepareMatrixProgram creates a program with glFragmentShader as the fragment shader.
// The vertex shader has numVector number of vectors and a matrix with numMatrixDimensions
// dimensions at location numMatrixPosition in the list of attributes.
// Ensures that every vector and matrix is used by the program.
// Returns a valid program on successfull link; null on link failure.
function prepareMatrixProgram(numVectors, numMatrixDimensions, numMatrixPosition) {
// Add the matrix and vector attribute declarations. Declare the vectors
// to have the same number of components as the matrix so we can perform
// operations on them when we assign to gl_Position later on.
var strVertexShader = "";
for (var ii = 1; ii <= numVectors; ++ii) {
if (numMatrixPosition === ii) {
strVertexShader += "attribute mat" + numMatrixDimensions + " matrix;\n";
}
strVertexShader += "attribute vec" + numMatrixDimensions + " vec_" + ii + ";\n";
}
// numMatrixPosition will be one past numVectors if the caller wants it to be
// last. Hence, we need this check outside the loop as well as inside.
if (numMatrixPosition === ii) {
strVertexShader += "attribute mat" + numMatrixDimensions + " matrix;\n";
}
// Add the body of the shader. Add up all of the vectors and multiply by the matrix.
// The operations we perform do not matter. We just need to ensure that all the vector and
// matrix attributes are used.
strVertexShader += "void main(void) { \ngl_Position = vec4((";
for (var ii = 1; ii <= numVectors; ++ii) {
if (ii > 1) {
strVertexShader += "+"
}
strVertexShader += "vec_" + ii;
}
strVertexShader += ")*matrix";
// Ensure the vec4 has the correct number of dimensions in order to be assignable
// to gl_Position.
for (var ii = numMatrixDimensions; ii < 4; ++ii) {
strVertexShader += ",0.0";
}
strVertexShader += ");}\n";
// Load the shader, attach it to a program, and return the link results
var glVertexShader = wtu.loadShader(gl, strVertexShader, gl.VERTEX_SHADER);
var strTest = 'Load shader with ' + numVectors + ' vectors and 1 matrix';
if (glVertexShader !== null) {
testPassed(strTest);
var glProgram = gl.createProgram();
gl.attachShader(glProgram, glVertexShader);
gl.attachShader(glProgram, glFragmentShader);
gl.linkProgram(glProgram);
if (gl.getProgramParameter(glProgram, gl.LINK_STATUS)) {
wtu.glErrorShouldBe(gl, gl.NO_ERROR, 'linkProgram');
return glProgram;
}
} else {
testFailed(strTest);
}
return null;
}
debug('');
// Test mat2, mat3 and mat4.
for (var mm = 2; mm <= 4; ++mm) {
// Add maxAttribute number of attributes by saving enough room in the attribute
// list for a matrix of mm dimensions. All of the other attribute slots will be
// filled with vectors.
var numVectors = maxAttributes - mm;
for (var pp = 1; pp <= numVectors + 1; ++pp) {
debug('Test ' + mm + ' dimensional matrix at position ' + pp);
var glProgram = prepareMatrixProgram(numVectors, /*numMatrixDimensions*/mm, /*numMatrixPosition*/pp);
shouldBeNonNull('glProgram');
var attribMatrix = gl.getAttribLocation(glProgram, 'matrix');
debug('Matrix is at attribute location ' + attribMatrix);
shouldBeTrue('attribMatrix > -1');
// Per the spec, when an attribute is a matrix attribute, getAttribLocation
// returns the index of the first component of the matrix. The implementation must
// leave sufficient room for all the components. Here we ensure none of the vectors
// in the shader are assigned attribute locations that belong to the matrix.
for (var vv = 1; vv <= numVectors; ++vv) {
var strVector = 'vec_' + vv
var attribVector = gl.getAttribLocation(glProgram, strVector);
debug(strVector + ' is at attribute location ' + attribVector);
// Begin with the first attribute location where the matrix begins and ensure
// the vector's attribute location is not assigned to the matrix. Loop until
// we've checked all of the attribute locations that belong to the matrix.
for (var ii = attribMatrix; ii < attribMatrix + mm; ++ii) {
var testStr = strVector + ' attribute location: ' + attribVector + '. Should not be ' + ii;
if (attribVector !== ii) {
testPassed(testStr);
} else {
testFailed(testStr);
}
}
}
debug('');
}
debug('');
}
var successfullyParsed = true;
</script>
<script src="../../resources/js-test-post.js"></script>
</body>
</html>

Просмотреть файл

@ -0,0 +1,110 @@
<!--
/*
** Copyright (c) 2012 The Khronos Group Inc.
**
** Permission is hereby granted, free of charge, to any person obtaining a
** copy of this software and/or associated documentation files (the
** "Materials"), to deal in the Materials without restriction, including
** without limitation the rights to use, copy, modify, merge, publish,
** distribute, sublicense, and/or sell copies of the Materials, and to
** permit persons to whom the Materials are furnished to do so, subject to
** the following conditions:
**
** The above copyright notice and this permission notice shall be included
** in all copies or substantial portions of the Materials.
**
** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
*/
-->
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<link rel="stylesheet" href="../../resources/js-test-style.css"/>
<script src="../../resources/js-test-pre.js"></script>
<script src="../resources/webgl-test-utils.js"></script>
<script id='vshader' type='x-shader'>
attribute vec4 a;
attribute vec2 p;
void main() {
gl_Position = vec4(p.x + a.x + a.y + a.z + a.w, p.y, 0.0, 1.0);
}
</script>
<script id='fshader' type='x-shader'>
precision mediump float;
void main() {
gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);
}
</script>
<script>
"use strict";
function checkRedPortion(gl, w, low, high) {
var buf = new Uint8Array(w * w * 4);
gl.readPixels(0, 0, w, w, gl.RGBA, gl.UNSIGNED_BYTE, buf);
var i = 0;
for (; i < w; ++i) {
if (buf[i * 4 + 0] == 255 && buf[i * 4 + 1] == 0 && buf[i * 4 + 2] == 0 && buf[i * 4 + 3] == 255) {
break;
}
}
return low <= i && i <= high;
}
function runTest() {
var wtu = WebGLTestUtils;
var gl = wtu.create3DContext('testbed', { preserveDrawingBuffer : true });
if (!gl) {
testFailed('could not create context');
return;
}
var program = wtu.setupProgram(gl, ['vshader', 'fshader'], ['p', 'a'])
gl.enableVertexAttribArray(gl.p);
var pos = gl.createBuffer();
pos.type = gl.FLOAT;
pos.size = 2;
pos.num = 4;
gl.bindBuffer(gl.ARRAY_BUFFER, pos);
gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([-1, -1, 1, -1, -1, 1, 1, 1]), gl.STATIC_DRAW);
gl.vertexAttribPointer(0, pos.size, pos.type, false, 0, 0);
debug('Test vertexAttrib[1..4]fv by setting different combinations that add up to 1.5 and use that when rendering.');
var vals = [[0.5], [0.1,0.4], [0.2,-0.2,0.5], [-1.0,0.3,0.2,2.0]];
for (var j = 0; j < 4; ++j) {
gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
gl['vertexAttrib' + (j+1) + 'fv'](1, vals[j]);
gl.drawArrays(gl.TRIANGLE_STRIP, 0, pos.num);
if (checkRedPortion(gl, 50, 50 * 0.7, 50 * 0.8)) {
testPassed('Attribute of size ' + (j+1) + ' was set correctly');
} else {
testFailed('Attribute of size ' + (j+1) + ' was not set correctly');
}
}
}
</script>
</head>
<body>
<canvas id="testbed" width="50" height="50"></canvas>
<div id="description"></div>
<div id="console"></div>
<script>
"use strict";
description('Verify that using constant attributes works.');
runTest();
var successfullyParsed = true;
</script>
<script src="../../resources/js-test-post.js"></script>
</body>
</html>

Просмотреть файл

@ -0,0 +1,152 @@
<!--
/*
** Copyright (c) 2012 The Khronos Group Inc.
**
** Permission is hereby granted, free of charge, to any person obtaining a
** copy of this software and/or associated documentation files (the
** "Materials"), to deal in the Materials without restriction, including
** without limitation the rights to use, copy, modify, merge, publish,
** distribute, sublicense, and/or sell copies of the Materials, and to
** permit persons to whom the Materials are furnished to do so, subject to
** the following conditions:
**
** The above copyright notice and this permission notice shall be included
** in all copies or substantial portions of the Materials.
**
** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
*/
-->
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>WebGL Enable Vertex Attrib Zero Test</title>
<link rel="stylesheet" href="../../resources/js-test-style.css"/>
<script src="../../resources/js-test-pre.js"></script>
<script src="../resources/webgl-test-utils.js"> </script>
</head>
<body>
<canvas id="example" width="50" height="50">
</canvas>
<div id="description"></div>
<div id="console"></div>
<script id="vshader" type="x-shader/x-vertex">
attribute vec4 vPosition;
void main()
{
gl_Position = vPosition;
}
</script>
<script id="fshader" type="x-shader/x-fragment">
void main()
{
gl_FragColor = vec4(0.0,1.0,0.0,1.0);
}
</script>
<script>
"use strict";
description("Test some of the issues of the difference between attrib 0 on OpenGL vs WebGL");
debug("");
var wtu = WebGLTestUtils;
var gl = wtu.create3DContext("example");
var g_program;
var g_attribLocation;
function setup(attribIndex) {
var program = wtu.setupProgram(
gl, ['vshader', 'fshader'], ['vPosition'], [attribIndex]);
g_program = program;
g_attribLocation = attribIndex;
shouldBe("g_attribLocation", "gl.getAttribLocation(g_program, 'vPosition')");
return program;
}
function setupVerts(numVerts) {
var verts = [
1.0, 1.0, 0.0,
-1.0, 1.0, 0.0,
-1.0, -1.0, 0.0,
1.0, 1.0, 0.0,
-1.0, -1.0, 0.0,
1.0, -1.0, 0.0
];
var positions = new Float32Array(numVerts * 3);
var indices = new Uint16Array(numVerts);
for (var ii = 0; ii < numVerts; ++ii) {
var ndx = ii % 6;
var dst = ii * 3;
var src = ndx * 3;
for (var jj = 0; jj < 3; ++jj) {
positions[dst + jj] = verts[src + jj];
}
indices[ii] = ii;
}
var vertexObject = gl.createBuffer();
gl.bindBuffer(gl.ARRAY_BUFFER, vertexObject);
gl.bufferData(gl.ARRAY_BUFFER, positions, gl.STATIC_DRAW);
var indexBuffer = gl.createBuffer();
gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, indexBuffer);
gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, indices, gl.STATIC_DRAW);
}
var p0 = setup(0);
var p3 = setup(3);
setupVerts(60000);
for (var ii = 0; ii < 5; ++ii) {
// test drawing with attrib 0
gl.useProgram(p0);
gl.enableVertexAttribArray(0);
gl.vertexAttribPointer(0, 3, gl.FLOAT, false, 0, 0);
gl.clear(gl.COLOR_BUFFER_BIT);
gl.drawElements(gl.TRIANGLES, 60000, gl.UNSIGNED_SHORT, 0);
wtu.glErrorShouldBe(
gl, gl.NO_ERROR,
"drawing using attrib 0 with 6 verts");
wtu.checkCanvas(gl, [0, 255, 0, 255], "canvas should be green");
gl.disableVertexAttribArray(0);
// test drawing without attrib 0
gl.useProgram(p3);
gl.enableVertexAttribArray(3);
gl.vertexAttribPointer(3, 3, gl.FLOAT, false, 0, 0);
gl.clear(gl.COLOR_BUFFER_BIT);
gl.drawArrays(gl.TRIANGLES, 0, 60000);
wtu.glErrorShouldBe(
gl, gl.NO_ERROR,
"drawing using attrib 3 with 60000 verts");
wtu.checkCanvas(gl, [0, 255, 0, 255], "canvas should be green");
gl.disableVertexAttribArray(3);
// This second test of drawing without attrib0 unconvered a bug in chrome
// where after the draw without attrib0 the attrib 0 emulation code disabled
// attrib 0 and it was never re-enabled so this next draw failed.
gl.useProgram(p3);
gl.enableVertexAttribArray(3);
gl.clear(gl.COLOR_BUFFER_BIT);
gl.drawElements(gl.TRIANGLES, 60000, gl.UNSIGNED_SHORT, 0);
wtu.glErrorShouldBe(
gl, gl.NO_ERROR,
"drawing using attrib 3 with 60000 verts");
wtu.checkCanvas(gl, [0, 255, 0, 255], "canvas should be green");
gl.disableVertexAttribArray(3);
}
var successfullyParsed = true;
</script>
<script src="../../resources/js-test-post.js"></script>
</body>
</html>

Просмотреть файл

@ -0,0 +1,118 @@
<!--
/*
** Copyright (c) 2012 The Khronos Group Inc.
**
** Permission is hereby granted, free of charge, to any person obtaining a
** copy of this software and/or associated documentation files (the
** "Materials"), to deal in the Materials without restriction, including
** without limitation the rights to use, copy, modify, merge, publish,
** distribute, sublicense, and/or sell copies of the Materials, and to
** permit persons to whom the Materials are furnished to do so, subject to
** the following conditions:
**
** The above copyright notice and this permission notice shall be included
** in all copies or substantial portions of the Materials.
**
** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
*/
-->
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>WebGL vertexAttrib Conformance Tests</title>
<link rel="stylesheet" href="../../resources/js-test-style.css"/>
<script src="../../resources/js-test-pre.js"></script>
<script src="../resources/webgl-test-utils.js"></script>
</head>
<body>
<div id="description"></div>
<div id="console"></div>
<canvas id="canvas" width="2" height="2"> </canvas>
<script>
"use strict";
description("This test ensures WebGL implementations vertexAttrib can be set and read.");
debug("");
debug("Canvas.getContext");
var wtu = WebGLTestUtils;
var gl = wtu.create3DContext("canvas");
if (!gl) {
testFailed("context does not exist");
} else {
testPassed("context exists");
debug("");
debug("Checking gl.vertexAttrib.");
var numVertexAttribs = gl.getParameter(gl.MAX_VERTEX_ATTRIBS);
for (var ii = 0; ii < numVertexAttribs; ++ii) {
gl.vertexAttrib1fv(ii, [1]);
shouldBe('gl.getVertexAttrib(' + ii + ', gl.CURRENT_VERTEX_ATTRIB)[0]', '1');
shouldBe('gl.getVertexAttrib(' + ii + ', gl.CURRENT_VERTEX_ATTRIB)[1]', '0');
shouldBe('gl.getVertexAttrib(' + ii + ', gl.CURRENT_VERTEX_ATTRIB)[2]', '0');
shouldBe('gl.getVertexAttrib(' + ii + ', gl.CURRENT_VERTEX_ATTRIB)[3]', '1');
gl.vertexAttrib2fv(ii, [1, 2]);
shouldBe('gl.getVertexAttrib(' + ii + ', gl.CURRENT_VERTEX_ATTRIB)[0]', '1');
shouldBe('gl.getVertexAttrib(' + ii + ', gl.CURRENT_VERTEX_ATTRIB)[1]', '2');
shouldBe('gl.getVertexAttrib(' + ii + ', gl.CURRENT_VERTEX_ATTRIB)[2]', '0');
shouldBe('gl.getVertexAttrib(' + ii + ', gl.CURRENT_VERTEX_ATTRIB)[3]', '1');
gl.vertexAttrib3fv(ii, [1, 2, 3]);
shouldBe('gl.getVertexAttrib(' + ii + ', gl.CURRENT_VERTEX_ATTRIB)[0]', '1');
shouldBe('gl.getVertexAttrib(' + ii + ', gl.CURRENT_VERTEX_ATTRIB)[1]', '2');
shouldBe('gl.getVertexAttrib(' + ii + ', gl.CURRENT_VERTEX_ATTRIB)[2]', '3');
shouldBe('gl.getVertexAttrib(' + ii + ', gl.CURRENT_VERTEX_ATTRIB)[3]', '1');
gl.vertexAttrib4fv(ii, [1, 2, 3, 4]);
shouldBe('gl.getVertexAttrib(' + ii + ', gl.CURRENT_VERTEX_ATTRIB)[0]', '1');
shouldBe('gl.getVertexAttrib(' + ii + ', gl.CURRENT_VERTEX_ATTRIB)[1]', '2');
shouldBe('gl.getVertexAttrib(' + ii + ', gl.CURRENT_VERTEX_ATTRIB)[2]', '3');
shouldBe('gl.getVertexAttrib(' + ii + ', gl.CURRENT_VERTEX_ATTRIB)[3]', '4');
gl.vertexAttrib1f(ii, 5);
shouldBe('gl.getVertexAttrib(' + ii + ', gl.CURRENT_VERTEX_ATTRIB)[0]', '5');
shouldBe('gl.getVertexAttrib(' + ii + ', gl.CURRENT_VERTEX_ATTRIB)[1]', '0');
shouldBe('gl.getVertexAttrib(' + ii + ', gl.CURRENT_VERTEX_ATTRIB)[2]', '0');
shouldBe('gl.getVertexAttrib(' + ii + ', gl.CURRENT_VERTEX_ATTRIB)[3]', '1');
gl.vertexAttrib2f(ii, 6, 7);
shouldBe('gl.getVertexAttrib(' + ii + ', gl.CURRENT_VERTEX_ATTRIB)[0]', '6');
shouldBe('gl.getVertexAttrib(' + ii + ', gl.CURRENT_VERTEX_ATTRIB)[1]', '7');
shouldBe('gl.getVertexAttrib(' + ii + ', gl.CURRENT_VERTEX_ATTRIB)[2]', '0');
shouldBe('gl.getVertexAttrib(' + ii + ', gl.CURRENT_VERTEX_ATTRIB)[3]', '1');
gl.vertexAttrib3f(ii, 7, 8, 9);
shouldBe('gl.getVertexAttrib(' + ii + ', gl.CURRENT_VERTEX_ATTRIB)[0]', '7');
shouldBe('gl.getVertexAttrib(' + ii + ', gl.CURRENT_VERTEX_ATTRIB)[1]', '8');
shouldBe('gl.getVertexAttrib(' + ii + ', gl.CURRENT_VERTEX_ATTRIB)[2]', '9');
shouldBe('gl.getVertexAttrib(' + ii + ', gl.CURRENT_VERTEX_ATTRIB)[3]', '1');
gl.vertexAttrib4f(ii, 6, 7, 8, 9);
shouldBe('gl.getVertexAttrib(' + ii + ', gl.CURRENT_VERTEX_ATTRIB)[0]', '6');
shouldBe('gl.getVertexAttrib(' + ii + ', gl.CURRENT_VERTEX_ATTRIB)[1]', '7');
shouldBe('gl.getVertexAttrib(' + ii + ', gl.CURRENT_VERTEX_ATTRIB)[2]', '8');
shouldBe('gl.getVertexAttrib(' + ii + ', gl.CURRENT_VERTEX_ATTRIB)[3]', '9');
}
wtu.glErrorShouldBe(gl, gl.NO_ERROR);
}
debug("");
var successfullyParsed = true;
</script>
<script src="../../resources/js-test-post.js"></script>
</body>
</html>

Просмотреть файл

@ -0,0 +1,181 @@
<!--
/*
** Copyright (c) 2012 The Khronos Group Inc.
**
** Permission is hereby granted, free of charge, to any person obtaining a
** copy of this software and/or associated documentation files (the
** "Materials"), to deal in the Materials without restriction, including
** without limitation the rights to use, copy, modify, merge, publish,
** distribute, sublicense, and/or sell copies of the Materials, and to
** permit persons to whom the Materials are furnished to do so, subject to
** the following conditions:
**
** The above copyright notice and this permission notice shall be included
** in all copies or substantial portions of the Materials.
**
** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
*/
-->
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>vertexattribpointer offsets test</title>
<link rel="stylesheet" href="../../resources/js-test-style.css"/>
<script src="../../resources/js-test-pre.js"></script>
<script src="../resources/webgl-test-utils.js"> </script>
</head>
<body>
<canvas id="example" width="50" height="50">
There is supposed to be an example drawing here, but it's not important.
</canvas>
<div id="description"></div>
<div id="console"></div>
<script id="vshader" type="x-shader/x-vertex">
attribute vec4 vPosition;
void main()
{
gl_Position = vPosition;
}
</script>
<script id="fshader" type="x-shader/x-fragment">
precision mediump float;
uniform vec4 color;
void main()
{
gl_FragColor = color;
}
</script>
<script>
"use strict";
function init()
{
description("test vertexattribpointer offsets work");
var wtu = WebGLTestUtils;
var gl = wtu.create3DContext("example");
var program = wtu.setupProgram(gl, ["vshader", "fshader"], ["vPosition"]);
var tests = [
{ data: new Float32Array([ 0, 1, 0, 1, 0, 0, 0, 0, 0 ]),
type: gl.FLOAT,
componentSize: 4,
normalize: false,
},
{ data: new Float32Array([ 0, 1, 0, 1, 0, 0, 0, 0, 0 ]),
type: gl.FLOAT,
componentSize: 4,
normalize: false,
},
{ data: new Uint16Array([ 0, 32767, 0, 32767, 0, 0, 0, 0, 0 ]),
type: gl.SHORT,
componentSize: 2,
normalize: true,
},
{ data: new Uint16Array([ 0, 65535, 0, 65535, 0, 0, 0, 0, 0 ]),
type: gl.UNSIGNED_SHORT,
componentSize: 2,
normalize: true,
},
{ data: new Uint16Array([ 0, 1, 0, 1, 0, 0, 0, 0, 0 ]),
type: gl.UNSIGNED_SHORT,
componentSize: 2,
normalize: false,
},
{ data: new Uint16Array([ 0, 1, 0, 1, 0, 0, 0, 0, 0 ]),
type: gl.SHORT,
componentSize: 2,
normalize: false,
},
{ data: new Uint8Array([ 0, 127, 0, 127, 0, 0, 0, 0, 0 ]),
type: gl.BYTE,
componentSize: 1,
normalize: true,
},
{ data: new Uint8Array([ 0, 255, 0, 255, 0, 0, 0, 0, 0 ]),
type: gl.UNSIGNED_BYTE,
componentSize: 1,
normalize: true,
},
{ data: new Uint8Array([ 0, 1, 0, 1, 0, 0, 0, 0, 0 ]),
type: gl.BYTE,
componentSize: 1,
normalize: false,
},
{ data: new Uint8Array([ 0, 1, 0, 1, 0, 0, 0, 0, 0 ]),
type: gl.UNSIGNED_BYTE,
componentSize: 1,
normalize: false,
}
];
var vertexObject = gl.createBuffer();
gl.bindBuffer(gl.ARRAY_BUFFER, vertexObject);
gl.bufferData(gl.ARRAY_BUFFER, 1024, gl.STATIC_DRAW);
gl.enableVertexAttribArray(0);
var colorLoc = gl.getUniformLocation(program, "color");
var kNumVerts = 3;
var kNumComponents = 3;
var count = 0;
for (var tt = 0; tt < tests.length; ++tt) {
var test = tests[tt];
for (var oo = 0; oo < 3; ++oo) {
for (var ss = 0; ss < 3; ++ss) {
var offset = (oo + 1) * test.componentSize;
var color = (count % 2) ? [1, 0, 0, 1] : [0, 1, 0, 1];
var stride = test.componentSize * kNumComponents + test.componentSize * ss;
debug("");
debug("check with " + wtu.glEnumToString(gl, test.type) + " at offset: " + offset + " with stride:" + stride + " normalize: " + test.normalize);
gl.uniform4fv(colorLoc, color);
var data = new Uint8Array(test.componentSize * kNumVerts * kNumComponents + stride * (kNumVerts - 1));
var view = new Uint8Array(test.data.buffer);
var size = test.componentSize * kNumComponents;
for (var jj = 0; jj < kNumVerts; ++jj) {
var off1 = jj * size;
var off2 = jj * stride;
for (var zz = 0; zz < size; ++zz) {
data[off2 + zz] = view[off1 + zz];
}
}
gl.bufferSubData(gl.ARRAY_BUFFER, offset, data);
gl.vertexAttribPointer(0, 3, test.type, test.normalize, stride, offset);
gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
gl.drawArrays(gl.TRIANGLES, 0, 3);
var buf = new Uint8Array(50 * 50 * 4);
gl.readPixels(0, 0, 50, 50, gl.RGBA, gl.UNSIGNED_BYTE, buf);
var black = [0, 0, 0, 0];
var other = [color[0] * 255, color[1] * 255, color[2] * 255, color[3] * 255];
var otherMsg = "should be " + ((count % 2) ? "red" : "green")
wtu.checkCanvasRect(gl, 0, 0, 1, 1, black, "should be black", 0);
wtu.checkCanvasRect(gl, 0, 49, 1, 1, black, "should be black", 0);
wtu.checkCanvasRect(gl, 26, 40, 1, 1, other, otherMsg, 0);
wtu.checkCanvasRect(gl, 26, 27, 1, 1, other, otherMsg, 0);
wtu.checkCanvasRect(gl, 40, 27, 1, 1, other, otherMsg, 0);
++count;
}
}
}
}
init();
var successfullyParsed = true;
</script>
<script src="../../resources/js-test-post.js"></script>
</body>
</html>

Просмотреть файл

@ -0,0 +1,154 @@
<!--
/*
** Copyright (c) 2012 The Khronos Group Inc.
**
** Permission is hereby granted, free of charge, to any person obtaining a
** copy of this software and/or associated documentation files (the
** "Materials"), to deal in the Materials without restriction, including
** without limitation the rights to use, copy, modify, merge, publish,
** distribute, sublicense, and/or sell copies of the Materials, and to
** permit persons to whom the Materials are furnished to do so, subject to
** the following conditions:
**
** The above copyright notice and this permission notice shall be included
** in all copies or substantial portions of the Materials.
**
** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
*/
-->
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>WebGL vertexAttribPointer Conformance Tests</title>
<link rel="stylesheet" href="../../resources/js-test-style.css"/>
<script src="../../resources/js-test-pre.js"></script>
<script src="../resources/webgl-test-utils.js"></script>
</head>
<body>
<div id="description"></div>
<div id="console"></div>
<canvas id="canvas" width="2" height="2"> </canvas>
<script>
"use strict";
description("This test checks vertexAttribPointer behaviors in WebGL.");
debug("");
debug("Canvas.getContext");
var wtu = WebGLTestUtils;
var gl = wtu.create3DContext("canvas");
if (!gl) {
testFailed("context does not exist");
} else {
testPassed("context exists");
debug("");
debug("Checking gl.vertexAttribPointer.");
if (!gl.FIXED) {
gl.FIXED = 0x140C;
}
gl.vertexAttribPointer(0, 3, gl.FLOAT, 0, 0, 12);
wtu.glErrorShouldBe(gl, gl.INVALID_OPERATION,
"vertexAttribPointer should fail if no buffer is bound");
var vertexObject = gl.createBuffer();
gl.bindBuffer(gl.ARRAY_BUFFER, vertexObject);
gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(0), gl.STATIC_DRAW);
gl.vertexAttribPointer(0, 1, gl.INT, 0, 0, 0);
wtu.glErrorShouldBe(gl, gl.INVALID_ENUM,
"vertexAttribPointer should not support INT");
gl.vertexAttribPointer(0, 1, gl.UNSIGNED_INT, 0, 0, 0);
wtu.glErrorShouldBe(gl, gl.INVALID_ENUM,
"vertexAttribPointer should not support UNSIGNED_INT");
gl.vertexAttribPointer(0, 1, gl.FIXED, 0, 0, 0);
wtu.glErrorShouldBe(gl, gl.INVALID_ENUM,
"vertexAttribPointer should not support FIXED");
var checkVertexAttribPointer = function(
gl, err, reason, size, type, normalize, stride, offset) {
gl.vertexAttribPointer(0, size, type, normalize, stride, offset);
wtu.glErrorShouldBe(gl, err,
"gl.vertexAttribPointer(0, " + size +
", gl." + wtu.glEnumToString(gl, type) +
", " + normalize +
", " + stride +
", " + offset +
") should " + (err == gl.NO_ERROR ? "succeed " : "fail ") + reason);
}
var types = [
{ type:gl.BYTE, bytesPerComponent: 1 },
{ type:gl.UNSIGNED_BYTE, bytesPerComponent: 1 },
{ type:gl.SHORT, bytesPerComponent: 2 },
{ type:gl.UNSIGNED_SHORT, bytesPerComponent: 2 },
{ type:gl.FLOAT, bytesPerComponent: 4 },
];
for (var ii = 0; ii < types.length; ++ii) {
var info = types[ii];
debug("");
for (var size = 1; size <= 4; ++size) {
debug("");
debug("checking: " + wtu.glEnumToString(gl, info.type) + " with size " + size);
var bytesPerElement = size * info.bytesPerComponent;
var offsetSet = [
0,
1,
info.bytesPerComponent - 1,
info.bytesPerComponent,
info.bytesPerComponent + 1,
info.bytesPerComponent * 2];
for (var jj = 0; jj < offsetSet.length; ++jj) {
var offset = offsetSet[jj];
for (var kk = 0; kk < offsetSet.length; ++kk) {
var stride = offsetSet[kk];
var err = gl.NO_ERROR;
var reason = ""
if (offset % info.bytesPerComponent != 0) {
reason = "because offset is bad";
err = gl.INVALID_OPERATION;
}
if (stride % info.bytesPerComponent != 0) {
reason = "because stride is bad";
err = gl.INVALID_OPERATION;
}
checkVertexAttribPointer(
gl, err, reason, size, info.type, false, stride, offset);
}
var stride = Math.floor(255 / info.bytesPerComponent) * info.bytesPerComponent;
if (offset == 0) {
checkVertexAttribPointer(
gl, gl.NO_ERROR, "at stride limit",
size, info.type, false, stride, offset);
checkVertexAttribPointer(
gl, gl.INVALID_VALUE, "over stride limit",
size, info.type, false,
stride + info.bytesPerComponent, offset);
}
}
}
}
}
debug("");
var successfullyParsed = true;
</script>
<script src="../../resources/js-test-post.js"></script>
</body>
</html>

Просмотреть файл

@ -0,0 +1,11 @@
buffer-bind-test.html
buffer-data-array-buffer.html
--min-version 1.0.3 buffer-data-array-buffer-delete.html
--min-version 1.0.2 element-array-buffer-delete-recreate.html
index-validation-copies-indices.html
index-validation-crash-with-buffer-sub-data.html
--min-version 1.0.2 index-validation-large-buffer.html
index-validation-verifies-too-many-indices.html
index-validation-with-resized-buffer.html
index-validation.html

Просмотреть файл

@ -0,0 +1,87 @@
<!--
/*
** Copyright (c) 2012 The Khronos Group Inc.
**
** Permission is hereby granted, free of charge, to any person obtaining a
** copy of this software and/or associated documentation files (the
** "Materials"), to deal in the Materials without restriction, including
** without limitation the rights to use, copy, modify, merge, publish,
** distribute, sublicense, and/or sell copies of the Materials, and to
** permit persons to whom the Materials are furnished to do so, subject to
** the following conditions:
**
** The above copyright notice and this permission notice shall be included
** in all copies or substantial portions of the Materials.
**
** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
*/
-->
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>WebGL BindBuffer conformance test.</title>
<link rel="stylesheet" href="../../resources/js-test-style.css"/>
<script src="../../resources/js-test-pre.js"></script>
<script src="../resources/webgl-test-utils.js"> </script>
</head>
<body>
<canvas id="example" width="40" height="40" style="width: 40px; height: 40px;"></canvas>
<div id="description"></div>
<div id="console"></div>
<script>
"use strict";
description("Checks a buffer can only be bound to 1 target.");
debug("");
debug("Canvas.getContext");
var wtu = WebGLTestUtils;
var gl = wtu.create3DContext("example");
if (!gl) {
testFailed("context does not exist");
} else {
testPassed("context exists");
debug("");
var buf = gl.createBuffer();
gl.bindBuffer(gl.ARRAY_BUFFER, buf);
wtu.glErrorShouldBe(gl, gl.NO_ERROR,
"should be able to bind array buffer.");
gl.bindBuffer(gl.ARRAY_BUFFER, null);
wtu.glErrorShouldBe(gl, gl.NO_ERROR,
"should be able to unbind array buffer.");
gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, buf);
wtu.glErrorShouldBe(gl, gl.INVALID_OPERATION,
"should get INVALID_OPERATION if attempting to bind array buffer to different target");
var buf = gl.createBuffer();
gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, buf);
wtu.glErrorShouldBe(gl, gl.NO_ERROR,
"should be able to bind element array buffer.");
gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, null);
wtu.glErrorShouldBe(gl, gl.NO_ERROR,
"should be able to unbind element array buffer.");
gl.bindBuffer(gl.ARRAY_BUFFER, buf);
wtu.glErrorShouldBe(gl, gl.INVALID_OPERATION,
"should get INVALID_OPERATION if attempting to bind element array buffer to different target");
}
debug("");
var successfullyParsed = true;
</script>
<script src="../../resources/js-test-post.js"></script>
</body>
</html>

Просмотреть файл

@ -0,0 +1,80 @@
<!--
/*
** Copyright (c) 2014 The Khronos Group Inc.
**
** Permission is hereby granted, free of charge, to any person obtaining a
** copy of this software and/or associated documentation files (the
** "Materials"), to deal in the Materials without restriction, including
** without limitation the rights to use, copy, modify, merge, publish,
** distribute, sublicense, and/or sell copies of the Materials, and to
** permit persons to whom the Materials are furnished to do so, subject to
** the following conditions:
**
** The above copyright notice and this permission notice shall be included
** in all copies or substantial portions of the Materials.
**
** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
*/
-->
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<link rel="stylesheet" href="../../resources/js-test-style.css"/>
<script src="../../resources/js-test-pre.js"></script>
<script src="../resources/webgl-test-utils.js"></script>
</head>
<body>
<div id="description"></div>
<div id="console"></div>
<script>
"use strict";
description("Test ARRAY_BUFFER deletion when a vertex attrib array with location != 0 is pointing to it and preserveDrawingBuffer is true.");
var canvas = document.createElement('canvas');
document.body.appendChild(canvas);
canvas.addEventListener(
"webglcontextlost",
function(event) {
testFailed("Context lost");
event.preventDefault();
},
false);
var wtu = WebGLTestUtils;
var gl = wtu.create3DContext(canvas, {preserveDrawingBuffer: true});
shouldBeNonNull("gl");
var array = new Float32Array([0]);
var buf = gl.createBuffer();
gl.bindBuffer(gl.ARRAY_BUFFER, buf);
gl.bufferData(gl.ARRAY_BUFFER, array, gl.STATIC_DRAW);
wtu.glErrorShouldBe(gl, gl.NO_ERROR);
var attribLocation = 1;
gl.enableVertexAttribArray(attribLocation);
gl.vertexAttribPointer(attribLocation, 1, gl.FLOAT, false, 0, 0);
gl.deleteBuffer(buf);
setTimeout(function() {
// Wait for possible context loss
finishTest();
}, 2000);
var successfullyParsed = true;
</script>
</body>
</html>

Просмотреть файл

@ -0,0 +1,94 @@
<!--
/*
** Copyright (c) 2012 The Khronos Group Inc.
**
** Permission is hereby granted, free of charge, to any person obtaining a
** copy of this software and/or associated documentation files (the
** "Materials"), to deal in the Materials without restriction, including
** without limitation the rights to use, copy, modify, merge, publish,
** distribute, sublicense, and/or sell copies of the Materials, and to
** permit persons to whom the Materials are furnished to do so, subject to
** the following conditions:
**
** The above copyright notice and this permission notice shall be included
** in all copies or substantial portions of the Materials.
**
** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
*/
-->
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<link rel="stylesheet" href="../../resources/js-test-style.css"/>
<script src="../../resources/js-test-pre.js"></script>
<script src="../resources/webgl-test-utils.js"></script>
</head>
<body>
<div id="description"></div>
<div id="console"></div>
<script>
"use strict";
description("Test bufferData/bufferSubData with ArrayBuffer input");
debug('Regression test for <a href="https://bugs.webkit.org/show_bug.cgi?id=41884">https://bugs.webkit.org/show_bug.cgi?id=41884</a> : <code>Implement bufferData and bufferSubData with ArrayBuffer as input</code>');
var wtu = WebGLTestUtils;
var gl = wtu.create3DContext();
shouldBeNonNull("gl");
var array = new ArrayBuffer(128);
shouldBeNonNull("array");
var buf = gl.createBuffer();
shouldBeNonNull("buf");
gl.bufferData(gl.ARRAY_BUFFER, array, gl.STATIC_DRAW);
wtu.glErrorShouldBe(gl, gl.INVALID_OPERATION);
gl.bindBuffer(gl.ARRAY_BUFFER, buf);
wtu.glErrorShouldBe(gl, gl.NO_ERROR);
gl.bufferData(gl.ARRAY_BUFFER, -10, gl.STATIC_DRAW);
wtu.glErrorShouldBe(gl, gl.INVALID_VALUE);
gl.bufferData(gl.ARRAY_BUFFER, null, gl.STATIC_DRAW);
wtu.glErrorShouldBe(gl, gl.INVALID_VALUE);
// This should not crash, but the selection of the overload is ambiguous per Web IDL.
gl.bufferData(gl.ARRAY_BUFFER, null, gl.STATIC_DRAW);
gl.getError();
gl.bufferData(gl.ARRAY_BUFFER, array, gl.STATIC_DRAW);
wtu.glErrorShouldBe(gl, gl.NO_ERROR);
array = new ArrayBuffer(64);
gl.bufferSubData(gl.ARRAY_BUFFER, -10, array);
wtu.glErrorShouldBe(gl, gl.INVALID_VALUE);
gl.bufferSubData(gl.ARRAY_BUFFER, -10, new Float32Array(8));
wtu.glErrorShouldBe(gl, gl.INVALID_VALUE);
gl.bufferSubData(gl.ARRAY_BUFFER, 10, array);
wtu.glErrorShouldBe(gl, gl.NO_ERROR);
gl.bufferSubData(gl.ARRAY_BUFFER, 10, null);
wtu.glErrorShouldBe(gl, [gl.NO_ERROR, gl.INVALID_VALUE]);
var successfullyParsed = true;
</script>
<script src="../../resources/js-test-post.js"></script>
</body>
</html>

Просмотреть файл

@ -0,0 +1,90 @@
<!--
/*
** Copyright (c) 2012 The Khronos Group Inc.
**
** Permission is hereby granted, free of charge, to any person obtaining a
** copy of this software and/or associated documentation files (the
** "Materials"), to deal in the Materials without restriction, including
** without limitation the rights to use, copy, modify, merge, publish,
** distribute, sublicense, and/or sell copies of the Materials, and to
** permit persons to whom the Materials are furnished to do so, subject to
** the following conditions:
**
** The above copyright notice and this permission notice shall be included
** in all copies or substantial portions of the Materials.
**
** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
*/
-->
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Element Array Buffer Deletion and Recreation Test</title>
<link rel="stylesheet" href="../../resources/js-test-style.css"/>
<script src="../../resources/js-test-pre.js"></script>
<script src="../resources/webgl-test-utils.js"> </script>
</head>
<body>
<canvas id="example" width="32" height="32"></canvas>
<div id="description"></div>
<div id="console"></div>
<script>
"use strict";
var wtu = WebGLTestUtils;
function init()
{
description();
// Clear the background with red.
var gl = wtu.create3DContext("example");
wtu.setupSimpleColorProgram(gl);
var color = [0, 255, 0, 255];
wtu.setUByteDrawColor(gl, color);
var vertexBuffer = gl.createBuffer();
gl.bindBuffer(gl.ARRAY_BUFFER, vertexBuffer);
gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([
-1, -1,
1, -1,
-1, 1,
1, 1
]), gl.STATIC_DRAW);
gl.enableVertexAttribArray(0);
gl.vertexAttribPointer(0, 2, gl.FLOAT, false, 0, 0);
// Create an element array buffer.
var indexBuffer = gl.createBuffer();
gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, indexBuffer);
gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, new Uint8Array([0, 1, 2, 3]), gl.STATIC_DRAW);
// Delete the element array buffer.
gl.deleteBuffer(indexBuffer);
// Create a new element array buffer.
indexBuffer = gl.createBuffer();
gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, indexBuffer);
gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, new Uint8Array([0, 1, 2, 3]), gl.STATIC_DRAW);
// Draw with the new element array buffer.
// If the geometry is drawn successfully, the fragment shader will color it green.
gl.drawElements(gl.TRIANGLE_STRIP, 4, gl.UNSIGNED_BYTE, 0);
wtu.glErrorShouldBe(gl, gl.NO_ERROR, "no errors from draw");
wtu.checkCanvas(gl, color, "should be green")
}
init();
var successfullyParsed = true;
</script>
<script src="../../resources/js-test-post.js"></script>
</body>
</html>

Просмотреть файл

@ -0,0 +1,73 @@
<!--
/*
** Copyright (c) 2012 The Khronos Group Inc.
**
** Permission is hereby granted, free of charge, to any person obtaining a
** copy of this software and/or associated documentation files (the
** "Materials"), to deal in the Materials without restriction, including
** without limitation the rights to use, copy, modify, merge, publish,
** distribute, sublicense, and/or sell copies of the Materials, and to
** permit persons to whom the Materials are furnished to do so, subject to
** the following conditions:
**
** The above copyright notice and this permission notice shall be included
** in all copies or substantial portions of the Materials.
**
** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
*/
-->
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<link rel="stylesheet" href="../../resources/js-test-style.css"/>
<script src="../../resources/js-test-pre.js"></script>
<script src="../resources/webgl-test-utils.js"></script>
</head>
<body>
<div id="description"></div>
<div id="console"></div>
<script>
"use strict";
description('Test that client data is always copied during bufferData and bufferSubData calls, because otherwise the data the GL uses to draw may differ from that checked by the index validation code.')
var wtu = WebGLTestUtils;
var context = wtu.create3DContext();
var program = wtu.loadStandardProgram(context);
context.useProgram(program);
var vertexObject = context.createBuffer();
context.enableVertexAttribArray(0);
context.bindBuffer(context.ARRAY_BUFFER, vertexObject);
// 4 vertices -> 2 triangles
context.bufferData(context.ARRAY_BUFFER, new Float32Array([ 0,0,0, 0,1,0, 1,0,0, 1,1,0 ]), context.STATIC_DRAW);
context.vertexAttribPointer(0, 3, context.FLOAT, false, 0, 0);
var indexObject = context.createBuffer();
context.bindBuffer(context.ELEMENT_ARRAY_BUFFER, indexObject);
var indices = new Uint16Array([ 10000, 0, 1, 2, 3, 10000 ]);
context.bufferData(context.ELEMENT_ARRAY_BUFFER, indices, context.STATIC_DRAW);
wtu.shouldGenerateGLError(context, context.NO_ERROR, "context.drawElements(context.TRIANGLE_STRIP, 4, context.UNSIGNED_SHORT, 2)");
wtu.shouldGenerateGLError(context, context.INVALID_OPERATION, "context.drawElements(context.TRIANGLE_STRIP, 4, context.UNSIGNED_SHORT, 0)");
wtu.shouldGenerateGLError(context, context.INVALID_OPERATION, "context.drawElements(context.TRIANGLE_STRIP, 4, context.UNSIGNED_SHORT, 4)");
indices[0] = 2;
indices[5] = 1;
wtu.shouldGenerateGLError(context, context.NO_ERROR, "context.drawElements(context.TRIANGLE_STRIP, 4, context.UNSIGNED_SHORT, 2)");
wtu.shouldGenerateGLError(context, context.INVALID_OPERATION, "context.drawElements(context.TRIANGLE_STRIP, 4, context.UNSIGNED_SHORT, 0)");
wtu.shouldGenerateGLError(context, context.INVALID_OPERATION, "context.drawElements(context.TRIANGLE_STRIP, 4, context.UNSIGNED_SHORT, 4)");
debug("")
var successfullyParsed = true;
</script>
<script src="../../resources/js-test-post.js"></script>
</body>
</html>

Просмотреть файл

@ -0,0 +1,59 @@
<!--
/*
** Copyright (c) 2012 The Khronos Group Inc.
**
** Permission is hereby granted, free of charge, to any person obtaining a
** copy of this software and/or associated documentation files (the
** "Materials"), to deal in the Materials without restriction, including
** without limitation the rights to use, copy, modify, merge, publish,
** distribute, sublicense, and/or sell copies of the Materials, and to
** permit persons to whom the Materials are furnished to do so, subject to
** the following conditions:
**
** The above copyright notice and this permission notice shall be included
** in all copies or substantial portions of the Materials.
**
** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
*/
-->
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<link rel="stylesheet" href="../../resources/js-test-style.css"/>
<script src="../../resources/js-test-pre.js"></script>
<script src="../resources/webgl-test-utils.js"></script>
</head>
<body>
<div id="description"></div>
<div id="console"></div>
<script>
"use strict";
description('Verifies that the index validation code which is within bufferSubData does not crash.')
var wtu = WebGLTestUtils;
var gl = wtu.create3DContext();
var elementBuffer = gl.createBuffer();
gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, elementBuffer);
gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, 256, gl.STATIC_DRAW);
var data = new Uint8Array(127);
gl.bufferSubData(gl.ELEMENT_ARRAY_BUFFER, 63, data);
testPassed("bufferSubData, when buffer object was initialized with null, did not crash");
var successfullyParsed = true;
</script>
<script src="../../resources/js-test-post.js"></script>
</body>
</html>

Просмотреть файл

@ -0,0 +1,77 @@
<!--
/*
** Copyright (c) 2012 The Khronos Group Inc.
**
** Permission is hereby granted, free of charge, to any person obtaining a
** copy of this software and/or associated documentation files (the
** "Materials"), to deal in the Materials without restriction, including
** without limitation the rights to use, copy, modify, merge, publish,
** distribute, sublicense, and/or sell copies of the Materials, and to
** permit persons to whom the Materials are furnished to do so, subject to
** the following conditions:
**
** The above copyright notice and this permission notice shall be included
** in all copies or substantial portions of the Materials.
**
** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
*/
-->
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<link rel="stylesheet" href="../../resources/js-test-style.css"/>
<script src="../../resources/js-test-pre.js"></script>
<script src="../resources/webgl-test-utils.js"></script>
</head>
<body>
<div id="description"></div>
<div id="console"></div>
<script>
"use strict";
description('Tests that index validation for drawElements works with large attribute buffers');
var wtu = WebGLTestUtils;
var context = wtu.create3DContext();
var program = wtu.loadStandardProgram(context);
context.useProgram(program);
// Create a small index buffer.
var indexObject = context.createBuffer();
context.bindBuffer(context.ELEMENT_ARRAY_BUFFER, indexObject);
var indexArray = new Uint16Array([0, 1, 2]);
context.bufferData(context.ELEMENT_ARRAY_BUFFER, indexArray, context.STATIC_DRAW);
// Create a large attribute buffer.
var vertexObject = context.createBuffer();
context.enableVertexAttribArray(0);
context.bindBuffer(context.ARRAY_BUFFER, vertexObject);
context.bufferData(context.ARRAY_BUFFER, new Float32Array(3 * 65536), context.STATIC_DRAW);
context.vertexAttribPointer(0, 3, context.FLOAT, false, 0, 0);
debug("Test large attribute buffer")
wtu.shouldGenerateGLError(context, context.NO_ERROR, "context.drawElements(context.TRIANGLES, 3, context.UNSIGNED_SHORT, 0)");
// Enlarge the attribute buffer slightly.
debug("Test even larger attribute buffer")
context.bufferData(context.ARRAY_BUFFER, new Float32Array(3 * 65536 + 3), context.STATIC_DRAW);
wtu.shouldGenerateGLError(context, context.NO_ERROR, "context.drawElements(context.TRIANGLES, 3, context.UNSIGNED_SHORT, 0)");
debug("")
var successfullyParsed = true;
</script>
<script src="../../resources/js-test-post.js"></script>
</body>
</html>

Просмотреть файл

@ -0,0 +1,71 @@
<!--
/*
** Copyright (c) 2012 The Khronos Group Inc.
**
** Permission is hereby granted, free of charge, to any person obtaining a
** copy of this software and/or associated documentation files (the
** "Materials"), to deal in the Materials without restriction, including
** without limitation the rights to use, copy, modify, merge, publish,
** distribute, sublicense, and/or sell copies of the Materials, and to
** permit persons to whom the Materials are furnished to do so, subject to
** the following conditions:
**
** The above copyright notice and this permission notice shall be included
** in all copies or substantial portions of the Materials.
**
** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
*/
-->
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<link rel="stylesheet" href="../../resources/js-test-style.css"/>
<script src="../../resources/js-test-pre.js"></script>
<script src="../resources/webgl-test-utils.js"></script>
</head>
<body>
<div id="description"></div>
<div id="console"></div>
<script>
"use strict";
description('Tests that index validation for drawElements does not examine too many indices');
var wtu = WebGLTestUtils;
var context = wtu.create3DContext();
var program = wtu.loadStandardProgram(context);
context.useProgram(program);
var vertexObject = context.createBuffer();
context.enableVertexAttribArray(0);
context.bindBuffer(context.ARRAY_BUFFER, vertexObject);
// 4 vertices -> 2 triangles
context.bufferData(context.ARRAY_BUFFER, new Float32Array([ 0,0,0, 0,1,0, 1,0,0, 1,1,0 ]), context.STATIC_DRAW);
context.vertexAttribPointer(0, 3, context.FLOAT, false, 0, 0);
var indexObject = context.createBuffer();
debug("Test out of range indices")
context.bindBuffer(context.ELEMENT_ARRAY_BUFFER, indexObject);
context.bufferData(context.ELEMENT_ARRAY_BUFFER, new Uint16Array([ 10000, 0, 1, 2, 3, 10000 ]), context.STATIC_DRAW);
wtu.shouldGenerateGLError(context, context.NO_ERROR, "context.drawElements(context.TRIANGLE_STRIP, 4, context.UNSIGNED_SHORT, 2)");
wtu.shouldGenerateGLError(context, context.INVALID_OPERATION, "context.drawElements(context.TRIANGLE_STRIP, 4, context.UNSIGNED_SHORT, 0)");
wtu.shouldGenerateGLError(context, context.INVALID_OPERATION, "context.drawElements(context.TRIANGLE_STRIP, 4, context.UNSIGNED_SHORT, 4)");
debug("")
var successfullyParsed = true;
</script>
<script src="../../resources/js-test-post.js"></script>
</body>
</html>

Просмотреть файл

@ -0,0 +1,128 @@
<!--
/*
** Copyright (c) 2012 The Khronos Group Inc.
**
** Permission is hereby granted, free of charge, to any person obtaining a
** copy of this software and/or associated documentation files (the
** "Materials"), to deal in the Materials without restriction, including
** without limitation the rights to use, copy, modify, merge, publish,
** distribute, sublicense, and/or sell copies of the Materials, and to
** permit persons to whom the Materials are furnished to do so, subject to
** the following conditions:
**
** The above copyright notice and this permission notice shall be included
** in all copies or substantial portions of the Materials.
**
** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
*/
-->
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<link rel="stylesheet" href="../../resources/js-test-style.css"/>
<script src="../../resources/js-test-pre.js"></script>
<script src="../resources/webgl-test-utils.js"></script>
</head>
<body>
<canvas id="example" width="1" height="1"></canvas>
<div id="description"></div>
<div id="console"></div>
<script id="vs" type="x-shader/x-vertex">
attribute vec4 vPosition;
attribute vec4 vColor;
varying vec4 color;
void main() {
gl_Position = vPosition;
color = vColor;
}
</script>
<script id="fs" type="x-shader/x-fragment">
precision mediump float;
varying vec4 color;
void main() {
gl_FragColor = color;
}
</script>
<script>
"use strict";
description('Test that updating the size of a vertex buffer is properly noticed by the WebGL implementation.')
var wtu = WebGLTestUtils;
var gl = wtu.create3DContext("example");
var program = wtu.setupProgram(gl, ["vs", "fs"], ["vPosition", "vColor"]);
wtu.glErrorShouldBe(gl, gl.NO_ERROR, "after initialization");
var vertexObject = gl.createBuffer();
gl.bindBuffer(gl.ARRAY_BUFFER, vertexObject);
gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(
[-1,1,0, 1,1,0, -1,-1,0,
-1,-1,0, 1,1,0, 1,-1,0]), gl.STATIC_DRAW);
gl.enableVertexAttribArray(0);
gl.vertexAttribPointer(0, 3, gl.FLOAT, false, 0, 0);
wtu.glErrorShouldBe(gl, gl.NO_ERROR, "after vertex setup");
var texCoordObject = gl.createBuffer();
gl.bindBuffer(gl.ARRAY_BUFFER, texCoordObject);
gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(
[0,0, 1,0, 0,1,
0,1, 1,0, 1,1]), gl.STATIC_DRAW);
gl.enableVertexAttribArray(1);
gl.vertexAttribPointer(1, 2, gl.FLOAT, false, 0, 0);
wtu.glErrorShouldBe(gl, gl.NO_ERROR, "after texture coord setup");
// Now resize these buffers because we want to change what we're drawing.
gl.bindBuffer(gl.ARRAY_BUFFER, vertexObject);
gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([
-1,1,0, 1,1,0, -1,-1,0, 1,-1,0,
-1,1,0, 1,1,0, -1,-1,0, 1,-1,0]), gl.STATIC_DRAW);
wtu.glErrorShouldBe(gl, gl.NO_ERROR, "after vertex redefinition");
gl.bindBuffer(gl.ARRAY_BUFFER, texCoordObject);
gl.bufferData(gl.ARRAY_BUFFER, new Uint8Array([
255, 0, 0, 255,
255, 0, 0, 255,
255, 0, 0, 255,
255, 0, 0, 255,
0, 255, 0, 255,
0, 255, 0, 255,
0, 255, 0, 255,
0, 255, 0, 255]), gl.STATIC_DRAW);
gl.vertexAttribPointer(1, 4, gl.UNSIGNED_BYTE, false, 0, 0);
wtu.glErrorShouldBe(gl, gl.NO_ERROR, "after texture coordinate / color redefinition");
var numQuads = 2;
var indices = new Uint8Array(numQuads * 6);
for (var ii = 0; ii < numQuads; ++ii) {
var offset = ii * 6;
var quad = (ii == (numQuads - 1)) ? 4 : 0;
indices[offset + 0] = quad + 0;
indices[offset + 1] = quad + 1;
indices[offset + 2] = quad + 2;
indices[offset + 3] = quad + 2;
indices[offset + 4] = quad + 1;
indices[offset + 5] = quad + 3;
}
var indexObject = gl.createBuffer();
gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, indexObject);
gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, indices, gl.STATIC_DRAW);
wtu.glErrorShouldBe(gl, gl.NO_ERROR, "after setting up indices");
gl.drawElements(gl.TRIANGLES, numQuads * 6, gl.UNSIGNED_BYTE, 0);
wtu.glErrorShouldBe(gl, gl.NO_ERROR, "after drawing");
debug("")
var successfullyParsed = true;
</script>
<script src="../../resources/js-test-post.js"></script>
</body>
</html>

Просмотреть файл

@ -0,0 +1,138 @@
<!--
/*
** Copyright (c) 2012 The Khronos Group Inc.
**
** Permission is hereby granted, free of charge, to any person obtaining a
** copy of this software and/or associated documentation files (the
** "Materials"), to deal in the Materials without restriction, including
** without limitation the rights to use, copy, modify, merge, publish,
** distribute, sublicense, and/or sell copies of the Materials, and to
** permit persons to whom the Materials are furnished to do so, subject to
** the following conditions:
**
** The above copyright notice and this permission notice shall be included
** in all copies or substantial portions of the Materials.
**
** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
*/
-->
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<link rel="stylesheet" href="../../resources/js-test-style.css"/>
<script src="../../resources/js-test-pre.js"></script>
<script src="../resources/webgl-test-utils.js"></script>
</head>
<body>
<div id="description"></div>
<div id="console"></div>
<script>
"use strict";
description("Tests that index validation verifies the correct number of indices");
function sizeInBytes(type) {
switch (type) {
case gl.BYTE:
case gl.UNSIGNED_BYTE:
return 1;
case gl.SHORT:
case gl.UNSIGNED_SHORT:
return 2;
case gl.INT:
case gl.UNSIGNED_INT:
case gl.FLOAT:
return 4;
default:
throw "unknown type";
}
}
var wtu = WebGLTestUtils;
var gl = wtu.create3DContext();
var program = wtu.loadStandardProgram(gl);
// 3 vertices => 1 triangle, interleaved data
var dataComplete = new Float32Array([0, 0, 0, 1,
0, 0, 1,
1, 0, 0, 1,
0, 0, 1,
1, 1, 1, 1,
0, 0, 1]);
var dataIncomplete = new Float32Array([0, 0, 0, 1,
0, 0, 1,
1, 0, 0, 1,
0, 0, 1,
1, 1, 1, 1]);
var indices = new Uint16Array([0, 1, 2]);
debug("Testing with valid indices");
var bufferComplete = gl.createBuffer();
gl.bindBuffer(gl.ARRAY_BUFFER, bufferComplete);
gl.bufferData(gl.ARRAY_BUFFER, dataComplete, gl.STATIC_DRAW);
var elements = gl.createBuffer();
gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, elements);
gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, indices, gl.STATIC_DRAW);
gl.useProgram(program);
var vertexLoc = gl.getAttribLocation(program, "a_vertex");
var normalLoc = gl.getAttribLocation(program, "a_normal");
gl.vertexAttribPointer(vertexLoc, 4, gl.FLOAT, false, 7 * sizeInBytes(gl.FLOAT), 0);
gl.enableVertexAttribArray(vertexLoc);
gl.vertexAttribPointer(normalLoc, 3, gl.FLOAT, false, 7 * sizeInBytes(gl.FLOAT), 4 * sizeInBytes(gl.FLOAT));
gl.enableVertexAttribArray(normalLoc);
shouldBe('gl.checkFramebufferStatus(gl.FRAMEBUFFER)', 'gl.FRAMEBUFFER_COMPLETE');
wtu.glErrorShouldBe(gl, gl.NO_ERROR);
shouldBeUndefined('gl.drawElements(gl.TRIANGLES, 3, gl.UNSIGNED_SHORT, 0)');
wtu.glErrorShouldBe(gl, gl.NO_ERROR);
debug("Testing with out-of-range indices");
var bufferIncomplete = gl.createBuffer();
gl.bindBuffer(gl.ARRAY_BUFFER, bufferIncomplete);
gl.bufferData(gl.ARRAY_BUFFER, dataIncomplete, gl.STATIC_DRAW);
gl.vertexAttribPointer(vertexLoc, 4, gl.FLOAT, false, 7 * sizeInBytes(gl.FLOAT), 0);
gl.enableVertexAttribArray(vertexLoc);
gl.disableVertexAttribArray(normalLoc);
debug("Enable vertices, valid");
wtu.glErrorShouldBe(gl, gl.NO_ERROR);
shouldBeUndefined('gl.drawElements(gl.TRIANGLES, 3, gl.UNSIGNED_SHORT, 0)');
wtu.glErrorShouldBe(gl, gl.NO_ERROR);
debug("Enable normals, out-of-range");
gl.vertexAttribPointer(normalLoc, 3, gl.FLOAT, false, 7 * sizeInBytes(gl.FLOAT), 4 * sizeInBytes(gl.FLOAT));
gl.enableVertexAttribArray(normalLoc);
wtu.glErrorShouldBe(gl, gl.NO_ERROR);
shouldBeUndefined('gl.drawElements(gl.TRIANGLES, 3, gl.UNSIGNED_SHORT, 0)');
wtu.glErrorShouldBe(gl, gl.INVALID_OPERATION);
debug("Test with enabled attribute that does not belong to current program");
gl.disableVertexAttribArray(normalLoc);
var extraLoc = Math.max(vertexLoc, normalLoc) + 1;
gl.enableVertexAttribArray(extraLoc);
debug("Enable an extra attribute with null");
wtu.glErrorShouldBe(gl, gl.NO_ERROR);
shouldBeUndefined('gl.drawElements(gl.TRIANGLES, 3, gl.UNSIGNED_SHORT, 0)');
wtu.glErrorShouldBe(gl, gl.INVALID_OPERATION);
debug("Enable an extra attribute with insufficient data buffer");
gl.vertexAttribPointer(extraLoc, 3, gl.FLOAT, false, 7 * sizeInBytes(gl.FLOAT), 4 * sizeInBytes(gl.FLOAT));
wtu.glErrorShouldBe(gl, gl.NO_ERROR);
shouldBeUndefined('gl.drawElements(gl.TRIANGLES, 3, gl.UNSIGNED_SHORT, 0)');
debug("Pass large negative index to vertexAttribPointer");
gl.vertexAttribPointer(normalLoc, 3, gl.FLOAT, false, 7 * sizeInBytes(gl.FLOAT), -2000000000 * sizeInBytes(gl.FLOAT));
wtu.glErrorShouldBe(gl, gl.INVALID_VALUE);
shouldBeUndefined('gl.drawElements(gl.TRIANGLES, 3, gl.UNSIGNED_SHORT, 0)');
var successfullyParsed = true;
</script>
<script src="../../resources/js-test-post.js"></script>
</body>
</html>

Просмотреть файл

@ -0,0 +1,15 @@
buffer-offscreen-test.html
buffer-preserve-test.html
canvas-test.html
canvas-zero-size.html
drawingbuffer-static-canvas-test.html
--min-version 1.0.2 drawingbuffer-hd-dpi-test.html
drawingbuffer-test.html
--min-version 1.0.3 draw-webgl-to-canvas-test.html
--min-version 1.0.3 draw-static-webgl-to-multiple-canvas-test.html
--min-version 1.0.2 framebuffer-bindings-unaffected-on-resize.html
--min-version 1.0.3 rapid-resizing.html
--min-version 1.0.2 texture-bindings-unaffected-on-resize.html
--min-version 1.0.2 to-data-url-test.html
viewport-unchanged-upon-resize.html

Просмотреть файл

@ -0,0 +1,99 @@
<!--
/*
** Copyright (c) 2012 The Khronos Group Inc.
**
** Permission is hereby granted, free of charge, to any person obtaining a
** copy of this software and/or associated documentation files (the
** "Materials"), to deal in the Materials without restriction, including
** without limitation the rights to use, copy, modify, merge, publish,
** distribute, sublicense, and/or sell copies of the Materials, and to
** permit persons to whom the Materials are furnished to do so, subject to
** the following conditions:
**
** The above copyright notice and this permission notice shall be included
** in all copies or substantial portions of the Materials.
**
** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
*/
-->
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>WebGL required buffer clear behaviour test</title>
<link rel="stylesheet" href="../../resources/js-test-style.css"/>
<script src="../../resources/js-test-pre.js"></script>
<script src="../resources/webgl-test-utils.js"> </script>
<style type="text/css">
body {
height: 3000px;
}
</style>
</head>
<body>
<div id="description"></div>
<canvas width="20" height="20" style="border: 1px solid blue;" id="c"></canvas>
<div id="console"></div>
<script>
description("This test ensures WebGL implementations correctly clear " +
"the drawing buffer on composite if preserveDrawingBuffer is false.");
debug("");
var wtu = WebGLTestUtils;
var gl1 = wtu.create3DContext("c");
var gl2 = wtu.create3DContext();
shouldBeTrue("gl1 != null");
shouldBeTrue("gl2 != null");
shouldBeTrue('gl1.getContextAttributes().preserveDrawingBuffer == false');
shouldBeTrue('gl2.getContextAttributes().preserveDrawingBuffer == false');
function init(gl) {
gl.clearColor(1, 0, 0, 1);
gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT | gl.STENCIL_BUFFER_BIT);
// enable scissor here, before compositing, to make sure it's correctly
// ignored and restored
gl.scissor(0, 10, 10, 10);
gl.enable(gl.SCISSOR_TEST);
}
init(gl1);
init(gl2);
wtu.waitForComposite(function() {
function clear(gl) {
// scissor was set earlier
gl.clearColor(0, 0, 1, 1);
gl.clear(gl.COLOR_BUFFER_BIT);
}
clear(gl1);
clear(gl2);
debug("check on screen canvas");
wtu.checkCanvasRect(gl1, 0, 10, 10, 10, [0, 0, 255, 255],
"cleared corner should be blue, stencil should be preserved");
wtu.checkCanvasRect(gl1, 0, 0, 10, 10, [0, 0, 0, 0],
"remainder of buffer should be cleared");
debug("check off screen canvas");
wtu.checkCanvasRect(gl2, 0, 10, 10, 10, [0, 0, 255, 255],
"cleared corner should be blue, stencil should be preserved");
wtu.checkCanvasRect(gl2, 0, 0, 10, 10, [255, 0, 0, 255],
"remainder of buffer should be un-cleared red");
finishTest();
});
var successfullyParsed = true;
</script>
</body>
</html>

Просмотреть файл

@ -0,0 +1,87 @@
<!--
/*
** Copyright (c) 2012 The Khronos Group Inc.
**
** Permission is hereby granted, free of charge, to any person obtaining a
** copy of this software and/or associated documentation files (the
** "Materials"), to deal in the Materials without restriction, including
** without limitation the rights to use, copy, modify, merge, publish,
** distribute, sublicense, and/or sell copies of the Materials, and to
** permit persons to whom the Materials are furnished to do so, subject to
** the following conditions:
**
** The above copyright notice and this permission notice shall be included
** in all copies or substantial portions of the Materials.
**
** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
*/
-->
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>WebGL required buffer clear behaviour test</title>
<link rel="stylesheet" href="../../resources/js-test-style.css"/>
<script src="../../resources/js-test-pre.js"></script>
<script src="../resources/webgl-test-utils.js"> </script>
<style type="text/css">
body {
height: 3000px;
}
</style>
</head>
<body>
<!-- Important to put the canvas at the top so that it's always visible even in the test suite runner.
Otherwise it just doesn't get composited in Firefox. -->
<canvas width="20" height="20" style="border: 1px solid blue;" id="c"></canvas>
<div id="description"></div>
<div id="console"></div>
<script type="text/javascript">
"use strict";
description("This test ensures WebGL implementations correctly clear the drawing buffer " +
"on composite if preserveDrawingBuffer is false.");
debug("");
var wtu = WebGLTestUtils;
var gl = wtu.create3DContext("c");
shouldBeTrue("gl != null");
shouldBeTrue('gl.getContextAttributes().preserveDrawingBuffer == false');
gl.clearColor(1, 0, 0, 1);
gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT | gl.STENCIL_BUFFER_BIT);
// enable scissor here, before compositing, to make sure it's correctly
// ignored and restored
gl.scissor(0, 10, 10, 10);
gl.enable(gl.SCISSOR_TEST);
function clear() {
// scissor was set earlier
gl.clearColor(0, 0, 1, 1);
gl.clear(gl.COLOR_BUFFER_BIT);
wtu.checkCanvasRect(gl, 0, 10, 10, 10, [0, 0, 255, 255],
"cleared corner should be blue, stencil should be preserved");
wtu.checkCanvasRect(gl, 0, 0, 10, 10, [0, 0, 0, 0],
"remainder of buffer should be cleared");
finishTest();
return;
}
wtu.waitForComposite(clear);
var successfullyParsed = true;
</script>
</body>
</html>

Просмотреть файл

@ -1,17 +1,38 @@
<!--
Copyright (c) 2011 The Chromium Authors. All rights reserved.
Use of this source code is governed by a BSD-style license that can be
found in the LICENSE file.
-->
/*
** Copyright (c) 2012 The Khronos Group Inc.
**
** Permission is hereby granted, free of charge, to any person obtaining a
** copy of this software and/or associated documentation files (the
** "Materials"), to deal in the Materials without restriction, including
** without limitation the rights to use, copy, modify, merge, publish,
** distribute, sublicense, and/or sell copies of the Materials, and to
** permit persons to whom the Materials are furnished to do so, subject to
** the following conditions:
**
** The above copyright notice and this permission notice shall be included
** in all copies or substantial portions of the Materials.
**
** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
*/
-->
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>WebGL Canvas Conformance Tests</title>
<link rel="stylesheet" href="../../resources/js-test-style.css"/>
<script src="../../resources/desktop-gl-constants.js" type="text/javascript"></script>
<script src="../../resources/js-test-pre.js"></script>
<script src="../resources/webgl-test.js"></script>
<script src="../resources/webgl-test-utils.js"></script>
</head>
<body>
<div id="description"></div>
@ -19,9 +40,7 @@ found in the LICENSE file.
<canvas id="canvas" style="width: 50px; height: 50px;"> </canvas>
<canvas id="canvas2d" width="40" height="40"> </canvas>
<script>
if (window.initNonKhronosFramework) {
window.initNonKhronosFramework(true);
}
"use strict";
description("This test ensures WebGL implementations interact correctly with the canvas tag.");
@ -29,10 +48,11 @@ debug("");
debug("Canvas.getContext");
var err;
var wtu = WebGLTestUtils;
var canvas = document.getElementById("canvas");
var canvas2d = document.getElementById("canvas2d");
var ctx2d = canvas2d.getContext("2d");
var gl = create3DContext(canvas);
var gl = wtu.create3DContext(canvas);
if (!gl) {
testFailed("context does not exist");
} else {
@ -46,7 +66,7 @@ if (!gl) {
shouldBe('canvas.height', '150');
// Check get a 4 value gl parameter as a csv string.
function getValue4v(name) {
var getValue4v = function(name) {
var v = gl.getParameter(name);
var result = '' +
v[0] + ',' +
@ -56,29 +76,29 @@ if (!gl) {
return result;
}
function getViewport() {
var getViewport = function() {
return getValue4v(gl.VIEWPORT);
}
function getClearColor() {
var getClearColor = function() {
return getValue4v(gl.COLOR_CLEAR_VALUE);
}
function isAboutEqual(a, b) {
var isAboutEqual = function(a, b) {
return Math.abs(a - b) < 0.01;
}
function isAboutEqualInt(a, b) {
var isAboutEqualInt = function(a, b) {
return Math.abs(a - b) < 3;
}
function checkCanvasContentIs(r3d,g3d,b3d,a3d) {
var checkCanvasContentIs = function(r3d,g3d,b3d,a3d) {
var r2d;
var g2d;
var b2d;
var a2d;
function checkPixel(x, y, r3d,g3d,b3d,a3d) {
var checkPixel = function(x, y, r3d,g3d,b3d,a3d) {
var offset = (y * 40 + x) * 4;
r2d = imgData.data[offset];
g2d = imgData.data[offset + 1];
@ -91,7 +111,7 @@ if (!gl) {
isAboutEqualInt(a2d, a3d);
}
function checkPixels(r3d,g3d,b3d,a3d) {
var checkPixels = function(r3d,g3d,b3d,a3d) {
return checkPixel(0, 0, r3d, g3d, b3d, a3d) &&
checkPixel(0, 39, r3d, g3d, b3d, a3d) &&
checkPixel(39, 0, r3d, g3d, b3d, a3d) &&
@ -158,7 +178,7 @@ if (!gl) {
gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
checkCanvasContentIs(64, 128, 192, 255);
gl.colorMask(0,0,0,0);
glErrorShouldBe(gl, gl.NO_ERROR, "No GL errors before resizing the canvas");
wtu.glErrorShouldBe(gl, gl.NO_ERROR, "No GL errors before resizing the canvas");
canvas.width = 400;
canvas.height = 10;
err = gl.getError();

Просмотреть файл

@ -0,0 +1,64 @@
<!--
/*
** Copyright (c) 2012 The Khronos Group Inc.
**
** Permission is hereby granted, free of charge, to any person obtaining a
** copy of this software and/or associated documentation files (the
** "Materials"), to deal in the Materials without restriction, including
** without limitation the rights to use, copy, modify, merge, publish,
** distribute, sublicense, and/or sell copies of the Materials, and to
** permit persons to whom the Materials are furnished to do so, subject to
** the following conditions:
**
** The above copyright notice and this permission notice shall be included
** in all copies or substantial portions of the Materials.
**
** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
*/
-->
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Zero Size Canvas Test</title>
<link rel="stylesheet" href="../../resources/js-test-style.css"/>
<script src="../../resources/js-test-pre.js"></script>
<script src="../resources/webgl-test-utils.js"> </script>
</head>
<body>
<div id="description"></div>
<div id="console"></div>
<script>
"use strict";
description("Tests that a zero size canvas does not fail.");
var wtu = WebGLTestUtils;
var canvas = document.createElement('canvas');
var gl = wtu.create3DContext(canvas);
canvas.width = 0;
canvas.height = 0;
gl.viewport(0, 0, 0, 0);
var program = wtu.setupTexturedQuad(gl);
shouldBeTrue("program != null");
var tex = gl.createTexture();
gl.bindTexture(gl.TEXTURE_2D, tex);
var pixel = new Uint8Array([0, 255, 0, 255]);
gl.texImage2D(
gl.TEXTURE_2D, 0, gl.RGBA, 1, 1, 0, gl.RGBA, gl.UNSIGNED_BYTE, pixel);
wtu.clearAndDrawUnitQuad(gl);
wtu.glErrorShouldBe(gl, gl.NO_ERROR, "Should be no errors from setup.");
var successfullyParsed = true;
</script>
<script src="../../resources/js-test-post.js"></script>
</body>
</html>

Просмотреть файл

@ -0,0 +1,96 @@
<!--
/*
** Copyright (c) 2013 The Khronos Group Inc.
**
** Permission is hereby granted, free of charge, to any person obtaining a
** copy of this software and/or associated documentation files (the
** "Materials"), to deal in the Materials without restriction, including
** without limitation the rights to use, copy, modify, merge, publish,
** distribute, sublicense, and/or sell copies of the Materials, and to
** permit persons to whom the Materials are furnished to do so, subject to
** the following conditions:
**
** The above copyright notice and this permission notice shall be included
** in all copies or substantial portions of the Materials.
**
** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
*/
-->
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>WebGL Canvas Conformance Tests</title>
<link rel="stylesheet" href="../../resources/js-test-style.css"/>
<script src="../../resources/js-test-pre.js"></script>
<script src="../resources/webgl-test-utils.js"></script>
</head>
<body>
<div id="description"></div>
<div id="console"></div>
<canvas id="canvas2d_0" width="128" height="128"> </canvas>
<canvas id="canvas2d_1" width="400" height="400"> </canvas>
<canvas id="canvas2d_2" width="128" height="128"> </canvas>
<canvas id="webgl" width="400" height="400"> </canvas>
<script>
"use strict";
description("This test ensures WebGL implementations interact correctly with the canvas 2D drawImage call when drawing the same content.");
var err;
var wtu = WebGLTestUtils;
var canvas2d = [];
var ctx2d = [];
for (var i = 0; i < 3; i ++) {
canvas2d[i] = document.getElementById("canvas2d_" + i);
ctx2d[i] = canvas2d[i].getContext("2d");
}
var canvas = document.getElementById("webgl");
var gl = wtu.create3DContext(canvas);
if (!gl) {
testFailed("context does not exist");
} else {
testPassed("context exists");
debug("Checking drawing the same WebGL content to HW accelerated canvas and SW Canvases");
debug("");
var color = [[0.25, 0.5, 0.75, 1], [1, 0, 0, 1], [1, 0, 1, 1]];
var colorValue = [[64, 128, 192, 255], [255, 0, 0, 255], [255, 0, 255, 255]];
for (var count = 0; count < 10; count ++) {
for (var i = 0; i < 3; i++) {
gl.clearColor(color[i][0], color[i][1], color[i][2], color[i][3]);
gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
ctx2d[0].drawImage(canvas, 0, 0, canvas2d[0].width, canvas2d[0].height);
ctx2d[1].drawImage(canvas, 0, 0, canvas2d[1].width, canvas2d[1].height);
ctx2d[2].drawImage(canvas, 0, 0, canvas2d[2].width, canvas2d[2].height);
wtu.checkCanvasRect(ctx2d[0], 0, 0, canvas2d[0].width, canvas2d[0].height, colorValue[i],
"drawImage: Should be (" + colorValue[i][0] + "," + colorValue[i][1] +
"," + colorValue[i][2] + "," + colorValue[i][3] + ").", 2);
wtu.checkCanvasRect(ctx2d[1], 0, 0, canvas2d[1].width, canvas2d[1].height, colorValue[i],
"drawImage: Should be (" + colorValue[i][0] + "," + colorValue[i][1] +
"," + colorValue[i][2] + "," + colorValue[i][3] + ").", 2);
wtu.checkCanvasRect(ctx2d[2], 0, 0, canvas2d[2].width, canvas2d[2].height, colorValue[i],
"drawImage: Should be (" + colorValue[i][0] + "," + colorValue[i][1] +
"," + colorValue[i][2] + "," + colorValue[i][3] + ").", 2);
}
}
err = gl.getError();
debug("");
finishTest();
}
</script>
</body>
</html>

Просмотреть файл

@ -0,0 +1,99 @@
<!--
/*
** Copyright (c) 2013 The Khronos Group Inc.
**
** Permission is hereby granted, free of charge, to any person obtaining a
** copy of this software and/or associated documentation files (the
** "Materials"), to deal in the Materials without restriction, including
** without limitation the rights to use, copy, modify, merge, publish,
** distribute, sublicense, and/or sell copies of the Materials, and to
** permit persons to whom the Materials are furnished to do so, subject to
** the following conditions:
**
** The above copyright notice and this permission notice shall be included
** in all copies or substantial portions of the Materials.
**
** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
*/
-->
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>WebGL Canvas Conformance Tests</title>
<link rel="stylesheet" href="../../resources/js-test-style.css"/>
<script src="../../resources/js-test-pre.js"></script>
<script src="../resources/webgl-test-utils.js"></script>
</head>
<body>
<div id="description"></div>
<div id="console"></div>
<canvas id="canvas2d_0" width="400" height="400"> </canvas>
<canvas id="canvas2d_1" width="400" height="400"> </canvas>
<canvas id="canvas2d_2" width="400" height="400"> </canvas>
<canvas id="webgl" width="400" height="400"> </canvas>
<script>
"use strict";
description("This test ensures WebGL implementations interact correctly with the canvas 2D drawImage call.");
var err;
var wtu = WebGLTestUtils;
var canvas2d = [];
var ctx2d = [];
for (var i = 0; i < 3; i ++) {
canvas2d[i] = document.getElementById("canvas2d_" + i);
ctx2d[i] = canvas2d[i].getContext("2d");
}
var canvas = document.getElementById("webgl");
var gl = wtu.create3DContext(canvas);
if (!gl) {
testFailed("context does not exist");
} else {
testPassed("context exists");
debug("");
debug("Checking canvas and WebGL drawImage interaction");
for (var count = 0; count < 10; count ++) {
gl.clearColor(0.25, 0.5, 0.75, 1);
gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
ctx2d[0].drawImage(canvas, 0, 0, canvas2d[0].width, canvas2d[0].height);
gl.clearColor(1, 0, 0, 1);
gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
ctx2d[1].drawImage(canvas, 0, 0, canvas2d[1].width, canvas2d[1].height);
gl.clearColor(1, 0, 1, 1);
gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
ctx2d[2].drawImage(canvas, 0, 0, canvas2d[2].width, canvas2d[2].height);
gl.clearColor(1, 1, 0, 1);
gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
wtu.checkCanvasRect(ctx2d[0], 0, 0, canvas2d[0].width, canvas2d[0].height, [64, 128, 192, 255],
"drawImage: Should be [64, 128, 192, 255]", 2);
wtu.checkCanvasRect(ctx2d[1], 0, 0, canvas2d[1].width, canvas2d[1].height, [255, 0, 0, 255],
"drawImage: Should be [255, 0, 0, 255]", 2);
wtu.checkCanvasRect(ctx2d[2], 0, 0, canvas2d[2].width, canvas2d[2].height, [255, 0, 255, 255],
"drawImage: Should be [255, 0, 255, 255]", 2);
}
err = gl.getError();
debug("");
finishTest();
}
</script>
</body>
</html>

Просмотреть файл

@ -0,0 +1,225 @@
<!--
/*
** Copyright (c) 2012 The Khronos Group Inc.
**
** Permission is hereby granted, free of charge, to any person obtaining a
** copy of this software and/or associated documentation files (the
** "Materials"), to deal in the Materials without restriction, including
** without limitation the rights to use, copy, modify, merge, publish,
** distribute, sublicense, and/or sell copies of the Materials, and to
** permit persons to whom the Materials are furnished to do so, subject to
** the following conditions:
**
** The above copyright notice and this permission notice shall be included
** in all copies or substantial portions of the Materials.
**
** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
*/
-->
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>WebGL DrawingBuffer dimensions on HD-DPI machines test</title>
<link rel="stylesheet" href="../../resources/js-test-style.css"/>
<script src="../../resources/js-test-pre.js"></script>
<script src="../resources/webgl-test-utils.js"></script>
</head>
<body>
<div id="description"></div>
<div id="console"></div>
<script id="vshaderGrid" type="x-shader/x-vertex">
attribute vec4 a_position;
void main()
{
gl_Position = a_position;
}
</script>
<script id="fshaderGrid" type="x-shader/x-fragment">
precision mediump float;
void main()
{
float r = mod(gl_FragCoord.x, 2.0) < 1.0 ? 0.0 : 1.0;
float g = mod(gl_FragCoord.y, 2.0) < 1.0 ? 0.0 : 1.0;
gl_FragColor = vec4(r, g, 0, 1);
}
</script>
<script>
"use strict";
description();
debug("");
var gl;
var canvas;
function checkDimensions() {
// We expect that for the sizes being testing drawingBufferWidth and drawingBufferHeight
// will match canvas.width and canvas.height.
// We need to test that devicePixelRatio does not effect the backbuffer size of a canvas.
shouldBe('gl.drawingBufferWidth', 'canvas.width');
shouldBe('gl.drawingBufferHeight', 'canvas.height');
}
// This uses gl_FragCoord to draw a device pixel relavent pattern.
// If drawBufferWidth or drawBufferHeight are not in device pixels
// this test should fail.
function checkGrid(gl, width, height) {
var program = wtu.setupProgram(gl, ["vshaderGrid", "fshaderGrid"], ["a_position"]);
wtu.setupUnitQuad(gl);
gl.useProgram(program);
shouldBe('gl.getError()', 'gl.NO_ERROR');
wtu.clearAndDrawUnitQuad(gl);
var pixels = new Uint8Array(width * height * 4);
gl.readPixels(0, 0, width, height, gl.RGBA, gl.UNSIGNED_BYTE, pixels);
var colors = [
[ { color: [0, 0, 0, 255], name: "black" }, { color: [255, 0, 0, 255], name: "red" } ],
[ { color: [0, 255, 0, 255], name: "green" }, { color: [255, 255, 0, 255], name: "yellow" } ],
];
for (var yy = 0; yy < height; ++yy) {
for (var xx = 0; xx < width; ++xx) {
var info = colors[yy % 2][xx % 2];
var color = info.color;
var offset = (yy * width + xx) * 4;
for (var jj = 0; jj < 4; ++jj) {
if (pixels[offset + jj] != color[jj]) {
var actual = [pixels[offset], pixels[offset + 1], pixels[offset + 2], pixels[offset + 3]];
testFailed("at " + xx + ", " + yy + " expected " + color + "(" + info.name + ") was " + actual);
return;
}
}
}
}
testPassed("grid rendered correctly");
}
// This passes device coordinate vertices in to make sure gl.viewport is not being mucked with.
function checkQuad(gl, width, height) {
var deviceToClipSpace = function(value, range) {
return value / range * 2 - 1;
}
var program = wtu.setupColorQuad(gl);
// draw a small green square in the top right corner.
var deviceX1 = width - 4;
var deviceX2 = width;
var deviceY1 = height - 4;
var deviceY2 = height;
var clipX1 = deviceToClipSpace(deviceX1, width);
var clipX2 = deviceToClipSpace(deviceX2, width);
var clipY1 = deviceToClipSpace(deviceY1, height);
var clipY2 = deviceToClipSpace(deviceY2, height);
var vertexObject = gl.createBuffer();
gl.bindBuffer(gl.ARRAY_BUFFER, vertexObject);
gl.bufferData(
gl.ARRAY_BUFFER,
new Float32Array(
[ clipX2, clipY2,
clipX1, clipY2,
clipX1, clipY1,
clipX2, clipY2,
clipX1, clipY1,
clipX2, clipY1]),
gl.STATIC_DRAW);
gl.enableVertexAttribArray(0);
gl.vertexAttribPointer(0, 2, gl.FLOAT, false, 0, 0);
var green = [0, 255, 0, 255];
var black = [0, 0, 0, 0];
gl.clearColor(0, 0, 0, 0);
gl.clear(gl.COLOR_BUFFER_BIT);
wtu.drawUByteColorQuad(gl, [0, 255, 0, 255]);
var squareWidth = deviceX2 - deviceX1;
var squareHeight = deviceY2 - deviceY1;
// check the square.
wtu.checkCanvasRect(gl, deviceX1, deviceY1, squareWidth, squareHeight, green, "should be green");
// check outside the square.
wtu.checkCanvasRect(gl, 0, 0, width, height - squareHeight, black, "should be black");
wtu.checkCanvasRect(gl, 0, height - squareHeight, width - squareWidth, squareHeight, black, "should be black");
}
function test(desiredWidth, desiredHeight) {
debug("");
debug("testing canvas width = " + desiredWidth + ", height = " + desiredHeight);
// Make a fresh canvas.
canvas = document.createElement("canvas");
canvas.width = desiredWidth;
canvas.height = desiredHeight;
// This 'gl' must be global for shouldBe to work.
gl = wtu.create3DContext(canvas, {antialias: false});
if (!gl) {
testFailed("context does not exist");
} else {
testPassed("context exists");
// Check the dimensions are correct.
checkDimensions();
// Draw a pixel grid using a shader that draws in device coordinates
checkGrid(gl, desiredWidth, desiredHeight);
// Draw a quad in the top right corner.
checkQuad(gl, desiredWidth, desiredHeight);
shouldBe('gl.getError()', 'gl.NO_ERROR');
debug("");
debug("testing resizing canvas to width = " + desiredWidth + ", height = " + desiredHeight);
var oldViewport = gl.getParameter(gl.VIEWPORT);
// flip width and height
canvas.width = desiredHeight;
canvas.height = desiredWidth;
// fix the viewport
gl.viewport(0, 0, desiredHeight, desiredWidth);
// Check the dimensions are correct.
checkDimensions();
// Draw a pixel grid using a shader that draws in device coordinates
checkGrid(gl, desiredHeight, desiredWidth);
// Draw a quad in the top right corner.
checkQuad(gl, desiredHeight, desiredWidth);
shouldBe('gl.getError()', 'gl.NO_ERROR');
}
}
var wtu = WebGLTestUtils;
// test a few sizes
test(32, 16);
test(128, 64);
test(256, 512);
debug("")
var successfullyParsed = true;
</script>
<script src="../../resources/js-test-post.js"></script>
</body>
</html>

Просмотреть файл

@ -0,0 +1,137 @@
<!--
/*
** Copyright (c) 2012 The Khronos Group Inc.
**
** Permission is hereby granted, free of charge, to any person obtaining a
** copy of this software and/or associated documentation files (the
** "Materials"), to deal in the Materials without restriction, including
** without limitation the rights to use, copy, modify, merge, publish,
** distribute, sublicense, and/or sell copies of the Materials, and to
** permit persons to whom the Materials are furnished to do so, subject to
** the following conditions:
**
** The above copyright notice and this permission notice shall be included
** in all copies or substantial portions of the Materials.
**
** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
*/
-->
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>WebGL Canvas Conformance Tests</title>
<link rel="stylesheet" href="../../resources/js-test-style.css"/>
<script src="../../resources/js-test-pre.js"></script>
<script src="../resources/webgl-test-utils.js"></script>
</head>
<body>
<div id="description"></div>
<div id="console"></div>
<canvas id="canvas" width="50" height="50"> </canvas>
<script id="vshader" type="x-shader/x-vertex">
attribute vec4 vPosition;
void main()
{
gl_Position = vPosition;
}
</script>
<script id="fshader" type="x-shader/x-fragment">
void main()
{
gl_FragColor = vec4(1.0,0.0,0.0,1.0);
}
</script>
<script>
"use strict";
function drawTriangleTest(gl)
{
var width = 50;
var height = 50;
gl.viewport(0, 0, width, height);
var vertexObject = gl.createBuffer();
gl.bindBuffer(gl.ARRAY_BUFFER, vertexObject);
gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([ 0,0.5,0, -0.5,-0.5,0, 0.5,-0.5,0 ]), gl.STATIC_DRAW);
gl.enableVertexAttribArray(0);
gl.vertexAttribPointer(0, 3, gl.FLOAT, false, 0, 0);
gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
gl.drawArrays(gl.TRIANGLES, 0, 3);
// Test several locations
wtu.checkCanvasRect(gl, 0, 0, width, 1, [0, 0, 0, 255],
'First line should be all black');
wtu.checkCanvasRect(gl, 20, 15, 10, 1, [255, 0, 0, 255],
'Line 15 should be red for at least 10 red pixels starting 20 pixels in');
wtu.checkCanvasRect(gl, 0, height - 1, width, 1, [0, 0, 0, 255],
'Last line should be all black');
}
description("This test ensures WebGL implementations correctly implement drawingbufferWidth/Height with compositing.");
debug("");
var wtu = WebGLTestUtils;
var err;
var maxSize;
var gl = wtu.create3DContext("canvas");
if (!gl) {
testFailed("context does not exist");
} else {
testPassed("context exists");
var program = wtu.setupProgram(gl, ["vshader", "fshader"], ["vPosition"]);
shouldBeNonNull("program");
gl.enable(gl.DEPTH_TEST);
gl.clearColor(0, 0, 0, 1);
shouldBe('gl.getError()', 'gl.NO_ERROR');
debug("");
debug("Checking drawingBufferWidth/drawingBufferHeight");
shouldBe('gl.drawingBufferWidth', 'gl.canvas.width');
shouldBe('gl.drawingBufferHeight', 'gl.canvas.height');
// Check that changing the canvas size to something too large falls back to reasonable values.
maxSize = gl.getParameter(gl.MAX_VIEWPORT_DIMS);
shouldBeTrue('maxSize[0] > 0');
shouldBeTrue('maxSize[1] > 0');
// debug("MAX_VIEWPORT_DIMS = " + maxSize[0] + "x" + maxSize[1]);
gl.canvas.width = maxSize[0] * 4;
gl.canvas.height = maxSize[1] * 4;
shouldBeTrue('gl.drawingBufferWidth > 0');
shouldBeTrue('gl.drawingBufferHeight > 0');
shouldBeTrue('gl.drawingBufferWidth <= maxSize[0]');
shouldBeTrue('gl.drawingBufferHeight <= maxSize[1]');
shouldBe('gl.getError()', 'gl.NO_ERROR');
debug("");
debug("Checking scaling up then back down to 50/50, drawing still works.");
gl.canvas.width = 50;
gl.canvas.height = 50;
shouldBeTrue('gl.drawingBufferWidth == 50');
shouldBeTrue('gl.drawingBufferHeight == 50');
shouldBe('gl.getError()', 'gl.NO_ERROR');
drawTriangleTest(gl);
shouldBe('gl.getError()', 'gl.NO_ERROR');
}
debug("")
var successfullyParsed = true;
</script>
<script src="../../resources/js-test-post.js"></script>
</body>
</html>

Просмотреть файл

@ -0,0 +1,138 @@
<!--
/*
** Copyright (c) 2012 The Khronos Group Inc.
**
** Permission is hereby granted, free of charge, to any person obtaining a
** copy of this software and/or associated documentation files (the
** "Materials"), to deal in the Materials without restriction, including
** without limitation the rights to use, copy, modify, merge, publish,
** distribute, sublicense, and/or sell copies of the Materials, and to
** permit persons to whom the Materials are furnished to do so, subject to
** the following conditions:
**
** The above copyright notice and this permission notice shall be included
** in all copies or substantial portions of the Materials.
**
** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
*/
-->
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>WebGL Canvas.drawingBufferWidth,drawingBufferHeight Conformance Tests</title>
<link rel="stylesheet" href="../../resources/js-test-style.css"/>
<script src="../../resources/js-test-pre.js"></script>
<script src="../resources/webgl-test-utils.js"></script>
</head>
<body>
<div id="description"></div>
<div id="console"></div>
<script>
"use strict";
description();
debug("");
var gl;
var oldViewport;
function getMaxViewportDimensions() {
// create a fresh canvas. This canvas will be discarded
// after exiting this function.
var canvas = document.createElement("canvas");
gl = wtu.create3DContext(canvas, {antialias: false});
if (!gl) {
testFailed("context does not exist");
return [0, 0];
} else {
testPassed("context exists");
// For a default size canvas these should be equal.
// WebGL contexts are not allowed to change the size of the drawingBuffer
// for things like hi-res displays.
shouldBe('gl.drawingBufferWidth', 'gl.canvas.width');
shouldBe('gl.drawingBufferHeight', 'gl.canvas.height');
return gl.getParameter(gl.MAX_VIEWPORT_DIMS);
}
}
function test(desiredWidth, desiredHeight) {
debug("");
debug("testing canvas width = " + desiredWidth + ", height = " + desiredHeight);
// Make a fresh canvas.
var canvas = document.createElement("canvas");
canvas.width = desiredWidth;
canvas.height = desiredHeight;
// This 'gl' must be global for shouldBe to work.
gl = wtu.create3DContext(canvas, {antialias: false});
if (!gl) {
testFailed("context does not exist");
} else {
testPassed("context exists");
// Verify these stats didn't change since they come from a different
// context.
shouldBe('gl.getParameter(gl.MAX_VIEWPORT_DIMS)[0]', 'maxSize[0]');
shouldBe('gl.getParameter(gl.MAX_VIEWPORT_DIMS)[1]', 'maxSize[1]');
// check the initial viewport matches the drawingBufferWidth and drawingBufferHeight
shouldBe('gl.getParameter(gl.VIEWPORT)[0]', '0');
shouldBe('gl.getParameter(gl.VIEWPORT)[1]', '0');
shouldBe('gl.getParameter(gl.VIEWPORT)[2]', 'gl.drawingBufferWidth');
shouldBe('gl.getParameter(gl.VIEWPORT)[3]', 'gl.drawingBufferHeight');
debug("");
debug("testing resizing canvas to width = " + desiredWidth + ", height = " + desiredHeight);
oldViewport = gl.getParameter(gl.VIEWPORT);
// flip width and height
canvas.width = desiredHeight;
canvas.height = desiredWidth;
// Verify the viewport didn't change.
shouldBe('gl.getParameter(gl.VIEWPORT)[0]', 'oldViewport[0]');
shouldBe('gl.getParameter(gl.VIEWPORT)[1]', 'oldViewport[1]');
shouldBe('gl.getParameter(gl.VIEWPORT)[2]', 'oldViewport[2]');
shouldBe('gl.getParameter(gl.VIEWPORT)[3]', 'oldViewport[3]');
// fix the viewport
// gl.viewport(0, 0, gl.drawingBufferWidth, gl.drawingBufferHeight);
shouldBe('gl.getError()', 'gl.NO_ERROR');
}
}
var wtu = WebGLTestUtils;
var maxSize = getMaxViewportDimensions();
debug("MAX_VIEWPORT_DIMS: " + maxSize[0] + ", " + maxSize[1]);
shouldBeTrue('maxSize[0] > 0');
shouldBeTrue('maxSize[1] > 0');
// test a small size to make sure it works at all.
test(16, 32);
// Make a canvas slightly larger than the max size WebGL can handle.
// From section 2.2 of the spec the WebGL implementation should allow this to work.
// test a size larger than MAX_VIEWPORT_DIMS in both dimensions
test(maxSize[0] + 32, 8);
debug("")
var successfullyParsed = true;
</script>
<script src="../../resources/js-test-post.js"></script>
</body>
</html>

Просмотреть файл

@ -0,0 +1,106 @@
<!--
/*
** Copyright (c) 2012 The Khronos Group Inc.
**
** Permission is hereby granted, free of charge, to any person obtaining a
** copy of this software and/or associated documentation files (the
** "Materials"), to deal in the Materials without restriction, including
** without limitation the rights to use, copy, modify, merge, publish,
** distribute, sublicense, and/or sell copies of the Materials, and to
** permit persons to whom the Materials are furnished to do so, subject to
** the following conditions:
**
** The above copyright notice and this permission notice shall be included
** in all copies or substantial portions of the Materials.
**
** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
*/
-->
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Verifies that GL framebuffer bindings do not change when canvas is resized</title>
<link rel="stylesheet" href="../../resources/js-test-style.css"/>
<script src="../../resources/js-test-pre.js"></script>
<script src="../resources/webgl-test-utils.js"></script>
</head>
<body>
<canvas id="example" width="4" height="4"></canvas>
<div id="description"></div>
<div id="console"></div>
<script>
"use strict";
enableJSTestPreVerboseLogging();
description("Verifies that GL framebuffer bindings do not change when canvas is resized");
var err;
var wtu = WebGLTestUtils;
var canvas = document.getElementById("example");
var gl = wtu.create3DContext(canvas);
var green = [0, 255, 0, 255];
var blue = [0, 0, 255, 255];
var fboSize = 2;
shouldBeTrue("fboSize < canvas.width");
var fbo = gl.createFramebuffer();
gl.bindFramebuffer(gl.FRAMEBUFFER, fbo);
var fboTex = gl.createTexture();
gl.activeTexture(gl.TEXTURE1);
gl.bindTexture(gl.TEXTURE_2D, fboTex);
gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, fboTex, 0);
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, fboSize, fboSize, 0, gl.RGBA, gl.UNSIGNED_BYTE, null);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
shouldBe("gl.checkFramebufferStatus(gl.FRAMEBUFFER)", "gl.FRAMEBUFFER_COMPLETE");
function checkFBO(color, msg) {
wtu.checkCanvasRect(gl, 0, 0, fboSize, fboSize, color, msg);
wtu.checkCanvasRect(gl, fboSize, fboSize, fboSize, fboSize, [0, 0, 0, 0], "area outside fbo should be transparent black");
}
// The FBO is 2x2 and it's bound so clearing should clear a 2x2 area
// and calling read pixels should read the clear color in that 2x2 area
// and 0,0,0,0 outside that area.
//
// If the FBO is no longer bound because of a WebGL implementation error
// then likely the clear will clear the backbuffer and reading outside
// the 2x2 area will not be 0,0,0,0
function test() {
gl.clearColor(0, 0, 1, 1);
gl.clear(gl.COLOR_BUFFER_BIT);
checkFBO(blue, "should be blue");
gl.clearColor(0, 1, 0, 1);
gl.clear(gl.COLOR_BUFFER_BIT);
checkFBO(green, "should be green");
}
debug("test before resizing canvas");
test();
debug("test after resizing canvas");
canvas.width = 8;
test();
debug("test after resizing canvas and waiting for compositing");
canvas.width = 16;
wtu.waitForComposite(function() {
test();
finishTest();
wtu.glErrorShouldBe(gl, gl.NO_ERROR, "Should be no errors.");
});
var successfullyParsed = true;
</script>
</body>
</html>

Просмотреть файл

@ -0,0 +1,170 @@
<!--
/*
** Copyright (c) 2013 The Khronos Group Inc.
**
** Permission is hereby granted, free of charge, to any person obtaining a
** copy of this software and/or associated documentation files (the
** "Materials"), to deal in the Materials without restriction, including
** without limitation the rights to use, copy, modify, merge, publish,
** distribute, sublicense, and/or sell copies of the Materials, and to
** permit persons to whom the Materials are furnished to do so, subject to
** the following conditions:
**
** The above copyright notice and this permission notice shall be included
** in all copies or substantial portions of the Materials.
**
** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
*/
-->
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>WebGL Rapid Resizing Test</title>
<link rel="stylesheet" href="../../resources/js-test-style.css"/>
<script src="../../resources/js-test-pre.js"></script>
<script src="../resources/webgl-test-utils.js"></script>
</head>
<body>
<div id="description"></div>
<canvas id="canvas" style="width: 256px; height: 256px;"> </canvas>
<div id="console"></div>
<script id="vshader" type="x-shader/x-vertex">
attribute vec2 position;
void main()
{
gl_Position = vec4(position, 0.0, 1.0);
}
</script>
<script id="fshader" type="x-shader/x-fragment">
void main()
{
gl_FragColor = vec4(0.0,1.0,0.0,1.0);
}
</script>
<script>
"use strict";
description("Verifies that rapidly resizing the canvas works correctly.");
debug("");
debug("Regression test for Chromium <a href='http://crbug.com/299371'>Issue 299371</a>");
debug("");
var err;
var wtu = WebGLTestUtils;
var canvas = document.getElementById("canvas");
var largeSize = 256;
var smallSize = 128;
var currentSize = largeSize;
canvas.width = largeSize;
canvas.height = largeSize;
var gl = wtu.create3DContext(canvas);
var numFrames = 0;
if (!gl) {
testFailed("context does not exist");
} else {
testPassed("context exists");
gl.clearColor(0, 0, 0, 1);
var program = wtu.setupProgram(gl, ["vshader", "fshader"], ["position"]);
shouldBeNonNull("program");
// Prepare to draw quads
var quadSize = 0.1;
var vertexBuffer = gl.createBuffer();
gl.bindBuffer(gl.ARRAY_BUFFER, vertexBuffer);
gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([
// Lower left
-1, -1 + quadSize,
-1, -1,
-1 + quadSize, -1,
-1 + quadSize, -1 + quadSize,
// Lower right
1 - quadSize, -1 + quadSize,
1 - quadSize, -1,
1, -1,
1, -1 + quadSize,
// Upper right
1 - quadSize, 1,
1 - quadSize, 1 - quadSize,
1, 1 - quadSize,
1, 1,
// Upper left
-1, 1,
-1, 1 - quadSize,
-1 + quadSize, 1 - quadSize,
-1 + quadSize, 1
]), gl.STATIC_DRAW);
gl.enableVertexAttribArray(0);
gl.vertexAttribPointer(0, 2, gl.FLOAT, false, 0, 0);
var indexBuffer = gl.createBuffer();
gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, indexBuffer);
gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, new Uint16Array([
0, 1, 2,
0, 2, 3,
4, 5, 6,
4, 6, 7,
8, 9, 10,
8, 10, 11,
12, 13, 14,
12, 14, 15
]), gl.STATIC_DRAW);
wtu.requestAnimFrame(render);
}
function render() {
if (++numFrames < 30) {
if (currentSize == largeSize) {
canvas.height = smallSize;
currentSize = smallSize;
} else {
canvas.height = largeSize;
currentSize = largeSize;
}
}
gl.viewport(0, 0, largeSize, currentSize);
gl.clear(gl.COLOR_BUFFER_BIT);
gl.drawElements(gl.TRIANGLES, 24, gl.UNSIGNED_SHORT, 0);
// Check the four corners
var green = [ 0, 255, 0, 255 ];
var inset = 3;
wtu.checkCanvasRect(gl, inset, inset, 1, 1, green, "lower left should be green", 1);
wtu.checkCanvasRect(gl, largeSize - inset, inset, 1, 1, green, "lower right should be green", 1);
wtu.checkCanvasRect(gl, inset, currentSize - inset, 1, 1, green, "upper left should be green", 1);
wtu.checkCanvasRect(gl, largeSize - inset, currentSize - inset, 1, 1, green, "upper right should be green", 1);
if (numFrames < 60) {
wtu.requestAnimFrame(render);
} else {
finishTest();
}
}
</script>
</body>
</html>

Просмотреть файл

@ -0,0 +1,87 @@
<!--
/*
** Copyright (c) 2012 The Khronos Group Inc.
**
** Permission is hereby granted, free of charge, to any person obtaining a
** copy of this software and/or associated documentation files (the
** "Materials"), to deal in the Materials without restriction, including
** without limitation the rights to use, copy, modify, merge, publish,
** distribute, sublicense, and/or sell copies of the Materials, and to
** permit persons to whom the Materials are furnished to do so, subject to
** the following conditions:
**
** The above copyright notice and this permission notice shall be included
** in all copies or substantial portions of the Materials.
**
** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
*/
-->
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<link rel="stylesheet" href="../../resources/js-test-style.css"/>
<script src="../../resources/js-test-pre.js"></script>
<script src="../resources/webgl-test-utils.js"></script>
</head>
<body>
<canvas id="example" width="4" height="4"></canvas>
<div id="description"></div>
<div id="console"></div>
<script>
"use strict";
description('Verifies that GL texture bindings do not change when canvas is resized');
var err;
var wtu = WebGLTestUtils;
var canvas = document.getElementById("example");
var gl = wtu.create3DContext(canvas);
var program = wtu.setupTexturedQuad(gl);
var green = [0, 255, 0, 255];
var blue = [0, 0, 255, 255];
var tex0 = gl.createTexture();
wtu.fillTexture(gl, tex0, 1, 1, blue, 0);
gl.activeTexture(gl.TEXTURE1)
var tex1 = gl.createTexture();
wtu.fillTexture(gl, tex1, 1, 1, green, 0);
var loc = gl.getUniformLocation(program, "tex");
function test() {
gl.viewport(0, 0, canvas.width, canvas.height);
gl.uniform1i(loc, 0);
wtu.clearAndDrawUnitQuad(gl);
wtu.checkCanvas(gl, blue, "should be blue");
gl.uniform1i(loc, 1);
wtu.clearAndDrawUnitQuad(gl);
wtu.checkCanvas(gl, green, "should be green");
}
debug("test before resizing canvas");
test();
debug("test after resizing canvas");
canvas.width = 8;
test();
debug("test after resizing canvas and waiting for compositing");
canvas.width = 16;
wtu.waitForComposite(function() {
test();
finishTest();
wtu.glErrorShouldBe(gl, gl.NO_ERROR, "Should be no errors.");
});
var successfullyParsed = true;
</script>
</body>
</html>

Просмотреть файл

@ -0,0 +1,128 @@
<!--
/*
** Copyright (c) 2012 The Khronos Group Inc.
**
** Permission is hereby granted, free of charge, to any person obtaining a
** copy of this software and/or associated documentation files (the
** "Materials"), to deal in the Materials without restriction, including
** without limitation the rights to use, copy, modify, merge, publish,
** distribute, sublicense, and/or sell copies of the Materials, and to
** permit persons to whom the Materials are furnished to do so, subject to
** the following conditions:
**
** The above copyright notice and this permission notice shall be included
** in all copies or substantial portions of the Materials.
**
** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
*/
-->
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>WebGL toDataURL test</title>
<link rel="stylesheet" href="../../resources/js-test-style.css"/>
<script src="../../resources/js-test-pre.js"></script>
<script src="../resources/webgl-test-utils.js"> </script>
</head>
<body>
<canvas width="20" height="20" style="border: 1px solid black; width: 16px; height: 16px" id="c3d"></canvas>
<canvas width="20" height="20" style="border: 1px solid black; width: 16px; height: 16px" id="c2d"></canvas>
<div id="description"></div>
<div id="console"></div>
<script type="text/javascript">
var wtu = WebGLTestUtils;
var numTests = 10;
var gl;
var ctx;
var main = function() {
description();
ctx = document.getElementById("c2d").getContext("2d");
gl = wtu.create3DContext("c3d");
if (!gl) {
testFailed("can't create 3d context");
return;
}
var clearRect = function(gl, x, y, width, height, color) {
gl.clearColor(color[0] / 255, color[1] / 255, color[2] / 255, color[3] / 255);
gl.scissor(x, y, width, height);
gl.clear(gl.COLOR_BUFFER_BIT);
};
var testSize = function(gl, width, height, callback) {
debug("testing " + width + " by " + height);
gl.canvas.width = width;
gl.canvas.height = height;
gl.viewport(0, 0, width, height);
gl.enable(gl.SCISSOR_TEST);
var bottomColor = [255, 0, 0, 255];
var topColor = [0, 255, 0, 255];
var rightColor = [0, 0, 255, 255];
var halfHeight = Math.floor(height / 2);
var topHeight = height - halfHeight;
var canvasTopHeight = height - topHeight;
clearRect(gl, 0, 0, width, halfHeight, bottomColor);
clearRect(gl, 0, halfHeight, width, topHeight, topColor);
clearRect(gl, width - 1, 0, 1, height, rightColor);
// Performs gl.canvas.toDataURL() internally
var img = wtu.makeImageFromCanvas(gl.canvas, function() {
ctx.canvas.width = width;
ctx.canvas.height = height;
ctx.drawImage(img, 0, 0);
wtu.checkCanvasRect(ctx, 0, 0, width - 1, topHeight, topColor);
wtu.checkCanvasRect(ctx, 0, topHeight, width - 1, halfHeight, bottomColor);
wtu.checkCanvasRect(ctx, width - 1, 0, 1, height, rightColor);
debug("");
callback();
});
};
var tests = [
{ width: 16 , height: 16 , },
{ width: 16 - 1, height: 16 , },
{ width: 16 - 1, height: 16 - 1, },
{ width: 16 + 1, height: 16 - 1, },
{ width: 16 - 1, height: 16 + 1, },
{ width: 256 , height: 256 , },
{ width: 256 - 1, height: 256 , },
{ width: 256 - 1, height: 256 - 1, },
{ width: 256 + 1, height: 256 - 1, },
{ width: 256 - 1, height: 256 + 1, },
{ width: 512 , height: 512 , },
{ width: 512 - 1, height: 512 , },
{ width: 512 - 1, height: 512 - 1, },
{ width: 512 + 1, height: 512 - 1, },
{ width: 512 - 1, height: 512 + 1, },
];
var testIndex = 0;
var runNextTest = function() {
if (testIndex == tests.length) {
finishTest();
return;
}
var test = tests[testIndex++];
testSize(gl, test.width, test.height, function() {
setTimeout(runNextTest, 0);
})
};
runNextTest();
};
main();
var successfullyParsed = true;
</script>
</body>
</html>

Просмотреть файл

@ -0,0 +1,113 @@
<!--
/*
** Copyright (c) 2012 The Khronos Group Inc.
**
** Permission is hereby granted, free of charge, to any person obtaining a
** copy of this software and/or associated documentation files (the
** "Materials"), to deal in the Materials without restriction, including
** without limitation the rights to use, copy, modify, merge, publish,
** distribute, sublicense, and/or sell copies of the Materials, and to
** permit persons to whom the Materials are furnished to do so, subject to
** the following conditions:
**
** The above copyright notice and this permission notice shall be included
** in all copies or substantial portions of the Materials.
**
** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
*/
-->
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<link rel="stylesheet" href="../../resources/js-test-style.css"/>
<script src="../../resources/js-test-pre.js"></script>
<script src="../resources/webgl-test-utils.js"></script>
<script id="vshader" type="x-shader/x-vertex">
attribute vec3 g_Position;
void main()
{
gl_Position = vec4(g_Position.x, g_Position.y, g_Position.z, 1.0);
}
</script>
<script id="fshader" type="x-shader/x-fragment">
void main()
{
gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);
}
</script>
</head>
<body>
<canvas id="example" width="4" height="4"></canvas>
<div id="description"></div>
<div id="console"></div>
<script>
"use strict";
description('Verifies that GL viewport does not change when canvas is resized');
var err;
var wtu = WebGLTestUtils;
var gl = wtu.create3DContext("example");
var program = wtu.setupProgram(gl, ["vshader", "fshader"], ["g_Position"]);
var vertices = new Float32Array([
1.0, 1.0, 0.0,
-1.0, 1.0, 0.0,
-1.0, -1.0, 0.0,
1.0, 1.0, 0.0,
-1.0, -1.0, 0.0,
1.0, -1.0, 0.0]);
var vbo = gl.createBuffer();
gl.bindBuffer(gl.ARRAY_BUFFER, vbo);
gl.bufferData(gl.ARRAY_BUFFER, vertices, gl.STATIC_DRAW);
gl.enableVertexAttribArray(0);
gl.vertexAttribPointer(0, 3, gl.FLOAT, false, 0, 0);
// Clear and set up
gl.clearColor(0, 0, 1, 1);
gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
gl.useProgram(program);
// Draw the triangle pair to the frame buffer
gl.drawArrays(gl.TRIANGLES, 0, 6);
// Ensure that the frame buffer is red at the sampled pixel
wtu.checkCanvasRect(gl, 2, 2, 1, 1, [255, 0, 0, 255]);
// Now resize the canvas
wtu.glErrorShouldBe(gl, gl.NO_ERROR, "No GL errors before resizing the canvas");
var canvas = gl.canvas;
canvas.width = 8;
canvas.height = 8;
err = gl.getError();
// Some implementations might lost the context when resizing
if (err == gl.CONTEXT_LOST_WEBGL) {
testPassed("canvas lost context on resize");
} else {
shouldBe("err", "gl.NO_ERROR");
// Do another render
gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
gl.drawArrays(gl.TRIANGLES, 0, 6);
// This time, because we did not change the viewport, it should
// still be (0, 0, 4, 4), so only the lower-left quadrant should
// have been filled.
wtu.checkCanvasRect(gl, 6, 6, 1, 1, [0, 0, 255, 255]);
}
var successfullyParsed = true;
</script>
<script src="../../resources/js-test-post.js"></script>
</body>
</html>

Просмотреть файл

@ -0,0 +1,17 @@
--max-version 1.9.9 constants-and-properties.html
--min-version 1.0.2 context-attribute-preserve-drawing-buffer.html
context-attributes-alpha-depth-stencil-antialias.html
--min-version 1.0.2 --slow context-creation-and-destruction.html
--min-version 1.0.3 --slow context-creation.html
--min-version 1.0.3 --slow context-eviction-with-garbage-collection.html
--min-version 1.0.3 context-hidden-alpha.html
--min-version 1.0.2 context-release-upon-reload.html
--min-version 1.0.2 context-release-with-workers.html
context-lost-restored.html
context-lost.html
--max-version 1.9.9 context-type-test.html
incorrect-context-object-behaviour.html
--max-version 1.9.9 methods.html
premultiplyalpha-test.html
resource-sharing-test.html

Просмотреть файл

@ -0,0 +1,566 @@
<!--
/*
** Copyright (c) 2012 The Khronos Group Inc.
**
** Permission is hereby granted, free of charge, to any person obtaining a
** copy of this software and/or associated documentation files (the
** "Materials"), to deal in the Materials without restriction, including
** without limitation the rights to use, copy, modify, merge, publish,
** distribute, sublicense, and/or sell copies of the Materials, and to
** permit persons to whom the Materials are furnished to do so, subject to
** the following conditions:
**
** The above copyright notice and this permission notice shall be included
** in all copies or substantial portions of the Materials.
**
** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
*/
-->
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>WebGL Constants and Properties Test</title>
<link rel="stylesheet" href="../../resources/js-test-style.css"/>
<script src="../../resources/js-test-pre.js"></script>
<script src="../resources/webgl-test-utils.js"></script>
</head>
<body>
<div id="description"></div>
<div id="console"></div>
<canvas id="canvas" style="width: 50px; height: 50px;"> </canvas>
<script>
"use strict";
description("This test ensures that the WebGL context has all the constants and (non-function) properties in the specification.");
var constants = {
/* ClearBufferMask */
DEPTH_BUFFER_BIT : 0x00000100,
STENCIL_BUFFER_BIT : 0x00000400,
COLOR_BUFFER_BIT : 0x00004000,
/* BeginMode */
POINTS : 0x0000,
LINES : 0x0001,
LINE_LOOP : 0x0002,
LINE_STRIP : 0x0003,
TRIANGLES : 0x0004,
TRIANGLE_STRIP : 0x0005,
TRIANGLE_FAN : 0x0006,
/* AlphaFunction (not supported in ES20) */
/* NEVER */
/* LESS */
/* EQUAL */
/* LEQUAL */
/* GREATER */
/* NOTEQUAL */
/* GEQUAL */
/* ALWAYS */
/* BlendingFactorDest */
ZERO : 0,
ONE : 1,
SRC_COLOR : 0x0300,
ONE_MINUS_SRC_COLOR : 0x0301,
SRC_ALPHA : 0x0302,
ONE_MINUS_SRC_ALPHA : 0x0303,
DST_ALPHA : 0x0304,
ONE_MINUS_DST_ALPHA : 0x0305,
/* BlendingFactorSrc */
/* ZERO */
/* ONE */
DST_COLOR : 0x0306,
ONE_MINUS_DST_COLOR : 0x0307,
SRC_ALPHA_SATURATE : 0x0308,
/* SRC_ALPHA */
/* ONE_MINUS_SRC_ALPHA */
/* DST_ALPHA */
/* ONE_MINUS_DST_ALPHA */
/* BlendEquationSeparate */
FUNC_ADD : 0x8006,
BLEND_EQUATION : 0x8009,
BLEND_EQUATION_RGB : 0x8009, /* same as BLEND_EQUATION */
BLEND_EQUATION_ALPHA : 0x883D,
/* BlendSubtract */
FUNC_SUBTRACT : 0x800A,
FUNC_REVERSE_SUBTRACT : 0x800B,
/* Separate Blend Functions */
BLEND_DST_RGB : 0x80C8,
BLEND_SRC_RGB : 0x80C9,
BLEND_DST_ALPHA : 0x80CA,
BLEND_SRC_ALPHA : 0x80CB,
CONSTANT_COLOR : 0x8001,
ONE_MINUS_CONSTANT_COLOR : 0x8002,
CONSTANT_ALPHA : 0x8003,
ONE_MINUS_CONSTANT_ALPHA : 0x8004,
BLEND_COLOR : 0x8005,
/* Buffer Objects */
ARRAY_BUFFER : 0x8892,
ELEMENT_ARRAY_BUFFER : 0x8893,
ARRAY_BUFFER_BINDING : 0x8894,
ELEMENT_ARRAY_BUFFER_BINDING : 0x8895,
STREAM_DRAW : 0x88E0,
STATIC_DRAW : 0x88E4,
DYNAMIC_DRAW : 0x88E8,
BUFFER_SIZE : 0x8764,
BUFFER_USAGE : 0x8765,
CURRENT_VERTEX_ATTRIB : 0x8626,
/* CullFaceMode */
FRONT : 0x0404,
BACK : 0x0405,
FRONT_AND_BACK : 0x0408,
/* DepthFunction */
/* NEVER */
/* LESS */
/* EQUAL */
/* LEQUAL */
/* GREATER */
/* NOTEQUAL */
/* GEQUAL */
/* ALWAYS */
/* EnableCap */
/* TEXTURE_2D */
CULL_FACE : 0x0B44,
BLEND : 0x0BE2,
DITHER : 0x0BD0,
STENCIL_TEST : 0x0B90,
DEPTH_TEST : 0x0B71,
SCISSOR_TEST : 0x0C11,
POLYGON_OFFSET_FILL : 0x8037,
SAMPLE_ALPHA_TO_COVERAGE : 0x809E,
SAMPLE_COVERAGE : 0x80A0,
/* ErrorCode */
NO_ERROR : 0,
INVALID_ENUM : 0x0500,
INVALID_VALUE : 0x0501,
INVALID_OPERATION : 0x0502,
OUT_OF_MEMORY : 0x0505,
/* FrontFaceDirection */
CW : 0x0900,
CCW : 0x0901,
/* GetPName */
LINE_WIDTH : 0x0B21,
ALIASED_POINT_SIZE_RANGE : 0x846D,
ALIASED_LINE_WIDTH_RANGE : 0x846E,
CULL_FACE_MODE : 0x0B45,
FRONT_FACE : 0x0B46,
DEPTH_RANGE : 0x0B70,
DEPTH_WRITEMASK : 0x0B72,
DEPTH_CLEAR_VALUE : 0x0B73,
DEPTH_FUNC : 0x0B74,
STENCIL_CLEAR_VALUE : 0x0B91,
STENCIL_FUNC : 0x0B92,
STENCIL_FAIL : 0x0B94,
STENCIL_PASS_DEPTH_FAIL : 0x0B95,
STENCIL_PASS_DEPTH_PASS : 0x0B96,
STENCIL_REF : 0x0B97,
STENCIL_VALUE_MASK : 0x0B93,
STENCIL_WRITEMASK : 0x0B98,
STENCIL_BACK_FUNC : 0x8800,
STENCIL_BACK_FAIL : 0x8801,
STENCIL_BACK_PASS_DEPTH_FAIL : 0x8802,
STENCIL_BACK_PASS_DEPTH_PASS : 0x8803,
STENCIL_BACK_REF : 0x8CA3,
STENCIL_BACK_VALUE_MASK : 0x8CA4,
STENCIL_BACK_WRITEMASK : 0x8CA5,
VIEWPORT : 0x0BA2,
SCISSOR_BOX : 0x0C10,
/* SCISSOR_TEST */
COLOR_CLEAR_VALUE : 0x0C22,
COLOR_WRITEMASK : 0x0C23,
UNPACK_ALIGNMENT : 0x0CF5,
PACK_ALIGNMENT : 0x0D05,
MAX_TEXTURE_SIZE : 0x0D33,
MAX_VIEWPORT_DIMS : 0x0D3A,
SUBPIXEL_BITS : 0x0D50,
RED_BITS : 0x0D52,
GREEN_BITS : 0x0D53,
BLUE_BITS : 0x0D54,
ALPHA_BITS : 0x0D55,
DEPTH_BITS : 0x0D56,
STENCIL_BITS : 0x0D57,
POLYGON_OFFSET_UNITS : 0x2A00,
/* POLYGON_OFFSET_FILL */
POLYGON_OFFSET_FACTOR : 0x8038,
TEXTURE_BINDING_2D : 0x8069,
SAMPLE_BUFFERS : 0x80A8,
SAMPLES : 0x80A9,
SAMPLE_COVERAGE_VALUE : 0x80AA,
SAMPLE_COVERAGE_INVERT : 0x80AB,
/* GetTextureParameter */
/* TEXTURE_MAG_FILTER */
/* TEXTURE_MIN_FILTER */
/* TEXTURE_WRAP_S */
/* TEXTURE_WRAP_T */
COMPRESSED_TEXTURE_FORMATS : 0x86A3,
/* HintMode */
DONT_CARE : 0x1100,
FASTEST : 0x1101,
NICEST : 0x1102,
/* HintTarget */
GENERATE_MIPMAP_HINT : 0x8192,
/* DataType */
BYTE : 0x1400,
UNSIGNED_BYTE : 0x1401,
SHORT : 0x1402,
UNSIGNED_SHORT : 0x1403,
INT : 0x1404,
UNSIGNED_INT : 0x1405,
FLOAT : 0x1406,
/* PixelFormat */
DEPTH_COMPONENT : 0x1902,
ALPHA : 0x1906,
RGB : 0x1907,
RGBA : 0x1908,
LUMINANCE : 0x1909,
LUMINANCE_ALPHA : 0x190A,
/* PixelType */
/* UNSIGNED_BYTE */
UNSIGNED_SHORT_4_4_4_4 : 0x8033,
UNSIGNED_SHORT_5_5_5_1 : 0x8034,
UNSIGNED_SHORT_5_6_5 : 0x8363,
/* Shaders */
FRAGMENT_SHADER : 0x8B30,
VERTEX_SHADER : 0x8B31,
MAX_VERTEX_ATTRIBS : 0x8869,
MAX_VERTEX_UNIFORM_VECTORS : 0x8DFB,
MAX_VARYING_VECTORS : 0x8DFC,
MAX_COMBINED_TEXTURE_IMAGE_UNITS : 0x8B4D,
MAX_VERTEX_TEXTURE_IMAGE_UNITS : 0x8B4C,
MAX_TEXTURE_IMAGE_UNITS : 0x8872,
MAX_FRAGMENT_UNIFORM_VECTORS : 0x8DFD,
SHADER_TYPE : 0x8B4F,
DELETE_STATUS : 0x8B80,
LINK_STATUS : 0x8B82,
VALIDATE_STATUS : 0x8B83,
ATTACHED_SHADERS : 0x8B85,
ACTIVE_UNIFORMS : 0x8B86,
ACTIVE_ATTRIBUTES : 0x8B89,
SHADING_LANGUAGE_VERSION : 0x8B8C,
CURRENT_PROGRAM : 0x8B8D,
/* StencilFunction */
NEVER : 0x0200,
LESS : 0x0201,
EQUAL : 0x0202,
LEQUAL : 0x0203,
GREATER : 0x0204,
NOTEQUAL : 0x0205,
GEQUAL : 0x0206,
ALWAYS : 0x0207,
/* StencilOp */
/* ZERO */
KEEP : 0x1E00,
REPLACE : 0x1E01,
INCR : 0x1E02,
DECR : 0x1E03,
INVERT : 0x150A,
INCR_WRAP : 0x8507,
DECR_WRAP : 0x8508,
/* StringName */
VENDOR : 0x1F00,
RENDERER : 0x1F01,
VERSION : 0x1F02,
/* TextureMagFilter */
NEAREST : 0x2600,
LINEAR : 0x2601,
/* TextureMinFilter */
/* NEAREST */
/* LINEAR */
NEAREST_MIPMAP_NEAREST : 0x2700,
LINEAR_MIPMAP_NEAREST : 0x2701,
NEAREST_MIPMAP_LINEAR : 0x2702,
LINEAR_MIPMAP_LINEAR : 0x2703,
/* TextureParameterName */
TEXTURE_MAG_FILTER : 0x2800,
TEXTURE_MIN_FILTER : 0x2801,
TEXTURE_WRAP_S : 0x2802,
TEXTURE_WRAP_T : 0x2803,
/* TextureTarget */
TEXTURE_2D : 0x0DE1,
TEXTURE : 0x1702,
TEXTURE_CUBE_MAP : 0x8513,
TEXTURE_BINDING_CUBE_MAP : 0x8514,
TEXTURE_CUBE_MAP_POSITIVE_X : 0x8515,
TEXTURE_CUBE_MAP_NEGATIVE_X : 0x8516,
TEXTURE_CUBE_MAP_POSITIVE_Y : 0x8517,
TEXTURE_CUBE_MAP_NEGATIVE_Y : 0x8518,
TEXTURE_CUBE_MAP_POSITIVE_Z : 0x8519,
TEXTURE_CUBE_MAP_NEGATIVE_Z : 0x851A,
MAX_CUBE_MAP_TEXTURE_SIZE : 0x851C,
/* TextureUnit */
TEXTURE0 : 0x84C0,
TEXTURE1 : 0x84C1,
TEXTURE2 : 0x84C2,
TEXTURE3 : 0x84C3,
TEXTURE4 : 0x84C4,
TEXTURE5 : 0x84C5,
TEXTURE6 : 0x84C6,
TEXTURE7 : 0x84C7,
TEXTURE8 : 0x84C8,
TEXTURE9 : 0x84C9,
TEXTURE10 : 0x84CA,
TEXTURE11 : 0x84CB,
TEXTURE12 : 0x84CC,
TEXTURE13 : 0x84CD,
TEXTURE14 : 0x84CE,
TEXTURE15 : 0x84CF,
TEXTURE16 : 0x84D0,
TEXTURE17 : 0x84D1,
TEXTURE18 : 0x84D2,
TEXTURE19 : 0x84D3,
TEXTURE20 : 0x84D4,
TEXTURE21 : 0x84D5,
TEXTURE22 : 0x84D6,
TEXTURE23 : 0x84D7,
TEXTURE24 : 0x84D8,
TEXTURE25 : 0x84D9,
TEXTURE26 : 0x84DA,
TEXTURE27 : 0x84DB,
TEXTURE28 : 0x84DC,
TEXTURE29 : 0x84DD,
TEXTURE30 : 0x84DE,
TEXTURE31 : 0x84DF,
ACTIVE_TEXTURE : 0x84E0,
/* TextureWrapMode */
REPEAT : 0x2901,
CLAMP_TO_EDGE : 0x812F,
MIRRORED_REPEAT : 0x8370,
/* Uniform Types */
FLOAT_VEC2 : 0x8B50,
FLOAT_VEC3 : 0x8B51,
FLOAT_VEC4 : 0x8B52,
INT_VEC2 : 0x8B53,
INT_VEC3 : 0x8B54,
INT_VEC4 : 0x8B55,
BOOL : 0x8B56,
BOOL_VEC2 : 0x8B57,
BOOL_VEC3 : 0x8B58,
BOOL_VEC4 : 0x8B59,
FLOAT_MAT2 : 0x8B5A,
FLOAT_MAT3 : 0x8B5B,
FLOAT_MAT4 : 0x8B5C,
SAMPLER_2D : 0x8B5E,
SAMPLER_CUBE : 0x8B60,
/* Vertex Arrays */
VERTEX_ATTRIB_ARRAY_ENABLED : 0x8622,
VERTEX_ATTRIB_ARRAY_SIZE : 0x8623,
VERTEX_ATTRIB_ARRAY_STRIDE : 0x8624,
VERTEX_ATTRIB_ARRAY_TYPE : 0x8625,
VERTEX_ATTRIB_ARRAY_NORMALIZED : 0x886A,
VERTEX_ATTRIB_ARRAY_POINTER : 0x8645,
VERTEX_ATTRIB_ARRAY_BUFFER_BINDING : 0x889F,
/* Read Format */
IMPLEMENTATION_COLOR_READ_TYPE : 0x8B9A,
IMPLEMENTATION_COLOR_READ_FORMAT : 0x8B9B,
/* Shader Source */
COMPILE_STATUS : 0x8B81,
/* Shader Precision-Specified Types */
LOW_FLOAT : 0x8DF0,
MEDIUM_FLOAT : 0x8DF1,
HIGH_FLOAT : 0x8DF2,
LOW_INT : 0x8DF3,
MEDIUM_INT : 0x8DF4,
HIGH_INT : 0x8DF5,
/* Framebuffer Object. */
FRAMEBUFFER : 0x8D40,
RENDERBUFFER : 0x8D41,
RGBA4 : 0x8056,
RGB5_A1 : 0x8057,
RGB565 : 0x8D62,
DEPTH_COMPONENT16 : 0x81A5,
STENCIL_INDEX : 0x1901,
STENCIL_INDEX8 : 0x8D48,
DEPTH_STENCIL : 0x84F9,
RENDERBUFFER_WIDTH : 0x8D42,
RENDERBUFFER_HEIGHT : 0x8D43,
RENDERBUFFER_INTERNAL_FORMAT : 0x8D44,
RENDERBUFFER_RED_SIZE : 0x8D50,
RENDERBUFFER_GREEN_SIZE : 0x8D51,
RENDERBUFFER_BLUE_SIZE : 0x8D52,
RENDERBUFFER_ALPHA_SIZE : 0x8D53,
RENDERBUFFER_DEPTH_SIZE : 0x8D54,
RENDERBUFFER_STENCIL_SIZE : 0x8D55,
FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE : 0x8CD0,
FRAMEBUFFER_ATTACHMENT_OBJECT_NAME : 0x8CD1,
FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL : 0x8CD2,
FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE : 0x8CD3,
COLOR_ATTACHMENT0 : 0x8CE0,
DEPTH_ATTACHMENT : 0x8D00,
STENCIL_ATTACHMENT : 0x8D20,
DEPTH_STENCIL_ATTACHMENT : 0x821A,
NONE : 0,
FRAMEBUFFER_COMPLETE : 0x8CD5,
FRAMEBUFFER_INCOMPLETE_ATTACHMENT : 0x8CD6,
FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT : 0x8CD7,
FRAMEBUFFER_INCOMPLETE_DIMENSIONS : 0x8CD9,
FRAMEBUFFER_UNSUPPORTED : 0x8CDD,
FRAMEBUFFER_BINDING : 0x8CA6,
RENDERBUFFER_BINDING : 0x8CA7,
MAX_RENDERBUFFER_SIZE : 0x84E8,
INVALID_FRAMEBUFFER_OPERATION : 0x0506,
/* WebGL-specific enums */
UNPACK_FLIP_Y_WEBGL : 0x9240,
UNPACK_PREMULTIPLY_ALPHA_WEBGL : 0x9241,
CONTEXT_LOST_WEBGL : 0x9242,
UNPACK_COLORSPACE_CONVERSION_WEBGL : 0x9243,
BROWSER_DEFAULT_WEBGL : 0x9244
};
// Other non-function properties on the WebGL object
var otherProperties = {
drawingBufferWidth : "number",
drawingBufferHeight : "number",
canvas : "implementation-dependent"
};
// Properties to be ignored (as a list of strings) because they were
// added in versions of the spec that are backward-compatible with
// this version
var ignoredProperties = [
];
// Constants removed from the WebGL spec compared to ES 2.0
var removedConstants = {
NUM_COMPRESSED_TEXTURE_FORMATS : 0x86A2,
FIXED : 0x140C,
ACTIVE_UNIFORM_MAX_LENGTH : 0x8B87,
ACTIVE_ATTRIBUTE_MAX_LENGTH : 0x8B8A,
EXTENSIONS : 0x1F03,
INFO_LOG_LENGTH : 0x8B84,
SHADER_SOURCE_LENGTH : 0x8B88,
SHADER_COMPILER : 0x8DFA,
SHADER_BINARY_FORMATS : 0x8DF8,
NUM_SHADER_BINARY_FORMATS : 0x8DF9,
};
function assertProperty(v, p) {
if (p in v) {
return true;
} else {
testFailed("Property does not exist: " + p)
return false;
}
}
function assertNoProperty(v, p) {
if (p in v) {
testFailed("Property is defined and should not be: " + p)
return false;
} else {
return true;
}
}
function assertMsg_(bool, msg) {
if (!bool) // show only failures to avoid spamming result list
assertMsg(bool, msg);
return bool;
}
debug("");
debug("Canvas.getContext");
var canvas = document.getElementById("canvas");
var wtu = WebGLTestUtils;
var gl = wtu.create3DContext(canvas);
var passed = true;
for (var i in constants) {
var r = assertProperty(gl, i) && assertMsg_(gl[i] == constants[i], "Property "+i+" value test "+gl[i]+" == "+constants[i]);
passed = passed && r;
}
if (passed) {
testPassed("All WebGL constants found to have correct values.");
}
passed = true;
for (var i in removedConstants) {
var r = assertNoProperty(gl, i);
passed = passed && r;
}
if (passed) {
testPassed("All constants removed from WebGL spec were absent from WebGL context.");
}
var extended = false;
for (var i in gl) {
if (constants[i] !== undefined) {
// OK; known constant
} else if (ignoredProperties.indexOf(i) != -1) {
// OK; constant that should be ignored because it was added in a later version of the spec
} else if (otherProperties[i] !== undefined &&
(otherProperties[i] == "implementation-dependent" || typeof gl[i] == otherProperties[i])) {
// OK; known property of known type
} else if (typeof gl[i] != "function") {
if (!extended) {
extended = true;
testFailed("Also found the following extra properties:");
}
testFailed(i);
}
}
if (!extended) {
testPassed("No extra properties found on WebGL context.");
}
debug("");
var successfullyParsed = true;
</script>
<script src="../../resources/js-test-post.js"></script>
</body>
</html>

Просмотреть файл

@ -0,0 +1,130 @@
<!--
/*
** Copyright (c) 2012 The Khronos Group Inc.
**
** Permission is hereby granted, free of charge, to any person obtaining a
** copy of this software and/or associated documentation files (the
** "Materials"), to deal in the Materials without restriction, including
** without limitation the rights to use, copy, modify, merge, publish,
** distribute, sublicense, and/or sell copies of the Materials, and to
** permit persons to whom the Materials are furnished to do so, subject to
** the following conditions:
**
** The above copyright notice and this permission notice shall be included
** in all copies or substantial portions of the Materials.
**
** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
*/
-->
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<link rel="stylesheet" href="../../resources/js-test-style.css"/>
<script src="../../resources/js-test-pre.js"></script>
<script src="../resources/webgl-test-utils.js"></script>
<style>
.pattern {
white-space: nowrap;
display: inline-block;
}
canvas {
width:50px;
height:50px;
}
.square {
display:inline-block;
width:50px;
height:50px;
background-color:red;
}
</style>
<script>
"use strict";
var wtu = WebGLTestUtils;
function checkResult(ctx1, ctx2, preserve) {
var imgData1 = ctx1.getImageData(0,0,1,1);
var imgData2 = ctx2.getImageData(0,0,1,1);
var correct1 = [255,0,0,255];
var correct2 = preserve ? [255,0,0,255] : [0,0,0,255];
var ok1 = true;
var ok2 = true;
for (var p = 0; p < 4; ++p) {
if (imgData1.data[p] != correct1[p])
ok1 = false;
if (imgData2.data[p] != correct2[p])
ok2 = false;
}
if (ok1 && ok2)
testPassed('Rendered ok with preserveDrawingBuffer ' + preserve +'.');
else
testFailed('Did not render ok with preserveDrawingBuffer ' + preserve + '.');
if (preserve) {
finishTest()
} else {
runTest(true);
}
}
function runTest(preserve) {
var c1 = document.getElementById('c' + (preserve * 3 + 1));
var c2 = document.getElementById('c' + (preserve * 3 + 2));
var c3 = document.getElementById('c' + (preserve * 3 + 3));
var ctx1 = c1.getContext('2d');
var ctx2 = c2.getContext('2d');
var gl = wtu.create3DContext(c3, { alpha:false, preserveDrawingBuffer:preserve });
gl.clearColor(1, 0, 0, 1);
gl.clear(gl.COLOR_BUFFER_BIT);
ctx1.drawImage(c3, 0, 0);
wtu.waitForComposite(function() {
ctx2.drawImage(c3, 0, 0);
checkResult(ctx1, ctx2, preserve);
});
}
</script>
</head>
<body>
<div class="pattern">
<canvas id='c1'></canvas>
<canvas id='c2'></canvas>
<canvas id='c3'></canvas>
</div>
<span>should look like</span>
<div class="pattern">
<div class='square'></div>
<div class='square' style='background-color:black'></div>
<div class='square'></div>
</div>
<hr />
<div class="pattern">
<canvas id='c4'></canvas>
<canvas id='c5'></canvas>
<canvas id='c6'></canvas>
</div>
<span>should look like</span>
<div class="pattern">
<div class='square'></div>
<div class='square'></div>
<div class='square'></div>
</div>
<div id="description"></div>
<div id="console"></div>
<script>
"use strict";
description('Verify that preserveDrawingBuffer attribute is honored.');
runTest(false);
var successfullyParsed = true;
shouldBeTrue("successfullyParsed");
</script>
</body>
</html>

Просмотреть файл

@ -0,0 +1,348 @@
<!--
/*
** Copyright (c) 2012 The Khronos Group Inc.
**
** Permission is hereby granted, free of charge, to any person obtaining a
** copy of this software and/or associated documentation files (the
** "Materials"), to deal in the Materials without restriction, including
** without limitation the rights to use, copy, modify, merge, publish,
** distribute, sublicense, and/or sell copies of the Materials, and to
** permit persons to whom the Materials are furnished to do so, subject to
** the following conditions:
**
** The above copyright notice and this permission notice shall be included
** in all copies or substantial portions of the Materials.
**
** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
*/
-->
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<link rel="stylesheet" href="../../resources/js-test-style.css"/>
<script src="../../resources/js-test-pre.js"></script>
<script src="../resources/webgl-test-utils.js"></script>
<script id="vshader" type="x-shader/x-vertex">
attribute vec3 pos;
attribute vec4 colorIn;
varying vec4 color;
void main()
{
color = colorIn;
gl_Position = vec4(pos.xyz, 1.0);
}
</script>
<script id="fshader" type="x-shader/x-fragment">
precision mediump float;
varying vec4 color;
void main()
{
gl_FragColor = color;
}
</script>
<script>
"use strict";
// These four declarations need to be global for "shouldBe" to see them
var wtu = WebGLTestUtils;
var gl;
var contextAttribs = null;
var pixel = [0, 0, 0, 1];
var correctColor = null;
var framebuffer;
var fbHasColor;
var fbHasDepth;
var fbHasStencil;
function init()
{
description('Verify WebGLContextAttributes are working as specified, including alpha, depth, stencil, antialias, but not premultipliedAlpha');
runTest();
}
function getWebGL(canvasWidth, canvasHeight, contextAttribs, clearColor, clearDepth, clearStencil)
{
var canvas = document.createElement("canvas");
if (!canvas)
return null;
canvas.width = canvasWidth;
canvas.height = canvasHeight;
gl = wtu.create3DContext(canvas, contextAttribs);
if (!gl)
return null;
var program = wtu.setupProgram(gl, ["vshader", "fshader"], ["pos", "colorIn"]);
if (!program)
return null;
gl.enable(gl.DEPTH_TEST);
gl.enable(gl.STENCIL_TEST);
gl.clearColor(clearColor[0], clearColor[1], clearColor[2], clearColor[3]);
gl.clearDepth(clearDepth);
gl.clearStencil(clearStencil);
gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT | gl.STENCIL_BUFFER_BIT);
framebuffer = gl.createFramebuffer();
gl.bindFramebuffer(gl.FRAMEBUFFER, framebuffer);
var texture = gl.createTexture();
gl.bindTexture(gl.TEXTURE_2D, texture);
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.canvas.width, gl.canvas.height, 0, gl.RGBA, gl.UNSIGNED_BYTE, null);
gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, texture, 0);
fbHasStencil = false;
fbHasDepth = false;
fbHasColor = gl.checkFramebufferStatus(gl.FRAMEBUFFER) == gl.FRAMEBUFFER_COMPLETE;
if (fbHasColor) {
var depthStencil = gl.createRenderbuffer();
gl.bindRenderbuffer(gl.RENDERBUFFER, depthStencil);
gl.renderbufferStorage(gl.RENDERBUFFER, gl.DEPTH_STENCIL, gl.canvas.width, gl.canvas.height);
gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.DEPTH_STENCIL_ATTACHMENT, gl.RENDERBUFFER, depthStencil);
fbHasDepth = gl.checkFramebufferStatus(gl.FRAMEBUFFER) == gl.FRAMEBUFFER_COMPLETE;
if (!fbHasDepth) {
gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.DEPTH_STENCIL_ATTACHMENT, gl.RENDERBUFFER, null);
shouldBe('gl.checkFramebufferStatus(gl.FRAMEBUFFER)', 'gl.FRAMEBUFFER_COMPLETE');
} else {
fbHasStencil = true;
}
}
gl.bindFramebuffer(gl.FRAMEBUFFER, null);
wtu.glErrorShouldBe(gl, gl.NO_ERROR, "should be no errors");
return gl;
}
function drawAndReadPixel(gl, vertices, colors)
{
var colorOffset = vertices.byteLength;
var vbo = gl.createBuffer();
gl.bindBuffer(gl.ARRAY_BUFFER, vbo);
gl.bufferData(gl.ARRAY_BUFFER, colorOffset + colors.byteLength, gl.STATIC_DRAW);
gl.bufferSubData(gl.ARRAY_BUFFER, 0, vertices);
gl.bufferSubData(gl.ARRAY_BUFFER, colorOffset, colors);
gl.vertexAttribPointer(0, 3, gl.FLOAT, false, 0, 0);
gl.enableVertexAttribArray(0);
gl.vertexAttribPointer(1, 4, gl.UNSIGNED_BYTE, true, 0, colorOffset);
gl.enableVertexAttribArray(1);
gl.drawArrays(gl.TRIANGLES, 0, vertices.length / 3);
}
function testDefault()
{
debug("Testing default attributes: { stencil:false }");
shouldBeNonNull("gl = getWebGL(1, 1, null, [ 0, 0, 0, 0 ], 1, 0)");
shouldBeFalse("gl.getContextAttributes().stencil");
shouldBeTrue("gl.getParameter(gl.STENCIL_BITS) == 0");
}
function testAlpha(alpha)
{
debug("Testing alpha = " + alpha);
if (alpha) {
shouldBeNonNull("gl = getWebGL(1, 1, { alpha: true, depth: false, stencil: false, antialias: false }, [ 0, 0, 0, 0 ], 1, 0)");
shouldBeTrue("gl.getParameter(gl.ALPHA_BITS) >= 8");
} else {
shouldBeNonNull("gl = getWebGL(1, 1, { alpha: false, depth: false, stencil: false, antialias: false }, [ 0, 0, 0, 0 ], 1, 0)");
shouldBeTrue("gl.getParameter(gl.ALPHA_BITS) == 0");
}
shouldBeTrue("gl.getParameter(gl.RED_BITS) >= 8");
shouldBeTrue("gl.getParameter(gl.GREEN_BITS) >= 8");
shouldBeTrue("gl.getParameter(gl.BLUE_BITS) >= 8");
shouldBeTrue("gl.getParameter(gl.DEPTH_BITS) == 0");
shouldBeTrue("gl.getParameter(gl.STENCIL_BITS) == 0");
shouldBeNonNull("contextAttribs = gl.getContextAttributes()");
shouldBeTrue("contextAttribs.alpha == " + alpha);
var correctColor = (contextAttribs.alpha ? [0, 0, 0, 0] : [0, 0, 0, 255]);
wtu.checkCanvasRect(gl, 0, 0, 1, 1, correctColor);
if (fbHasColor) {
gl.bindFramebuffer(gl.FRAMEBUFFER, framebuffer);
gl.clearColor(0.5, 0.5, 0.5, 0.5);
gl.clear(gl.COLOR_BUFFER_BIT);
wtu.checkCanvasRect(gl, 0, 0, 1, 1, [127, 127, 127, 127], undefined, 1);
gl.bindFramebuffer(gl.FRAMEBUFFER, null);
}
}
function testDepth(depth)
{
debug("Testing depth = " + depth);
if (depth) {
shouldBeNonNull("gl = getWebGL(1, 1, { stencil: false, antialias: false }, [ 0, 0, 0, 1 ], 1, 0)");
shouldBeTrue("gl.getParameter(gl.DEPTH_BITS) >= 16");
} else {
shouldBeNonNull("gl = getWebGL(1, 1, { depth: false, stencil: false, antialias: false }, [ 0, 0, 0, 1 ], 1, 0)");
shouldBeTrue("gl.getParameter(gl.DEPTH_BITS) == 0");
}
shouldBeTrue("gl.getParameter(gl.RED_BITS) >= 8");
shouldBeTrue("gl.getParameter(gl.GREEN_BITS) >= 8");
shouldBeTrue("gl.getParameter(gl.BLUE_BITS) >= 8");
shouldBeTrue("gl.getParameter(gl.ALPHA_BITS) >= 8");
shouldBeNonNull("contextAttribs = gl.getContextAttributes()");
gl.depthFunc(gl.NEVER);
var vertices = new Float32Array([
1.0, 1.0, 0.0,
-1.0, 1.0, 0.0,
-1.0, -1.0, 0.0,
1.0, 1.0, 0.0,
-1.0, -1.0, 0.0,
1.0, -1.0, 0.0]);
var colors = new Uint8Array([
255, 0, 0, 255,
255, 0, 0, 255,
255, 0, 0, 255,
255, 0, 0, 255,
255, 0, 0, 255,
255, 0, 0, 255]);
drawAndReadPixel(gl, vertices, colors, 0, 0);
correctColor = (contextAttribs.depth ? [0, 0, 0, 255] : [255, 0, 0, 255]);
wtu.checkCanvasRect(gl, 0, 0, 1, 1, correctColor);
if (fbHasDepth) {
gl.bindFramebuffer(gl.FRAMEBUFFER, framebuffer);
gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
drawAndReadPixel(gl, vertices, colors, 0, 0);
wtu.checkCanvasRect(gl, 0, 0, 1, 1, [0, 0, 0, 255]);
gl.bindFramebuffer(gl.FRAMEBUFFER, null);
}
}
function testStencilAndDepth(stencil, depth)
{
debug("Testing stencil = " + stencil + ", depth = " + depth);
var creationString =
"gl = getWebGL(1, 1, { depth: " + depth + ", stencil: " + stencil + ", antialias: false }, [ 0, 0, 0, 1 ], 1, 0)";
shouldBeNonNull(creationString);
shouldBeTrue("gl.getParameter(gl.RED_BITS) >= 8");
shouldBeTrue("gl.getParameter(gl.GREEN_BITS) >= 8");
shouldBeTrue("gl.getParameter(gl.BLUE_BITS) >= 8");
shouldBeTrue("gl.getParameter(gl.ALPHA_BITS) >= 8");
if (depth)
shouldBeTrue("gl.getParameter(gl.DEPTH_BITS) >= 16");
else
shouldBeTrue("gl.getParameter(gl.DEPTH_BITS) == 0");
if (stencil)
shouldBeTrue("gl.getParameter(gl.STENCIL_BITS) >= 8");
else
shouldBeTrue("gl.getParameter(gl.STENCIL_BITS) == 0");
shouldBeNonNull("contextAttribs = gl.getContextAttributes()");
if (!depth && contextAttribs.depth) {
testFailed("WebGL implementation provided a depth buffer when it should not have");
}
if (!contextAttribs.depth)
depth = false;
if (!stencil && contextAttribs.stencil) {
testFailed("WebGL implementation provided a stencil buffer when it should not have");
}
if (!contextAttribs.stencil)
stencil = false;
gl.depthFunc(gl.ALWAYS);
gl.stencilFunc(gl.NEVER, 1, 1);
gl.stencilOp(gl.KEEP, gl.KEEP, gl.KEEP);
var vertices = new Float32Array([
1.0, 1.0, 0.0,
-1.0, 1.0, 0.0,
-1.0, -1.0, 0.0,
1.0, 1.0, 0.0,
-1.0, -1.0, 0.0,
1.0, -1.0, 0.0]);
var colors = new Uint8Array([
255, 0, 0, 255,
255, 0, 0, 255,
255, 0, 0, 255,
255, 0, 0, 255,
255, 0, 0, 255,
255, 0, 0, 255]);
drawAndReadPixel(gl, vertices, colors, 0, 0);
correctColor = (stencil ? [0, 0, 0, 255] : [255, 0, 0, 255]);
wtu.checkCanvasRect(gl, 0, 0, 1, 1, correctColor)
if (fbHasStencil) {
gl.bindFramebuffer(gl.FRAMEBUFFER, framebuffer);
gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
drawAndReadPixel(gl, vertices, colors, 0, 0);
wtu.checkCanvasRect(gl, 0, 0, 1, 1, [0, 0, 0, 255]);
gl.bindFramebuffer(gl.FRAMEBUFFER, null);
}
}
function testAntialias(antialias)
{
debug("Testing antialias = " + antialias);
if (antialias)
shouldBeNonNull("gl = getWebGL(2, 2, { depth: false, stencil: false, alpha: false, antialias: true }, [ 0, 0, 0, 1 ], 1, 0)");
else
shouldBeNonNull("gl = getWebGL(2, 2, { depth: false, stencil: false, alpha: false, antialias: false }, [ 0, 0, 0, 1 ], 1, 0)");
shouldBeNonNull("contextAttribs = gl.getContextAttributes()");
var vertices = new Float32Array([
1.0, 1.0, 0.0,
-1.0, 1.0, 0.0,
-1.0, -1.0, 0.0]);
var colors = new Uint8Array([
255, 0, 0, 255,
255, 0, 0, 255,
255, 0, 0, 255]);
drawAndReadPixel(gl, vertices, colors, 0, 0);
var buf = new Uint8Array(1 * 1 * 4);
gl.readPixels(0, 0, 1, 1, gl.RGBA, gl.UNSIGNED_BYTE, buf);
pixel[0] = buf[0];
shouldBe("pixel[0] != 255 && pixel[0] != 0", "contextAttribs.antialias");
}
function runTest()
{
testDefault();
testAlpha(true);
testAlpha(false);
testDepth(true);
testDepth(false);
testStencilAndDepth(true, false);
testStencilAndDepth(false, false);
testStencilAndDepth(true, true);
testStencilAndDepth(false, true);
testAntialias(true);
testAntialias(false);
finishTest();
}
</script>
</head>
<body onload="init()">
<div id="description"></div>
<div id="console"></div>
</body>
</html>

Просмотреть файл

@ -0,0 +1,56 @@
<!--
/*
** Copyright (c) 2012 The Khronos Group Inc.
**
** Permission is hereby granted, free of charge, to any person obtaining a
** copy of this software and/or associated documentation files (the
** "Materials"), to deal in the Materials without restriction, including
** without limitation the rights to use, copy, modify, merge, publish,
** distribute, sublicense, and/or sell copies of the Materials, and to
** permit persons to whom the Materials are furnished to do so, subject to
** the following conditions:
**
** The above copyright notice and this permission notice shall be included
** in all copies or substantial portions of the Materials.
**
** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
*/
-->
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Test that contexts are freed and garbage collected reasonably</title>
<link rel="stylesheet" href="../../resources/js-test-style.css"/>
<script src="../../resources/js-test-pre.js"></script>
<script src="../resources/webgl-test-utils.js"> </script>
<script src="../resources/iterable-test.js"> </script>
</head>
<body>
<div id="description"></div>
<div id="console"></div>
<script>
"use strict";
description();
var wtu = WebGLTestUtils;
var test = IterableTest.createContextCreationAndDestructionTest();
var iterations = parseInt(wtu.getUrlOptions().iterations, 10) || 50;
IterableTest.run(test, iterations);
var successfullyParsed = true;
</script>
</body>
</html>

Просмотреть файл

@ -0,0 +1,56 @@
<!--
/*
** Copyright (c) 2013 The Khronos Group Inc.
**
** Permission is hereby granted, free of charge, to any person obtaining a
** copy of this software and/or associated documentation files (the
** "Materials"), to deal in the Materials without restriction, including
** without limitation the rights to use, copy, modify, merge, publish,
** distribute, sublicense, and/or sell copies of the Materials, and to
** permit persons to whom the Materials are furnished to do so, subject to
** the following conditions:
**
** The above copyright notice and this permission notice shall be included
** in all copies or substantial portions of the Materials.
**
** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
*/
-->
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Test that you can create large numbers of WebGL contexts.</title>
<link rel="stylesheet" href="../../resources/js-test-style.css"/>
<script src="../../resources/js-test-pre.js"></script>
<script src="../resources/webgl-test-utils.js"> </script>
<script src="../resources/iterable-test.js"> </script>
</head>
<body>
<div id="description"></div>
<div id="console"></div>
<script>
"use strict";
description();
var wtu = WebGLTestUtils;
var test = IterableTest.createContextCreationTest();
var iterations = parseInt(wtu.getUrlOptions().iterations, 10) || 50;
IterableTest.run(test, iterations);
var successfullyParsed = true;
</script>
</body>
</html>

Просмотреть файл

@ -0,0 +1,78 @@
<!--
/*
** Copyright (c) 2014 The Khronos Group Inc.
**
** Permission is hereby granted, free of charge, to any person obtaining a
** copy of this software and/or associated documentation files (the
** "Materials"), to deal in the Materials without restriction, including
** without limitation the rights to use, copy, modify, merge, publish,
** distribute, sublicense, and/or sell copies of the Materials, and to
** permit persons to whom the Materials are furnished to do so, subject to
** the following conditions:
**
** The above copyright notice and this permission notice shall be included
** in all copies or substantial portions of the Materials.
**
** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
*/
-->
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Test that context eviction and garbage collection do not interfere with each other</title>
<link rel="stylesheet" href="../../resources/js-test-style.css"/>
<script src="../../resources/js-test-pre.js"></script>
<script src="../resources/webgl-test-utils.js"> </script>
</head>
<body>
<div id="description"></div>
<div id="console"></div>
<script>
"use strict";
// See http://crbug.com/374086 for original failing case.
description("Test that context eviction and garbage collection do not interfere with each other.");
var wtu = WebGLTestUtils;
var total_iteration = 50;
var array_count = 10;
var bank = [];
for (var i = 0; i < array_count; i++)
bank[i] = [];
for (var iter = 0; iter < total_iteration; ++iter) {
for (var i = 0; i < array_count; i++)
bank[i][iter * i] = iter;
var canvas = document.createElement('canvas');
var gl = wtu.create3DContext(canvas);
canvas.width = 50;
canvas.height = 50;
var program = wtu.setupTexturedQuad(gl);
shouldBeTrue("program != null");
var tex = gl.createTexture();
gl.bindTexture(gl.TEXTURE_2D, tex);
var pixel = new Uint8Array([0, 255, 0, 255]);
gl.texImage2D(
gl.TEXTURE_2D, 0, gl.RGBA, 1, 1, 0, gl.RGBA, gl.UNSIGNED_BYTE, pixel);
wtu.clearAndDrawUnitQuad(gl);
wtu.glErrorShouldBe(gl, gl.NO_ERROR, "Should be no errors from iteration " + iter);
}
var successfullyParsed = true;
</script>
<script src="../../resources/js-test-post.js"></script>
</body>
</html>

Просмотреть файл

@ -0,0 +1,187 @@
<!--
/*
** Copyright (c) 2014 The Khronos Group Inc.
**
** Permission is hereby granted, free of charge, to any person obtaining a
** copy of this software and/or associated documentation files (the
** "Materials"), to deal in the Materials without restriction, including
** without limitation the rights to use, copy, modify, merge, publish,
** distribute, sublicense, and/or sell copies of the Materials, and to
** permit persons to whom the Materials are furnished to do so, subject to
** the following conditions:
**
** The above copyright notice and this permission notice shall be included
** in all copies or substantial portions of the Materials.
**
** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
*/
-->
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<link rel="stylesheet" href="../../resources/js-test-style.css"/>
<script src="../../resources/js-test-pre.js"></script>
<script src="../resources/webgl-test-utils.js"></script>
<script id='vs' type='x-shader/x-vertex'>
attribute vec2 aPosCoord;
void main(void) {
gl_Position = vec4(aPosCoord, 0.0, 1.0);
}
</script>
<script id='fs' type='x-shader/x-fragment'>
precision mediump float;
void main(void) {
gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);
}
</script>
<script>
"use strict";
var posCoords_arr = new Float32Array(2 * 4);
var posCoords_buff = null;
function DrawQuad(gl, prog, x0, y0, x1, y1) {
gl.useProgram(prog);
if (!posCoords_buff) {
posCoords_buff = gl.createBuffer();
}
gl.bindBuffer(gl.ARRAY_BUFFER, posCoords_buff);
posCoords_arr[0] = x0;
posCoords_arr[1] = y0;
posCoords_arr[2] = x1;
posCoords_arr[3] = y0;
posCoords_arr[4] = x0;
posCoords_arr[5] = y1;
posCoords_arr[6] = x1;
posCoords_arr[7] = y1;
gl.bufferData(gl.ARRAY_BUFFER, posCoords_arr, gl.STREAM_DRAW);
gl.enableVertexAttribArray(prog.aPosCoord);
gl.vertexAttribPointer(prog.aPosCoord, 2, gl.FLOAT, false, 0, 0);
gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4);
}
function DrawSquare(gl, prog, size) {
DrawQuad(gl, prog, -size, -size, size, size);
}
function Reset(gl) {
gl.canvas.width += 1;
gl.canvas.width -= 1;
}
var iColor;
var pixel;
var dataURL_pre;
var dataURL_post;
function Test(gl, prog, shouldFinish) {
gl.enable(gl.BLEND);
gl.blendFunc(gl.ZERO, gl.DST_ALPHA);
iColor = 64;
var fColor = iColor / 255.0;
//////////////////
debug('clear(R,G,B,0)');
Reset(gl);
gl.clearColor(fColor, fColor, fColor, 0.0);
gl.clear(gl.COLOR_BUFFER_BIT);
dataURL_pre = gl.canvas.toDataURL();
//console.log('Before blending: ' + dataURL_pre);
DrawSquare(gl, prog, 0.7);
WebGLTestUtils.checkCanvasRect(gl, gl.drawingBufferWidth/2,
gl.drawingBufferHeight/2, 1, 1,
[iColor, iColor, iColor, 255],
'Should blend as if alpha is 1.0.');
dataURL_post = gl.canvas.toDataURL();
//console.log('After blending: ' + dataURL_post);
shouldBe("dataURL_post", "dataURL_pre");
//////////////////
debug('mask(R,G,B,0), clear(R,G,B,1)');
Reset(gl);
gl.colorMask(true, true, true, false);
gl.clearColor(fColor, fColor, fColor, 1.0);
gl.clear(gl.COLOR_BUFFER_BIT);
gl.colorMask(true, true, true, true);
dataURL_pre = gl.canvas.toDataURL();
//console.log('Before blending: ' + dataURL_pre);
DrawSquare(gl, prog, 0.7);
WebGLTestUtils.checkCanvasRect(gl, gl.drawingBufferWidth/2,
gl.drawingBufferHeight/2, 1, 1,
[iColor, iColor, iColor, 255],
'Should blend as if alpha is 1.0.');
dataURL_post = gl.canvas.toDataURL();
//console.log('After blending: ' + dataURL_post);
shouldBe("dataURL_post", "dataURL_pre");
////////////////
WebGLTestUtils.glErrorShouldBe(gl, gl.NO_ERROR, "should be no errors");
if (shouldFinish)
finishTest();
}
var gl;
function init() {
var canvas = document.getElementById('canvas');
var attribs = {
alpha: false,
antialias: false,
premultipliedAlpha: false,
};
gl = canvas.getContext('experimental-webgl', attribs);
shouldBeNonNull(gl);
shouldBe("gl.getParameter(gl.ALPHA_BITS)", "0");
var prog = WebGLTestUtils.setupProgram(gl, ['vs', 'fs']);
shouldBeNonNull(prog);
prog.aPosCoord = gl.getAttribLocation(prog, 'aPosCoord');
Test(gl, prog, false);
requestAnimationFrame(function(){ Test(gl, prog, true); });
}
</script>
</head>
<body onload="init()">
<canvas id='canvas'></canvas>
<br/>
<div id="description"></div>
<div id="console"></div>
</body>
</html>

Просмотреть файл

@ -0,0 +1,306 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<!--
/*
** Copyright (c) 2012 The Khronos Group Inc.
**
** Permission is hereby granted, free of charge, to any person obtaining a
** copy of this software and/or associated documentation files (the
** "Materials"), to deal in the Materials without restriction, including
** without limitation the rights to use, copy, modify, merge, publish,
** distribute, sublicense, and/or sell copies of the Materials, and to
** permit persons to whom the Materials are furnished to do so, subject to
** the following conditions:
**
** The above copyright notice and this permission notice shall be included
** in all copies or substantial portions of the Materials.
**
** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
*/
-->
<link rel="stylesheet" href="../../resources/js-test-style.css"/>
<script src="../../resources/js-test-pre.js"></script>
<script src="../resources/webgl-test-utils.js"></script>
<script>
"use strict";
var wtu = WebGLTestUtils;
var canvas;
var gl;
var shouldGenerateGLError;
var WEBGL_lose_context;
var new_WEBGL_lose_context;
var bufferObjects;
var program;
var texture;
var texColor = [255, 10, 20, 255];
var allowRestore;
var contextLostEventFired;
var contextRestoredEventFired;
var OES_vertex_array_object;
var old_OES_vertex_array_object;
var vertexArrayObject;
var OES_texture_float;
var newExtension;
function init()
{
enableJSTestPreVerboseLogging();
description("Tests behavior under a restored context.");
shouldGenerateGLError = wtu.shouldGenerateGLError;
testLosingContext();
}
function setupTest()
{
canvas = document.createElement("canvas");
canvas.width = 1;
canvas.height = 1;
gl = wtu.create3DContext(canvas);
WEBGL_lose_context = getExtensionAndAddProperty(gl, "WEBGL_lose_context");
if (!WEBGL_lose_context) {
debug("Could not find WEBGL_lose_context extension");
return false;
}
// Try to get a few extensions
OES_vertex_array_object = getExtensionAndAddProperty(gl, "OES_vertex_array_object");
OES_texture_float = getExtensionAndAddProperty(gl, "OES_texture_float");
return true;
}
function getExtensionAndAddProperty(gl, name) {
var ext = wtu.getExtensionWithKnownPrefixes(gl, name);
if (ext) {
ext.webglTestProperty = true;
}
return ext;
}
function reGetExtensionAndTestForProperty(gl, name, expectProperty) {
newExtension = wtu.getExtensionWithKnownPrefixes(gl, name);
// NOTE: while getting a extension after context lost/restored is allowed to fail
// for the purpose the conformance tests it is not.
//
// Hypothetically the user can switch GPUs live. For example on Windows, install 2 GPUs,
// then in the control panen enable 1, disable the others and visa versa. Since the GPUs
// have different capabilities one or the other may not support a particlar extension.
//
// But, for the purpose of the conformance tests the context is expected to restore
// on the same GPU and therefore the extensions that succeeded previously should
// succeed on restore.
shouldBeTrue("newExtension != null");
if (expectProperty) {
shouldBeTrue("newExtension.webglTestProperty === true");
} else {
shouldBeTrue("newExtension.webglTestProperty === undefined");
}
return newExtension;
}
function testLosingContext()
{
if (!setupTest()) {
finishTest();
return;
}
debug("Test losing a context and inability to restore it.");
canvas.addEventListener("webglcontextlost", function(e) {
testLostContext(e);
// restore the context after this event has exited.
setTimeout(function() {
// we didn't call prevent default so we should not be able to restore the context
shouldGenerateGLError(gl, gl.INVALID_OPERATION, "WEBGL_lose_context.restoreContext()");
testLosingAndRestoringContext();
}, 0);
});
canvas.addEventListener("webglcontextrestored", testShouldNotRestoreContext);
allowRestore = false;
contextLostEventFired = false;
contextRestoredEventFired = false;
testOriginalContext();
WEBGL_lose_context.loseContext();
// The context should be lost immediately.
shouldBeTrue("gl.isContextLost()");
shouldBe("gl.getError()", "gl.CONTEXT_LOST_WEBGL");
shouldBe("gl.getError()", "gl.NO_ERROR");
// gl methods should be no-ops
shouldGenerateGLError(gl, gl.NO_ERROR, "gl.blendFunc(gl.TEXTURE_2D, gl.TEXTURE_CUBE_MAP)");
// but the event should not have been fired.
shouldBeFalse("contextLostEventFired");
}
function testLosingAndRestoringContext()
{
if (!setupTest())
finishTest();
debug("");
debug("Test losing and restoring a context.");
canvas.addEventListener("webglcontextlost", function(e) {
testLostContext(e);
// restore the context after this event has exited.
setTimeout(function() {
shouldGenerateGLError(gl, gl.NO_ERROR, "WEBGL_lose_context.restoreContext()");
// The context should still be lost. It will not get restored until the
// webglrestorecontext event is fired.
shouldBeTrue("gl.isContextLost()");
shouldBe("gl.getError()", "gl.NO_ERROR");
// gl methods should still be no-ops
shouldGenerateGLError(gl, gl.NO_ERROR, "gl.blendFunc(gl.TEXTURE_2D, gl.TEXTURE_CUBE_MAP)");
}, 0);
});
canvas.addEventListener("webglcontextrestored", function() {
testRestoredContext();
finishTest();
});
allowRestore = true;
contextLostEventFired = false;
contextRestoredEventFired = false;
testOriginalContext();
WEBGL_lose_context.loseContext();
// The context should be lost immediately.
shouldBeTrue("gl.isContextLost()");
shouldBe("gl.getError()", "gl.CONTEXT_LOST_WEBGL");
shouldBe("gl.getError()", "gl.NO_ERROR");
// gl methods should be no-ops
shouldGenerateGLError(gl, gl.NO_ERROR, "gl.blendFunc(gl.TEXTURE_2D, gl.TEXTURE_CUBE_MAP)");
// but the event should not have been fired.
shouldBeFalse("contextLostEventFired");
}
function testRendering()
{
gl.clearColor(0, 0, 0, 255);
gl.colorMask(1, 1, 1, 0);
gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
program = wtu.setupSimpleTextureProgram(gl);
bufferObjects = wtu.setupUnitQuad(gl);
texture = wtu.createColoredTexture(gl, canvas.width, canvas.height, texColor);
gl.uniform1i(gl.getUniformLocation(program, "tex"), 0);
wtu.clearAndDrawUnitQuad(gl, [0, 0, 0, 255]);
var compare = texColor.slice(0, 3);
wtu.checkCanvasRect(gl, 0, 0, canvas.width, canvas.height, compare, "shouldBe " + compare);
shouldBe("gl.getError()", "gl.NO_ERROR");
}
function testOriginalContext()
{
debug("Test valid context");
shouldBeFalse("gl.isContextLost()");
shouldBe("gl.getError()", "gl.NO_ERROR");
testRendering();
debug("");
}
function testLostContext(e)
{
debug("Test lost context");
shouldBeFalse("contextLostEventFired");
contextLostEventFired = true;
shouldBeTrue("gl.isContextLost()");
shouldBe("gl.getError()", "gl.NO_ERROR");
debug("");
if (allowRestore)
e.preventDefault();
}
function testShouldNotRestoreContext(e)
{
testFailed("Should not restore the context unless preventDefault is called on the context lost event");
debug("");
}
function testResources(expected)
{
var tests = [
"gl.bindTexture(gl.TEXTURE_2D, texture)",
"gl.useProgram(program)",
"gl.bindBuffer(gl.ARRAY_BUFFER, bufferObjects[0])",
];
for (var i = 0; i < tests.length; ++i)
shouldGenerateGLError(gl, expected, tests[i]);
}
function testOESTextureFloat() {
if (OES_texture_float) {
// Extension must still be lost.
var tex = gl.createTexture();
gl.bindTexture(gl.TEXTURE_2D, tex);
shouldGenerateGLError(gl, gl.INVALID_ENUM, "gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, 1, 1, 0, gl.RGBA, gl.FLOAT, null)");
// Try re-enabling extension
OES_texture_float = reGetExtensionAndTestForProperty(gl, "OES_texture_float", false);
shouldGenerateGLError(gl, gl.NO_ERROR, "gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, 1, 1, 0, gl.RGBA, gl.FLOAT, null)");
}
}
function testOESVertexArrayObject() {
if (OES_vertex_array_object) {
// Extension must still be lost.
shouldBeNull("OES_vertex_array_object.createVertexArrayOES()");
// Try re-enabling extension
old_OES_vertex_array_object = OES_vertex_array_object;
OES_vertex_array_object = reGetExtensionAndTestForProperty(gl, "OES_vertex_array_object", false);
shouldBeTrue("OES_vertex_array_object.createVertexArrayOES() != null");
shouldBeTrue("old_OES_vertex_array_object.createVertexArrayOES() == null");
}
}
function testExtensions() {
testOESTextureFloat();
testOESVertexArrayObject();
// Only the WEBGL_lose_context extension should be the same object after context lost.
new_WEBGL_lose_context = reGetExtensionAndTestForProperty(gl, "WEBGL_lose_context", true);
}
function testRestoredContext()
{
debug("Test restored context");
shouldBeFalse("contextRestoredEventFired");
contextRestoredEventFired = true;
shouldBeFalse("gl.isContextLost()");
shouldBe("gl.getError()", "gl.NO_ERROR");
// Validate that using old resources fails.
testResources(gl.INVALID_OPERATION);
testRendering();
// Validate new resources created in testRendering().
testResources(gl.NO_ERROR);
testExtensions();
debug("");
}
</script>
</head>
<body onload="init()">
<div id="description"></div>
<div id="console"></div>
</body>
</html>

Просмотреть файл

@ -1,19 +1,42 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<!--
/*
** Copyright (c) 2012 The Khronos Group Inc.
**
** Permission is hereby granted, free of charge, to any person obtaining a
** copy of this software and/or associated documentation files (the
** "Materials"), to deal in the Materials without restriction, including
** without limitation the rights to use, copy, modify, merge, publish,
** distribute, sublicense, and/or sell copies of the Materials, and to
** permit persons to whom the Materials are furnished to do so, subject to
** the following conditions:
**
** The above copyright notice and this permission notice shall be included
** in all copies or substantial portions of the Materials.
**
** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
*/
-->
<link rel="stylesheet" href="../../resources/js-test-style.css"/>
<script src="../../resources/js-test-pre.js"></script>
<script src="../resources/webgl-test.js"></script>
<script src="../resources/webgl-test-utils.js"></script>
<script>
"use strict";
var wtu;
var canvas;
var gl;
var shouldGenerateGLError;
var extensionNames = [
"WEBKIT_WEBGL_lose_context",
"MOZ_WEBGL_lose_context",
];
var extensionName;
var extension;
@ -33,6 +56,8 @@ var ctx2d;
var imageData;
var float32array;
var int32array;
var OES_vertex_array_object;
var vertexArrayObject;
function init()
{
@ -43,26 +68,20 @@ function init()
description("Tests behavior under a lost context");
if (window.initNonKhronosFramework) {
window.initNonKhronosFramework(true);
}
// call testValidContext() before checking for the extension, because this is where we check
// for the isContextLost() method, which we want to do regardless of the extension's presence.
testValidContext();
for (var ii = 0; ii < extensionNames.length; ++ii) {
extension = gl.getExtension(extensionNames[ii]);
if (extension) {
extensionName = extensionNames[ii];
break;
}
}
if (!extension) {
debug("Could not find lose_context extension under the following names: " + extensionNames.join(" "));
extensionName = wtu.getSupportedExtensionWithKnownPrefixes(gl, "WEBGL_lose_context");
if (!extensionName) {
debug("Could not find WEBGL_lose_context extension");
finishTest();
return false;
}
extension = gl.getExtension(extensionName);
// need an extension that exposes new API methods.
OES_vertex_array_object = wtu.getExtensionWithKnownPrefixes(gl, "OES_vertex_array_object");
canvas.addEventListener("webglcontextlost", testLostContext, false);
@ -111,6 +130,24 @@ function testValidContext()
shouldBeTrue("gl.isRenderbuffer(renderbuffer)");
shouldBeTrue("gl.isShader(shader)");
shouldBeTrue("gl.isTexture(texture)");
if (OES_vertex_array_object) {
vertexArrayObject = OES_vertex_array_object.createVertexArrayOES();
shouldBe("gl.getError()", "gl.NO_ERROR");
shouldBeTrue("OES_vertex_array_object.isVertexArrayOES(vertexArrayObject)");
}
}
function testGLNOErrorFunctions(tests) {
tests.forEach(function(test) {
shouldGenerateGLError(gl, gl.NO_ERROR, test);
});
}
function testFunctionsThatReturnNULL(tests) {
tests.forEach(function(test) {
shouldBeNull(test);
});
}
function testLostContext()
@ -262,9 +299,7 @@ function testLostContext()
"gl.vertexAttribPointer(0, 0, gl.FLOAT, false, 0, 0)",
"gl.viewport(0, 0, 0, 0)",
];
for (var i = 0; i < voidTests.length; ++i) {
shouldGenerateGLError(gl, gl.NO_ERROR, voidTests[i]);
}
testGLNOErrorFunctions(voidTests);
// Functions return nullable values should all return null.
var nullTests = [
@ -278,8 +313,7 @@ function testLostContext()
"gl.getActiveUniform(program, 0)",
"gl.getAttachedShaders(program)",
"gl.getBufferParameter(gl.ARRAY_BUFFER, gl.BUFFER_SIZE)",
// Disabled pending test suite issue:
// "gl.getContextAttributes()",
"gl.getContextAttributes()",
"gl.getFramebufferAttachmentParameter(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.FRAMEBUFFER_ATTACHMENT_OBJECT_NAME)",
"gl.getParameter(gl.CURRENT_PROGRAM)",
"gl.getProgramInfoLog(program)",
@ -295,9 +329,7 @@ function testLostContext()
"gl.getSupportedExtensions()",
"gl.getExtension('" + extensionName + "')",
];
for (var i = 0; i < nullTests.length; ++i) {
shouldBeNull(nullTests[i]);
}
testFunctionsThatReturnNULL(nullTests);
// "Is" queries should all return false.
shouldBeFalse("gl.isBuffer(buffer)");
@ -310,6 +342,20 @@ function testLostContext()
shouldBe("gl.getError()", "gl.NO_ERROR");
// test extensions
if (OES_vertex_array_object) {
testGLNOErrorFunctions(
[
"OES_vertex_array_object.bindVertexArrayOES(vertexArrayObject)",
"OES_vertex_array_object.isVertexArrayOES(vertexArrayObject)",
"OES_vertex_array_object.deleteVertexArrayOES(vertexArrayObject)",
]);
testFunctionsThatReturnNULL(
[
"OES_vertex_array_object.createVertexArrayOES()",
]);
}
debug("");
finishTest();

Просмотреть файл

@ -0,0 +1,93 @@
<!--
/*
** Copyright (c) 2012 The Khronos Group Inc.
**
** Permission is hereby granted, free of charge, to any person obtaining a
** copy of this software and/or associated documentation files (the
** "Materials"), to deal in the Materials without restriction, including
** without limitation the rights to use, copy, modify, merge, publish,
** distribute, sublicense, and/or sell copies of the Materials, and to
** permit persons to whom the Materials are furnished to do so, subject to
** the following conditions:
**
** The above copyright notice and this permission notice shall be included
** in all copies or substantial portions of the Materials.
**
** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
*/
-->
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>WebGL Context Release Test</title>
<link rel="stylesheet" href="../../resources/js-test-style.css"/>
<script src="../../resources/js-test-pre.js"></script>
<script src="../resources/webgl-test-utils.js"></script>
</head>
<body>
<iframe id="host" style="width: 256px; height: 256px; border: 0;"></iframe>
<div id="description"></div>
<div id="console"></div>
<script>
"use strict";
description("This test ensures that WebGL contexts are released properly upon page reload");
var wtu = WebGLTestUtils;
var host = document.getElementById("host");
var testIterations = 25;
var currentIteration = 0;
function refreshFrame() {
if(currentIteration < testIterations) {
currentIteration++;
debug("");
debug("Test " + currentIteration + " of " + testIterations);
host.src = "resources/context-release-upon-reload-child.html";
} else {
finishTest();
}
}
function testContext() {
var gl = host.contentWindow.glContext;
assertMsg(gl != null, "context was created properly");
wtu.glErrorShouldBe(gl, gl.NO_ERROR, "Should be no errors");
if(gl.canvas.width != gl.drawingBufferWidth ||
gl.canvas.height != gl.drawingBufferHeight) {
testFailed("Buffer was the wrong size: " +
gl.drawingBufferWidth + "x" + gl.drawingBufferHeight);
} else {
testPassed("Buffer was the correct size: " +
gl.drawingBufferWidth + "x" + gl.drawingBufferHeight);
refreshFrame();
}
gl = null;
}
window.addEventListener("message", function(event) {
if(event.data == "Ready") {
testContext();
}
});
refreshFrame();
var successfullyParsed = true;
</script>
</body>
</html>

Просмотреть файл

@ -0,0 +1,93 @@
<!--
/*
** Copyright (c) 2012 The Khronos Group Inc.
**
** Permission is hereby granted, free of charge, to any person obtaining a
** copy of this software and/or associated documentation files (the
** "Materials"), to deal in the Materials without restriction, including
** without limitation the rights to use, copy, modify, merge, publish,
** distribute, sublicense, and/or sell copies of the Materials, and to
** permit persons to whom the Materials are furnished to do so, subject to
** the following conditions:
**
** The above copyright notice and this permission notice shall be included
** in all copies or substantial portions of the Materials.
**
** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
*/
-->
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>WebGL Context Release Test</title>
<link rel="stylesheet" href="../../resources/js-test-style.css"/>
<script src="../../resources/js-test-pre.js"></script>
<script src="../resources/webgl-test-utils.js"></script>
</head>
<body>
<iframe id="host" style="width: 256px; height: 256px; border: 0;"></iframe>
<div id="description"></div>
<div id="console"></div>
<script>
"use strict";
description("This test ensures that WebGL contexts are released properly when a worker is used");
var wtu = WebGLTestUtils;
var host = document.getElementById("host");
var testIterations = 25;
var currentIteration = 0;
function refreshFrame() {
if(currentIteration < testIterations) {
currentIteration++;
debug("");
debug("Test " + currentIteration + " of " + testIterations);
host.src = "resources/context-release-child-with-worker.html";
} else {
finishTest();
}
}
function testContext() {
var gl = host.contentWindow.glContext;
assertMsg(gl != null, "context was created properly");
wtu.glErrorShouldBe(gl, gl.NO_ERROR, "Should be no errors");
if(gl.canvas.width != gl.drawingBufferWidth ||
gl.canvas.height != gl.drawingBufferHeight) {
testFailed("Buffer was the wrong size: " +
gl.drawingBufferWidth + "x" + gl.drawingBufferHeight);
} else {
testPassed("Buffer was the correct size: " +
gl.drawingBufferWidth + "x" + gl.drawingBufferHeight);
refreshFrame();
}
gl = null;
}
window.addEventListener("message", function(event) {
if(event.data == "Ready") {
testContext();
}
});
refreshFrame();
var successfullyParsed = true;
</script>
</body>
</html>

Просмотреть файл

@ -0,0 +1,74 @@
<!--
/*
** Copyright (c) 2012 The Khronos Group Inc.
**
** Permission is hereby granted, free of charge, to any person obtaining a
** copy of this software and/or associated documentation files (the
** "Materials"), to deal in the Materials without restriction, including
** without limitation the rights to use, copy, modify, merge, publish,
** distribute, sublicense, and/or sell copies of the Materials, and to
** permit persons to whom the Materials are furnished to do so, subject to
** the following conditions:
**
** The above copyright notice and this permission notice shall be included
** in all copies or substantial portions of the Materials.
**
** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
*/
-->
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>WebGL Canvas Conformance Tests</title>
<link rel="stylesheet" href="../../resources/js-test-style.css"/>
<script src="../../resources/js-test-pre.js"></script>
<script src="../resources/webgl-test-utils.js"></script>
</head>
<body>
<div id="description"></div>
<div id="console"></div>
<canvas id="canvas" style="width: 50px; height: 50px;"> </canvas>
<canvas id="canvas2d" width="40" height="40"> </canvas>
<script>
"use strict";
description("This test ensures WebGL implementations interact correctly with the canvas tag.");
debug("");
debug("Canvas.getContext");
assertMsg(window.WebGLRenderingContext,
"WebGLRenderingContext should be a member of window");
assertMsg('WebGLRenderingContext' in window,
"WebGLRenderingContext should be 'in' window");
assertMsg(Object.getPrototypeOf(WebGLRenderingContext.prototype) === Object.prototype,
"WebGLRenderingContext should only have Object in it's prototype chain");
var wtu = WebGLTestUtils;
var canvas = document.getElementById("canvas");
var gl = wtu.create3DContext(canvas);
if (!gl) {
testFailed("context does not exist");
} else {
testPassed("context exists");
debug("Checking context type");
assertMsg(gl instanceof WebGLRenderingContext,
"context type should be WebGLRenderingContext");
}
debug("");
var successfullyParsed = true;
</script>
<script src="../../resources/js-test-post.js"></script>
</body>
</html>

Просмотреть файл

@ -0,0 +1,88 @@
<!--
/*
** Copyright (c) 2012 The Khronos Group Inc.
**
** Permission is hereby granted, free of charge, to any person obtaining a
** copy of this software and/or associated documentation files (the
** "Materials"), to deal in the Materials without restriction, including
** without limitation the rights to use, copy, modify, merge, publish,
** distribute, sublicense, and/or sell copies of the Materials, and to
** permit persons to whom the Materials are furnished to do so, subject to
** the following conditions:
**
** The above copyright notice and this permission notice shall be included
** in all copies or substantial portions of the Materials.
**
** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
*/
-->
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<link rel="stylesheet" href="../../resources/js-test-style.css"/>
<script src="../../resources/js-test-pre.js"></script>
<script src="../resources/webgl-test-utils.js"></script>
</head>
<body>
<div id="description"></div>
<div id="console"></div>
<script>
"use strict";
description("Tests calling WebGL APIs with objects from other contexts");
var wtu = WebGLTestUtils;
var contextA = wtu.create3DContext();
var contextB = wtu.create3DContext();
var programA = wtu.loadStandardProgram(contextA);
var programB = wtu.loadStandardProgram(contextB);
var shaderA = wtu.loadStandardVertexShader(contextA);
var shaderB = wtu.loadStandardVertexShader(contextB);
var textureA = contextA.createTexture();
var textureB = contextB.createTexture();
var frameBufferA = contextA.createFramebuffer();
var frameBufferB = contextB.createFramebuffer();
var renderBufferA = contextA.createRenderbuffer();
var renderBufferB = contextB.createRenderbuffer();
var locationA = contextA.getUniformLocation(programA, 'u_modelViewProjMatrix');
var locationB = contextB.getUniformLocation(programB, 'u_modelViewProjMatrix');
wtu.shouldGenerateGLError(contextA, contextA.INVALID_OPERATION, "contextA.compileShader(shaderB)");
wtu.shouldGenerateGLError(contextA, contextA.INVALID_OPERATION, "contextA.linkProgram(programB)");
wtu.shouldGenerateGLError(contextA, contextA.INVALID_OPERATION, "contextA.attachShader(programA, shaderB)");
wtu.shouldGenerateGLError(contextA, contextA.INVALID_OPERATION, "contextA.attachShader(programB, shaderA)");
wtu.shouldGenerateGLError(contextA, contextA.INVALID_OPERATION, "contextA.attachShader(programB, shaderB)");
wtu.shouldGenerateGLError(contextA, contextA.INVALID_OPERATION, "contextA.detachShader(programA, shaderB)");
wtu.shouldGenerateGLError(contextA, contextA.INVALID_OPERATION, "contextA.detachShader(programB, shaderA)");
wtu.shouldGenerateGLError(contextA, contextA.INVALID_OPERATION, "contextA.detachShader(programB, shaderB)");
wtu.shouldGenerateGLError(contextA, contextA.INVALID_OPERATION, "contextA.shaderSource(shaderB, 'foo')");
wtu.shouldGenerateGLError(contextA, contextA.INVALID_OPERATION, "contextA.bindAttribLocation(programB, 0, 'foo')");
wtu.shouldGenerateGLError(contextA, contextA.INVALID_OPERATION, "contextA.bindFramebuffer(contextA.FRAMEBUFFER, frameBufferB)");
wtu.shouldGenerateGLError(contextA, contextA.INVALID_OPERATION, "contextA.bindRenderbuffer(contextA.RENDERBUFFER, renderBufferB)");
wtu.shouldGenerateGLError(contextA, contextA.INVALID_OPERATION, "contextA.bindTexture(contextA.TEXTURE_2D, textureB)");
wtu.shouldGenerateGLError(contextA, contextA.INVALID_OPERATION, "contextA.framebufferRenderbuffer(contextA.FRAMEBUFFER, contextA.DEPTH_ATTACHMENT, contextA.RENDERBUFFER, renderBufferB)");
wtu.shouldGenerateGLError(contextA, contextA.INVALID_OPERATION, "contextA.framebufferTexture2D(contextA.FRAMEBUFFER, contextA.COLOR_ATTACHMENT0, contextA.TEXTURE_2D, textureB, 0)");
wtu.shouldGenerateGLError(contextA, contextA.INVALID_OPERATION, "contextA.getProgramParameter(programB, 0)");
wtu.shouldGenerateGLError(contextA, contextA.INVALID_OPERATION, "contextA.getProgramInfoLog(programB, 0)");
wtu.shouldGenerateGLError(contextA, contextA.INVALID_OPERATION, "contextA.getShaderParameter(shaderB, 0)");
wtu.shouldGenerateGLError(contextA, contextA.INVALID_OPERATION, "contextA.getShaderInfoLog(shaderB, 0)");
wtu.shouldGenerateGLError(contextA, contextA.INVALID_OPERATION, "contextA.getShaderSource(shaderB)");
wtu.shouldGenerateGLError(contextA, contextA.INVALID_OPERATION, "contextA.getUniform(programB, locationA)");
wtu.shouldGenerateGLError(contextA, contextA.INVALID_OPERATION, "contextA.getUniformLocation(programB, 'u_modelViewProjMatrix')");
var successfullyParsed = true;
</script>
<script src="../../resources/js-test-post.js"></script>
</body>
</html>

Просмотреть файл

@ -0,0 +1,236 @@
<!--
/*
** Copyright (c) 2012 The Khronos Group Inc.
**
** Permission is hereby granted, free of charge, to any person obtaining a
** copy of this software and/or associated documentation files (the
** "Materials"), to deal in the Materials without restriction, including
** without limitation the rights to use, copy, modify, merge, publish,
** distribute, sublicense, and/or sell copies of the Materials, and to
** permit persons to whom the Materials are furnished to do so, subject to
** the following conditions:
**
** The above copyright notice and this permission notice shall be included
** in all copies or substantial portions of the Materials.
**
** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
*/
-->
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>WebGL Methods Test</title>
<link rel="stylesheet" href="../../resources/js-test-style.css"/>
<script src="../../resources/js-test-pre.js"></script>
<script src="../resources/webgl-test-utils.js"></script>
</head>
<body>
<div id="description"></div>
<div id="console"></div>
<canvas id="canvas" style="width: 50px; height: 50px;"> </canvas>
<script>
"use strict";
description("This test ensures that the WebGL context has all the methods in the specification.");
var methods = [
"getContextAttributes",
"activeTexture",
"attachShader",
"bindAttribLocation",
"bindBuffer",
"bindFramebuffer",
"bindRenderbuffer",
"bindTexture",
"blendColor",
"blendEquation",
"blendEquationSeparate",
"blendFunc",
"blendFuncSeparate",
"bufferData",
"bufferSubData",
"checkFramebufferStatus",
"clear",
"clearColor",
"clearDepth",
"clearStencil",
"colorMask",
"compileShader",
"compressedTexImage2D",
"compressedTexSubImage2D",
"copyTexImage2D",
"copyTexSubImage2D",
"createBuffer",
"createFramebuffer",
"createProgram",
"createRenderbuffer",
"createShader",
"createTexture",
"cullFace",
"deleteBuffer",
"deleteFramebuffer",
"deleteProgram",
"deleteRenderbuffer",
"deleteShader",
"deleteTexture",
"depthFunc",
"depthMask",
"depthRange",
"detachShader",
"disable",
"disableVertexAttribArray",
"drawArrays",
"drawElements",
"enable",
"enableVertexAttribArray",
"finish",
"flush",
"framebufferRenderbuffer",
"framebufferTexture2D",
"frontFace",
"generateMipmap",
"getActiveAttrib",
"getActiveUniform",
"getAttachedShaders",
"getAttribLocation",
"getParameter",
"getBufferParameter",
"getError",
"getExtension",
"getFramebufferAttachmentParameter",
"getProgramParameter",
"getProgramInfoLog",
"getRenderbufferParameter",
"getShaderParameter",
"getShaderInfoLog",
"getShaderPrecisionFormat",
"getShaderSource",
"getSupportedExtensions",
"getTexParameter",
"getUniform",
"getUniformLocation",
"getVertexAttrib",
"getVertexAttribOffset",
"hint",
"isBuffer",
"isContextLost",
"isEnabled",
"isFramebuffer",
"isProgram",
"isRenderbuffer",
"isShader",
"isTexture",
"lineWidth",
"linkProgram",
"pixelStorei",
"polygonOffset",
"readPixels",
"renderbufferStorage",
"sampleCoverage",
"scissor",
"shaderSource",
"stencilFunc",
"stencilFuncSeparate",
"stencilMask",
"stencilMaskSeparate",
"stencilOp",
"stencilOpSeparate",
"texImage2D",
"texParameterf",
"texParameteri",
"texSubImage2D",
"uniform1f",
"uniform1fv",
"uniform1i",
"uniform1iv",
"uniform2f",
"uniform2fv",
"uniform2i",
"uniform2iv",
"uniform3f",
"uniform3fv",
"uniform3i",
"uniform3iv",
"uniform4f",
"uniform4fv",
"uniform4i",
"uniform4iv",
"uniformMatrix2fv",
"uniformMatrix3fv",
"uniformMatrix4fv",
"useProgram",
"validateProgram",
"vertexAttrib1f",
"vertexAttrib1fv",
"vertexAttrib2f",
"vertexAttrib2fv",
"vertexAttrib3f",
"vertexAttrib3fv",
"vertexAttrib4f",
"vertexAttrib4fv",
"vertexAttribPointer",
"viewport"
];
// Properties to be ignored because they were added in versions of the
// spec that are backward-compatible with this version
var ignoredMethods = [
];
function assertFunction(v, f) {
try {
if (typeof v[f] != "function") {
testFailed("Property either does not exist or is not a function: " + f);
return false;
} else {
return true;
}
} catch(e) {
testFailed("Trying to access the property '" + f + "' threw an error: "+e.toString());
}
}
debug("");
debug("Canvas.getContext");
var wtu = WebGLTestUtils;
var canvas = document.getElementById("canvas");
var gl = wtu.create3DContext(canvas);
var passed = true;
for (var i=0; i<methods.length; i++) {
var r = assertFunction(gl, methods[i]);
passed = passed && r;
}
if (passed) {
testPassed("All WebGL methods found.");
}
var extended = false;
for (var i in gl) {
if (typeof gl[i] == "function" && methods.indexOf(i) == -1 && ignoredMethods.indexOf(i) == -1) {
if (!extended) {
extended = true;
testFailed("Also found the following extra methods:");
}
testFailed(i);
}
}
if (!extended) {
testPassed("No extra methods found on WebGL context.");
}
debug("");
var successfullyParsed = true;
</script>
<script src="../../resources/js-test-post.js"></script>
</body>
</html>

Просмотреть файл

@ -0,0 +1,266 @@
<!--
/*
** Copyright (c) 2012 The Khronos Group Inc.
**
** Permission is hereby granted, free of charge, to any person obtaining a
** copy of this software and/or associated documentation files (the
** "Materials"), to deal in the Materials without restriction, including
** without limitation the rights to use, copy, modify, merge, publish,
** distribute, sublicense, and/or sell copies of the Materials, and to
** permit persons to whom the Materials are furnished to do so, subject to
** the following conditions:
**
** The above copyright notice and this permission notice shall be included
** in all copies or substantial portions of the Materials.
**
** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
*/
-->
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Test the WebGL premultipliedAlpha context creation flag.</title>
<link rel="stylesheet" href="../../resources/js-test-style.css"/>
<script src="../../resources/js-test-pre.js"></script>
<script src="../resources/webgl-test-utils.js"> </script>
</head>
<body>
<div id="description"></div><div id="console"></div>
<script>
"use strict";
var wtu = WebGLTestUtils;
// wtu.create3DContext(...) will set antialias to false by default
// if the antialias property is not set to true explicitly.
// To cover the antialias case, it needs to set antialias to true
// explicitly.
var tests = [
// If premultipliedAlpha is true and antialias is false then
// [texture] [canvas] [dataURL]
// 32, 64, 128, 128 -> 64, 128, 255, 128 -> 64, 128, 255, 128
{ creationAttributes: {},
sentColor: [32, 64, 128, 128],
expectedColor: [64, 128, 255, 128],
errorRange: 2,
imageFormat: "image/png"
},
// If premultipliedAlpha is true and antialias is true then
// [texture] [canvas] [dataURL]
// 32, 64, 128, 128 -> 64, 128, 255, 128 -> 64, 128, 255, 128
{ creationAttributes: {antialias: true},
sentColor: [32, 64, 128, 128],
expectedColor: [64, 128, 255, 128],
errorRange: 2,
imageFormat: "image/png"
},
// If premultipliedAlpha is true and antialias is false then
// [texture] [canvas] [texture]
// 32, 64, 128, 128 -> 64, 128, 255, 128 -> 64, 128, 255, 128
{ creationAttributes: {},
sentColor: [32, 64, 128, 128],
expectedColor: [64, 128, 255, 128],
errorRange: 2,
},
// If premultipliedAlpha is true and antialias is true then
// [texture] [canvas] [texture]
// 32, 64, 128, 128 -> 64, 128, 255, 128 -> 64, 128, 255, 128
{ creationAttributes: {antialias: true},
sentColor: [32, 64, 128, 128],
expectedColor: [64, 128, 255, 128],
errorRange: 2,
},
// If premultipliedAlpha is false and antialias is false then
// [texture] [canvas] [dataURL]
// 255, 192, 128, 1 -> 255, 192, 128, 1 -> 255, 192, 128, 1
{ creationAttributes: {premultipliedAlpha: false},
sentColor: [255, 192, 128, 1],
expectedColor: [255, 192, 128, 1],
errorRange: 0,
imageFormat: "image/png"
},
// If premultipliedAlpha is false and antialias is true then
// [texture] [canvas] [dataURL]
// 255, 192, 128, 1 -> 255, 192, 128, 1 -> 255, 192, 128, 1
{ creationAttributes: {premultipliedAlpha: false, antialias: true},
sentColor: [255, 192, 128, 1],
expectedColor: [255, 192, 128, 1],
errorRange: 0,
imageFormat: "image/png"
},
// If premultipliedAlpha is false and antialias is false then
// [texture] [canvas] [texture]
// 255, 192, 128, 1 -> 255, 192, 128, 1 -> 255, 192, 128, 1
{ creationAttributes: {premultipliedAlpha: false},
sentColor: [255, 192, 128, 1],
expectedColor: [255, 192, 128, 1],
errorRange: 0,
},
// If premultipliedAlpha is false and antialias is true then
// [texture] [canvas] [texture]
// 255, 192, 128, 1 -> 255, 192, 128, 1 -> 255, 192, 128, 1
{ creationAttributes: {premultipliedAlpha: false, antialias: true},
sentColor: [255, 192, 128, 1],
expectedColor: [255, 192, 128, 1],
errorRange: 0,
},
// If premultipliedAlpha is false and antialias is false then
// [texture] [canvas] [dataURL]
// 255, 255, 255, 128 -> 255, 255, 255, 128 -> 128, 128, 128, 255
{ creationAttributes: {premultipliedAlpha: false},
sentColor: [255, 255, 255, 128],
expectedColor: [128, 128, 128, 255],
errorRange: 2,
imageFormat: "image/jpeg"
},
// If premultipliedAlpha is false and antialias is true then
// [texture] [canvas] [dataURL]
// 255, 255, 255, 128 -> 255, 255, 255, 128 -> 128, 128, 128, 255
{ creationAttributes: {premultipliedAlpha: false, antialias: true},
sentColor: [255, 255, 255, 128],
expectedColor: [128, 128, 128, 255],
errorRange: 2,
imageFormat: "image/jpeg"
},
// If premultipliedAlpha is true and antialias is false then
// [texture] [canvas] [dataURL]
// 128, 128, 128, 128 -> 255, 255, 255, 128 -> 128, 128, 128, 255
{ creationAttributes: {},
sentColor: [128, 128, 128, 128],
expectedColor: [128, 128, 128, 255],
errorRange: 2,
imageFormat: "image/jpeg"
},
// If premultipliedAlpha is true and antialias is true then
// [texture] [canvas] [dataURL]
// 128, 128, 128, 128 -> 255, 255, 255, 128 -> 128, 128, 128, 255
{ creationAttributes: {antialias: true},
sentColor: [128, 128, 128, 128],
expectedColor: [128, 128, 128, 255],
errorRange: 2,
imageFormat: "image/jpeg"
}
];
var g_count = 0;
var gl;
var canvas;
var premultipliedAlpha;
enableJSTestPreVerboseLogging();
description("Test the WebGL premultipliedAlpha context creation flag.");
doNextTest();
function doNextTest() {
if (g_count < tests.length) {
var test = tests[g_count++];
canvas = document.createElement("canvas");
// Need to preserve drawing buffer to load it in a callback
test.creationAttributes.preserveDrawingBuffer = true;
gl = wtu.create3DContext(canvas, test.creationAttributes);
var premultipliedAlpha = test.creationAttributes.premultipliedAlpha != false;
var antialias = test.creationAttributes.antialias == true;
debug("")
debug("testing: premultipliedAlpha: " + premultipliedAlpha
+ ", antialias: " + antialias
+ ", imageFormat: " + test.imageFormat);
shouldBe('gl.getContextAttributes().premultipliedAlpha', premultipliedAlpha.toString());
shouldBeTrue('gl.getContextAttributes().preserveDrawingBuffer');
wtu.log(gl.getContextAttributes());
var program = wtu.setupTexturedQuad(gl);
wtu.glErrorShouldBe(gl, gl.NO_ERROR, "Should be no errors from setup.");
var tex = gl.createTexture();
wtu.fillTexture(gl, tex, 2, 2, test.sentColor, 0);
var loc = gl.getUniformLocation(program, "tex");
gl.uniform1i(loc, 0);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
wtu.clearAndDrawUnitQuad(gl);
wtu.glErrorShouldBe(gl, gl.NO_ERROR, "Should be no errors from drawing.");
var loadTexture = function() {
debug("loadTexture called");
var pngTex = gl.createTexture();
// not needed as it's the default
// gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, false);
gl.pixelStorei(gl.UNPACK_COLORSPACE_CONVERSION_WEBGL, gl.NONE);
gl.bindTexture(gl.TEXTURE_2D, pngTex);
if (test.imageFormat) {
// create texture from image
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, this);
} else {
// create texture from canvas
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, canvas);
}
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
wtu.glErrorShouldBe(gl, gl.NO_ERROR, "Should be no errors from creating copy.");
wtu.clearAndDrawUnitQuad(gl);
wtu.glErrorShouldBe(gl, gl.NO_ERROR, "Should be no errors from 2nd drawing.");
wtu.checkCanvas(
gl, test.expectedColor,
"should draw with " + test.expectedColor, test.errorRange);
doNextTest();
}
var loadTextureError = function() {
testFailed("Creating image from canvas failed. Image src: " + this.src);
finishTest();
}
var shrinkString = function(string) {
if (string.length < 63) {
return string;
}
return string.substr(0, 30) + "..." + string.substr(string.length - 30);
}
if (test.imageFormat) {
// Load canvas into string using toDataURL
debug("Calling canvas.toDataURL('" + test.imageFormat + "')");
var imageUrl = canvas.toDataURL(test.imageFormat);
debug("imageUrl = '" + shrinkString(imageUrl) + "'");
if (test.imageFormat != "image/png" &&
(imageUrl.indexOf("data:image/png,") == 0 ||
imageUrl.indexOf("data:image/png;") == 0)) {
debug("Image format " + test.imageFormat + " not supported; skipping");
setTimeout(doNextTest, 0);
} else {
// Load string into the texture
debug("Waiting for image.onload");
var input = wtu.makeImage(imageUrl, loadTexture, loadTextureError);
}
} else {
// Load canvas into the texture asynchronously (to prevent unbounded stack consumption)
debug("Waiting for setTimeout");
setTimeout(loadTexture, 0);
}
} else {
var successfullyParsed = true;
finishTest();
}
}
</script>
</body>
</html>

Просмотреть файл

@ -0,0 +1,64 @@
<!--
/*
** Copyright (c) 2012 The Khronos Group Inc.
**
** Permission is hereby granted, free of charge, to any person obtaining a
** copy of this software and/or associated documentation files (the
** "Materials"), to deal in the Materials without restriction, including
** without limitation the rights to use, copy, modify, merge, publish,
** distribute, sublicense, and/or sell copies of the Materials, and to
** permit persons to whom the Materials are furnished to do so, subject to
** the following conditions:
**
** The above copyright notice and this permission notice shall be included
** in all copies or substantial portions of the Materials.
**
** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
*/
-->
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>WebGL Resource Sharing.</title>
<link rel="stylesheet" href="../../resources/js-test-style.css"/>
<script src="../../resources/js-test-pre.js"></script>
<script src="../resources/webgl-test-utils.js"></script>
</head>
<body>
<canvas id="example1" width="2" height="2" style="width: 40px; height: 40px;"></canvas>
<canvas id="example2" width="2" height="2" style="width: 40px; height: 40px;"></canvas>
<div id="description"></div>
<div id="console"></div>
<script>
"use strict";
description("Tests that resources can not be shared.");
debug("");
var wtu = WebGLTestUtils;
var gl1 = wtu.create3DContext("example1");
var gl2 = wtu.create3DContext("example2");
assertMsg(gl1 && gl2,
"Got 3d context.");
var vertexObject = gl1.createBuffer();
gl2.bindBuffer(gl2.ARRAY_BUFFER, vertexObject);
assertMsg(
gl2.getError() == gl2.INVALID_OPERATION,
"attempt to use a resource from the wrong context should fail with INVALID_OPERATION");
var successfullyParsed = true;
</script>
<script src="../../resources/js-test-post.js"></script>
</body>
</html>

Просмотреть файл

@ -0,0 +1,78 @@
<!--
/*
** Copyright (c) 2012 The Khronos Group Inc.
**
** Permission is hereby granted, free of charge, to any person obtaining a
** copy of this software and/or associated documentation files (the
** "Materials"), to deal in the Materials without restriction, including
** without limitation the rights to use, copy, modify, merge, publish,
** distribute, sublicense, and/or sell copies of the Materials, and to
** permit persons to whom the Materials are furnished to do so, subject to
** the following conditions:
**
** The above copyright notice and this permission notice shall be included
** in all copies or substantial portions of the Materials.
**
** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
*/
-->
<!DOCTYPE html>
<html style="margin: 0; padding: 0;">
<head>
<meta charset="utf-8">
<title>Simple WebGL context with Worker</title>
<script src="../../resources/webgl-test-utils.js"> </script>
</head>
<body style="margin: 0; padding: 0; overflow: hidden;">
<canvas id="c"
width="1680" height="1050"
style="width: 256px; height: 256px;"> <!-- scaled to fit page better -->
<script id="vshader" type="x-shader/x-vertex">
attribute vec4 vPosition;
void main()
{
gl_Position = vPosition;
}
</script>
<script id="fshader" type="x-shader/x-fragment">
void main()
{
gl_FragColor = vec4(1.0,0.0,0.0,1.0);
}
</script>
<script>
"use strict";
var wtu = WebGLTestUtils;
var myWorker = new Worker("context-release-worker.js");
var gl = wtu.create3DContext("c", { antialias: false });
var program = wtu.setupProgram(gl, ["vshader", "fshader"], ["vPosition"]);
var vertexObject = gl.createBuffer();
gl.bindBuffer(gl.ARRAY_BUFFER, vertexObject);
gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([ 0,0.75,0, -0.75,-0.75,0, 0.75,-0.75,0 ]), gl.STATIC_DRAW);
gl.enableVertexAttribArray(0);
gl.vertexAttribPointer(0, 3, gl.FLOAT, false, 0, 0);
gl.clearColor(0.0, 0.0, 0.0, 1.0);
gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
gl.drawArrays(gl.TRIANGLES, 0, 3);
if(parent) {
window.glContext = gl;
parent.postMessage("Ready", "*");
}
</script>
</body>
</html>

Просмотреть файл

@ -0,0 +1,77 @@
<!--
/*
** Copyright (c) 2012 The Khronos Group Inc.
**
** Permission is hereby granted, free of charge, to any person obtaining a
** copy of this software and/or associated documentation files (the
** "Materials"), to deal in the Materials without restriction, including
** without limitation the rights to use, copy, modify, merge, publish,
** distribute, sublicense, and/or sell copies of the Materials, and to
** permit persons to whom the Materials are furnished to do so, subject to
** the following conditions:
**
** The above copyright notice and this permission notice shall be included
** in all copies or substantial portions of the Materials.
**
** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
*/
-->
<!DOCTYPE html>
<html style="margin: 0; padding: 0;">
<head>
<meta charset="utf-8">
<title>Simple WebGL context</title>
<script src="../../resources/webgl-test-utils.js"> </script>
</head>
<body style="margin: 0; padding: 0; overflow: hidden;">
<canvas id="c"
width="1680" height="1050"
style="width: 256px; height: 256px;"> <!-- scaled to fit page better -->
<script id="vshader" type="x-shader/x-vertex">
attribute vec4 vPosition;
void main()
{
gl_Position = vPosition;
}
</script>
<script id="fshader" type="x-shader/x-fragment">
void main()
{
gl_FragColor = vec4(1.0,0.0,0.0,1.0);
}
</script>
<script>
"use strict";
var wtu = WebGLTestUtils;
var gl = wtu.create3DContext("c", { antialias: false });
var program = wtu.setupProgram(gl, ["vshader", "fshader"], ["vPosition"]);
var vertexObject = gl.createBuffer();
gl.bindBuffer(gl.ARRAY_BUFFER, vertexObject);
gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([ 0,0.75,0, -0.75,-0.75,0, 0.75,-0.75,0 ]), gl.STATIC_DRAW);
gl.enableVertexAttribArray(0);
gl.vertexAttribPointer(0, 3, gl.FLOAT, false, 0, 0);
gl.clearColor(0.0, 0.0, 0.0, 1.0);
gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
gl.drawArrays(gl.TRIANGLES, 0, 3);
if (parent) {
window.glContext = gl;
parent.postMessage("Ready", "*");
}
</script>
</body>
</html>

Просмотреть файл

@ -0,0 +1,4 @@
// Simple worker used to provoke WebGL context release bugs on Chrome
postMessage("Hello World");
close();

Просмотреть файл

@ -0,0 +1,34 @@
--min-version 1.0.3 angle-instanced-arrays.html
--min-version 1.0.3 angle-instanced-arrays-out-of-bounds.html
--min-version 1.0.3 ext-blend-minmax.html
--min-version 1.0.3 ext-frag-depth.html
--min-version 1.0.3 ext-shader-texture-lod.html
--min-version 1.0.3 ext-sRGB.html
--min-version 1.0.2 ext-texture-filter-anisotropic.html
--min-version 1.0.2 get-extension.html
oes-standard-derivatives.html
oes-texture-float-with-canvas.html
oes-texture-float-with-image-data.html
oes-texture-float-with-image.html
oes-texture-float-with-video.html
oes-texture-float.html
oes-vertex-array-object.html
--min-version 1.0.3 oes-vertex-array-object-bufferData.html
--min-version 1.0.3 oes-texture-half-float.html
--min-version 1.0.3 oes-texture-float-linear.html
--min-version 1.0.3 oes-texture-half-float-linear.html
--min-version 1.0.3 oes-texture-half-float-with-canvas.html
--min-version 1.0.3 oes-texture-half-float-with-image-data.html
--min-version 1.0.3 oes-texture-half-float-with-image.html
--min-version 1.0.3 oes-texture-half-float-with-video.html
--min-version 1.0.2 oes-element-index-uint.html
webgl-debug-renderer-info.html
webgl-debug-shaders.html
--min-version 1.0.3 webgl-compressed-texture-atc.html
--min-version 1.0.3 webgl-compressed-texture-pvrtc.html
--min-version 1.0.2 webgl-compressed-texture-s3tc.html
--min-version 1.0.3 webgl-compressed-texture-size-limit.html
--min-version 1.0.2 webgl-depth-texture.html
--min-version 1.0.3 webgl-draw-buffers.html
--min-version 1.0.3 webgl-shared-resources.html

Просмотреть файл

@ -0,0 +1,77 @@
<!--
/*
** Copyright (c) 2014 The Khronos Group Inc.
**
** Permission is hereby granted, free of charge, to any person obtaining a
** copy of this software and/or associated documentation files (the
** "Materials"), to deal in the Materials without restriction, including
** without limitation the rights to use, copy, modify, merge, publish,
** distribute, sublicense, and/or sell copies of the Materials, and to
** permit persons to whom the Materials are furnished to do so, subject to
** the following conditions:
**
** The above copyright notice and this permission notice shall be included
** in all copies or substantial portions of the Materials.
**
** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
*/
-->
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<link rel="stylesheet" href="../../resources/js-test-style.css"/>
<script src="../../resources/js-test-pre.js"></script>
<script src="../resources/webgl-test-utils.js"></script>
<script src="../resources/out-of-bounds-test.js"></script>
</head>
<body>
<div id="description"></div>
<div id="console"></div>
<script>
"use strict";
description("Test of drawArraysInstancedANGLE and drawElementsInstancedANGLE with out-of-bounds parameters");
var wtu = WebGLTestUtils;
var gl = wtu.create3DContext();
var ext = wtu.getExtensionWithKnownPrefixes(gl, "ANGLE_instanced_arrays");
if (!ext) {
testPassed("No ANGLE_instanced_arrays support -- this is legal");
} else {
testPassed("Successfully enabled ANGLE_instanced_arrays extension");
debug("");
debug("Test with 1 instance without instanced attributes");
debug("");
OutOfBoundsTest.runDrawArraysTest("ext.drawArraysInstancedANGLE(gl.TRIANGLES, $(offset), $(count), 1)", gl, wtu, ext);
debug("");
OutOfBoundsTest.runDrawElementsTest("ext.drawElementsInstancedANGLE(gl.TRIANGLES, $(count), $(type), $(offset), 1)", gl, wtu, ext);
debug("");
debug("Test with 2 instances without instanced attributes");
debug("");
OutOfBoundsTest.runDrawArraysTest("ext.drawArraysInstancedANGLE(gl.TRIANGLES, $(offset), $(count), 2)", gl, wtu, ext);
debug("");
OutOfBoundsTest.runDrawElementsTest("ext.drawElementsInstancedANGLE(gl.TRIANGLES, $(count), $(type), $(offset), 2)", gl, wtu, ext);
debug("");
OutOfBoundsTest.runDrawArraysInstancedTest("ext.drawArraysInstancedANGLE(gl.TRIANGLES, $(offset), $(count), $(primcount))", gl, wtu, ext);
debug("");
OutOfBoundsTest.runDrawElementsInstancedTest("ext.drawElementsInstancedANGLE(gl.TRIANGLES, $(count), $(type), $(offset), $(primcount))", gl, wtu, ext);
debug("");
}
var successfullyParsed = true;
</script>
<script src="../../resources/js-test-post.js"></script>
</body>
</html>

Просмотреть файл

@ -0,0 +1,420 @@
<!--
/*
** Copyright (c) 2013 The Khronos Group Inc.
**
** Permission is hereby granted, free of charge, to any person obtaining a
** copy of this software and/or associated documentation files (the
** "Materials"), to deal in the Materials without restriction, including
** without limitation the rights to use, copy, modify, merge, publish,
** distribute, sublicense, and/or sell copies of the Materials, and to
** permit persons to whom the Materials are furnished to do so, subject to
** the following conditions:
**
** The above copyright notice and this permission notice shall be included
** in all copies or substantial portions of the Materials.
**
** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
*/
-->
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>WebGL ANGLE_instanced_arrays Conformance Tests</title>
<link rel="stylesheet" href="../../resources/js-test-style.css"/>
<script src="../../resources/desktop-gl-constants.js" type="text/javascript"></script>
<script src="../../resources/js-test-pre.js"></script>
<script src="../resources/webgl-test-utils.js"></script>
</head>
<body>
<div id="description"></div>
<canvas id="canvas" style="width: 50px; height: 50px;"> </canvas>
<div id="console"></div>
<!-- Shaders for testing instanced draws -->
<script id="outputVertexShader" type="x-shader/x-vertex">
attribute vec4 aPosition;
attribute vec2 aOffset;
attribute vec4 aColor;
varying vec4 vColor;
void main() {
vColor = aColor;
gl_Position = aPosition + vec4(aOffset, 0.0, 0.0);
}
</script>
<script id="outputFragmentShader" type="x-shader/x-fragment">
precision mediump float;
varying vec4 vColor;
void main() {
gl_FragColor = vColor;
}
</script>
<script>
"use strict";
description("This test verifies the functionality of the ANGLE_instanced_arrays extension, if it is available.");
debug("");
var wtu = WebGLTestUtils;
var canvas = document.getElementById("canvas");
var gl = wtu.create3DContext(canvas);
var ext = null;
var positionLoc = 0;
var offsetLoc = 2;
var colorLoc = 3;
var program;
if (!gl) {
testFailed("WebGL context does not exist");
finishTest();
} else {
testPassed("WebGL context exists");
runDivisorTestDisabled();
// Query the extension and store globally so shouldBe can access it
ext = wtu.getExtensionWithKnownPrefixes(gl, "ANGLE_instanced_arrays");
if (!ext) {
testPassed("No ANGLE_instanced_arrays support -- this is legal");
runSupportedTest(false);
finishTest();
} else {
testPassed("Successfully enabled ANGLE_instanced_arrays extension");
runSupportedTest(true);
runDivisorTestEnabled();
runUniqueObjectTest();
setupCanvas();
runOutputTests();
runANGLECorruptionTest();
}
}
function runSupportedTest(extensionEnabled) {
var supported = gl.getSupportedExtensions();
if (supported.indexOf("ANGLE_instanced_arrays") >= 0) {
if (extensionEnabled) {
testPassed("ANGLE_instanced_arrays listed as supported and getExtension succeeded");
} else {
testFailed("ANGLE_instanced_arrays listed as supported but getExtension failed");
}
} else {
if (extensionEnabled) {
testFailed("ANGLE_instanced_arrays not listed as supported but getExtension succeeded");
} else {
testPassed("ANGLE_instanced_arrays not listed as supported and getExtension failed -- this is legal");
}
}
}
function runDivisorTestDisabled() {
debug("Testing VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE with extension disabled");
var VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE = 0x88FE;
gl.getVertexAttrib(0, VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE);
wtu.glErrorShouldBe(gl, gl.INVALID_ENUM, "VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE should not be queryable if extension is disabled");
}
function runDivisorTestEnabled() {
debug("Testing VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE with extension enabled");
shouldBe("ext.VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE", "0x88FE");
var max_vertex_attribs = gl.getParameter(gl.MAX_VERTEX_ATTRIBS);
for (var i = 0; i < max_vertex_attribs; ++i) {
var queried_value = gl.getVertexAttrib(i, ext.VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE);
if(queried_value == 0){
testPassed("Vertex attribute " + i + " must has a default divisor of 0");
}
else{
testFailed("Default divisor of vertex attribute " + i + " should be: 0, returned value was: " + queried_value);
}
}
ext.vertexAttribDivisorANGLE(max_vertex_attribs, 2);
wtu.glErrorShouldBe(gl, gl.INVALID_VALUE, "vertexAttribDivisorANGLE index set greater than or equal to MAX_VERTEX_ATTRIBS should be an invalid value");
ext.vertexAttribDivisorANGLE(max_vertex_attribs-1, 2);
wtu.glErrorShouldBe(gl, gl.NO_ERROR, "vertexAttribDivisorANGLE index set less than MAX_VERTEX_ATTRIBS should succeed");
var queried_value = gl.getVertexAttrib(max_vertex_attribs-1, ext.VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE);
if(queried_value == 2){
testPassed("Set value of VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE matches expecation");
}
else{
testFailed("Set value of VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE should be: 2, returned value was: " + queried_value);
}
}
function setupCanvas() {
canvas.width = 50; canvas.height = 50;
gl.viewport(0, 0, canvas.width, canvas.height);
gl.clearColor(0, 0, 0, 0);
program = wtu.setupProgram(gl, ["outputVertexShader", "outputFragmentShader"], ['aPosition', 'aOffset', 'aColor'], [positionLoc, offsetLoc, colorLoc]);
}
function runOutputTests() {
var instanceCount = 4;
debug("Testing various draws for valid built-in function behavior");
var offsets = new Float32Array([
-1.0, 1.0,
1.0, 1.0,
-1.0, -1.0,
1.0, -1.0,
]);
var offsetBuffer = gl.createBuffer();
gl.bindBuffer(gl.ARRAY_BUFFER, offsetBuffer);
gl.bufferData(gl.ARRAY_BUFFER, offsets, gl.STATIC_DRAW);
gl.enableVertexAttribArray(offsetLoc);
gl.vertexAttribPointer(offsetLoc, 2, gl.FLOAT, false, 0, 0);
ext.vertexAttribDivisorANGLE(offsetLoc, 1);
var colors = new Float32Array([
1.0, 0.0, 0.0, 1.0, // Red
0.0, 1.0, 0.0, 1.0, // Green
0.0, 0.0, 1.0, 1.0, // Blue
1.0, 1.0, 0.0, 1.0, // Yellow
]);
var colorBuffer = gl.createBuffer();
gl.bindBuffer(gl.ARRAY_BUFFER, colorBuffer);
gl.bufferData(gl.ARRAY_BUFFER, colors, gl.STATIC_DRAW);
gl.enableVertexAttribArray(colorLoc);
gl.vertexAttribPointer(colorLoc, 4, gl.FLOAT, false, 0, 0);
ext.vertexAttribDivisorANGLE(colorLoc, 1);
wtu.setupUnitQuad(gl, 0);
// Draw 1: Regular drawArrays
debug("");
debug("Testing drawArrays with non-zero divisor");
gl.clear(gl.COLOR_BUFFER_BIT);
gl.drawArrays(gl.TRIANGLES, 0, 6);
wtu.glErrorShouldBe(gl, gl.NO_ERROR, "vertex attrib divisor should affect regular drawArrays when the extension is enabled");
wtu.checkCanvasRect(gl, 0, canvas.height/2, canvas.width/2, canvas.height/2, [255, 0, 0, 255]);
// Draw 2: Draw Non-indexed instances
debug("");
debug("Testing drawArraysInstancedANGLE");
gl.clear(gl.COLOR_BUFFER_BIT);
// Test drawArraysInstancedANGLE error conditions
ext.drawArraysInstancedANGLE(gl.TRIANGLES, 0, 6, instanceCount);
wtu.checkCanvasRect(gl, 0, canvas.height/2, canvas.width/2, canvas.height/2, [255, 0, 0, 255]);
wtu.checkCanvasRect(gl, canvas.width/2, canvas.height/2, canvas.width/2, canvas.height/2, [0, 255, 0, 255]);
wtu.checkCanvasRect(gl, 0, 0, canvas.width/2, canvas.height/2, [0, 0, 255, 255]);
wtu.checkCanvasRect(gl, canvas.width/2, 0, canvas.width/2, canvas.height/2, [255, 255, 0, 255]);
ext.drawArraysInstancedANGLE(gl.TRIANGLES, 0, 6, -1);
wtu.glErrorShouldBe(gl, gl.INVALID_VALUE, "drawArraysInstancedANGLE cannot have a primcount less than 0");
ext.drawArraysInstancedANGLE(gl.TRIANGLES, 0, -1, instanceCount);
wtu.glErrorShouldBe(gl, gl.INVALID_VALUE, "drawArraysInstancedANGLE cannot have a count less than 0");
ext.vertexAttribDivisorANGLE(positionLoc, 1);
ext.drawArraysInstancedANGLE(gl.TRIANGLES, 0, 6, instanceCount);
wtu.glErrorShouldBe(gl, gl.INVALID_OPERATION, "There must be at least one vertex attribute with a divisor of zero when calling drawArraysInstancedANGLE");
ext.vertexAttribDivisorANGLE(positionLoc, 0);
ext.drawArraysInstancedANGLE(gl.POINTS, 0, 6, instanceCount);
wtu.glErrorShouldBe(gl, gl.NO_ERROR, "drawArraysInstancedANGLE with POINTS should succeed");
ext.drawArraysInstancedANGLE(gl.LINES, 0, 6, instanceCount);
wtu.glErrorShouldBe(gl, gl.NO_ERROR, "drawArraysInstancedANGLE with LINES should succeed");
ext.drawArraysInstancedANGLE(gl.LINE_LIST, 0, 6, instanceCount);
wtu.glErrorShouldBe(gl, gl.NO_ERROR, "drawArraysInstancedANGLE with LINE_LIST should return succeed");
ext.drawArraysInstancedANGLE(gl.TRIANGLE_LIST, 0, 6, instanceCount);
wtu.glErrorShouldBe(gl, gl.NO_ERROR, "drawArraysInstancedANGLE with TRIANGLE_LIST should succeed");
ext.drawArraysInstancedANGLE(desktopGL['QUAD_STRIP'], 0, 6, instanceCount);
wtu.glErrorShouldBe(gl, gl.INVALID_ENUM, "drawArraysInstancedANGLE with QUAD_STRIP should return INVALID_ENUM");
ext.drawArraysInstancedANGLE(desktopGL['QUADS'], 0, 6, instanceCount);
wtu.glErrorShouldBe(gl, gl.INVALID_ENUM, "drawArraysInstancedANGLE with QUADS should return INVALID_ENUM");
ext.drawArraysInstancedANGLE(desktopGL['POLYGON'], 0, 6, instanceCount);
wtu.glErrorShouldBe(gl, gl.INVALID_ENUM, "drawArraysInstancedANGLE with POLYGON should return INVALID_ENUM");
wtu.setupIndexedQuad(gl, 1, 0);
// Draw 3: Regular drawElements
debug("");
debug("Testing drawElements with non-zero divisor");
gl.clear(gl.COLOR_BUFFER_BIT);
// Point to another location in the buffer so that the draw would overflow without the divisor
gl.bindBuffer(gl.ARRAY_BUFFER, colorBuffer);
gl.vertexAttribPointer(colorLoc, 4, gl.FLOAT, false, 0, 48);
gl.drawElements(gl.TRIANGLES, 6, gl.UNSIGNED_SHORT, 0);
wtu.glErrorShouldBe(gl, gl.NO_ERROR, "vertex attrib divisor should affect regular drawElements when the extension is enabled");
wtu.checkCanvasRect(gl, 0, canvas.height/2, canvas.width/2, canvas.height/2, [255, 255, 0, 255]);
// Restore the vertex attrib pointer
gl.vertexAttribPointer(colorLoc, 4, gl.FLOAT, false, 0, 0);
// Draw 4: Draw indexed instances
debug("");
debug("Testing drawElementsInstancedANGLE");
gl.clear(gl.COLOR_BUFFER_BIT);
ext.drawElementsInstancedANGLE(gl.TRIANGLES, 6, gl.UNSIGNED_SHORT, 0, instanceCount);
wtu.checkCanvasRect(gl, 0, canvas.height/2, canvas.width/2, canvas.height/2, [255, 0, 0, 255]);
wtu.checkCanvasRect(gl, canvas.width/2, canvas.height/2, canvas.width/2, canvas.height/2, [0, 255, 0, 255]);
wtu.checkCanvasRect(gl, 0, 0, canvas.width/2, canvas.height/2, [0, 0, 255, 255]);
wtu.checkCanvasRect(gl, canvas.width/2, 0, canvas.width/2, canvas.height/2, [255, 255, 0, 255]);
// Test drawElementsInstancedANGLE error conditions
ext.drawElementsInstancedANGLE(gl.TRIANGLES, 6, gl.UNSIGNED_SHORT, 0, -1);
wtu.glErrorShouldBe(gl, gl.INVALID_VALUE, "drawElementsInstancedANGLE cannot have a primcount less than 0");
ext.drawElementsInstancedANGLE(gl.TRIANGLES, -1, gl.UNSIGNED_SHORT, 0, instanceCount);
wtu.glErrorShouldBe(gl, gl.INVALID_VALUE, "drawElementsInstancedANGLE cannot have a count less than 0");
ext.vertexAttribDivisorANGLE(positionLoc, 1);
ext.drawElementsInstancedANGLE(gl.TRIANGLES, 6, gl.UNSIGNED_SHORT, 0, instanceCount);
wtu.glErrorShouldBe(gl, gl.INVALID_OPERATION, "There must be at least one vertex attribute with a divisor of zero when calling drawElementsInstancedANGLE");
ext.vertexAttribDivisorANGLE(positionLoc, 0);
ext.drawElementsInstancedANGLE(gl.TRIANGLES, 6, gl.UNSIGNED_BYTE, 0, instanceCount);
wtu.glErrorShouldBe(gl, gl.NO_ERROR, "drawElementsInstancedANGLE with UNSIGNED_BYTE should succeed");
ext.drawElementsInstancedANGLE(gl.POINTS, 6, gl.UNSIGNED_SHORT, 0, instanceCount);
wtu.glErrorShouldBe(gl, gl.NO_ERROR, "drawElementsInstancedANGLE with POINTS should succeed");
ext.drawElementsInstancedANGLE(gl.LINES, 6, gl.UNSIGNED_SHORT, 0, instanceCount);
wtu.glErrorShouldBe(gl, gl.NO_ERROR, "drawElementsInstancedANGLE with LINES should succeed");
ext.drawElementsInstancedANGLE(gl.LINE_LIST, 6, gl.UNSIGNED_SHORT, 0, instanceCount);
wtu.glErrorShouldBe(gl, gl.NO_ERROR, "drawElementsInstancedANGLE with LINE_LIST should return succeed");
ext.drawElementsInstancedANGLE(gl.TRIANGLE_LIST, 6, gl.UNSIGNED_SHORT, 0, instanceCount);
wtu.glErrorShouldBe(gl, gl.NO_ERROR, "drawElementsInstancedANGLE with TRIANGLE_LIST should succeed");
ext.drawElementsInstancedANGLE(desktopGL['QUAD_STRIP'], 6, gl.UNSIGNED_SHORT, 0, instanceCount);
wtu.glErrorShouldBe(gl, gl.INVALID_ENUM, "drawElementsInstancedANGLE with QUAD_STRIP should return INVALID_ENUM");
ext.drawElementsInstancedANGLE(desktopGL['QUADS'], 6, gl.UNSIGNED_SHORT, 0, instanceCount);
wtu.glErrorShouldBe(gl, gl.INVALID_ENUM, "drawElementsInstancedANGLE with QUADS should return INVALID_ENUM");
ext.drawElementsInstancedANGLE(desktopGL['POLYGON'], 6, gl.UNSIGNED_SHORT, 0, instanceCount);
wtu.glErrorShouldBe(gl, gl.INVALID_ENUM, "drawElementsInstancedANGLE with POLYGON should return INVALID_ENUM");
}
function runUniqueObjectTest()
{
debug("");
debug("Testing that getExtension() returns the same object each time");
gl.getExtension("ANGLE_instanced_arrays").myProperty = 2;
gc();
shouldBe('gl.getExtension("ANGLE_instanced_arrays").myProperty', '2');
}
function runANGLECorruptionTest()
{
debug("")
debug("Testing to ensure that rendering isn't corrupt due to an ANGLE bug");
// See: https://code.google.com/p/angleproject/issues/detail?id=467
var tolerance = 2; // Amount of variance to allow in result pixels - may need to be tweaked higher
var instanceCount = 10; // Must be higher than 6
var iteration = 0;
var totalIterations = 10;
var offsets = new Float32Array([
0.0, 0.0,
0.2, 0.0,
0.4, 0.0,
0.6, 0.0,
0.8, 0.0,
1.0, 0.0,
1.2, 0.0,
1.4, 0.0,
1.6, 0.0,
1.8, 0.0,
]);
var offsetBuffer = gl.createBuffer();
gl.bindBuffer(gl.ARRAY_BUFFER, offsetBuffer);
gl.bufferData(gl.ARRAY_BUFFER, offsets.byteLength * 2, gl.STATIC_DRAW);
gl.bufferSubData(gl.ARRAY_BUFFER, 0, offsets);
gl.enableVertexAttribArray(offsetLoc);
gl.vertexAttribPointer(offsetLoc, 2, gl.FLOAT, false, 0, 0);
ext.vertexAttribDivisorANGLE(offsetLoc, 1);
var colors = new Float32Array([
1.0, 0.0, 0.0, 1.0,
1.0, 1.0, 0.0, 1.0,
0.0, 1.0, 0.0, 1.0,
0.0, 1.0, 1.0, 1.0,
0.0, 0.0, 1.0, 1.0,
1.0, 0.0, 1.0, 1.0,
1.0, 0.0, 0.0, 1.0,
1.0, 1.0, 0.0, 1.0,
0.0, 1.0, 0.0, 1.0,
0.0, 1.0, 1.0, 1.0,
]);
var colorBuffer = gl.createBuffer();
gl.bindBuffer(gl.ARRAY_BUFFER, colorBuffer);
gl.bufferData(gl.ARRAY_BUFFER, colors.byteLength * 2, gl.STATIC_DRAW);
gl.bufferSubData(gl.ARRAY_BUFFER, 0, colors);
gl.enableVertexAttribArray(colorLoc);
gl.vertexAttribPointer(colorLoc, 4, gl.FLOAT, false, 0, 0);
ext.vertexAttribDivisorANGLE(colorLoc, 1);
gl.clear(gl.COLOR_BUFFER_BIT);
wtu.setupUnitQuad(gl, 0);
function cycleAndTest() {
// Update the instanced data buffers outside the accessed range.
// This, plus rendering more instances than vertices, triggers the bug.
var nullData = new Float32Array(offsets.length);
gl.bindBuffer(gl.ARRAY_BUFFER, offsetBuffer);
gl.bufferSubData(gl.ARRAY_BUFFER, offsets.byteLength, nullData);
nullData = new Float32Array(colors.length);
gl.bindBuffer(gl.ARRAY_BUFFER, colorBuffer);
gl.bufferSubData(gl.ARRAY_BUFFER, colors.byteLength, nullData);
ext.drawArraysInstancedANGLE(gl.TRIANGLES, 0, 6, instanceCount);
// Make sure each color was drawn correctly
var i;
var passed = true;
for (i = 0; i < instanceCount; ++i) {
var w = canvas.width / instanceCount;
var x = w * i;
var color = [colors[(i*4)] * 255, colors[(i*4)+1] * 255, colors[(i*4)+2] * 255, 255]
wtu.checkCanvasRectColor(
gl, x, 0, w, canvas.height, color, tolerance,
function() {},
function() {
passed = false;
}, debug);
}
if (passed) {
testPassed("Passed test " + iteration + " of " + totalIterations);
if (iteration < totalIterations) {
++iteration;
setTimeout(cycleAndTest, 0);
} else {
finishTest();
}
} else {
testFailed("Failed test " + iteration + " of " + totalIterations);
finishTest();
}
}
cycleAndTest();
}
</script>
</body>
</html>

Просмотреть файл

@ -0,0 +1,245 @@
<!--
/*
** Copyright (c) 2014 The Khronos Group Inc.
**
** Permission is hereby granted, free of charge, to any person obtaining a
** copy of this software and/or associated documentation files (the
** "Materials"), to deal in the Materials without restriction, including
** without limitation the rights to use, copy, modify, merge, publish,
** distribute, sublicense, and/or sell copies of the Materials, and to
** permit persons to whom the Materials are furnished to do so, subject to
** the following conditions:
**
** The above copyright notice and this permission notice shall be included
** in all copies or substantial portions of the Materials.
**
** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
*/
-->
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>WebGL EXT_blend_minmax Conformance Tests</title>
<link rel="stylesheet" href="../../resources/js-test-style.css"/>
<script src="../../resources/js-test-pre.js"></script>
<script src="../resources/webgl-test-utils.js"></script>
</head>
<body>
<div id="description"></div>
<canvas id="canvas" style="width: 50px; height: 50px;"> </canvas>
<div id="console"></div>
<!-- Shaders to test output -->
<script id="outputVertexShader" type="x-shader/x-vertex">
attribute vec4 vPosition;
void main() {
gl_Position = vPosition;
}
</script>
<script id="outputFragmentShader" type="x-shader/x-fragment">
precision mediump float;
uniform vec4 uColor;
void main() {
gl_FragColor = uColor;
}
</script>
<script>
"use strict";
description("This test verifies the functionality of the EXT_blend_minmax extension, if it is available.");
debug("");
var wtu = WebGLTestUtils;
var canvas = document.getElementById("canvas");
var gl = wtu.create3DContext(canvas);
var ext = null;
// Use the constant directly when we don't have the extension
var MIN_EXT = 0x8007;
var MAX_EXT = 0x8008;
if (!gl) {
testFailed("WebGL context does not exist");
} else {
testPassed("WebGL context exists");
runBlendTestDisabled();
// Query the extension and store globally so shouldBe can access it
ext = wtu.getExtensionWithKnownPrefixes(gl, "EXT_blend_minmax");
if (!ext) {
testPassed("No EXT_blend_minmax support -- this is legal");
runSupportedTest(false);
} else {
debug("");
testPassed("Successfully enabled EXT_blend_minmax extension");
runSupportedTest(true);
runBlendTestEnabled();
runOutputTests();
runUniqueObjectTest();
}
}
function runSupportedTest(extensionEnabled) {
var supported = gl.getSupportedExtensions();
if (supported.indexOf("EXT_blend_minmax") >= 0) {
if (extensionEnabled) {
testPassed("EXT_blend_minmax listed as supported and getExtension succeeded");
} else {
testFailed("EXT_blend_minmax listed as supported but getExtension failed");
}
} else {
if (extensionEnabled) {
testFailed("EXT_blend_minmax not listed as supported but getExtension succeeded");
} else {
testPassed("EXT_blend_minmax not listed as supported and getExtension failed -- this is legal");
}
}
}
function runBlendTestDisabled() {
debug("");
debug("Testing blending enums with extension disabled");
// Set the blend equation to a known-good enum first
gl.blendEquation(gl.FUNC_ADD);
wtu.shouldGenerateGLError(gl, gl.INVALID_ENUM, "gl.blendEquation(MIN_EXT)");
shouldBe("gl.getParameter(gl.BLEND_EQUATION)", "gl.FUNC_ADD");
wtu.shouldGenerateGLError(gl, gl.INVALID_ENUM, "gl.blendEquation(MAX_EXT)");
shouldBe("gl.getParameter(gl.BLEND_EQUATION)", "gl.FUNC_ADD");
wtu.shouldGenerateGLError(gl, gl.INVALID_ENUM, "gl.blendEquationSeparate(MIN_EXT, gl.FUNC_ADD)");
shouldBe("gl.getParameter(gl.BLEND_EQUATION_RGB)", "gl.FUNC_ADD");
wtu.shouldGenerateGLError(gl, gl.INVALID_ENUM, "gl.blendEquationSeparate(gl.FUNC_ADD, MIN_EXT)");
shouldBe("gl.getParameter(gl.BLEND_EQUATION_ALPHA)", "gl.FUNC_ADD");
wtu.shouldGenerateGLError(gl, gl.INVALID_ENUM, "gl.blendEquationSeparate(MAX_EXT, gl.FUNC_ADD)");
shouldBe("gl.getParameter(gl.BLEND_EQUATION_RGB)", "gl.FUNC_ADD");
wtu.shouldGenerateGLError(gl, gl.INVALID_ENUM, "gl.blendEquationSeparate(gl.FUNC_ADD, MAX_EXT)");
shouldBe("gl.getParameter(gl.BLEND_EQUATION_ALPHA)", "gl.FUNC_ADD");
}
function runBlendTestEnabled() {
debug("");
debug("Testing blending enums with extension enabled");
shouldBe("ext.MIN_EXT", "0x8007");
shouldBe("ext.MAX_EXT", "0x8008");
wtu.shouldGenerateGLError(gl, gl.NO_ERROR, "gl.blendEquation(ext.MIN_EXT)");
shouldBe("gl.getParameter(gl.BLEND_EQUATION)", "ext.MIN_EXT");
wtu.shouldGenerateGLError(gl, gl.NO_ERROR, "gl.blendEquation(ext.MAX_EXT)");
shouldBe("gl.getParameter(gl.BLEND_EQUATION)", "ext.MAX_EXT");
wtu.shouldGenerateGLError(gl, gl.NO_ERROR, "gl.blendEquationSeparate(ext.MIN_EXT, gl.FUNC_ADD)");
shouldBe("gl.getParameter(gl.BLEND_EQUATION_RGB)", "ext.MIN_EXT");
shouldBe("gl.getParameter(gl.BLEND_EQUATION_ALPHA)", "gl.FUNC_ADD");
wtu.shouldGenerateGLError(gl, gl.NO_ERROR, "gl.blendEquationSeparate(gl.FUNC_ADD, ext.MIN_EXT)");
shouldBe("gl.getParameter(gl.BLEND_EQUATION_RGB)", "gl.FUNC_ADD");
shouldBe("gl.getParameter(gl.BLEND_EQUATION_ALPHA)", "ext.MIN_EXT");
wtu.shouldGenerateGLError(gl, gl.NO_ERROR, "gl.blendEquationSeparate(ext.MAX_EXT, gl.FUNC_ADD)");
shouldBe("gl.getParameter(gl.BLEND_EQUATION_RGB)", "ext.MAX_EXT");
shouldBe("gl.getParameter(gl.BLEND_EQUATION_ALPHA)", "gl.FUNC_ADD");
wtu.shouldGenerateGLError(gl, gl.NO_ERROR, "gl.blendEquationSeparate(gl.FUNC_ADD, ext.MAX_EXT)");
shouldBe("gl.getParameter(gl.BLEND_EQUATION_RGB)", "gl.FUNC_ADD");
shouldBe("gl.getParameter(gl.BLEND_EQUATION_ALPHA)", "ext.MAX_EXT");
}
function runOutputTests() {
var e = 2; // Amount of variance to allow in result pixels - may need to be tweaked higher
debug("");
debug("Testing various draws for valid blending behavior");
canvas.width = 50; canvas.height = 50;
gl.viewport(0, 0, canvas.width, canvas.height);
gl.enable(gl.BLEND);
gl.blendFunc(gl.ONE, gl.ONE);
var program = wtu.setupProgram(gl, ["outputVertexShader", "outputFragmentShader"], ['vPosition'], [0]);
var quadParameters = wtu.setupUnitQuad(gl, 0, 1);
var colorUniform = gl.getUniformLocation(program, "uColor");
// Draw 1
gl.blendEquation(ext.MIN_EXT);
gl.clearColor(0.2, 0.4, 0.6, 0.8);
gl.clear(gl.COLOR_BUFFER_BIT);
gl.uniform4f(colorUniform, 0.8, 0.6, 0.4, 0.2);
wtu.drawUnitQuad(gl);
wtu.checkCanvasRect(gl, 0, 0, canvas.width, canvas.height, [51, 102, 102, 51]);
// Draw 2:
gl.blendEquation(ext.MAX_EXT);
gl.clearColor(0.2, 0.4, 0.6, 0.8);
gl.clear(gl.COLOR_BUFFER_BIT);
gl.uniform4f(colorUniform, 0.8, 0.6, 0.4, 0.2);
wtu.drawUnitQuad(gl);
wtu.checkCanvasRect(gl, 0, 0, canvas.width, canvas.height, [204, 153, 153, 204]);
// Draw 3
gl.blendEquationSeparate(ext.MIN_EXT, ext.MAX_EXT);
gl.clearColor(0.2, 0.4, 0.6, 0.8);
gl.clear(gl.COLOR_BUFFER_BIT);
gl.uniform4f(colorUniform, 0.8, 0.6, 0.4, 0.2);
wtu.drawUnitQuad(gl);
wtu.checkCanvasRect(gl, 0, 0, canvas.width, canvas.height, [51, 102, 102, 204]);
// Draw 4
gl.blendEquationSeparate(ext.MAX_EXT, ext.MIN_EXT);
gl.clearColor(0.2, 0.4, 0.6, 0.8);
gl.clear(gl.COLOR_BUFFER_BIT);
gl.uniform4f(colorUniform, 0.8, 0.6, 0.4, 0.2);
wtu.drawUnitQuad(gl);
wtu.checkCanvasRect(gl, 0, 0, canvas.width, canvas.height, [204, 153, 153, 51]);
}
function runUniqueObjectTest()
{
debug("");
debug("Testing that getExtension() returns the same object each time");
gl.getExtension("EXT_blend_minmax").myProperty = 2;
gc();
shouldBe('gl.getExtension("EXT_blend_minmax").myProperty', '2');
}
debug("");
var successfullyParsed = true;
</script>
<script src="../../resources/js-test-post.js"></script>
</body>
</html>

Просмотреть файл

@ -0,0 +1,241 @@
<!--
/*
** Copyright (c) 2013 The Khronos Group Inc.
**
** Permission is hereby granted, free of charge, to any person obtaining a
** copy of this software and/or associated documentation files (the
** "Materials"), to deal in the Materials without restriction, including
** without limitation the rights to use, copy, modify, merge, publish,
** distribute, sublicense, and/or sell copies of the Materials, and to
** permit persons to whom the Materials are furnished to do so, subject to
** the following conditions:
**
** The above copyright notice and this permission notice shall be included
** in all copies or substantial portions of the Materials.
**
** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
*/
-->
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>WebGL EXT_frag_depth Conformance Tests</title>
<link rel="stylesheet" href="../../resources/js-test-style.css"/>
<script src="../../resources/js-test-pre.js"></script>
<script src="../resources/webgl-test-utils.js"></script>
</head>
<body>
<div id="description"></div>
<canvas id="canvas" style="width: 50px; height: 50px;"> </canvas>
<div id="console"></div>
<!-- Shaders for testing fragment depth writing -->
<!-- Shader omitting the required #extension pragma -->
<script id="missingPragmaFragmentShader" type="x-shader/x-fragment">
precision mediump float;
void main() {
gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);
gl_FragDepthEXT = 1.0;
}
</script>
<!-- Shader to test macro definition -->
<script id="macroFragmentShader" type="x-shader/x-fragment">
precision mediump float;
void main() {
#ifdef GL_EXT_frag_depth
gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);
#else
// Error expected
#error no GL_EXT_frag_depth;
#endif
}
</script>
<!-- Shader with required #extension pragma -->
<script id="testFragmentShader" type="x-shader/x-fragment">
#extension GL_EXT_frag_depth : enable
precision mediump float;
void main() {
gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);
gl_FragDepthEXT = 1.0;
}
</script>
<!-- Shaders to link with test fragment shaders -->
<script id="goodVertexShader" type="x-shader/x-vertex">
attribute vec4 vPosition;
void main() {
gl_Position = vPosition;
}
</script>
<!-- Shaders to test output -->
<script id="outputVertexShader" type="x-shader/x-vertex">
attribute vec4 vPosition;
void main() {
gl_Position = vPosition;
}
</script>
<script id="outputFragmentShader" type="x-shader/x-fragment">
#extension GL_EXT_frag_depth : enable
precision mediump float;
uniform float uDepth;
void main() {
gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);
gl_FragDepthEXT = uDepth;
}
</script>
<script>
"use strict";
description("This test verifies the functionality of the EXT_frag_depth extension, if it is available.");
debug("");
var wtu = WebGLTestUtils;
var canvas = document.getElementById("canvas");
var gl = wtu.create3DContext(canvas);
var ext = null;
if (!gl) {
testFailed("WebGL context does not exist");
} else {
testPassed("WebGL context exists");
runShaderTests(false);
// Query the extension and store globally so shouldBe can access it
ext = wtu.getExtensionWithKnownPrefixes(gl, "EXT_frag_depth");
if (!ext) {
testPassed("No EXT_frag_depth support -- this is legal");
runSupportedTest(false);
} else {
testPassed("Successfully enabled EXT_frag_depth extension");
runSupportedTest(true);
runShaderTests(true);
runOutputTests();
runUniqueObjectTest();
}
}
function runSupportedTest(extensionEnabled) {
var supported = gl.getSupportedExtensions();
if (supported.indexOf("EXT_frag_depth") >= 0) {
if (extensionEnabled) {
testPassed("EXT_frag_depth listed as supported and getExtension succeeded");
} else {
testFailed("EXT_frag_depth listed as supported but getExtension failed");
}
} else {
if (extensionEnabled) {
testFailed("EXT_frag_depth not listed as supported but getExtension succeeded");
} else {
testPassed("EXT_frag_depth not listed as supported and getExtension failed -- this is legal");
}
}
}
function runShaderTests(extensionEnabled) {
debug("");
debug("Testing various shader compiles with extension " + (extensionEnabled ? "enabled" : "disabled"));
// Expect the macro shader to succeed ONLY if enabled
var macroFragmentProgram = wtu.loadProgramFromScriptExpectError(gl, "goodVertexShader", "macroFragmentShader");
if (extensionEnabled) {
if (macroFragmentProgram) {
// Expected result
testPassed("GL_EXT_frag_depth defined in shaders when extension is enabled");
} else {
testFailed("GL_EXT_frag_depth not defined in shaders when extension is enabled");
}
} else {
if (macroFragmentProgram) {
testFailed("GL_EXT_frag_depth defined in shaders when extension is disabled");
} else {
testPassed("GL_EXT_frag_depth not defined in shaders when extension disabled");
}
}
// Always expect the shader missing the #pragma to fail (whether enabled or not)
var missingPragmaFragmentProgram = wtu.loadProgramFromScriptExpectError(gl, "goodVertexShader", "missingPragmaFragmentShader");
if (missingPragmaFragmentProgram) {
testFailed("Shader built-ins allowed without #extension pragma");
} else {
testPassed("Shader built-ins disallowed without #extension pragma");
}
// Try to compile a shader using the built-ins that should only succeed if enabled
var testFragmentProgram = wtu.loadProgramFromScriptExpectError(gl, "goodVertexShader", "testFragmentShader");
if (extensionEnabled) {
if (testFragmentProgram) {
testPassed("Shader built-ins compiled successfully when extension enabled");
} else {
testFailed("Shader built-ins failed to compile when extension enabled");
}
} else {
if (testFragmentProgram) {
testFailed("Shader built-ins compiled successfully when extension disabled");
} else {
testPassed("Shader built-ins failed to compile when extension disabled");
}
}
}
function runOutputTests() {
var e = 2; // Amount of variance to allow in result pixels - may need to be tweaked higher
debug("Testing various draws for valid built-in function behavior");
canvas.width = 50; canvas.height = 50;
gl.viewport(0, 0, canvas.width, canvas.height);
// Enable depth testing with a clearDepth of 0.5
// This makes it so that fragments are only rendered when
// gl_fragDepthEXT is < 0.5
gl.clearDepth(0.5);
gl.enable(gl.DEPTH_TEST);
var positionLoc = 0;
var texcoordLoc = 1;
var program = wtu.setupProgram(gl, ["outputVertexShader", "outputFragmentShader"], ['vPosition'], [0]);
var quadParameters = wtu.setupUnitQuad(gl, 0, 1);
var depthUniform = gl.getUniformLocation(program, "uDepth");
// Draw 1: Greater than clear depth
gl.uniform1f(depthUniform, 1.0);
wtu.clearAndDrawUnitQuad(gl);
wtu.checkCanvasRect(gl, 0, 0, canvas.width, canvas.height, [255, 255, 255, 255]);
// Draw 2: Less than clear depth
gl.uniform1f(depthUniform, 0.0);
wtu.clearAndDrawUnitQuad(gl);
wtu.checkCanvasRect(gl, 0, 0, canvas.width, canvas.height, [255, 0, 0, 255]);
}
function runUniqueObjectTest()
{
debug("Testing that getExtension() returns the same object each time");
gl.getExtension("EXT_frag_depth").myProperty = 2;
gc();
shouldBe('gl.getExtension("EXT_frag_depth").myProperty', '2');
}
debug("");
var successfullyParsed = true;
</script>
<script src="../../resources/js-test-post.js"></script>
</body>
</html>

Просмотреть файл

@ -0,0 +1,411 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<link rel="stylesheet" href="../../resources/js-test-style.css"/>
<script src="../../resources/js-test-pre.js"></script>
<script src="../resources/webgl-test.js"></script>
<script src="../resources/webgl-test-utils.js"></script>
</head>
<body>
<div id="description"></div>
<div id="console"></div>
<canvas id="canvas" width="16" height="16" style="width: 50px; height: 50px; border: 1px solid black;"></canvas>
<!-- Shaders to test output -->
<script id="vertexShader" type="x-shader/x-vertex">
attribute vec4 aPosition;
void main() {
gl_Position = aPosition;
}
</script>
<script id="fragmentShader" type="x-shader/x-fragment">
precision mediump float;
uniform float uColor;
void main() {
gl_FragColor = vec4(uColor, uColor, uColor, 1);
}
</script>
<script>
"use strict";
var wtu = WebGLTestUtils;
var canvas;
var gl;
var ext = null;
var extConstants = {
"SRGB_EXT": 0x8C40,
"SRGB_ALPHA_EXT": 0x8C42,
"SRGB8_ALPHA8_EXT": 0x8C43,
"FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING_EXT": 0x8210
};
function getExtension() {
ext = gl.getExtension("EXT_sRGB");
}
function listsExtension() {
var supported = gl.getSupportedExtensions();
return (supported.indexOf("EXT_sRGB") >= 0);
}
function toVec3String(val) {
if (typeof(val) == 'number') {
return toVec3String([val, val, val]);
}
return '[' + val[0] + ', ' + val[1] + ', ' + val[2] + ']';
}
var e = 2; // Amount of variance to allow in result pixels - may need to be tweaked higher
function expectResult(target) {
wtu.checkCanvasRect(gl,
Math.floor(gl.drawingBufferWidth / 2),
Math.floor(gl.drawingBufferHeight / 2),
1,
1,
target,
undefined,
e);
}
function createGreysRGBTexture(gl, color, format) {
var numPixels = gl.drawingBufferWidth * gl.drawingBufferHeight;
var elements;
switch (format) {
case ext.SRGB_EXT: elements = 3; break;
case ext.SRGB_ALPHA_EXT: elements = 4; break;
default: return null;
}
var size = numPixels * elements;
var buf = new Uint8Array(size);
for (var ii = 0; ii < numPixels; ++ii) {
var off = ii * elements;
buf[off + 0] = color;
buf[off + 1] = color;
buf[off + 2] = color;
if (format == ext.SRGB_ALPHA_EXT) {
buf[off + 3] = 255;
}
}
var tex = gl.createTexture();
gl.bindTexture(gl.TEXTURE_2D, tex);
gl.texImage2D(gl.TEXTURE_2D,
0,
format,
gl.drawingBufferWidth,
gl.drawingBufferHeight,
0,
format,
gl.UNSIGNED_BYTE,
buf);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
return tex;
}
function testValidFormat(fn, internalFormat, formatName, enabled) {
if (enabled) {
fn(internalFormat);
wtu.glErrorShouldBe(gl, gl.NO_ERROR, "was able to create type " + formatName);
} else {
testInvalidFormat(fn, internalFormat, formatName, enabled);
}
}
function testInvalidFormat(fn, internalFormat, formatName, enabled) {
fn(internalFormat);
var err = gl.getError();
if (err == gl.NO_ERROR) {
testFailed("should NOT be able to create type " + formatName);
} else if (err == gl.INVALID_OPERATION) {
testFailed("should return gl.INVALID_ENUM for type " + formatName);
} else if (err == gl.INVALID_ENUM) {
testPassed("not able to create invalid format: " + formatName);
}
}
var textureFormatFixture = {
desc: "Checking texture formats",
create: function(format) {
var tex = gl.createTexture();
gl.bindTexture(gl.TEXTURE_2D, tex);
gl.texImage2D(gl.TEXTURE_2D,
0, // level
format, // internalFormat
gl.drawingBufferWidth, // width
gl.drawingBufferHeight, // height
0, // border
format, // format
gl.UNSIGNED_BYTE, // type
null); // data
},
tests: [
{
desc: "Checking valid formats",
fn: testValidFormat,
formats: [ 'SRGB_EXT', 'SRGB_ALPHA_EXT' ]
},
{
desc: "Checking invalid formats",
fn: testInvalidFormat,
formats: [ 'SRGB8_ALPHA8_EXT' ]
}
]
};
var renderbufferFormatFixture = {
desc: "Checking renderbuffer formats",
create: function(format) {
var rbo = gl.createRenderbuffer();
gl.bindRenderbuffer(gl.RENDERBUFFER, rbo);
gl.renderbufferStorage(gl.RENDERBUFFER,
format,
gl.drawingBufferWidth,
gl.drawingBufferHeight);
},
tests: [
{
desc: "Checking valid formats",
fn: testValidFormat,
formats: [ 'SRGB8_ALPHA8_EXT' ]
},
{
desc: "Checking invalid formats",
fn: testInvalidFormat,
formats: [ 'SRGB_EXT', 'SRGB_ALPHA_EXT' ]
}
]
};
description("Test sRGB texture support");
debug("");
debug("Canvas.getContext");
canvas = document.getElementById("canvas");
gl = wtu.create3DContext(canvas);
if (!gl) {
testFailed("context does not exist");
} else {
testPassed("context exists");
debug("");
debug("Checking sRGB texture support with extension disabled");
runFormatTest(textureFormatFixture, false);
runFormatTest(renderbufferFormatFixture, false);
debug("");
debug("Checking sRGB texture support");
// Query the extension and store globally so shouldBe can access it
ext = gl.getExtension("EXT_sRGB");
if (!ext) {
testPassed("No EXT_sRGB support -- this is legal");
runSupportedTest(false);
} else {
testPassed("Successfully enabled EXT_sRGB extension");
runSupportedTest(true);
gl.viewport(0, 0, gl.drawingBufferWidth, gl.drawingBufferHeight);
runConstantsTest();
runFormatTest(textureFormatFixture, true);
runFormatTest(renderbufferFormatFixture, true);
runTextureReadConversionTest();
runFramebufferTextureConversionTest(ext.SRGB_EXT);
runFramebufferTextureConversionTest(ext.SRGB_ALPHA_EXT);
runFramebufferRenderbufferConversionTest();
}
}
function runConstantsTest() {
debug("");
debug("Checking extension constants values");
for (var constant in extConstants) {
if (constant in ext) {
if (extConstants[constant] != ext[constant]) {
testFailed("Value of " + constant + " should be: " + extConstants[constant] + ", was: " + ext[constant]);
} else {
testPassed("Value of " + constant + " was expected value: " + extConstants[constant]);
}
} else {
testFailed(constant + " not found in extension object");
}
}
}
function runSupportedTest(extensionEnabled) {
if (listsExtension()) {
if (extensionEnabled) {
testPassed("EXT_sRGB listed as supported and getExtension succeeded");
} else {
testFailed("EXT_sRGB listed as supported but getExtension failed");
}
} else {
if (extensionEnabled) {
testFailed("EXT_sRGB not listed as supported but getExtension succeeded");
} else {
testPassed("EXT_sRGB not listed as supported and getExtension failed -- this is legal");
}
}
}
function runFormatTest(fixture, enabled) {
debug("");
debug(fixture.desc);
for (var tt = 0; tt < fixture.tests.length; ++tt) {
var test = fixture.tests[tt];
debug(test.desc);
for (var ii = 0; ii < test.formats.length; ++ii) {
var formatName = test.formats[ii];
test.fn(fixture.create, extConstants[formatName], "ext." + formatName, enabled);
}
if (tt != fixture.tests.length - 1)
debug("");
}
}
function runTextureReadConversionTest() {
debug("");
debug("Test the conversion of colors from sRGB to linear on texture read");
// Draw
var conversions = [
[ 0, 0 ],
[ 63, 13 ],
[ 127, 54 ],
[ 191, 133 ],
[ 255, 255 ]
];
var program = wtu.setupTexturedQuad(gl);
gl.uniform1i(gl.getUniformLocation(program, "tex2d"), 0);
for (var ii = 0; ii < conversions.length; ii++) {
var tex = createGreysRGBTexture(gl, conversions[ii][0], ext.SRGB_EXT);
wtu.drawUnitQuad(gl);
expectResult(conversions[ii][1]);
}
}
function runFramebufferTextureConversionTest(format) {
var formatString;
var validFormat;
switch (format) {
case ext.SRGB_EXT: formatString = "sRGB"; validFormat = false; break;
case ext.SRGB_ALPHA_EXT: formatString = "sRGB_ALPHA"; validFormat = true; break;
default: return null;
}
debug("");
debug("Test " + formatString + " framebuffer attachments." + (validFormat ? "" : " (Invalid)"));
var program = wtu.setupProgram(gl, ['vertexShader', 'fragmentShader'], ['aPosition'], [0]);
var tex = createGreysRGBTexture(gl, 0, format);
var fbo = gl.createFramebuffer();
gl.bindFramebuffer(gl.FRAMEBUFFER, fbo);
gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, tex, 0);
wtu.glErrorShouldBe(gl, gl.NO_ERROR);
shouldBe('gl.getFramebufferAttachmentParameter(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, ext.FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING_EXT)', 'ext.SRGB_EXT');
if (validFormat) {
shouldBe("gl.checkFramebufferStatus(gl.FRAMEBUFFER)", "gl.FRAMEBUFFER_COMPLETE");
debug("");
debug("Test the conversion of colors from linear to " + formatString + " on framebuffer (texture) write");
// Draw
var conversions = [
[ 0, 0 ],
[ 13, 63 ],
[ 54, 127 ],
[ 133, 191 ],
[ 255, 255 ]
];
wtu.setupUnitQuad(gl, 0);
for (var ii = 0; ii < conversions.length; ii++) {
gl.uniform1f(gl.getUniformLocation(program, "uColor"), conversions[ii][0]/255.0);
wtu.drawUnitQuad(gl, [0, 0, 0, 0]);
wtu.glErrorShouldBe(gl, gl.NO_ERROR);
expectResult(conversions[ii][1]);
}
} else {
shouldBe("gl.checkFramebufferStatus(gl.FRAMEBUFFER)", "gl.FRAMEBUFFER_INCOMPLETE_ATTACHMENT");
wtu.setupUnitQuad(gl, 0);
gl.uniform1f(gl.getUniformLocation(program, "uColor"), 0.5);
wtu.drawUnitQuad(gl, [0, 0, 0, 0]);
wtu.glErrorShouldBe(gl, gl.INVALID_FRAMEBUFFER_OPERATION);
}
gl.bindFramebuffer(gl.FRAMEBUFFER, null);
}
function runFramebufferRenderbufferConversionTest() {
debug("");
debug("Test the conversion of colors from linear to sRGB on framebuffer (renderbuffer) write");
function createsRGBFramebuffer(gl, width, height) {
var rbo = gl.createRenderbuffer();
gl.bindRenderbuffer(gl.RENDERBUFFER, rbo);
gl.renderbufferStorage(gl.RENDERBUFFER, ext.SRGB8_ALPHA8_EXT, width, height);
wtu.glErrorShouldBe(gl, gl.NO_ERROR);
var fbo = gl.createFramebuffer();
gl.bindFramebuffer(gl.FRAMEBUFFER, fbo);
gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0,
gl.RENDERBUFFER, rbo);
wtu.glErrorShouldBe(gl, gl.NO_ERROR);
shouldBe('gl.getFramebufferAttachmentParameter(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, ext.FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING_EXT)', 'ext.SRGB_EXT');
shouldBe("gl.checkFramebufferStatus(gl.FRAMEBUFFER)", "gl.FRAMEBUFFER_COMPLETE");
return fbo;
}
// Draw
var conversions = [
[ 0, 0 ],
[ 13, 63 ],
[ 54, 127 ],
[ 133, 191 ],
[ 255, 255 ]
];
var program = wtu.setupProgram(gl, ['vertexShader', 'fragmentShader'], ['aPosition'], [0]);
wtu.setupUnitQuad(gl, 0);
var fbo = createsRGBFramebuffer(gl, 4, 4);
for (var ii = 0; ii < conversions.length; ii++) {
gl.uniform1f(gl.getUniformLocation(program, "uColor"), conversions[ii][0]/255.0);
wtu.drawUnitQuad(gl, [0, 0, 0, 0]);
expectResult(conversions[ii][1]);
}
}
debug("");
var successfullyParsed = true;
</script>
<script>finishTest();</script>
</body>
</html>

Просмотреть файл

@ -1,8 +1,29 @@
<!--
Copyright (c) 2011 The Chromium Authors. All rights reserved.
Use of this source code is governed by a BSD-style license that can be
found in the LICENSE file.
-->
/*
** Copyright (c) 2014 The Khronos Group Inc.
**
** Permission is hereby granted, free of charge, to any person obtaining a
** copy of this software and/or associated documentation files (the
** "Materials"), to deal in the Materials without restriction, including
** without limitation the rights to use, copy, modify, merge, publish,
** distribute, sublicense, and/or sell copies of the Materials, and to
** permit persons to whom the Materials are furnished to do so, subject to
** the following conditions:
**
** The above copyright notice and this permission notice shall be included
** in all copies or substantial portions of the Materials.
**
** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
*/
-->
<!DOCTYPE html>
<html>
<head>
@ -11,14 +32,13 @@ found in the LICENSE file.
<link rel="stylesheet" href="../../resources/js-test-style.css"/>
<script src="../../resources/desktop-gl-constants.js" type="text/javascript"></script>
<script src="../../resources/js-test-pre.js"></script>
<script src="../resources/webgl-test.js"></script>
<script src="../resources/webgl-test-utils.js"></script>
</head>
<body>
<div id="description"></div>
<canvas id="canvas" width="256" height="256" style="width: 50px; height: 50px;"> </canvas>
<canvas id="canvas" style="width: 50px; height: 50px;"> </canvas>
<div id="console"></div>
<!-- Shaders for testing standard derivatives -->
<!-- Shaders for testing texture LOD functions -->
<!-- Shader omitting the required #extension pragma -->
<script id="missingPragmaFragmentShader" type="x-shader/x-fragment">
@ -96,9 +116,7 @@ debug("");
var wtu = WebGLTestUtils;
var canvas = document.getElementById("canvas");
shouldBe("canvas.width", "256");
shouldBe("canvas.height", "256");
canvas.width = 256; canvas.height = 256;
var gl = wtu.create3DContext(canvas);
var ext = null;
@ -193,63 +211,56 @@ function runShaderTests(extensionEnabled) {
}
function runOutputTests() {
debug("");
debug("Testing various draws for valid built-in function behavior");
canvas.width = 256; canvas.height = 256;
gl.viewport(0, 0, canvas.width, canvas.height);
var program = wtu.setupProgram(gl, ["outputVertexShader", "outputFragmentShader"], ['vPosition', 'texCoord0'], [0, 1]);
var quadParameters = wtu.setupUnitQuad(gl, 0, 1);
var colors = [
{name: 'red', color:[255, 0, 0, 255]},
{name: 'green', color:[0, 255, 0, 255]},
{name: 'blue', color:[0, 0, 255, 255]},
{name: 'yellow', color:[255, 255, 0, 255]},
{name: 'magenta', color:[255, 0, 255, 255]},
{name: 'cyan', color:[0, 255, 255, 255]},
{name: 'pink', color:[255, 128, 128, 255]},
{name: 'gray', color:[128, 128, 128, 255]},
{name: 'light green', color:[128, 255, 128, 255]},
{name: 'red', color:[255, 0, 0, 255]},
{name: 'green', color:[0, 255, 0, 255]},
{name: 'blue', color:[0, 0, 255, 255]},
{name: 'yellow', color:[255, 255, 0, 255]},
{name: 'magenta', color:[255, 0, 255, 255]},
{name: 'cyan', color:[0, 255, 255, 255]},
{name: 'pink', color:[255, 128, 128, 255]},
{name: 'gray', color:[128, 128, 128, 255]},
{name: 'light green', color:[128, 255, 128, 255]},
];
if (colors.length != 9) {
testFailed("9 colors are needed (9 mips for 256x256 texture), only have " + colors.length);
} else {
testPassed("9 colors found (9 mips for 256x256 texture)");
}
var tex = gl.createTexture();
gl.bindTexture(gl.TEXTURE_2D, tex);
gl.texParameteri(
gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST_MIPMAP_LINEAR);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST_MIPMAP_LINEAR);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.REPEAT);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.REPEAT);
for (var ii = 0; ii < colors.length; ++ii) {
var color = colors[ii];
var size = Math.pow(2, colors.length - ii - 1);
wtu.fillTexture(gl, tex, size, size, color.color, ii);
var color = colors[ii];
var size = Math.pow(2, colors.length - ii - 1);
wtu.fillTexture(gl, tex, size, size, color.color, ii);
}
var loc = gl.getUniformLocation(program, "lod");
for (var ii = 0; ii < colors.length; ++ii) {
gl.uniform1f(loc, ii);
var color = colors[ii];
wtu.drawQuad(gl);
wtu.checkCanvas(
gl, color.color,
"256x256 texture drawn to 256x256 dest with lod = " + ii +
" should be " + color.name);
gl.uniform1f(loc, ii);
var color = colors[ii];
wtu.drawUnitQuad(gl);
wtu.checkCanvas(
gl, color.color,
"256x256 texture drawn to 256x256 dest with lod = " + ii +
" should be " + color.name);
}
glErrorShouldBe(gl, gl.NO_ERROR, "Should be no errors.");
wtu.glErrorShouldBe(gl, gl.NO_ERROR);
}
function runUniqueObjectTest()
{
debug("");
debug("Testing that getExtension() returns the same object each time");
gl.getExtension("EXT_shader_texture_lod").myProperty = 2;
gc();
@ -260,7 +271,7 @@ function runReferenceCycleTest()
{
// create some reference cycles. The goal is to see if they cause leaks. The point is that
// some browser test runners have instrumentation to detect leaked refcounted objects.
debug("");
debug("Testing reference cycles between context and extension objects");
var ext = gl.getExtension("EXT_shader_texture_lod");

Просмотреть файл

@ -0,0 +1,190 @@
<!--
/*
** Copyright (c) 2012 Florian Boesch <pyalot@gmail.com>.
**
** Permission is hereby granted, free of charge, to any person obtaining a
** copy of this software and/or associated documentation files (the
** "Materials"), to deal in the Materials without restriction, including
** without limitation the rights to use, copy, modify, merge, publish,
** distribute, sublicense, and/or sell copies of the Materials, and to
** permit persons to whom the Materials are furnished to do so, subject to
** the following conditions:
**
** The above copyright notice and this permission notice shall be included
** in all copies or substantial portions of the Materials.
**
** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
*/
-->
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>WebGL EXT_texture_filter_anisotropic Conformance Tests</title>
<link rel="stylesheet" href="../../resources/js-test-style.css"/>
<script src="../../resources/js-test-pre.js"></script>
<script src="../resources/webgl-test-utils.js"></script>
</head>
<body>
<div id="description"></div>
<canvas id="canvas" style="width: 50px; height: 50px;"> </canvas>
<div id="console"></div>
<script>
"use strict";
description("This test verifies the functionality of the EXT_texture_filter_anisotropic extension, if it is available.");
debug("");
var wtu = WebGLTestUtils;
var canvas = document.getElementById("canvas");
var gl = wtu.create3DContext(canvas);
var ext = null;
if (!gl) {
testFailed("WebGL context does not exist");
} else {
testPassed("WebGL context exists");
// Run tests with extension disabled
runHintTestDisabled();
// Query the extension and store globally so shouldBe can access it
ext = wtu.getExtensionWithKnownPrefixes(gl, "EXT_texture_filter_anisotropic");
if (!ext) {
testPassed("No EXT_texture_filter_anisotropic support -- this is legal");
runSupportedTest(false);
} else {
testPassed("Successfully enabled EXT_texture_filter_anisotropic extension");
runSupportedTest(true);
runHintTestEnabled();
}
}
function runSupportedTest(extensionEnabled) {
if (wtu.getSupportedExtensionWithKnownPrefixes(gl, "EXT_texture_filter_anisotropic") !== undefined) {
if (extensionEnabled) {
testPassed("EXT_texture_filter_anisotropic listed as supported and getExtension succeeded");
} else {
testFailed("EXT_texture_filter_anisotropic listed as supported but getExtension failed");
}
} else {
if (extensionEnabled) {
testFailed("EXT_texture_filter_anisotropic not listed as supported but getExtension succeeded");
} else {
testPassed("EXT_texture_filter_anisotropic not listed as supported and getExtension failed -- this is legal");
}
}
}
function runHintTestDisabled() {
debug("Testing MAX_TEXTURE_MAX_ANISOTROPY_EXT with extension disabled");
var MAX_TEXTURE_MAX_ANISOTROPY_EXT = 0x84FF;
gl.getParameter(MAX_TEXTURE_MAX_ANISOTROPY_EXT);
wtu.glErrorShouldBe(gl, gl.INVALID_ENUM, "MAX_TEXTURE_MAX_ANISOTROPY_EXT should not be queryable if extension is disabled");
debug("Testing TEXTURE_MAX_ANISOTROPY_EXT with extension disabled");
var TEXTURE_MAX_ANISOTROPY_EXT = 0x84FE;
var texture = gl.createTexture();
gl.bindTexture(gl.TEXTURE_2D, texture);
gl.getTexParameter(gl.TEXTURE_2D, TEXTURE_MAX_ANISOTROPY_EXT);
wtu.glErrorShouldBe(gl, gl.INVALID_ENUM, "TEXTURE_MAX_ANISOTROPY_EXT should not be queryable if extension is disabled");
gl.texParameterf(gl.TEXTURE_2D, TEXTURE_MAX_ANISOTROPY_EXT, 1);
wtu.glErrorShouldBe(gl, gl.INVALID_ENUM, "TEXTURE_MAX_ANISOTROPY_EXT should not be settable if extension is disabled");
gl.texParameteri(gl.TEXTURE_2D, TEXTURE_MAX_ANISOTROPY_EXT, 1);
wtu.glErrorShouldBe(gl, gl.INVALID_ENUM, "TEXTURE_MAX_ANISOTROPY_EXT should not be settable if extension is disabled");
gl.deleteTexture(texture);
}
function runHintTestEnabled() {
debug("Testing MAX_TEXTURE_MAX_ANISOTROPY_EXT with extension enabled");
shouldBe("ext.MAX_TEXTURE_MAX_ANISOTROPY_EXT", "0x84FF");
var max_anisotropy = gl.getParameter(ext.MAX_TEXTURE_MAX_ANISOTROPY_EXT);
wtu.glErrorShouldBe(gl, gl.NO_ERROR, "MAX_TEXTURE_MAX_ANISOTROPY_EXT query should succeed if extension is enabled");
if(max_anisotropy >= 2){
testPassed("Minimum value of MAX_TEXTURE_MAX_ANISOTROPY_EXT is 2.0");
}
else{
testFailed("Minimum value of MAX_TEXTURE_MAX_ANISOTROPY_EXT is 2.0, returned values was: " + max_anisotropy);
}
// TODO make a texture and verify initial value == 1 and setting to less than 1 is invalid value
debug("Testing TEXTURE_MAX_ANISOTROPY_EXT with extension disabled");
shouldBe("ext.TEXTURE_MAX_ANISOTROPY_EXT", "0x84FE");
var texture = gl.createTexture();
gl.bindTexture(gl.TEXTURE_2D, texture);
var queried_value = gl.getTexParameter(gl.TEXTURE_2D, ext.TEXTURE_MAX_ANISOTROPY_EXT);
wtu.glErrorShouldBe(gl, gl.NO_ERROR, "TEXTURE_MAX_ANISOTROPY_EXT query should succeed if extension is enabled");
if(queried_value == 1){
testPassed("Initial value of TEXTURE_MAX_ANISOTROPY_EXT is 1.0");
}
else{
testFailed("Initial value of TEXTURE_MAX_ANISOTROPY_EXT should be 1.0, returned value was: " + queried_value);
}
gl.texParameterf(gl.TEXTURE_2D, ext.TEXTURE_MAX_ANISOTROPY_EXT, 0);
wtu.glErrorShouldBe(gl, gl.INVALID_VALUE, "texParameterf TEXTURE_MAX_ANISOTROPY_EXT set to < 1 should be an invalid value");
gl.texParameteri(gl.TEXTURE_2D, ext.TEXTURE_MAX_ANISOTROPY_EXT, 0);
wtu.glErrorShouldBe(gl, gl.INVALID_VALUE, "texParameteri TEXTURE_MAX_ANISOTROPY_EXT set to < 1 should be an invalid value");
gl.texParameterf(gl.TEXTURE_2D, ext.TEXTURE_MAX_ANISOTROPY_EXT, max_anisotropy);
wtu.glErrorShouldBe(gl, gl.NO_ERROR, "texParameterf TEXTURE_MAX_ANISOTROPY_EXT set to >= 2 should succeed");
gl.texParameteri(gl.TEXTURE_2D, ext.TEXTURE_MAX_ANISOTROPY_EXT, max_anisotropy);
wtu.glErrorShouldBe(gl, gl.NO_ERROR, "texParameteri TEXTURE_MAX_ANISOTROPY_EXT set to >= 2 should succeed");
var queried_value = gl.getTexParameter(gl.TEXTURE_2D, ext.TEXTURE_MAX_ANISOTROPY_EXT);
if(queried_value == max_anisotropy){
testPassed("Set value of TEXTURE_MAX_ANISOTROPY_EXT matches expecation");
}
else{
testFailed("Set value of TEXTURE_MAX_ANISOTROPY_EXT should be: " + max_anisotropy + " , returned value was: " + queried_value);
}
gl.texParameterf(gl.TEXTURE_2D, ext.TEXTURE_MAX_ANISOTROPY_EXT, 1.5);
wtu.glErrorShouldBe(gl, gl.NO_ERROR, "texParameterf TEXTURE_MAX_ANISOTROPY_EXT set to 1.5 should succeed");
queried_value = gl.getTexParameter(gl.TEXTURE_2D, ext.TEXTURE_MAX_ANISOTROPY_EXT);
if(queried_value == 1.5){
testPassed("Set value of TEXTURE_MAX_ANISOTROPY_EXT matches expecation");
}
else{
testFailed("Set value of TEXTURE_MAX_ANISOTROPY_EXT should be: " + 1.5 + " , returned value was: " + queried_value);
}
gl.deleteTexture(texture);
}
debug("");
var successfullyParsed = true;
</script>
<script src="../../resources/js-test-post.js"></script>
</body>
</html>

Просмотреть файл

@ -0,0 +1,120 @@
<!--
/*
** Copyright (c) 2012 The Khronos Group Inc.
**
** Permission is hereby granted, free of charge, to any person obtaining a
** copy of this software and/or associated documentation files (the
** "Materials"), to deal in the Materials without restriction, including
** without limitation the rights to use, copy, modify, merge, publish,
** distribute, sublicense, and/or sell copies of the Materials, and to
** permit persons to whom the Materials are furnished to do so, subject to
** the following conditions:
**
** The above copyright notice and this permission notice shall be included
** in all copies or substantial portions of the Materials.
**
** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
*/
-->
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>WebGL Extension Conformance Tests</title>
<link rel="stylesheet" href="../../resources/js-test-style.css"/>
<script src="../../resources/js-test-pre.js"></script>
<script src="../resources/webgl-test-utils.js"></script>
</head>
<body>
<div id="description"></div>
<canvas id="canvas" style="width: 50px; height: 50px;"> </canvas>
<div id="console"></div>
<script>
"use strict";
var pseudoRandom = (function() {
var seed = 3;
return function() {
seed = (seed * 11 + 17) % 25;
return seed / 25;
};
})();
var randomizeCase = function(str) {
var newChars = [];
for (var ii = 0; ii < str.length; ++ii) {
var c = str.substr(ii, 1);
var m = (pseudoRandom() > 0.5) ? c.toLowerCase() : c.toUpperCase();
newChars.push(m);
}
return newChars.join("");
};
description();
var wtu = WebGLTestUtils;
var canvas = document.getElementById("canvas");
var gl = wtu.create3DContext(canvas);
var ii;
debug("check every extension advertised can be enabled");
debug("");
var extensionNames = gl.getSupportedExtensions();
var extensionNamesLower = [];
for (ii = 0; ii < extensionNames.length; ++ii) {
extensionNamesLower.push(extensionNames[ii].toLowerCase());
}
for (ii = 0; ii < extensionNames.length; ++ii) {
var originalName = extensionNames[ii];
var mixedName = randomizeCase(originalName);
var extension = gl.getExtension(mixedName);
assertMsg(extension, "able to get " + originalName + " as " + mixedName);
if (extension) {
var kTestString = "this is a test";
var kTestNumber = 123;
var kTestFunction = function() { };
var kTestObject = { };
extension.testStringProperty = kTestString;
extension.testNumberProperty = kTestNumber;
extension.testFunctionProperty = kTestFunction;
extension.testObjectProperty = kTestObject;
gc();
var extension2 = gl.getExtension(originalName);
assertMsg(
extension === extension2,
"calling getExtension twice for the same extension returns the same object");
assertMsg(
extension2.testStringProperty === kTestString &&
extension2.testFunctionProperty === kTestFunction &&
extension2.testObjectProperty === kTestObject &&
extension2.testNumberProperty === kTestNumber,
"object returned by 2nd call to getExtension has same properties");
var prefixedVariants = wtu.getExtensionPrefixedNames(originalName);
for (var jj = 0; jj < prefixedVariants.length; ++jj) {
assertMsg(
gl.getExtension(prefixedVariants[jj]) === null ||
extensionNamesLower.indexOf(prefixedVariants[jj].toLowerCase()) !== -1,
"getExtension('" + prefixedVariants[jj] + "') returns an object only if the name is returned by getSupportedExtensions");
}
}
debug("");
}
var successfullyParsed = true;
</script>
<script src="../../resources/js-test-post.js"></script>
</body>
</html>

Просмотреть файл

@ -0,0 +1,446 @@
<!--
/*
** Copyright (c) 2012 The Khronos Group Inc.
**
** Permission is hereby granted, free of charge, to any person obtaining a
** copy of this software and/or associated documentation files (the
** "Materials"), to deal in the Materials without restriction, including
** without limitation the rights to use, copy, modify, merge, publish,
** distribute, sublicense, and/or sell copies of the Materials, and to
** permit persons to whom the Materials are furnished to do so, subject to
** the following conditions:
**
** The above copyright notice and this permission notice shall be included
** in all copies or substantial portions of the Materials.
**
** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
*/
-->
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>WebGL OES_element_index_uint Conformance Tests</title>
<link rel="stylesheet" href="../../resources/js-test-style.css"/>
<script src="../../resources/js-test-pre.js"></script>
<script src="../resources/webgl-test-utils.js"></script>
<script id="vs" type="x-shader/x-vertex">
attribute vec4 vPosition;
attribute vec4 vColor;
varying vec4 color;
void main() {
gl_Position = vPosition;
color = vColor;
}
</script>
<script id="fs" type="x-shader/x-fragment">
precision mediump float;
varying vec4 color;
void main() {
gl_FragColor = color;
}
</script>
</head>
<body>
<div id="description"></div>
<div id="console"></div>
<script>
"use strict";
description("This test verifies the functionality of the OES_element_index_uint extension, if it is available.");
debug("");
var wtu = WebGLTestUtils;
var gl = null;
var ext = null;
var canvas = null;
// Test both STATIC_DRAW and DYNAMIC_DRAW as a regression test
// for a bug in ANGLE which has since been fixed.
for (var ii = 0; ii < 2; ++ii) {
canvas = document.createElement("canvas");
canvas.width = 50;
canvas.height = 50;
gl = wtu.create3DContext(canvas);
if (!gl) {
testFailed("WebGL context does not exist");
} else {
testPassed("WebGL context exists");
var drawType = (ii == 0) ? gl.STATIC_DRAW : gl.DYNAMIC_DRAW;
debug("Testing " + ((ii == 0) ? "STATIC_DRAW" : "DYNAMIC_DRAW"));
// Query the extension and store globally so shouldBe can access it
ext = gl.getExtension("OES_element_index_uint");
if (!ext) {
testPassed("No OES_element_index_uint support -- this is legal");
runSupportedTest(false);
} else {
testPassed("Successfully enabled OES_element_index_uint extension");
runSupportedTest(true);
runDrawTests(drawType);
// These tests are tweaked duplicates of the buffers/index-validation* tests
// using unsigned int indices to ensure that behavior remains consistent
runIndexValidationTests(drawType);
runCopiesIndicesTests(drawType);
runResizedBufferTests(drawType);
runVerifiesTooManyIndicesTests(drawType);
runCrashWithBufferSubDataTests(drawType);
wtu.glErrorShouldBe(gl, gl.NO_ERROR, "there should be no errors");
}
}
}
function runSupportedTest(extensionEnabled) {
var supported = gl.getSupportedExtensions();
if (supported.indexOf("OES_element_index_uint") >= 0) {
if (extensionEnabled) {
testPassed("OES_element_index_uint listed as supported and getExtension succeeded");
} else {
testFailed("OES_element_index_uint listed as supported but getExtension failed");
}
} else {
if (extensionEnabled) {
testFailed("OES_element_index_uint not listed as supported but getExtension succeeded");
} else {
testPassed("OES_element_index_uint not listed as supported and getExtension failed -- this is legal");
}
}
}
function runDrawTests(drawType) {
debug("Test that draws with unsigned integer indices produce the expected results");
canvas.width = 50; canvas.height = 50;
gl.viewport(0, 0, canvas.width, canvas.height);
var program = wtu.setupNoTexCoordTextureProgram(gl);
function setupDraw(s) {
// Create a vertex buffer that cannot be fully indexed via shorts
var quadArrayLen = 65537 * 3;
var quadArray = new Float32Array(quadArrayLen);
// Leave all but the last 4 values zero-ed out
var idx = quadArrayLen - 12;
// Initialized the last 4 values to a quad
quadArray[idx++] = 1.0 * s;
quadArray[idx++] = 1.0 * s;
quadArray[idx++] = 0.0;
quadArray[idx++] = -1.0 * s;
quadArray[idx++] = 1.0 * s;
quadArray[idx++] = 0.0;
quadArray[idx++] = -1.0 * s;
quadArray[idx++] = -1.0 * s;
quadArray[idx++] = 0.0;
quadArray[idx++] = 1.0 * s;
quadArray[idx++] = -1.0 * s;
quadArray[idx++] = 0.0;
var vertexObject = gl.createBuffer();
gl.bindBuffer(gl.ARRAY_BUFFER, vertexObject);
gl.bufferData(gl.ARRAY_BUFFER, quadArray, drawType);
// Create an unsigned int index buffer that indexes the last 4 vertices
var baseIndex = (quadArrayLen / 3) - 4;
var indexObject = gl.createBuffer();
gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, indexObject);
gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, new Uint32Array([
baseIndex + 0,
baseIndex + 1,
baseIndex + 2,
baseIndex + 2,
baseIndex + 3,
baseIndex + 0]), drawType);
var opt_positionLocation = 0;
gl.enableVertexAttribArray(opt_positionLocation);
gl.vertexAttribPointer(opt_positionLocation, 3, gl.FLOAT, false, 0, 0);
};
function testPixel(blackList, whiteList) {
function testList(list, expected) {
for (var n = 0; n < list.length; n++) {
var l = list[n];
var x = -Math.floor(l * canvas.width / 2) + canvas.width / 2;
var y = -Math.floor(l * canvas.height / 2) + canvas.height / 2;
wtu.checkCanvasRect(gl, x, y, 1, 1, [expected, expected, expected],
"Draw should pass", 2);
}
}
testList(blackList, 0);
testList(whiteList, 255);
};
function verifyDraw(s) {
gl.clearColor(1.0, 1.0, 1.0, 1.0);
gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
gl.drawElements(gl.TRIANGLES, 6, gl.UNSIGNED_INT, 0);
var blackList = [];
var whiteList = [];
var points = [0.0, 0.2, 0.4, 0.6, 0.8, 1.0];
for (var n = 0; n < points.length; n++) {
if (points[n] <= s) {
blackList.push(points[n]);
} else {
whiteList.push(points[n]);
}
}
testPixel(blackList, whiteList);
};
setupDraw(0.5);
verifyDraw(0.5);
}
function runIndexValidationTests(drawType) {
description("Tests that index validation verifies the correct number of indices");
function sizeInBytes(type) {
switch (type) {
case gl.BYTE:
case gl.UNSIGNED_BYTE:
return 1;
case gl.SHORT:
case gl.UNSIGNED_SHORT:
return 2;
case gl.INT:
case gl.UNSIGNED_INT:
case gl.FLOAT:
return 4;
default:
throw "unknown type";
}
}
var program = wtu.loadStandardProgram(gl);
// 3 vertices => 1 triangle, interleaved data
var dataComplete = new Float32Array([0, 0, 0, 1,
0, 0, 1,
1, 0, 0, 1,
0, 0, 1,
1, 1, 1, 1,
0, 0, 1]);
var dataIncomplete = new Float32Array([0, 0, 0, 1,
0, 0, 1,
1, 0, 0, 1,
0, 0, 1,
1, 1, 1, 1]);
var indices = new Uint32Array([0, 1, 2]);
debug("Testing with valid indices");
var bufferComplete = gl.createBuffer();
gl.bindBuffer(gl.ARRAY_BUFFER, bufferComplete);
gl.bufferData(gl.ARRAY_BUFFER, dataComplete, drawType);
var elements = gl.createBuffer();
gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, elements);
gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, indices, drawType);
gl.useProgram(program);
var vertexLoc = gl.getAttribLocation(program, "a_vertex");
var normalLoc = gl.getAttribLocation(program, "a_normal");
gl.vertexAttribPointer(vertexLoc, 4, gl.FLOAT, false, 7 * sizeInBytes(gl.FLOAT), 0);
gl.enableVertexAttribArray(vertexLoc);
gl.vertexAttribPointer(normalLoc, 3, gl.FLOAT, false, 7 * sizeInBytes(gl.FLOAT), 4 * sizeInBytes(gl.FLOAT));
gl.enableVertexAttribArray(normalLoc);
shouldBe('gl.checkFramebufferStatus(gl.FRAMEBUFFER)', 'gl.FRAMEBUFFER_COMPLETE');
wtu.glErrorShouldBe(gl, gl.NO_ERROR);
shouldBeUndefined('gl.drawElements(gl.TRIANGLES, 3, gl.UNSIGNED_INT, 0)');
wtu.glErrorShouldBe(gl, gl.NO_ERROR);
debug("Testing with out-of-range indices");
var bufferIncomplete = gl.createBuffer();
gl.bindBuffer(gl.ARRAY_BUFFER, bufferIncomplete);
gl.bufferData(gl.ARRAY_BUFFER, dataIncomplete, drawType);
gl.vertexAttribPointer(vertexLoc, 4, gl.FLOAT, false, 7 * sizeInBytes(gl.FLOAT), 0);
gl.enableVertexAttribArray(vertexLoc);
gl.disableVertexAttribArray(normalLoc);
debug("Enable vertices, valid");
wtu.glErrorShouldBe(gl, gl.NO_ERROR);
shouldBeUndefined('gl.drawElements(gl.TRIANGLES, 3, gl.UNSIGNED_INT, 0)');
wtu.glErrorShouldBe(gl, gl.NO_ERROR);
debug("Enable normals, out-of-range");
gl.vertexAttribPointer(normalLoc, 3, gl.FLOAT, false, 7 * sizeInBytes(gl.FLOAT), 4 * sizeInBytes(gl.FLOAT));
gl.enableVertexAttribArray(normalLoc);
wtu.glErrorShouldBe(gl, gl.NO_ERROR);
shouldBeUndefined('gl.drawElements(gl.TRIANGLES, 3, gl.UNSIGNED_INT, 0)');
wtu.glErrorShouldBe(gl, gl.INVALID_OPERATION);
debug("Test with enabled attribute that does not belong to current program");
gl.disableVertexAttribArray(normalLoc);
var extraLoc = Math.max(vertexLoc, normalLoc) + 1;
gl.enableVertexAttribArray(extraLoc);
debug("Enable an extra attribute with null");
wtu.glErrorShouldBe(gl, gl.NO_ERROR);
shouldBeUndefined('gl.drawElements(gl.TRIANGLES, 3, gl.UNSIGNED_INT, 0)');
wtu.glErrorShouldBe(gl, gl.INVALID_OPERATION);
debug("Enable an extra attribute with insufficient data buffer");
gl.vertexAttribPointer(extraLoc, 3, gl.FLOAT, false, 7 * sizeInBytes(gl.FLOAT), 4 * sizeInBytes(gl.FLOAT));
wtu.glErrorShouldBe(gl, gl.NO_ERROR);
shouldBeUndefined('gl.drawElements(gl.TRIANGLES, 3, gl.UNSIGNED_INT, 0)');
debug("Pass large negative index to vertexAttribPointer");
gl.vertexAttribPointer(normalLoc, 3, gl.FLOAT, false, 7 * sizeInBytes(gl.FLOAT), -2000000000 * sizeInBytes(gl.FLOAT));
wtu.glErrorShouldBe(gl, gl.INVALID_VALUE);
shouldBeUndefined('gl.drawElements(gl.TRIANGLES, 3, gl.UNSIGNED_INT, 0)');
}
function runCopiesIndicesTests(drawType) {
debug("Test that client data is always copied during bufferData and bufferSubData calls");
var program = wtu.loadStandardProgram(gl);
gl.useProgram(program);
var vertexObject = gl.createBuffer();
gl.enableVertexAttribArray(0);
gl.bindBuffer(gl.ARRAY_BUFFER, vertexObject);
// 4 vertices -> 2 triangles
gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([ 0,0,0, 0,1,0, 1,0,0, 1,1,0 ]), drawType);
gl.vertexAttribPointer(0, 3, gl.FLOAT, false, 0, 0);
var indexObject = gl.createBuffer();
gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, indexObject);
var indices = new Uint32Array([ 10000, 0, 1, 2, 3, 10000 ]);
gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, indices, drawType);
wtu.shouldGenerateGLError(gl, gl.NO_ERROR, "gl.drawElements(gl.TRIANGLE_STRIP, 4, gl.UNSIGNED_INT, 4)");
wtu.shouldGenerateGLError(gl, gl.INVALID_OPERATION, "gl.drawElements(gl.TRIANGLE_STRIP, 4, gl.UNSIGNED_INT, 0)");
wtu.shouldGenerateGLError(gl, gl.INVALID_OPERATION, "gl.drawElements(gl.TRIANGLE_STRIP, 4, gl.UNSIGNED_INT, 8)");
indices[0] = 2;
indices[5] = 1;
wtu.shouldGenerateGLError(gl, gl.NO_ERROR, "gl.drawElements(gl.TRIANGLE_STRIP, 4, gl.UNSIGNED_INT, 4)");
wtu.shouldGenerateGLError(gl, gl.INVALID_OPERATION, "gl.drawElements(gl.TRIANGLE_STRIP, 4, gl.UNSIGNED_INT, 0)");
wtu.shouldGenerateGLError(gl, gl.INVALID_OPERATION, "gl.drawElements(gl.TRIANGLE_STRIP, 4, gl.UNSIGNED_INT, 8)");
}
function runResizedBufferTests(drawType) {
debug("Test that updating the size of a vertex buffer is properly noticed by the WebGL implementation.");
var program = wtu.setupProgram(gl, ["vs", "fs"], ["vPosition", "vColor"]);
wtu.glErrorShouldBe(gl, gl.NO_ERROR, "after initialization");
var vertexObject = gl.createBuffer();
gl.bindBuffer(gl.ARRAY_BUFFER, vertexObject);
gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(
[-1,1,0, 1,1,0, -1,-1,0,
-1,-1,0, 1,1,0, 1,-1,0]), drawType);
gl.enableVertexAttribArray(0);
gl.vertexAttribPointer(0, 3, gl.FLOAT, false, 0, 0);
wtu.glErrorShouldBe(gl, gl.NO_ERROR, "after vertex setup");
var texCoordObject = gl.createBuffer();
gl.bindBuffer(gl.ARRAY_BUFFER, texCoordObject);
gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(
[0,0, 1,0, 0,1,
0,1, 1,0, 1,1]), drawType);
gl.enableVertexAttribArray(1);
gl.vertexAttribPointer(1, 2, gl.FLOAT, false, 0, 0);
wtu.glErrorShouldBe(gl, gl.NO_ERROR, "after texture coord setup");
// Now resize these buffers because we want to change what we're drawing.
gl.bindBuffer(gl.ARRAY_BUFFER, vertexObject);
gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([
-1,1,0, 1,1,0, -1,-1,0, 1,-1,0,
-1,1,0, 1,1,0, -1,-1,0, 1,-1,0]), drawType);
wtu.glErrorShouldBe(gl, gl.NO_ERROR, "after vertex redefinition");
gl.bindBuffer(gl.ARRAY_BUFFER, texCoordObject);
gl.bufferData(gl.ARRAY_BUFFER, new Uint8Array([
255, 0, 0, 255,
255, 0, 0, 255,
255, 0, 0, 255,
255, 0, 0, 255,
0, 255, 0, 255,
0, 255, 0, 255,
0, 255, 0, 255,
0, 255, 0, 255]), drawType);
gl.vertexAttribPointer(1, 4, gl.UNSIGNED_BYTE, false, 0, 0);
wtu.glErrorShouldBe(gl, gl.NO_ERROR, "after texture coordinate / color redefinition");
var numQuads = 2;
var indices = new Uint32Array(numQuads * 6);
for (var ii = 0; ii < numQuads; ++ii) {
var offset = ii * 6;
var quad = (ii == (numQuads - 1)) ? 4 : 0;
indices[offset + 0] = quad + 0;
indices[offset + 1] = quad + 1;
indices[offset + 2] = quad + 2;
indices[offset + 3] = quad + 2;
indices[offset + 4] = quad + 1;
indices[offset + 5] = quad + 3;
}
var indexObject = gl.createBuffer();
gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, indexObject);
gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, indices, drawType);
wtu.glErrorShouldBe(gl, gl.NO_ERROR, "after setting up indices");
gl.drawElements(gl.TRIANGLES, numQuads * 6, gl.UNSIGNED_INT, 0);
wtu.glErrorShouldBe(gl, gl.NO_ERROR, "after drawing");
}
function runVerifiesTooManyIndicesTests(drawType) {
description("Tests that index validation for drawElements does not examine too many indices");
var program = wtu.loadStandardProgram(gl);
gl.useProgram(program);
var vertexObject = gl.createBuffer();
gl.enableVertexAttribArray(0);
gl.disableVertexAttribArray(1);
gl.bindBuffer(gl.ARRAY_BUFFER, vertexObject);
// 4 vertices -> 2 triangles
gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([ 0,0,0, 0,1,0, 1,0,0, 1,1,0 ]), drawType);
gl.vertexAttribPointer(0, 3, gl.FLOAT, false, 0, 0);
var indexObject = gl.createBuffer();
debug("Test out of range indices")
gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, indexObject);
gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, new Uint32Array([ 10000, 0, 1, 2, 3, 10000 ]), drawType);
wtu.shouldGenerateGLError(gl, gl.NO_ERROR, "gl.drawElements(gl.TRIANGLE_STRIP, 4, gl.UNSIGNED_INT, 4)");
wtu.shouldGenerateGLError(gl, gl.INVALID_OPERATION, "gl.drawElements(gl.TRIANGLE_STRIP, 4, gl.UNSIGNED_INT, 0)");
wtu.shouldGenerateGLError(gl, gl.INVALID_OPERATION, "gl.drawElements(gl.TRIANGLE_STRIP, 4, gl.UNSIGNED_INT, 8)");
}
function runCrashWithBufferSubDataTests(drawType) {
debug('Verifies that the index validation code which is within bufferSubData does not crash.')
var elementBuffer = gl.createBuffer();
gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, elementBuffer);
gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, 256, drawType);
var data = new Uint32Array(127);
gl.bufferSubData(gl.ELEMENT_ARRAY_BUFFER, 64, data);
wtu.glErrorShouldBe(gl, gl.INVALID_VALUE, "after attempting to update a buffer outside of the allocated bounds");
testPassed("bufferSubData, when buffer object was initialized with null, did not crash");
}
debug("");
var successfullyParsed = true;
</script>
<script src="../../resources/js-test-post.js"></script>
</body>
</html>

Просмотреть файл

@ -0,0 +1,352 @@
<!--
/*
** Copyright (c) 2012 The Khronos Group Inc.
**
** Permission is hereby granted, free of charge, to any person obtaining a
** copy of this software and/or associated documentation files (the
** "Materials"), to deal in the Materials without restriction, including
** without limitation the rights to use, copy, modify, merge, publish,
** distribute, sublicense, and/or sell copies of the Materials, and to
** permit persons to whom the Materials are furnished to do so, subject to
** the following conditions:
**
** The above copyright notice and this permission notice shall be included
** in all copies or substantial portions of the Materials.
**
** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
*/
-->
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>WebGL OES_standard_derivatives Conformance Tests</title>
<link rel="stylesheet" href="../../resources/js-test-style.css"/>
<script src="../../resources/js-test-pre.js"></script>
<script src="../resources/webgl-test-utils.js"></script>
</head>
<body>
<div id="description"></div>
<canvas id="canvas" style="width: 50px; height: 50px;"> </canvas>
<div id="console"></div>
<!-- Shaders for testing standard derivatives -->
<!-- Shader omitting the required #extension pragma -->
<script id="missingPragmaFragmentShader" type="x-shader/x-fragment">
precision mediump float;
varying vec2 texCoord;
void main() {
float dx = dFdx(texCoord.x);
float dy = dFdy(texCoord.y);
float w = fwidth(texCoord.x);
gl_FragColor = vec4(dx, dy, w, 1.0);
}
</script>
<!-- Shader to test macro definition -->
<script id="macroFragmentShader" type="x-shader/x-fragment">
precision mediump float;
void main() {
#ifdef GL_OES_standard_derivatives
gl_FragColor = vec4(0.0, 0.0, 0.0, 0.0);
#else
// Error expected
#error no GL_OES_standard_derivatives;
#endif
}
</script>
<!-- Shader with required #extension pragma -->
<script id="testFragmentShader" type="x-shader/x-fragment">
#extension GL_OES_standard_derivatives : enable
precision mediump float;
varying vec2 texCoord;
void main() {
float dx = dFdx(texCoord.x);
float dy = dFdy(texCoord.y);
float w = fwidth(texCoord.x);
gl_FragColor = vec4(dx, dy, w, 1.0);
}
</script>
<!-- Shaders to link with test fragment shaders -->
<script id="goodVertexShader" type="x-shader/x-vertex">
attribute vec4 vPosition;
varying vec2 texCoord;
void main() {
texCoord = vPosition.xy;
gl_Position = vPosition;
}
</script>
<!-- Shaders to test output -->
<script id="outputVertexShader" type="x-shader/x-vertex">
attribute vec4 vPosition;
varying vec4 position;
void main() {
position = vPosition;
gl_Position = vPosition;
}
</script>
<script id="outputFragmentShader" type="x-shader/x-fragment">
#extension GL_OES_standard_derivatives : enable
precision mediump float;
varying vec4 position;
void main() {
float dzdx = dFdx(position.z);
float dzdy = dFdy(position.z);
float fw = fwidth(position.z);
gl_FragColor = vec4(abs(dzdx) * 40.0, abs(dzdy) * 40.0, fw * 40.0, 1.0);
}
</script>
<script>
"use strict";
description("This test verifies the functionality of the OES_standard_derivatives extension, if it is available.");
debug("");
var wtu = WebGLTestUtils;
var canvas = document.getElementById("canvas");
var gl = wtu.create3DContext(canvas);
var ext = null;
if (!gl) {
testFailed("WebGL context does not exist");
} else {
testPassed("WebGL context exists");
// Run tests with extension disabled
runHintTestDisabled();
runShaderTests(false);
// Query the extension and store globally so shouldBe can access it
ext = gl.getExtension("OES_standard_derivatives");
if (!ext) {
testPassed("No OES_standard_derivatives support -- this is legal");
runSupportedTest(false);
} else {
testPassed("Successfully enabled OES_standard_derivatives extension");
runSupportedTest(true);
runHintTestEnabled();
runShaderTests(true);
runOutputTests();
runUniqueObjectTest();
}
}
function runSupportedTest(extensionEnabled) {
var supported = gl.getSupportedExtensions();
if (supported.indexOf("OES_standard_derivatives") >= 0) {
if (extensionEnabled) {
testPassed("OES_standard_derivatives listed as supported and getExtension succeeded");
} else {
testFailed("OES_standard_derivatives listed as supported but getExtension failed");
}
} else {
if (extensionEnabled) {
testFailed("OES_standard_derivatives not listed as supported but getExtension succeeded");
} else {
testPassed("OES_standard_derivatives not listed as supported and getExtension failed -- this is legal");
}
}
}
function runHintTestDisabled() {
debug("Testing FRAGMENT_SHADER_DERIVATIVE_HINT_OES with extension disabled");
// Use the constant directly as we don't have the extension
var FRAGMENT_SHADER_DERIVATIVE_HINT_OES = 0x8B8B;
gl.getParameter(FRAGMENT_SHADER_DERIVATIVE_HINT_OES);
wtu.glErrorShouldBe(gl, gl.INVALID_ENUM, "FRAGMENT_SHADER_DERIVATIVE_HINT_OES should not be queryable if extension is disabled");
gl.hint(FRAGMENT_SHADER_DERIVATIVE_HINT_OES, gl.DONT_CARE);
wtu.glErrorShouldBe(gl, gl.INVALID_ENUM, "hint should not accept FRAGMENT_SHADER_DERIVATIVE_HINT_OES if extension is disabled");
}
function runHintTestEnabled() {
debug("Testing FRAGMENT_SHADER_DERIVATIVE_HINT_OES with extension enabled");
shouldBe("ext.FRAGMENT_SHADER_DERIVATIVE_HINT_OES", "0x8B8B");
gl.getParameter(ext.FRAGMENT_SHADER_DERIVATIVE_HINT_OES);
wtu.glErrorShouldBe(gl, gl.NO_ERROR, "FRAGMENT_SHADER_DERIVATIVE_HINT_OES query should succeed if extension is enabled");
// Default value is DONT_CARE
if (gl.getParameter(ext.FRAGMENT_SHADER_DERIVATIVE_HINT_OES) == gl.DONT_CARE) {
testPassed("Default value of FRAGMENT_SHADER_DERIVATIVE_HINT_OES is DONT_CARE");
} else {
testFailed("Default value of FRAGMENT_SHADER_DERIVATIVE_HINT_OES is not DONT_CARE");
}
// Ensure that we can set the target
gl.hint(ext.FRAGMENT_SHADER_DERIVATIVE_HINT_OES, gl.DONT_CARE);
wtu.glErrorShouldBe(gl, gl.NO_ERROR, "hint should accept FRAGMENT_SHADER_DERIVATIVE_HINT_OES");
// Test all the hint modes
var validModes = ["FASTEST", "NICEST", "DONT_CARE"];
var anyFailed = false;
for (var n = 0; n < validModes.length; n++) {
var mode = validModes[n];
gl.hint(ext.FRAGMENT_SHADER_DERIVATIVE_HINT_OES, gl[mode]);
if (gl.getParameter(ext.FRAGMENT_SHADER_DERIVATIVE_HINT_OES) != gl[mode]) {
testFailed("Round-trip of hint()/getParameter() failed on mode " + mode);
anyFailed = true;
}
}
if (!anyFailed) {
testPassed("Round-trip of hint()/getParameter() with all supported modes");
}
}
function runShaderTests(extensionEnabled) {
debug("");
debug("Testing various shader compiles with extension " + (extensionEnabled ? "enabled" : "disabled"));
// Expect the macro shader to succeed ONLY if enabled
var macroFragmentProgram = wtu.loadProgramFromScriptExpectError(gl, "goodVertexShader", "macroFragmentShader");
if (extensionEnabled) {
if (macroFragmentProgram) {
// Expected result
testPassed("GL_OES_standard_derivatives defined in shaders when extension is enabled");
} else {
testFailed("GL_OES_standard_derivatives not defined in shaders when extension is enabled");
}
} else {
if (macroFragmentProgram) {
testFailed("GL_OES_standard_derivatives defined in shaders when extension is disabled");
} else {
testPassed("GL_OES_standard_derivatives not defined in shaders when extension disabled");
}
}
// Always expect the shader missing the #pragma to fail (whether enabled or not)
var missingPragmaFragmentProgram = wtu.loadProgramFromScriptExpectError(gl, "goodVertexShader", "missingPragmaFragmentShader");
if (missingPragmaFragmentProgram) {
testFailed("Shader built-ins allowed without #extension pragma");
} else {
testPassed("Shader built-ins disallowed without #extension pragma");
}
// Try to compile a shader using the built-ins that should only succeed if enabled
var testFragmentProgram = wtu.loadProgramFromScriptExpectError(gl, "goodVertexShader", "testFragmentShader");
if (extensionEnabled) {
if (testFragmentProgram) {
testPassed("Shader built-ins compiled successfully when extension enabled");
} else {
testFailed("Shader built-ins failed to compile when extension enabled");
}
} else {
if (testFragmentProgram) {
testFailed("Shader built-ins compiled successfully when extension disabled");
} else {
testPassed("Shader built-ins failed to compile when extension disabled");
}
}
}
function runOutputTests() {
// This tests does several draws with various values of z.
// The output of the fragment shader is:
// [dFdx(z), dFdy(z), fwidth(z), 1.0]
// The expected math: (note the conversion to uint8)
// canvas.width = canvas.height = 50
// dFdx = totalChange.x / canvas.width = 0.5 / 50.0 = 0.01
// dFdy = totalChange.y / canvas.height = 0.5 / 50.0 = 0.01
// fw = abs(dFdx + dFdy) = 0.01 + 0.01 = 0.02
// r = floor(dFdx * 40.0 * 255) = 102
// g = floor(dFdy * 40.0 * 255) = 102
// b = floor(fw * 40.0 * 255) = 204
var e = 5; // Amount of variance to allow in result pixels - may need to be tweaked higher
debug("Testing various draws for valid built-in function behavior");
canvas.width = 50; canvas.height = 50;
gl.viewport(0, 0, canvas.width, canvas.height);
gl.hint(ext.FRAGMENT_SHADER_DERIVATIVE_HINT_OES, gl.NICEST);
var positionLoc = 0;
var texcoordLoc = 1;
var program = wtu.setupProgram(gl, ["outputVertexShader", "outputFragmentShader"], ['vPosition', 'texCoord0'], [0, 1]);
var quadParameters = wtu.setupUnitQuad(gl, positionLoc, texcoordLoc);
function expectResult(target, message) {
var locations = [
[ 0.1, 0.1 ],
[ 0.9, 0.1 ],
[ 0.1, 0.9 ],
[ 0.9, 0.9 ],
[ 0.5, 0.5 ]
];
for (var n = 0; n < locations.length; n++) {
var loc = locations[n];
var px = Math.floor(loc[0] * canvas.width);
var py = Math.floor(loc[1] * canvas.height);
wtu.checkCanvasRect(gl, px, py, 1, 1, target, message, 4);
}
};
function setupBuffers(tl, tr, bl, br) {
gl.bindBuffer(gl.ARRAY_BUFFER, quadParameters[0]);
gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([
1.0, 1.0, tr,
-1.0, 1.0, tl,
-1.0, -1.0, bl,
1.0, 1.0, tr,
-1.0, -1.0, bl,
1.0, -1.0, br]), gl.STATIC_DRAW);
gl.vertexAttribPointer(positionLoc, 3, gl.FLOAT, false, 0, 0);
};
// Draw 1: (no variation)
setupBuffers(0.0, 0.0, 0.0, 0.0);
wtu.clearAndDrawUnitQuad(gl);
expectResult([0, 0, 0, 255],
"Draw 1 (no variation) should pass");
// Draw 2: (variation in x)
setupBuffers(1.0, 0.0, 1.0, 0.0);
wtu.clearAndDrawUnitQuad(gl);
expectResult([204, 0, 204, 255],
"Draw 2 (variation in x) should pass");
// Draw 3: (variation in y)
setupBuffers(1.0, 1.0, 0.0, 0.0);
wtu.clearAndDrawUnitQuad(gl);
expectResult([0, 204, 204, 255],
"Draw 3 (variation in y) should pass");
// Draw 4: (variation in x & y)
setupBuffers(1.0, 0.5, 0.5, 0.0);
wtu.clearAndDrawUnitQuad(gl);
expectResult([102, 102, 204, 255],
"Draw 4 (variation in x & y) should pass");
}
function runUniqueObjectTest()
{
debug("Testing that getExtension() returns the same object each time");
gl.getExtension("OES_standard_derivatives").myProperty = 2;
gc();
shouldBe('gl.getExtension("OES_standard_derivatives").myProperty', '2');
}
debug("");
var successfullyParsed = true;
</script>
<script src="../../resources/js-test-post.js"></script>
</body>
</html>

Просмотреть файл

@ -0,0 +1,53 @@
<!--
/*
** Copyright (c) 2013 The Khronos Group Inc.
**
** Permission is hereby granted, free of charge, to any person obtaining a
** copy of this software and/or associated documentation files (the
** "Materials"), to deal in the Materials without restriction, including
** without limitation the rights to use, copy, modify, merge, publish,
** distribute, sublicense, and/or sell copies of the Materials, and to
** permit persons to whom the Materials are furnished to do so, subject to
** the following conditions:
**
** The above copyright notice and this permission notice shall be included
** in all copies or substantial portions of the Materials.
**
** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
*/
-->
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<link rel="stylesheet" href="../../resources/js-test-style.css"/>
<script src="../../resources/js-test-pre.js"></script>
<script src="../resources/webgl-test-utils.js"></script>
<script src="../resources/oes-texture-float-and-half-float-linear.js"></script>
<script>
"use strict";
function testPrologue(gl, extensionTypeName) {
if (!gl.getExtension(extensionTypeName)) {
testPassed("No " + extensionTypeName + " support -- this is legal");
return false;
}
testPassed("Successfully enabled " + extensionTypeName + " extension");
return true;
}
</script>
</head>
<body onload='generateTest("OES_texture_float", "OES_texture_float_linear", "FLOAT", testPrologue)()'>
<div id="description"></div>
<canvas id="canvas" style="width: 50px; height: 50px;"> </canvas>
<div id="console"></div>
</body>
</html>

Некоторые файлы не были показаны из-за слишком большого количества измененных файлов Показать больше