diff options
| author | git perforce import user <a@b> | 2016-10-25 12:29:14 -0600 |
|---|---|---|
| committer | Sheikh Dawood Abdul Ajees <Sheikh Dawood Abdul Ajees> | 2016-10-25 18:56:37 -0500 |
| commit | 3dfe2108cfab31ba3ee5527e217d0d8e99a51162 (patch) | |
| tree | fa6485c169e50d7415a651bf838f5bcd0fd3bfbd /PhysX_3.4/Samples/SampleFramework/renderer/src | |
| download | physx-3.4-3dfe2108cfab31ba3ee5527e217d0d8e99a51162.tar.xz physx-3.4-3dfe2108cfab31ba3ee5527e217d0d8e99a51162.zip | |
Initial commit:
PhysX 3.4.0 Update @ 21294896
APEX 1.4.0 Update @ 21275617
[CL 21300167]
Diffstat (limited to 'PhysX_3.4/Samples/SampleFramework/renderer/src')
149 files changed, 31634 insertions, 0 deletions
diff --git a/PhysX_3.4/Samples/SampleFramework/renderer/src/Renderer.cpp b/PhysX_3.4/Samples/SampleFramework/renderer/src/Renderer.cpp new file mode 100644 index 00000000..3c59cfef --- /dev/null +++ b/PhysX_3.4/Samples/SampleFramework/renderer/src/Renderer.cpp @@ -0,0 +1,2107 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved. +#include "RendererFoundation.h" +#include <Renderer.h> +#include <RendererDesc.h> +#include "ogl/OGLRenderer.h" +#include "gles2/GLES2Renderer.h" +#include "d3d9/D3D9Renderer.h" +#if defined(RENDERER_ENABLE_LIBGNM) +#include "ps4/GnmRenderer.h" +#endif +#include "d3d11/D3D11Renderer.h" +#include "null/NULLRenderer.h" +#include <RendererMesh.h> +#include <RendererMeshContext.h> + +#include <RendererMaterial.h> +#include <RendererMaterialDesc.h> +#include <RendererMaterialInstance.h> +#include <RendererProjection.h> + +#include <RendererTarget.h> +#include <RendererTexture2D.h> +#include <RendererTexture2DDesc.h> + +#include <RendererVertexBuffer.h> +#include <RendererVertexBufferDesc.h> +#include <RendererMesh.h> +#include <RendererMeshDesc.h> + +#include <RendererLight.h> +#include "PsUtilities.h" + +#include <algorithm> +#include <sstream> +#include <string> +#include <vector> + +#include "PsUtilities.h" +#include "extensions/PxDefaultStreams.h" + +#if defined(RENDERER_ANDROID) +#include <android/AndroidSampleUserInputIds.h> +#endif + +// for PsString.h +#include <PsString.h> +#include <PxTkFile.h> + +namespace Ps = physx::shdfnd; + +using namespace SampleRenderer; + + +/* Screen pads for tablets. + Initialize two controls - second one is the vertically mirrored version of the first one with respect to the screen center + All values are in relative units, given that bottom-left point is (-1.0f, -1.0f), center is (0.0f, 0.0f) and top-right point is (1.0f, 1.0f) */ +#if defined(RENDERER_TABLET) +const PxReal gControlSizeRelative = 0.16f; +const PxReal gControlMarginRelative = 0.08f; +const PxU8 CONTROL_COUNT = 2; + +const PxU8 TEXT_HEIGHT = 16; +const PxU8 TEXT_VERTICAL_SPACING = TEXT_HEIGHT / 4; +#endif + +Renderer *Renderer::createRenderer(const RendererDesc &desc, const char* assetDir, bool enableMaterialCaching) +{ + Renderer *renderer = 0; + const bool valid = desc.isValid(); + if(valid) + { + switch(desc.driver) + { + case DRIVER_GLES2: +#if defined(RENDERER_ENABLE_GLES2) + renderer = new GLES2Renderer(desc, assetDir); + // disable material caching, not implemented! + enableMaterialCaching = false; +#endif + break; + + case DRIVER_OPENGL: +#if defined(RENDERER_ENABLE_OPENGL) + renderer = new OGLRenderer(desc, assetDir); +#endif + break; + + case DRIVER_DIRECT3D9: +#if defined(RENDERER_ENABLE_DIRECT3D9) + renderer = new D3D9Renderer(desc, assetDir); +#endif + break; + + case DRIVER_DIRECT3D11: +#if defined(RENDERER_ENABLE_DIRECT3D11) + renderer = new D3D11Renderer(desc, assetDir); +#endif + break; + + case DRIVER_LIBGCM: +#if defined(RENDERER_ENABLE_LIBGCM) + // not implemented, PS3 should use OpenGL +#endif + break; + + case DRIVER_LIBGNM: +#if defined(RENDERER_ENABLE_LIBGNM) + renderer = new GnmRenderer(desc, assetDir); + // disable material caching, not implemented! + enableMaterialCaching = false; +#endif + break; + + case DRIVER_NULL: + renderer = new NullRenderer(desc,assetDir); + break; + } + + if(renderer) + { + renderer->setEnableMaterialCaching(enableMaterialCaching); + } + } + if(renderer && !renderer->isOk()) + { + renderer->release(); + renderer = 0; + } + RENDERER_ASSERT(renderer, "Failed to create renderer!"); + return renderer; +} + +const char *Renderer::getDriverTypeName(DriverType type) +{ + const char *name = 0; + switch(type) + { + case DRIVER_OPENGL: name = "OpenGL"; break; + case DRIVER_GLES2: name = "OpenGL ES 2.0"; break; + case DRIVER_DIRECT3D9: name = "Direct3D9"; break; + case DRIVER_DIRECT3D11: name = "Direct3D11"; break; + case DRIVER_LIBGCM: name = "LibGCM"; break; + case DRIVER_LIBGNM: name = "LibGNM"; break; + case DRIVER_NULL: name = "NullRenderer"; break; + } + RENDERER_ASSERT(name, "Unable to find Name String for Renderer Driver Type."); + return name; +} + + +Renderer::Renderer(DriverType driver, PxErrorCallback* errorCallback, const char* assetDir) : + m_driver (driver), + m_errorCallback (errorCallback), + m_textMaterial (NULL), + m_textMaterialInstance (NULL), + m_screenquadOpaqueMaterial (NULL), + m_screenquadOpaqueMaterialInstance (NULL), + m_screenquadAlphaMaterial (NULL), + m_screenquadAlphaMaterialInstance (NULL), + m_useShadersForTextRendering (true), + m_assetDir (assetDir), + m_cacheDir (NULL), + m_enableTessellation (false), + m_enableWireframe (false), + m_enableBlendingOverride (false), + m_enableBlendingCull (false), + mEnableMaterialCaching (true) +{ + m_pixelCenterOffset = 0; + setAmbientColor(RendererColor(64,64,64, 255)); + setFog(RendererColor(0,0,10,255), 20000.0f); + setClearColor(RendererColor(133,153,181,255)); + Ps::strlcpy(m_deviceName, sizeof(m_deviceName), "UNKNOWN"); +#ifdef RENDERER_TABLET + m_buttons.reserve(16); +#endif +} + +Renderer::~Renderer(void) +{ + PX_ASSERT(!m_screenquadOpaqueMaterial); + PX_ASSERT(!m_screenquadOpaqueMaterialInstance); + PX_ASSERT(!m_screenquadAlphaMaterial); + PX_ASSERT(!m_screenquadAlphaMaterialInstance); + + PX_ASSERT(!m_textMaterial); + PX_ASSERT(!m_textMaterialInstance); + + for (tMaterialCache::iterator it = m_materialCache.begin(); it != m_materialCache.end(); ++it) + { + ::free((void*)it->first.vertexShaderPath); + ::free((void*)it->first.fragmentShaderPath); + ::free((void*)it->first.geometryShaderPath); + ::free((void*)it->first.domainShaderPath); + ::free((void*)it->first.hullShaderPath); + + PX_ASSERT(it->second == NULL); + } +} + + +void Renderer::release(void) +{ + closeScreenquad(); + delete this; +} + +// Create a 2D or 3D texture, depending on texture depth +RendererTexture* SampleRenderer::Renderer::createTexture(const RendererTextureDesc &desc) +{ + return desc.depth > 1 ? createTexture3D(desc) : createTexture2D(desc); +} + +// get the driver type for this renderer. +Renderer::DriverType Renderer::getDriverType(void) const +{ + return m_driver; +} + +// get the offset to the center of a pixel relative to the size of a pixel (so either 0 or 0.5). +PxF32 Renderer::getPixelCenterOffset(void) const +{ + return m_pixelCenterOffset; +} + +// get the name of the hardware device. +const char *Renderer::getDeviceName(void) const +{ + return m_deviceName; +} + +const char *Renderer::getAssetDir() +{ + return m_assetDir.c_str(); +} + +void Renderer::setAssetDir(const char * assetDir) +{ + m_assetDir = assetDir; +} + +// adds a mesh to the render queue. +void Renderer::queueMeshForRender(RendererMeshContext &mesh) +{ + RENDERER_ASSERT( mesh.isValid(), "Mesh Context is invalid."); + if(mesh.isValid()) + { + if (mesh.screenSpace) + { + m_screenSpaceMeshes.push_back(mesh); + } + else + { + switch (mesh.material->getType()) + { + case RendererMaterial::TYPE_LIT: + if (mesh.material->getBlending()) + m_visibleLitTransparentMeshes.push_back(mesh); + else + m_visibleLitMeshes.push_back(mesh); + break; + default: //case RendererMaterial::TYPE_UNLIT: + m_visibleUnlitMeshes.push_back(mesh); + // break; + } + } + } +} + +struct RenderMeshContextHasMesh +{ + RenderMeshContextHasMesh(const RendererMesh* mesh) : mMesh(mesh) { } + + bool operator()(const RendererMeshContext& meshContext) + { + return meshContext.mesh == mMesh; + } + + const RendererMesh* mMesh; +}; + +void SampleRenderer::Renderer::removeMeshFromRenderQueue(RendererMesh& mesh) +{ + MeshVector* meshContextQueues[] = { &m_visibleLitMeshes, + &m_visibleUnlitMeshes, + &m_screenSpaceMeshes, + &m_visibleLitTransparentMeshes }; + + // All queues must be searched, as a single mesh can be used in multiple contexts + for (PxU32 i = 0; i < PX_ARRAY_SIZE(meshContextQueues); ++i) + { + MeshVector& meshContextQueue = *meshContextQueues[i]; + meshContextQueue.erase(std::remove_if(meshContextQueue.begin(), + meshContextQueue.end(), + RenderMeshContextHasMesh(&mesh)), + meshContextQueue.end()); + } +} + +// adds a light to the render queue. +void Renderer::queueLightForRender(RendererLight &light) +{ + RENDERER_ASSERT(!light.isLocked(), "Light is already locked to a Renderer."); + if(!light.isLocked()) + { + light.m_renderer = this; + m_visibleLights.push_back(&light); + } +} + +void SampleRenderer::Renderer::removeLightFromRenderQueue(RendererLight &light) +{ + m_visibleLights.erase(std::remove(m_visibleLights.begin(), m_visibleLights.end(), &light)); +} + +// renders the current scene to the offscreen buffers. empties the render queue when done. +void Renderer::render(const physx::PxMat44 &eye, const RendererProjection &proj, RendererTarget *target, bool depthOnly) +{ + PX_PROFILE_ZONE("Renderer_render",0); + const PxU32 numLights = (PxU32)m_visibleLights.size(); + if(target) + { + target->bind(); + } + // TODO: Sort meshes by material.. + ScopedRender renderSection(*this); + if(renderSection) + { + if(!depthOnly) + { + // YOU CAN PASS THE PROJECTION MATIX RIGHT INTO THIS FUNCTION! + // TODO: Get rid of this. + if (m_screenSpaceMeshes.size()) + { + physx::PxMat44 id = physx::PxMat44(PxIdentity); + bindViewProj(id, RendererProjection(-1.0f, 1.0f, -1.0f, 1.0f, 1.0f, -1.0f)); //TODO: pass screen space matrices + renderMeshes(m_screenSpaceMeshes, RendererMaterial::PASS_UNLIT); //render screen space stuff first so stuff we occlude doesn't waste time on shading. + } + } + + sortMeshes(eye); + + if(depthOnly) + { + PX_PROFILE_ZONE("Renderer_render_depthOnly",0); + bindAmbientState(RendererColor(0,0,0,255)); + bindViewProj(eye, proj); + renderMeshes(m_visibleLitMeshes, RendererMaterial::PASS_DEPTH); + renderMeshes(m_visibleUnlitMeshes, RendererMaterial::PASS_DEPTH); + } + else if(numLights > RENDERER_DEFERRED_THRESHOLD) + { + PX_PROFILE_ZONE("Renderer_render_deferred",0); + bindDeferredState(); + bindViewProj(eye, proj); + renderMeshes(m_visibleLitMeshes, RendererMaterial::PASS_UNLIT); + renderMeshes(m_visibleUnlitMeshes, RendererMaterial::PASS_UNLIT); + renderMeshes(m_visibleLitTransparentMeshes, RendererMaterial::PASS_UNLIT); + renderDeferredLights(); + } + else if(numLights > 0) + { + PX_PROFILE_ZONE("Renderer_render_lit",0); + bindAmbientState(m_ambientColor); + bindFogState(m_fogColor, m_fogDistance); + bindViewProj(eye, proj); + +#if RENDERER_ENABLE_SINGLE_PASS_LIGHTING + for(PxU32 i=0; i<numLights; i++) + { + m_visibleLights[i]->bind(i); + } + renderMeshes(m_visibleLitMeshes, m_visibleLights[0]->getPass()); + for(PxU32 i=0; i<numLights; i++) + { + m_visibleLights[i]->m_renderer = NULL; + } +#else + RendererLight &light0 = *m_visibleLights[0]; + light0.bind(); + renderMeshes(m_visibleLitMeshes, light0.getPass()); + + bindAmbientState(RendererColor(0,0,0,255)); + beginMultiPass(); + for(PxU32 i=1; i<numLights; i++) + { + RendererLight &light = *m_visibleLights[i]; + light.bind(); + renderMeshes(m_visibleLitMeshes, light.getPass()); + } + endMultiPass(); +#endif + renderMeshes(m_visibleUnlitMeshes, RendererMaterial::PASS_UNLIT); + + /////////////////////////////////////////////////////////////////////////// + if (m_visibleLitTransparentMeshes.size() > 0) + { + light0.bind(); + renderMeshes(m_visibleLitTransparentMeshes, light0.getPass()); + + bindAmbientState(RendererColor(0,0,0,255)); + beginTransparentMultiPass(); + for(PxU32 i=1; i<numLights; i++) + { + RendererLight &light = *m_visibleLights[i]; + light.bind(); + renderMeshes(m_visibleLitTransparentMeshes, light.getPass()); + } + endTransparentMultiPass(); + } + /////////////////////////////////////////////////////////////////////////// + + for (physx::PxU32 i = 0; i < numLights; ++i) + m_visibleLights[i]->m_renderer = 0; + } + else + { + PX_PROFILE_ZONE("Renderer_render_unlit",0); + bindAmbientState(RendererColor(0,0,0,255)); + bindViewProj(eye, proj); + renderMeshes(m_visibleLitMeshes, RendererMaterial::PASS_UNLIT); + renderMeshes(m_visibleUnlitMeshes, RendererMaterial::PASS_UNLIT); + renderMeshes(m_visibleLitTransparentMeshes, RendererMaterial::PASS_UNLIT); + } + } + { + PX_PROFILE_ZONE("Cleanup", 0); + if (target) target->unbind(); + m_visibleLitMeshes.clear(); + m_visibleUnlitMeshes.clear(); + m_visibleLitTransparentMeshes.clear(); + m_screenSpaceMeshes.clear(); + m_visibleLights.clear(); + } +} + +// sets the ambient lighting color. +void Renderer::setAmbientColor(const RendererColor &ambientColor) +{ + m_ambientColor = ambientColor; + m_ambientColor.a = 255; +} + +void Renderer::setFog(const RendererColor &fogColor, float fogDistance) +{ + m_fogColor = fogColor; + m_fogDistance = fogDistance; +} + +void Renderer::setClearColor(const RendererColor &clearColor) +{ + m_clearColor = clearColor; + m_clearColor.a = 255; +} + +Renderer::TessellationParams::TessellationParams() +{ + setDefault(); +} + +void Renderer::TessellationParams::setDefault() +{ + tessFactor = PxVec4(6.f, 6.f, 3.f, 100.f); + tessMinMaxDistance[0] = 5.0f; + tessMinMaxDistance[1] = 50; + tessHeightScaleAndBias[0] = 1.0f; + tessHeightScaleAndBias[1] = 0.5f; + tessUVScale[0] = 1.0f; + tessUVScale[1] = 1.0f; +} + +std::string SampleRenderer::Renderer::TessellationParams::toString() +{ + std::stringstream ss; + ss << "TessParams = " << std::endl; + ss << "\tTessFactor: " << tessFactor.x << " " << tessFactor.y << " " << tessFactor.z << " " << tessFactor.w << std::endl; + ss << "\tTessMinMax: " << tessMinMaxDistance[0] << " " << tessMinMaxDistance[1] << std::endl; + ss << "\tTessHeightScale: " << tessHeightScaleAndBias[0] << " " << tessHeightScaleAndBias[1] << std::endl; + ss << "\tTessUVScale: " << tessUVScale[0] << " " << tessUVScale[1] << std::endl; + return ss.str(); +} + +void Renderer::setTessellationParams(const TessellationParams& params) +{ + m_tessellationParams = params; +} + +static PX_INLINE PxU32 createPixel(PxU8 r, PxU8 g, PxU8 b) +{ + // G = bits 0-7 + // B = bits 8-15 + // R = bits 16-23 + return (r << 16) | (g << 8) | b; +} + +void Renderer::formatScreenshot(PxU32 width, PxU32 height, PxU32 sizeInBytes, int rPosition, int gPosition, int bPosition, bool bFlipY, void* screenshotData) +{ + if (width <= 0 || height <= 0 || sizeInBytes <= 0) + return; + + PxU32 srcByteStride = sizeInBytes / (width * height); + RENDERER_ASSERT((srcByteStride > 0) && (srcByteStride <= sizeof(PxU32)), "Invalid image format."); + if (srcByteStride <= 0 || srcByteStride > sizeof(PxU32)) + return; + + PxU32* pSrc = static_cast<PxU32*>(screenshotData); + PxU8* pSrcByte = static_cast<PxU8*>(screenshotData); + if (bFlipY) + { + for (PxU32 i = 0; i < height/2; ++i) + { + PxU32* pSrc2 = static_cast<PxU32*>(screenshotData) + width * (height - i - 1); + PxU8* pSrc2Byte = static_cast<PxU8*>(screenshotData) + srcByteStride * width * (height - i - 1); + for (PxU32 j = 0; j < width; ++j, pSrcByte+=srcByteStride, pSrc2Byte+=srcByteStride, ++pSrc, ++pSrc2) + { + PxU32 temp = createPixel(pSrcByte[rPosition], pSrcByte[gPosition], pSrcByte[bPosition]); + *pSrc = createPixel(pSrc2Byte[rPosition], pSrc2Byte[gPosition], pSrc2Byte[bPosition]); + *pSrc2 = temp; + } + } + // Format the middle scanline + if (height % 2 == 1) + { + for (PxU32 j = 0; j < width; ++j, pSrcByte+=srcByteStride,++pSrc) + { + *pSrc = createPixel(pSrcByte[rPosition], pSrcByte[gPosition], pSrcByte[bPosition]); + } + } + } + else + { + for (PxU32 i = 0; i < height; ++i) + { + for (PxU32 j = 0; j < width; ++j, pSrcByte+=srcByteStride,++pSrc) + { + *pSrc = createPixel(pSrcByte[rPosition], pSrcByte[gPosition], pSrcByte[bPosition]); + } + } + } +} + +void Renderer::renderMeshes(std::vector<RendererMeshContext>& meshes, RendererMaterial::Pass pass) +{ + PX_PROFILE_ZONE("Renderer_renderMeshes",0); + + RendererMaterial *lastMaterial = 0; + RendererMaterialInstance *lastMaterialInstance = 0; + const RendererMesh *lastMesh = 0; + + const PxU32 numMeshes = (PxU32)meshes.size(); + for(PxU32 i=0; i<numMeshes; i++) + { + RendererMeshContext& context = meshes[i]; + + if(!context.mesh->willRender()) + { + continue; + } + + // the mesh context should be bound before the material, this is + // necessary because the materials read state from the graphics device + // for instance to determine if two-sided lighting should be enabled + // for gles 2 this doesn't work yet due to internal hacks +#if !defined(RENDERER_ENABLE_GLES2) + bindMeshContext(context); +#endif + + bool instanced = context.mesh->getInstanceBuffer()?true:false; + + if(context.materialInstance && context.materialInstance != lastMaterialInstance) + { + if(lastMaterial) lastMaterial->unbind(); + lastMaterialInstance = context.materialInstance; + lastMaterial = &context.materialInstance->getMaterial(); + lastMaterial->bind(pass, lastMaterialInstance, instanced); + } + else if(context.material != lastMaterial) + { + if(lastMaterial) lastMaterial->unbind(); + lastMaterialInstance = 0; + lastMaterial = context.material; + lastMaterial->bind(pass, lastMaterialInstance, instanced); + } + +#if defined(RENDERER_ENABLE_GLES2) + bindMeshContext(context); +#endif + + if(lastMaterial) lastMaterial->bindMeshState(instanced); + if(context.mesh != lastMesh) + { + if(lastMesh) lastMesh->unbind(); + lastMesh = context.mesh; + if(lastMesh) lastMesh->bind(); + } + if(lastMesh) context.mesh->render(context.material); + } + if(lastMesh) lastMesh->unbind(); + if(lastMaterial) lastMaterial->unbind(); +} + +struct CompareMeshCameraDist +{ + CompareMeshCameraDist(const physx::PxVec3& t_) : t(t_) { } + bool operator()(const RendererMeshContext& c1, const RendererMeshContext& c2) const + { + // Equivalent, return false + if (NULL == c1.transform && NULL == c2.transform) + return false; + // NULL transforms will be rendered first + if (NULL == c1.transform) + return true; + if (NULL == c2.transform) + return false; + // A larger magnitude means further away, which should be ordered first + // TODO: Use bones + return (c1.transform->getPosition() - t).magnitudeSquared() > (c2.transform->getPosition() - t).magnitudeSquared(); + } + physx::PxVec3 t; +}; + +void Renderer::sortMeshes(const physx::PxMat44& eye) +{ + CompareMeshCameraDist meshComp(eye.getPosition()); + std::sort(m_visibleLitTransparentMeshes.begin(), m_visibleLitTransparentMeshes.end(), meshComp); +} + +void Renderer::renderDeferredLights(void) +{ + PX_PROFILE_ZONE("Renderer_renderDeferredLights",0); + const PxU32 numLights = (PxU32)m_visibleLights.size(); + for(PxU32 i=0; i<numLights; i++) + { + renderDeferredLight(*m_visibleLights[i]); + } +} + +bool Renderer::CompareRenderMaterialDesc::operator()(const RendererMaterialDesc& desc1, const RendererMaterialDesc& desc2) const +{ + if (desc1.type != desc2.type) + return desc1.type < desc2.type; + + if (desc1.alphaTestFunc != desc2.alphaTestFunc) + return desc1.alphaTestFunc < desc2.alphaTestFunc; + + if (desc1.alphaTestRef != desc2.alphaTestRef) + return desc1.alphaTestRef < desc2.alphaTestRef; + + if (desc1.blending != desc2.blending) + return desc1.blending < desc2.blending; + + if (desc1.srcBlendFunc != desc2.srcBlendFunc) + return desc1.srcBlendFunc < desc2.srcBlendFunc; + + if (desc1.dstBlendFunc != desc2.dstBlendFunc) + return desc1.dstBlendFunc < desc2.dstBlendFunc; + + int result = Ps::stricmp(desc1.vertexShaderPath, desc2.vertexShaderPath); + if (result != 0) + return result < 0; + + result = Ps::stricmp(desc1.fragmentShaderPath, desc2.fragmentShaderPath); + if (result != 0) + return result < 0; + + // Geometry, hull and domain shaders are optional, so only check when present + // * stricmp only works properly for well defined pointers, so only test when both present + // * if one material has a particular shader when the other material does not, the one WITH should be first + if (desc1.geometryShaderPath || desc2.geometryShaderPath) + { + if (desc1.geometryShaderPath && desc2.geometryShaderPath) + result = Ps::stricmp(desc1.geometryShaderPath, desc2.geometryShaderPath); + else + result = desc1.geometryShaderPath ? -1 : 1; + } + + if (0 == result && (desc1.hullShaderPath || desc2.hullShaderPath)) + { + if (desc1.hullShaderPath && desc2.hullShaderPath) + result = Ps::stricmp(desc1.hullShaderPath, desc2.hullShaderPath); + else + result = desc1.hullShaderPath ? -1 : 1; + } + + if (0 == result && (desc1.domainShaderPath || desc2.domainShaderPath)) + { + if (desc1.domainShaderPath && desc2.domainShaderPath) + result = Ps::stricmp(desc1.domainShaderPath, desc2.domainShaderPath); + else + result = desc1.domainShaderPath ? -1 : 1; + } + + return result < 0; +} + +RendererMaterial* Renderer::hasMaterialAlready(const RendererMaterialDesc& desc) +{ + if (mEnableMaterialCaching) + { + tMaterialCache::iterator it = m_materialCache.find(desc); + + if (it != m_materialCache.end()) + { + PX_ASSERT(it->second != NULL); + it->second->incRefCount(); + return it->second; + } + } + + return NULL; +} + + + +static const char* local_strdup(const char* input) +{ + if (input == NULL) + { + return NULL; + } + + unsigned int strLen = (unsigned int)strlen(input) + 1; + char* retStr = (char*)::malloc(strLen); + + PX_ASSERT(retStr); + + if (NULL != retStr) + { +#if PX_WINDOWS + strcpy_s(retStr, strLen, input); +#else + strncpy(retStr, input, strLen); +#endif + } + return retStr; +} + + + +void Renderer::registerMaterial(const RendererMaterialDesc& desc, RendererMaterial* mat) +{ + if (mEnableMaterialCaching) + { + tMaterialCache::iterator it = m_materialCache.find(desc); + + if (it == m_materialCache.end()) + { + RendererMaterialDesc descCopy = desc; + descCopy.vertexShaderPath = local_strdup(desc.vertexShaderPath); + descCopy.fragmentShaderPath = local_strdup(desc.fragmentShaderPath); + descCopy.geometryShaderPath = local_strdup(desc.geometryShaderPath); + descCopy.domainShaderPath = local_strdup(desc.domainShaderPath); + descCopy.hullShaderPath = local_strdup(desc.hullShaderPath); + + PX_ASSERT(mat->m_refCount == 1); + m_materialCache[descCopy] = mat; + } + else + { + PX_ASSERT(it->second == NULL); + it->second = mat; + } + } +} + + + +void Renderer::releaseAllMaterials() +{ + for (tMaterialCache::iterator it = m_materialCache.begin(); it != m_materialCache.end(); ++it) + { + PX_ASSERT(it->second != NULL); + delete it->second; + + it->second = NULL; + } +} + + + +/////////////////////////////////////////////////////////////////////////////// + + +#include "RendererMemoryMacros.h" +#include "RendererMaterialDesc.h" +#include "RendererTexture2DDesc.h" + +// PT: text stuff from ICE. Adapted quickly, should be cleaned up when we have some time. + +struct FntInfo +{ + PxReal u0; + PxReal v0; + PxReal u1; + PxReal v1; + PxU32 dx; + PxU32 dy; +}; + +class FntData +{ +public: + FntData(); + ~FntData(); + + void Reset(); + PxU32 ComputeSize(const char* text, PxReal& width, PxReal& height, PxReal scale, bool forceFixWidthNumbers) const; + + bool Load(Renderer& renderer, const char* filename); + + PX_FORCE_INLINE PxU32 GetNbFnts() const { return mNbFnts; } + PX_FORCE_INLINE const FntInfo* GetFnts() const { return mFnts; } + PX_FORCE_INLINE PxU32 GetMaxDx() const { return mMaxDx; } + PX_FORCE_INLINE PxU32 GetMaxDy() const { return mMaxDy; } + PX_FORCE_INLINE const PxU8* GetXRef() const { return mXRef; } + PX_FORCE_INLINE PxU32 GetMaxDxNumbers() const { return mMaxDxNumbers; } + PX_FORCE_INLINE bool IsFixWidthCharacter(unsigned char c) const { return mFixWidthCharacters[c]; } + +private: + PxU32 mNbFnts; + FntInfo* mFnts; + PxU32 mMaxDx, mMaxDy; + PxU8 mXRef[256]; + bool mFixWidthCharacters[256]; + PxU32 mMaxDxNumbers; +public: + RendererTexture2D* mTexture; +}; + +FntData::FntData() +{ + mNbFnts = 0; + mFnts = NULL; + mMaxDx = 0; + mMaxDy = 0; + memset(mXRef, 0, 256*sizeof(PxU8)); + memset(mFixWidthCharacters, 0, 256 * sizeof(bool)); + for (int i = '0'; i <= '9'; i++) + { + mFixWidthCharacters[i] = true; + } + //mFixWidthCharacters[size_t(' ')] = true; + mFixWidthCharacters[size_t('.')] = true; + mFixWidthCharacters[size_t('+')] = true; + mFixWidthCharacters[size_t('-')] = true; + mFixWidthCharacters[size_t('*')] = true; + mFixWidthCharacters[size_t('/')] = true; + mMaxDxNumbers = 0; + mTexture = NULL; +} + +FntData::~FntData() +{ + Reset(); +} + +void FntData::Reset() +{ + SAFE_RELEASE(mTexture); + DELETEARRAY(mFnts); + mNbFnts = 0; + mMaxDx = 0; + mMaxDy = 0; + memset(mXRef, 0, 256*sizeof(PxU8)); + memset(mFixWidthCharacters, 0, 256 * sizeof(bool)); + mMaxDxNumbers = 0; +} + +// Compute size of a given text +PxU32 FntData::ComputeSize(const char* text, PxReal& width, PxReal& height, PxReal scale, bool forceFixWidthNumbers) const +{ + // Get and check length + if(!text) return 0; + PxU32 Nb = (PxU32)strlen((const char*)text); + if(!Nb) return 0; + + PxReal x = 0.0f; + PxReal y = 0.0f; + + width = -1.0f; + height = -1.0f; + + // Loop through characters + for(PxU32 j=0;j<Nb;j++) + { + if(text[j]!='\n') + { + // Catch current character index + const PxU32 i = mXRef[(unsigned char)(text[j])]; + + // Catch size of current character + const PxReal sx = PxReal((forceFixWidthNumbers && mFixWidthCharacters[(size_t)text[j]]) ? mMaxDxNumbers : mFnts[i].dx) * scale; + const PxReal sy = PxReal(mFnts[i].dy) * scale; + + // Keep track of greatest dimensions + if((x+sx)>width) width = x+sx; + if((y+sy)>height) height = y+sy; + + // Adjust x for next character + x += sx + 1.0f; + } + else + { + // Jump to next line + x = 0.0f; + y += PxReal(mMaxDy) * scale; + } + } + return Nb; +} + +#include "PxTkFile.h" + +#if PX_INTEL_FAMILY +static const bool gFlip = false; +#elif PX_PPC +static const bool gFlip = true; +#elif PX_ARM_FAMILY +static const bool gFlip = false; +#else +#error Unknown platform! +#endif + +PX_INLINE void Flip(PxU32& v) +{ + PxU8* b = (PxU8*)&v; + + PxU8 temp = b[0]; + b[0] = b[3]; + b[3] = temp; + temp = b[1]; + b[1] = b[2]; + b[2] = temp; +} + +PX_INLINE void Flip(PxI32& v) +{ + Flip((PxU32&)v); +} + +PX_INLINE void Flip(PxF32& v) +{ + Flip((PxU32&)v); +} + +static PxU32 read32(File* fp) +{ + PxU32 data; + size_t numRead = fread(&data, 1, 4, fp); + if(numRead != 4) { fclose(fp); return 0; } + if(gFlip) + Flip(data); + return data; +} + +bool FntData::Load(Renderer& renderer, const char* filename) +{ + File* fp = NULL; + PxToolkit::fopen_s(&fp, filename, "rb"); + if(!fp) + return false; + + // Init texture + { + const PxU32 width = read32(fp); + const PxU32 height = read32(fp); + PxU8* data = new PxU8[width*height*4]; + const size_t size = width*height*4; + size_t numRead = fread(data, 1, size, fp); + if(numRead != size) { fclose(fp); return false; } + + /* if(gFlip) + { + PxU32* data32 = (PxU32*)data; + for(PxU32 i=0;i<width*height;i++) + { + Flip(data32[i]); + } + }*/ + + RendererTexture2DDesc tdesc; + tdesc.format = RendererTexture2D::FORMAT_B8G8R8A8; + tdesc.width = width; + tdesc.height = height; + tdesc.filter = RendererTexture2D::FILTER_ANISOTROPIC; + tdesc.numLevels = 1; + /* + tdesc.filter; + tdesc.addressingU; + tdesc.addressingV; + tdesc.renderTarget; + */ + PX_ASSERT(tdesc.isValid()); + mTexture = renderer.createTexture2D(tdesc); + PX_ASSERT(mTexture); + if(!mTexture) + { + DELETEARRAY(data); + fclose(fp); + return false; + } + + const PxU32 componentCount = 4; + + if(mTexture) + { + PxU32 pitch = 0; + void* buffer = mTexture->lockLevel(0, pitch); + PX_ASSERT(buffer); + if(buffer) + { + PxU8* levelDst = (PxU8*)buffer; + const PxU8* levelSrc = (PxU8*)data; + const PxU32 levelWidth = mTexture->getWidthInBlocks(); + const PxU32 levelHeight = mTexture->getHeightInBlocks(); + PX_ASSERT(levelWidth * mTexture->getBlockSize() <= pitch); // the pitch can't be less than the source row size. + for(PxU32 row=0; row<levelHeight; row++) + { + // copy per pixel to handle RBG case, based on component count + for(PxU32 col=0; col<levelWidth; col++) + { + *levelDst++ = levelSrc[0]; + *levelDst++ = levelSrc[1]; + *levelDst++ = levelSrc[2]; + *levelDst++ = levelSrc[3]; + levelSrc += componentCount; + } + } + } + mTexture->unlockLevel(0); + } + DELETEARRAY(data); + } + + mNbFnts = read32(fp); + + mFnts = new FntInfo[mNbFnts]; + const size_t size = mNbFnts*sizeof(FntInfo); + size_t numRead = fread(mFnts, 1, size, fp); + if(numRead != size) { fclose(fp); return false; } + if(gFlip) + { + for(PxU32 i=0;i<mNbFnts;i++) + { + Flip(mFnts[i].u0); + Flip(mFnts[i].v0); + Flip(mFnts[i].u1); + Flip(mFnts[i].v1); + Flip(mFnts[i].dx); + Flip(mFnts[i].dy); + } + } + + mMaxDx = read32(fp); + mMaxDy = read32(fp); + + const size_t xRefSize = 256*sizeof(PxU8); + numRead = fread(mXRef, 1, xRefSize, fp); + if(numRead != xRefSize) { fclose(fp); return false; } + + for (unsigned int c = 0; c < 256; c++) + { + if (mFixWidthCharacters[c]) + { + mMaxDxNumbers = PxMax(mFnts[mXRef[c]].dx, mMaxDxNumbers); + } + } + + fclose(fp); + return true; +} + + +struct ClipBox +{ + PxReal mXMin; + PxReal mYMin; + PxReal mXMax; + PxReal mYMax; +}; + +static bool ClipQuad(Renderer::TextVertex* /*quad*/, const ClipBox& /*clip_box*/) +{ + return true; +} + +static bool GenerateTextQuads( const char* text, PxU32 nb_characters, + Renderer::TextVertex* fnt_verts, PxU16* fnt_indices, const ClipBox& clip_box, const FntData* fnt_data, PxReal& x, PxReal& y, PxReal scale_x, PxReal scale_y, PxU32 color, + PxReal* x_min, PxReal* y_min, PxReal* x_max, PxReal* y_max, PxU32* nb_lines, PxU32* nb_active_characters, bool forceFixWidthNumbers) +{ + // Checkings + if(!text || !fnt_verts || !fnt_indices || !fnt_data) return false; + + PxReal mX = x; + + ////////// + + Renderer::TextVertex* V = fnt_verts; + PxU16* I = fnt_indices; + PxU16 Offset = 0; + PxU32 NbActiveCharacters = 0; // Number of non-NULL characters (the ones to render) + + PxReal XMin = 100000.0f, XMax = -100000.0f; + PxReal YMin = 100000.0f, YMax = -100000.0f; + + PxU32 NbLines = 1; // Number of lines + + // Loop through characters + for(PxU32 j=0;j<nb_characters;j++) + { + if(text[j]!='\n') + { + PxU32 i = fnt_data->GetXRef()[(size_t)text[j]]; + const FntInfo character = fnt_data->GetFnts()[i]; + + // Character size + const PxReal sx = PxReal(character.dx) * scale_x; + const PxReal sy = PxReal(character.dy) * scale_y; + + if (forceFixWidthNumbers && fnt_data->IsFixWidthCharacter(text[j])) + { + // move forward half the distance + x += (fnt_data->GetMaxDxNumbers() - character.dx) * scale_x * 0.5f; + } + + if(text[j]!=' ') + { + const PxReal rhw = 1.0f; + + + // Initialize the vertices + V[0].p.x = x; V[0].p.y = y+sy; V[0].u = character.u0; V[0].v = character.v1; + V[1].p.x = x; V[1].p.y = y; V[1].u = character.u0; V[1].v = character.v0; + V[2].p.x = x+sx; V[2].p.y = y+sy; V[2].u = character.u1; V[2].v = character.v1; + V[3].p.x = x+sx; V[3].p.y = y; V[3].u = character.u1; V[3].v = character.v0; + V[0].rhw = V[1].rhw = V[2].rhw = V[3].rhw = rhw; + V[0].p.z = V[1].p.z = V[2].p.z = V[3].p.z = 0.0f; + V[0].color = V[1].color = V[2].color = V[3].color = color; + + if(ClipQuad(V, clip_box)) + { + V+=4; + + // Initialize the indices + *I++ = Offset+0; + *I++ = Offset+1; + *I++ = Offset+2; + *I++ = Offset+2; + *I++ = Offset+1; + *I++ = Offset+3; + Offset+=4; + + NbActiveCharacters++; + } + } + + if (forceFixWidthNumbers && fnt_data->IsFixWidthCharacter(text[j])) + { + // move forward theo ther half of the distance + x += (fnt_data->GetMaxDxNumbers() - character.dx) * scale_x * 0.5f; + } + + // + if((x+sx)>XMax) XMax = x+sx; if(x<XMin) XMin = x; + if((y+sy)>YMax) YMax = y+sy; if(y<YMin) YMin = y; + + x += sx + 1.0f; + } + else + { + // Jump to next line + x = mX; + y += PxReal(fnt_data->GetMaxDy()) * scale_y; + NbLines++; + } + } + + if(x_min) *x_min = XMin; + if(y_min) *y_min = YMin; + if(x_max) *x_max = XMax; + if(y_max) *y_max = YMax; + if(nb_lines) *nb_lines = NbLines; + if(nb_active_characters) *nb_active_characters = NbActiveCharacters; + + return true; +} + +enum RenderTextQuadFlag_ +{ + RTQF_ALIGN_LEFT = 0, + RTQF_ALIGN_CENTER = (1<<0), + RTQF_ALIGN_RIGHT = (1<<1), +}; + +struct RenderTextData +{ + RenderTextData(Renderer::TextVertex* pFntVerts, PxU16* pFntIndices) + : mpFntVerts(pFntVerts), mpFntIndices(pFntIndices) { } + + ~RenderTextData() + { + DELETEARRAY(mpFntVerts); + DELETEARRAY(mpFntIndices); + } + + Renderer::TextVertex* mpFntVerts; + PxU16* mpFntIndices; + +private: + // Disable default, copy and assign + RenderTextData(); + RenderTextData(const RenderTextData&); + void operator=(const RenderTextData&); +}; + +static void RenderTextQuads(Renderer* textRender, + const FntData* fnts, + const char* text, PxReal x, PxReal y, PxU32 text_color, PxU32 shadow_color, + PxReal scale_x, PxReal scale_y, + PxU32 align_flags, PxReal max_length, + PxReal shadow_offset, + PxReal* nx, PxReal* ny, + const ClipBox* clip_box, + PxReal text_y_offset, + bool use_max_dy, + bool forceFixWidthNumbers, + RendererMaterial* material + ) +{ + // We want to render the whole text in one run... + const PxReal text_x = x; + const PxReal text_y = y; + + // Compute text size + PxReal Width, Height; + const PxU32 NbCharacters = fnts->ComputeSize(text, Width, Height, 1.0f, forceFixWidthNumbers); + + // Prepare clip box + ClipBox CB; + if(clip_box) + { + CB = *clip_box; + } + else + { + PxU32 width, height; + textRender->getWindowSize(width, height); + + const PxReal Margin = 0.0f; + CB.mXMin = Margin; + CB.mYMin = Margin; + CB.mXMax = PxReal(width) - Margin; + CB.mYMax = PxReal(height) - Margin; + } + + // Allocate space for vertices + RenderTextData FntData(new Renderer::TextVertex[NbCharacters*4], new PxU16[NbCharacters*6]); + + // Generate quads + PxReal XMin, YMin, XMax, YMax; + PxU32 NbLines, NbActiveCharacters; + GenerateTextQuads(text, NbCharacters, FntData.mpFntVerts, FntData.mpFntIndices, CB, fnts, x, y, scale_x, scale_y, text_color, &XMin, &YMin, &XMax, &YMax, &NbLines, &NbActiveCharacters, forceFixWidthNumbers); + + for(PxU32 i=0;i<NbActiveCharacters*4;i++) + FntData.mpFntVerts[i].p.y += text_y_offset; + + if(use_max_dy) + YMax = YMin + (PxReal)fnts->GetMaxDy(); + + const bool centered = (align_flags & RTQF_ALIGN_CENTER)!=0; + const bool align_right = (align_flags & RTQF_ALIGN_RIGHT)!=0; + + if(centered || align_right) + { + const PxReal L = XMax - XMin; + XMax = XMin + max_length; + const PxReal Offset = centered ? (-FntData.mpFntVerts[0].p.x + XMin + (max_length - L)*0.5f) : + (-FntData.mpFntVerts[0].p.x + XMax - L); + // (-FntVerts[0].p.x + XMin + (max_length - L)); + for(PxU32 i=0;i<NbActiveCharacters*4;i++) + FntData.mpFntVerts[i].p.x += Offset; + } + + textRender->setupTextRenderStates(); + + // Handle shadow + if(shadow_offset!=0.0f) + { + // Allocate space for vertices + RenderTextData SFntData(new Renderer::TextVertex[NbCharacters*4], new PxU16[NbCharacters*6]); + + // Generate quads + PxReal SXMin, SYMin, SXMax, SYMax; + PxU32 SNbLines, SNbActiveCharacters; + PxReal ShX = text_x + shadow_offset; + PxReal ShY = text_y + shadow_offset; + GenerateTextQuads(text, NbCharacters, SFntData.mpFntVerts, SFntData.mpFntIndices, CB, fnts, ShX, ShY, scale_x, scale_y, shadow_color, &SXMin, &SYMin, &SXMax, &SYMax, &SNbLines, &SNbActiveCharacters, forceFixWidthNumbers); + + for(PxU32 i=0;i<SNbActiveCharacters*4;i++) + SFntData.mpFntVerts[i].p.y += text_y_offset; + + if(centered || align_right) + { + const PxReal L = SXMax - SXMin; + SXMax = SXMin + max_length; + const PxReal Offset = centered ? (-SFntData.mpFntVerts[0].p.x + SXMin + (max_length - L)*0.5f) : + (-SFntData.mpFntVerts[0].p.x + SXMax - L); + for(PxU32 i=0;i<SNbActiveCharacters*4;i++) + SFntData.mpFntVerts[i].p.x += Offset; + } + + textRender->renderTextBuffer(SFntData.mpFntVerts, 4*SNbActiveCharacters, SFntData.mpFntIndices, 6*SNbActiveCharacters, material); + } + + textRender->renderTextBuffer(FntData.mpFntVerts, 4*NbActiveCharacters, FntData.mpFntIndices, 6*NbActiveCharacters, material); + + textRender->resetTextRenderStates(); +} + + +static FntData* gFntData = NULL; + + +bool Renderer::initTexter() +{ + if(gFntData) + return true; + + char filename[1024]; + Ps::strlcpy(filename, sizeof(filename), getAssetDir()); + Ps::strlcat(filename, sizeof(filename), "fonts/arial_black.bin"); + + gFntData = new FntData; + if(!gFntData->Load(*this, filename)) + { + closeTexter(); + return false; + } + + { + RendererMaterialDesc matDesc; + matDesc.alphaTestFunc = RendererMaterial::ALPHA_TEST_ALWAYS; + matDesc.alphaTestRef = 0.0f; + matDesc.type = RendererMaterial::TYPE_UNLIT; + matDesc.blending = true; + matDesc.srcBlendFunc = RendererMaterial::BLEND_SRC_ALPHA; + matDesc.dstBlendFunc = RendererMaterial::BLEND_ONE_MINUS_SRC_ALPHA; + matDesc.geometryShaderPath = NULL; + matDesc.vertexShaderPath = "vertex/text.cg"; + matDesc.fragmentShaderPath = "fragment/text.cg"; + PX_ASSERT(matDesc.isValid()); + + m_textMaterial = createMaterial(matDesc); + if(!m_textMaterial) + { + closeTexter(); + return false; + } + + m_textMaterialInstance = new RendererMaterialInstance(*m_textMaterial); + if(!m_textMaterialInstance) + { + closeTexter(); + return false; + } + + const RendererMaterial::Variable* var = m_textMaterial->findVariable("diffuseTexture", RendererMaterial::VARIABLE_SAMPLER2D); + if(!var) + { + closeTexter(); + return false; + } + m_textMaterialInstance->writeData(*var, &(gFntData->mTexture)); + } + + return true; +} + +void Renderer::closeTexter() +{ + DELETESINGLE(m_textMaterialInstance); + SAFE_RELEASE(m_textMaterial); + DELETESINGLE(gFntData); +} + +// splits string by delimeter +#if defined(RENDERER_TABLET) +static std::vector<std::string> &split(const std::string &s, char delim, std::vector<std::string> &elems) { + std::stringstream ss(s); + std::string item; + while(std::getline(ss, item, delim)) { + elems.push_back(item); + } + return elems; +} + +static std::vector<std::string> split(const std::string &s, char delim) { + std::vector<std::string> elems; + return split(s, delim, elems); +} +#endif + +void SampleRenderer::Renderer::print(PxU32* x, PxU32* y, const char** text, PxU32 textCount, PxReal scale, PxReal shadowOffset, RendererColor* textColors, bool forceFixWidthNumbers) +{ + // we split string containing '\n' in a vector of strings. This prevents from need to have a really big vertex/index buffer for text in GLES2 renderer +#if defined(RENDERER_TABLET) + if(std::string(*text).find('\n') != std::string::npos) { + std::vector<std::string> strings = split(*text, '\n'); + PxU32 nx = *x, ny = *y; + for(PxU32 i = 0; i < strings.size(); ++i) + { + const char* sptr = strings[i].c_str(); + print(&nx, &ny, &sptr, 1, scale, shadowOffset, textColors, forceFixWidthNumbers); + ny += TEXT_HEIGHT + TEXT_VERTICAL_SPACING; + } + return; + } +#endif + + if(!gFntData || !gFntData->mTexture || !m_textMaterial || !m_textMaterialInstance || 0==textCount || NULL==x || NULL==y || NULL==text || 0 == *text || (*text)[0] == '\0') + return; + + ScopedRender renderSection(*this); + if (renderSection) + { + m_textMaterial->bind(RendererMaterial::PASS_UNLIT, m_textMaterialInstance, false); + + if(!m_useShadersForTextRendering) + { + m_textMaterial->unbind(); + gFntData->mTexture->select(0); + } + + const PxU32 alignFlags = 0; + const float maxLength = 0.0f; + float* nx = NULL; + float* ny = NULL; + const ClipBox* clipBox = NULL; + const float textYOffset = 0.0f; + const bool useMaxDy = false; + const RendererColor defaultColor(255, 255, 255, 255); + +#if defined(RENDERER_TABLET) + shadowOffset = 0.0f; +#endif + + for (PxU32 i = 0; i < textCount; ++i) + { + const PxU32 color = convertColor(textColors ? textColors[i] : defaultColor); + const PxU32 shadowColor = convertColor(textColors ? RendererColor(0,0,0,textColors[i].a) : RendererColor(0,0,0,defaultColor.a)); + + RenderTextQuads(this, + gFntData, + text[i], + PxReal(x[i]), PxReal(y[i]), + color, shadowColor, + scale, scale, + alignFlags, + maxLength, + shadowOffset * scale, + nx, ny, + clipBox, + textYOffset, + useMaxDy, + forceFixWidthNumbers, + m_textMaterial + ); + } + + if(m_useShadersForTextRendering) + m_textMaterial->unbind(); + } +} + +bool SampleRenderer::Renderer::captureScreen(const char* filename) +{ + if(!filename) + return false; + + physx::PxU32 width, height, sizeInBytes; + const void* data = NULL; + if (captureScreen(width, height, sizeInBytes, data) && sizeInBytes > 0) + { + PxDefaultFileOutputStream fileBuffer(filename); + return fileBuffer.write(data, sizeInBytes) > 0; + } + else + { + return false; + } +} + + +void Renderer::print(PxU32 x, PxU32 y, const char* text, PxReal scale, PxReal shadowOffset, RendererColor textColor, bool forceFixWidthNumbers) +{ + if (NULL == text || strlen(text) <= 0) + return; + print(&x, &y, &text, 1, scale, shadowOffset, &textColor, forceFixWidthNumbers); +} + +/////////////////////////////////////////////////////////////////////////////// + +bool Renderer::initScreenquad() +{ + RendererMaterialDesc matDesc; + matDesc.alphaTestFunc = RendererMaterial::ALPHA_TEST_ALWAYS; + matDesc.alphaTestRef = 0.0f; + matDesc.type = RendererMaterial::TYPE_UNLIT; + matDesc.blending = false; + matDesc.vertexShaderPath = "vertex/screenquad.cg"; + matDesc.fragmentShaderPath = "fragment/screenquad.cg"; + matDesc.geometryShaderPath = NULL; +#if defined(RENDERER_TABLET) + matDesc.srcBlendFunc = RendererMaterial::BLEND_SRC_ALPHA; + matDesc.dstBlendFunc = RendererMaterial::BLEND_ONE_MINUS_SRC_ALPHA; +#else + matDesc.srcBlendFunc = RendererMaterial::BLEND_ONE; + matDesc.dstBlendFunc = RendererMaterial::BLEND_ONE; +#endif + PX_ASSERT(matDesc.isValid()); + + m_screenquadOpaqueMaterial = createMaterial(matDesc); + if(!m_screenquadOpaqueMaterial) + { + closeScreenquad(); + return false; + } + + m_screenquadOpaqueMaterialInstance = new RendererMaterialInstance(*m_screenquadOpaqueMaterial); + if(!m_screenquadOpaqueMaterialInstance) + { + closeScreenquad(); + return false; + } + + matDesc.blending = true; + matDesc.srcBlendFunc = RendererMaterial::BLEND_SRC_ALPHA; + matDesc.dstBlendFunc = RendererMaterial::BLEND_ONE_MINUS_SRC_ALPHA; + + m_screenquadAlphaMaterial = createMaterial(matDesc); + if(!m_screenquadAlphaMaterial) + { + closeScreenquad(); + return false; + } + + m_screenquadAlphaMaterialInstance = new RendererMaterialInstance(*m_screenquadAlphaMaterial); + if(!m_screenquadAlphaMaterialInstance ) + { + closeScreenquad(); + return false; + } + + return true; +} + +#if defined(RENDERER_TABLET) +void Renderer::setControlPosition(int ctrl_idx, const PxVec2& pos) +{ + if(ctrl_idx < CONTROL_COUNT) + { + m_controlPos[ctrl_idx] = pos; + } +} + +#include "foundation/PxBounds3.h" + +PxBounds3 Renderer::getCenteredControlBounds(int ctrl_idx) +{ + /* Return PxBounds3 with positive volume */ + return PxBounds3( + PxVec3(m_controlCenteredPos[ctrl_idx].x - m_controlHalfSize.x, m_controlCenteredPos[ctrl_idx].y - m_controlHalfSize.y, -1.0f), + PxVec3(m_controlCenteredPos[ctrl_idx].x + m_controlHalfSize.x, m_controlCenteredPos[ctrl_idx].y + m_controlHalfSize.y, 1.0f)); +} + +PxBounds3 Renderer::getControlBounds(int ctrl_idx) +{ + /* Return PxBounds3 with positive volume */ + return PxBounds3( + PxVec3(m_controlPos[ctrl_idx].x - m_controlHalfSize.x, m_controlPos[ctrl_idx].y - m_controlHalfSize.y, -1.0f), + PxVec3(m_controlPos[ctrl_idx].x + m_controlHalfSize.x, m_controlPos[ctrl_idx].y + m_controlHalfSize.y, 1.0f)); +} + +PxVec2 Renderer::getControlPosition(int ctrl_idx) +{ + return m_controlPos[ctrl_idx]; +} + +PxVec2 Renderer::getCenteredControlPosition(int ctrl_idx) +{ + return m_controlCenteredPos[ctrl_idx]; +} + +bool Renderer::initControls(RendererMaterial* controlMaterial, RendererMaterialInstance* controlMaterialInstance) +{ + // create quad control + using physx::PxReal; + using physx::PxU32; + using physx::PxU8; + + m_controlMaterial = controlMaterial; + m_controlMaterialInstance = controlMaterialInstance; + + // compute control dimensions and placement according to window aspect + // screen coordinate range: [-1,1] + PxVec2 controlSize; + PxVec2 controlCenterOffset; + { + PxU32 width, height; + getWindowSize(width, height); + + PX_ASSERT(width > 0 && height > 0); + PX_ASSERT(gControlSizeRelative > 0.0f && gControlSizeRelative < 0.5f); + PX_ASSERT(gControlMarginRelative > 0.0f && gControlMarginRelative < 0.5f); + + //size and margin should be relative to smaller screen dimension + if (width > height) + { + PxReal aspect = (PxReal)height/(PxReal)width; + controlSize.y = 2.0f*gControlSizeRelative; + controlSize.x = controlSize.y * aspect; + controlCenterOffset.y = 1.0f - controlSize.y*0.5f - 2.0f*gControlMarginRelative; + controlCenterOffset.x = 1.0f - controlSize.x*0.5f - 2.0f*gControlMarginRelative*aspect; + } + else + { + PxReal aspect = (PxReal)width/(PxReal)height; + controlSize.x = 2.0f*gControlSizeRelative; + controlSize.y = controlSize.x * aspect; + controlCenterOffset.x = 1.0f - controlSize.x*0.5f - 2.0f*gControlMarginRelative; + controlCenterOffset.y = 1.0f - controlSize.y*0.5f - 2.0f*gControlMarginRelative*aspect; + } + } + + m_controlHalfSize = controlSize*0.5f; + + /* Initialize sticks positions - default and current */ + m_controlCenteredPos[0].x = -controlCenterOffset.x; + m_controlCenteredPos[0].y = -controlCenterOffset.y; + m_controlCenteredPos[1].x = controlCenterOffset.x; + m_controlCenteredPos[1].y = -controlCenterOffset.y; + m_controlPos[0] = m_controlCenteredPos[0]; + m_controlPos[1] = m_controlCenteredPos[1]; + + PxReal controlVertices[] = { + -m_controlHalfSize.x, -m_controlHalfSize.y, 0.0f, + -m_controlHalfSize.x, m_controlHalfSize.y, 0.0f, + m_controlHalfSize.x, -m_controlHalfSize.y, 0.0f, + m_controlHalfSize.x, m_controlHalfSize.y, 0.0f }; + + PxReal controlTexcoords[] = { + 0.0f, 0.0f, // each face + 0.0f, 1.0f, + 1.0f, 0.0f, + 1.0f, 1.0f }; + + const PxU32 controlVerticesCount = sizeof(controlVertices) / (sizeof(controlVertices[0]) * 3); + + m_controlMesh[0] = initControl(controlVertices, controlTexcoords, controlVerticesCount); + + for(int i = 0; i < controlVerticesCount; ++i) + controlVertices[3 * i] = -controlVertices[3 * i]; + + m_controlMesh[1] = initControl(controlVertices, controlTexcoords, controlVerticesCount); + + return true; +} + +void Renderer::setControlDefaultPosition(int ctrl_idx) +{ + m_controlPos[ctrl_idx] = m_controlCenteredPos[ctrl_idx]; +} + +RendererMesh* Renderer::initControl(PxReal* controlVertices, PxReal* controlTexcoords, PxU32 count) +{ + const PxU32 controlVerticesCount = count; + + RendererVertexBufferDesc vbdesc; + vbdesc.hint = RendererVertexBuffer::HINT_STATIC; + vbdesc.maxVertices = controlVerticesCount; + vbdesc.semanticFormats[RendererVertexBuffer::SEMANTIC_POSITION] = RendererVertexBuffer::FORMAT_FLOAT3; + vbdesc.semanticFormats[RendererVertexBuffer::SEMANTIC_TEXCOORD0] = RendererVertexBuffer::FORMAT_FLOAT2; + RendererVertexBuffer* mVertexBuffer = createVertexBuffer(vbdesc); + RendererMesh* controlMesh = NULL; + if(mVertexBuffer) + { + RendererMeshDesc meshdesc; + meshdesc.primitives = RendererMesh::PRIMITIVE_TRIANGLE_STRIP; + meshdesc.vertexBuffers = &mVertexBuffer; + meshdesc.numVertexBuffers = 1; + meshdesc.firstVertex = 0; + meshdesc.numVertices = mVertexBuffer->getMaxVertices(); + meshdesc.indexBuffer = NULL; + meshdesc.firstIndex = 0; + meshdesc.numIndices = 0; + meshdesc.instanceBuffer = NULL; + meshdesc.firstInstance = 0; + meshdesc.numInstances = 0; + controlMesh = createMesh(meshdesc); + RENDERER_ASSERT(controlMesh, "Failed to create Mesh."); + } + PxU32 positionStride = 0, texcoordStride = 0; + PxU8* locked_positions = static_cast<PxU8*>(mVertexBuffer->lockSemantic(RendererVertexBuffer::SEMANTIC_POSITION, positionStride)); + PxU8* locked_texcoords = static_cast<PxU8*>(mVertexBuffer->lockSemantic(RendererVertexBuffer::SEMANTIC_TEXCOORD0, texcoordStride)); + for(PxU32 i = 0; i < controlVerticesCount; ++i, + locked_positions += positionStride, + locked_texcoords += texcoordStride) + { + memcpy(locked_positions, controlVertices + 3 * i, sizeof(PxReal) * 3); + memcpy(locked_texcoords, controlTexcoords + 2 * i , sizeof(PxReal) * 2); + } + mVertexBuffer->unlockSemantic(RendererVertexBuffer::SEMANTIC_TEXCOORD0); + mVertexBuffer->unlockSemantic(RendererVertexBuffer::SEMANTIC_POSITION); + return controlMesh; +} + +Renderer::TabletButton::TabletButton() : + pressedCount(0), + emulatedKeyCode(0), + defaultColor(PxVec4(1.0f, 1.0f, 1.0f, 0.4f)), + pressedColor(PxVec4(1.0f, 0.0f, 0.0f, 0.4f)), + callback(NULL) +{ +} + + +void Renderer::TabletButton::setPressedCount(physx::PxU8 p) +{ + pressedCount = p; +} + +void Renderer::TabletButton::incPressed() +{ + pressedCount++; +} + +void Renderer::TabletButton::decPressed() +{ + //sschirm: this caused issues on switching samples, because the OS keeps the touch states. + //PX_ASSERT(pressedCount); + if(pressedCount > 0) + pressedCount--; +} + +void Renderer::addButton(const PxVec2& leftBottom, const PxVec2& rightTop, void (*func_ptr)(), RendererMaterial* controlMaterial, + RendererMaterialInstance* controlMaterialInstance) +{ + /* Create button object and save into the vector */ + TabletButton button; + button.leftBottom = leftBottom; + button.rightTop = rightTop; + button.emulatedKeyCode = 0; + button.text = "Empty"; + button.callback = func_ptr; + /* Create graphic representation of the button. That is, quad. */ + PxReal buttonVertices[] = { leftBottom.x, leftBottom.y, 0.0f, + leftBottom.x, rightTop.y, 0.0f, + rightTop.x, leftBottom.y, 0.0f, + rightTop.x, rightTop.y, 0.0f }; + + /* Use full texture */ + PxReal buttonTexcoords[] = { 0.0f, 0.0f, + 0.0f, 1.0f, + 1.0f, 0.0f, + 1.0f, 1.0f}; + const PxU32 buttonVerticesCount = sizeof(buttonVertices) / (sizeof(buttonVertices[0]) * 3); + button.mesh = initControl(buttonVertices, buttonTexcoords, buttonVerticesCount); + button.material = controlMaterial; + button.materialInstance = controlMaterialInstance; + button.setPressedCount(0); + + m_buttons.push_back(button); +} + +void Renderer::releaseAllButtons() +{ + m_buttons.clear(); +} + +void Renderer::bindButtonToUserInput(size_t buttonIndex, physx::PxU16 userInputId, const char* buttonName) +{ + PX_ASSERT(m_buttons.size() > buttonIndex); + + TabletButton& button = m_buttons[buttonIndex]; + button.emulatedKeyCode = userInputId; + button.text = buttonName; +} +#endif // RENDERER_TABLET + + +void Renderer::closeScreenquad() +{ + DELETESINGLE(m_screenquadAlphaMaterialInstance); + SAFE_RELEASE(m_screenquadAlphaMaterial); + DELETESINGLE(m_screenquadOpaqueMaterialInstance); + SAFE_RELEASE(m_screenquadOpaqueMaterial); +} + +ScreenQuad::ScreenQuad() : + mLeftUpColor (0xffffffff), + mLeftDownColor (0xffffffff), + mRightUpColor (0xffffffff), + mRightDownColor (0xffffffff), + mAlpha (1.0f), + mX0 (0.0f), + mY0 (0.0f), + mX1 (1.0f), + mY1 (1.0f) +{ +} + +bool Renderer::drawScreenQuad(const ScreenQuad& screenQuad) +{ + RendererMaterial* screenquadMaterial; + RendererMaterialInstance* screenquadMaterialInstance; + if(screenQuad.mAlpha==1.0f) + { + screenquadMaterial = m_screenquadOpaqueMaterial; + screenquadMaterialInstance = m_screenquadOpaqueMaterialInstance; + } + else + { + screenquadMaterial = m_screenquadAlphaMaterial; + screenquadMaterialInstance = m_screenquadAlphaMaterialInstance; + } + + if(!screenquadMaterialInstance || !screenquadMaterial) + return false; + + screenquadMaterial->bind(RendererMaterial::PASS_UNLIT, screenquadMaterialInstance, false); + if(!m_useShadersForTextRendering) + screenquadMaterial->unbind(); + + ScopedRender renderSection(*this); + if(renderSection) + { + setupScreenquadRenderStates(); + + TextVertex Verts[4]; + const PxU16 Indices[6] = { 0,1,2,2,1,3 }; + + PxU32 renderWidth, renderHeight; + getWindowSize(renderWidth, renderHeight); + + // Initalize the vertices + const PxReal xCoeff = PxReal(renderWidth); + const PxReal yCoeff = PxReal(renderHeight); + const PxReal x0 = screenQuad.mX0 * xCoeff; + const PxReal y0 = screenQuad.mY0 * yCoeff; + const PxReal sx = screenQuad.mX1 * xCoeff; + const PxReal sy = screenQuad.mY1 * yCoeff; + const PxReal rhw = 1.0f; + const PxReal z = 0.0f; + + RendererColor leftUpColor = screenQuad.mLeftUpColor; + RendererColor leftDownColor = screenQuad.mLeftDownColor; + RendererColor rightUpColor = screenQuad.mRightUpColor; + RendererColor rightDownColor = screenQuad.mRightDownColor; + const PxU8 alpha = PxU8(screenQuad.mAlpha*255.0f); + leftUpColor.a = alpha; + leftDownColor.a = alpha; + rightUpColor.a = alpha; + rightDownColor.a = alpha; + + Verts[0].p = PxVec3(x0, sy, z); Verts[0].rhw = rhw; Verts[0].color = convertColor(leftDownColor); + Verts[1].p = PxVec3(x0, y0, z); Verts[1].rhw = rhw; Verts[1].color = convertColor(leftUpColor); + Verts[2].p = PxVec3(sx, sy, z); Verts[2].rhw = rhw; Verts[2].color = convertColor(rightDownColor); + Verts[3].p = PxVec3(sx, y0, z); Verts[3].rhw = rhw; Verts[3].color = convertColor(rightUpColor); + + renderTextBuffer(Verts, 4, Indices, 6, screenquadMaterial); + resetScreenquadRenderStates(); + } + + if(m_useShadersForTextRendering) + screenquadMaterial->unbind(); + + return true; +} + +bool Renderer::drawTouchControls() +{ +#if defined(RENDERER_TABLET) + renderControls(); + renderButtons(); +#endif + return true; +} + +#ifdef RENDERER_TABLET +void Renderer::renderControls() +{ + m_controlMaterial->bind(RendererMaterial::PASS_UNLIT, m_controlMaterialInstance, false); + for(int i = 0; i < PX_ARRAY_SIZE(m_controlMesh); ++i) + { + RendererMeshContext ctx; + PxReal zero = 0; + physx::PxMat44 ctrl_transform(PxVec4(m_controlPos[i].x, zero, zero, zero), + PxVec4(m_controlPos[i].y, zero, zero, zero), + PxVec4(m_controlPos[i].x, zero, zero, zero), + PxVec4(zero, zero, zero, zero)); + ctx.cullMode = RendererMeshContext::NONE; + ctx.transform = &ctrl_transform; + bindMeshContext(ctx); + m_controlMesh[i]->bind(); + m_controlMesh[i]->render(m_controlMaterial); + m_controlMesh[i]->unbind(); + } + m_controlMaterial->unbind(); +} + +std::vector<Renderer::TabletButton>& Renderer::screenButtons() +{ + return m_buttons; +} + +void Renderer::renderButtons() +{ + if(m_buttons.size()) + { + for(PxU32 i = 0; i < m_buttons.size(); ++i) + { + // if the button is not used do not draw it + if(m_buttons[i].emulatedKeyCode == 0) + continue; + + const PxVec4& color = m_buttons[i].pressedCount ? m_buttons[i].pressedColor : m_buttons[i].defaultColor; + const RendererMaterial::Variable* var = m_buttons[i].materialInstance->findVariable("diffuseColor", RendererMaterial::VARIABLE_FLOAT4); + if(var) + { + const PxReal data[] = { color.x, color.y, color.z, color.w }; + m_buttons[i].materialInstance->writeData(*var, data); + } + + m_buttons[i].material->bind(RendererMaterial::PASS_UNLIT, m_buttons[i].materialInstance, false); + RendererMeshContext ctx; + physx::PxMat44 ctrl_transform(PxVec4(0.0f)); + ctx.cullMode = RendererMeshContext::NONE; + ctx.transform = &ctrl_transform; + + bindMeshContext(ctx); + + m_buttons[i].mesh->bind(); + m_buttons[i].mesh->render(m_buttons[i].material); + m_buttons[i].mesh->unbind(); + m_buttons[i].material->unbind(); + } + for(PxU32 i = 0; i < m_buttons.size(); ++i) + { + if(m_buttons[i].emulatedKeyCode == 0) + continue; + + /* TODO: It seems that characters has variable width, so this code is not entirely valid, + even though it makes it look better than just printing text starting from + the center of the button */ + const RendererColor textColor(255, 255, 255, 255); + const PxReal TEXT_CHARACTER_WIDTH = 12.0f; + const PxReal TEXT_CHARACTER_HEIGHT = 12.0f; + /* Convert relative buttons coordinates to the absolute screen coordinates */ + PxU32 width, height; + getWindowSize(width, height); + PxVec2 absoluteLeftBottom = PxVec2((m_buttons[i].leftBottom.x + 1.0f) * ((PxReal)width / 2.0f), -(m_buttons[i].leftBottom.y - 1.0f) * ((PxReal)height / 2.0f)); + PxVec2 absoluteRightTop = PxVec2((m_buttons[i].rightTop.x + 1.0f) * ((PxReal)width / 2.0f), -(m_buttons[i].rightTop.y - 1.0f) * ((PxReal)height / 2.0f)); + + PxVec2 absoluteCenter = (absoluteLeftBottom + absoluteRightTop) / 2.0f; + PxReal absoluteWidth = absoluteRightTop.x - absoluteLeftBottom.x; + + /* Leave empty space for half character near edges of the button */ + PxU8 characterToFit = (PxU8) (absoluteWidth / TEXT_CHARACTER_WIDTH - 1); + + std::string text; + PxVec2 textPos; + /* Shrink text if not enough space and decide where to start printing */ + if(characterToFit < m_buttons[i].text.size()) + { + textPos.x = absoluteLeftBottom.x + TEXT_CHARACTER_WIDTH / 2.0f; + text = m_buttons[i].text.substr(0, characterToFit); + } + else + { + textPos.x = absoluteCenter.x - ((PxReal)m_buttons[i].text.size() / 2.0f) * TEXT_CHARACTER_WIDTH; + text = m_buttons[i].text; + } + textPos.y = absoluteCenter.y - TEXT_CHARACTER_HEIGHT / 2.0f; + + + print((PxU32) textPos.x,(PxU32) textPos.y, text.c_str(), 0.5f, 6.0f, textColor, true); + } + } +} +#endif + +bool Renderer::drawLines2D(PxU32 nbVerts, const PxReal* vertices, const RendererColor& color) +{ + RendererMaterial* screenquadMaterial; + RendererMaterialInstance* screenquadMaterialInstance; + screenquadMaterial = m_screenquadOpaqueMaterial; + screenquadMaterialInstance = m_screenquadOpaqueMaterialInstance; + if(!screenquadMaterialInstance || !screenquadMaterial) + return false; + + screenquadMaterial->bind(RendererMaterial::PASS_UNLIT, screenquadMaterialInstance, false); + if(!m_useShadersForTextRendering) + screenquadMaterial->unbind(); + + setupScreenquadRenderStates(); + + TextVertex* verts = new TextVertex[nbVerts]; + + PxU32 renderWidth, renderHeight; + getWindowSize(renderWidth, renderHeight); + const PxReal xCoeff = PxReal(renderWidth); + const PxReal yCoeff = PxReal(renderHeight); + + const PxU32 convertedColor = convertColor(color); + + for(PxU32 i=0;i<nbVerts;i++) + { + verts[i].p.x = vertices[i*2+0] * xCoeff; + verts[i].p.y = vertices[i*2+1] * yCoeff; + verts[i].p.z = 0.0f; + verts[i].rhw = 1.0f; + verts[i].color = convertedColor; + verts[i].u = 0.0f; + verts[i].v = 0.0f; + } + + renderLines2D(verts, nbVerts); + + DELETEARRAY(verts); + + resetScreenquadRenderStates(); + if(m_useShadersForTextRendering) + screenquadMaterial->unbind(); + + return true; +} + +bool Renderer::drawLines2D(PxU32 nbVerts, const PxReal* vertices, const RendererColor* colors) +{ + RendererMaterial* screenquadMaterial; + RendererMaterialInstance* screenquadMaterialInstance; + screenquadMaterial = m_screenquadOpaqueMaterial; + screenquadMaterialInstance = m_screenquadOpaqueMaterialInstance; + if(!screenquadMaterialInstance || !screenquadMaterial) + return false; + + screenquadMaterial->bind(RendererMaterial::PASS_UNLIT, screenquadMaterialInstance, false); + if(!m_useShadersForTextRendering) + screenquadMaterial->unbind(); + + setupScreenquadRenderStates(); + + TextVertex* verts = new TextVertex[nbVerts]; + + PxU32 renderWidth, renderHeight; + getWindowSize(renderWidth, renderHeight); + const PxReal xCoeff = PxReal(renderWidth); + const PxReal yCoeff = PxReal(renderHeight); + + for(PxU32 i=0;i<nbVerts;i++) + { + verts[i].p.x = vertices[i*2+0] * xCoeff; + verts[i].p.y = vertices[i*2+1] * yCoeff; + verts[i].p.z = 0.0f; + verts[i].rhw = 1.0f; + verts[i].color = convertColor(colors[i]); + verts[i].u = 0.0f; + verts[i].v = 0.0f; + } + + renderLines2D(verts, nbVerts); + + DELETEARRAY(verts); + + resetScreenquadRenderStates(); + if(m_useShadersForTextRendering) + screenquadMaterial->unbind(); + + return true; +} + + diff --git a/PhysX_3.4/Samples/SampleFramework/renderer/src/RendererBoxShape.cpp b/PhysX_3.4/Samples/SampleFramework/renderer/src/RendererBoxShape.cpp new file mode 100644 index 00000000..c19c5c72 --- /dev/null +++ b/PhysX_3.4/Samples/SampleFramework/renderer/src/RendererBoxShape.cpp @@ -0,0 +1,193 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved. +// +// RendererBoxShape : convenience class for generating a box mesh. +// +#include <RendererBoxShape.h> + +#include <Renderer.h> + +#include <RendererVertexBuffer.h> +#include <RendererVertexBufferDesc.h> + +#include <RendererIndexBuffer.h> +#include <RendererIndexBufferDesc.h> + +#include <RendererMesh.h> +#include <RendererMeshDesc.h> + +#include <RendererMemoryMacros.h> + +using namespace SampleRenderer; + +typedef struct +{ + PxVec3 positions[4]; + PxVec3 normal; +} BoxFace; + +static const BoxFace g_BoxFaces[] = +{ + { // Z+ + {PxVec3(-1,-1, 1), PxVec3(-1, 1, 1), PxVec3( 1, 1, 1), PxVec3( 1,-1, 1)}, + PxVec3( 0, 0, 1) + }, + { // X+ + {PxVec3( 1,-1, 1), PxVec3( 1, 1, 1), PxVec3( 1, 1,-1), PxVec3( 1,-1,-1)}, + PxVec3( 1, 0, 0) + }, + { // Z- + {PxVec3( 1,-1,-1), PxVec3( 1, 1,-1), PxVec3(-1, 1,-1), PxVec3(-1,-1,-1)}, + PxVec3( 0, 0,-1) + }, + { // X- + {PxVec3(-1,-1,-1), PxVec3(-1, 1,-1), PxVec3(-1, 1, 1), PxVec3(-1,-1, 1)}, + PxVec3(-1, 0, 0) + }, + { // Y+ + {PxVec3(-1, 1, 1), PxVec3(-1, 1,-1), PxVec3( 1, 1,-1), PxVec3( 1, 1, 1)}, + PxVec3( 0, 1, 0) + }, + { // Y- + {PxVec3(-1,-1,-1), PxVec3(-1,-1, 1), PxVec3( 1,-1, 1), PxVec3( 1,-1,-1)}, + PxVec3( 0,-1, 0) + } +}; + +static const PxVec3 g_BoxUVs[] = +{ + PxVec3(0,1,0), PxVec3(0,0,0), + PxVec3(1,0,0), PxVec3(1,1,0), +}; + +namespace physx +{ + static PxVec3 operator*(const PxVec3 &a, const PxVec3 &b) + { + return PxVec3(a.x*b.x, a.y*b.y, a.z*b.z); + } +} + +RendererBoxShape::RendererBoxShape(Renderer &renderer, const PxVec3 &extents, const PxReal* userUVs) : +RendererShape(renderer) +{ + const PxU32 numVerts = 24; + const PxU32 numIndices = 36; + + RendererVertexBufferDesc vbdesc; + vbdesc.hint = RendererVertexBuffer::HINT_STATIC; + vbdesc.semanticFormats[RendererVertexBuffer::SEMANTIC_POSITION] = RendererVertexBuffer::FORMAT_FLOAT3; + vbdesc.semanticFormats[RendererVertexBuffer::SEMANTIC_NORMAL] = RendererVertexBuffer::FORMAT_FLOAT3; + vbdesc.semanticFormats[RendererVertexBuffer::SEMANTIC_TEXCOORD0] = RendererVertexBuffer::FORMAT_FLOAT2; + vbdesc.maxVertices = numVerts; + m_vertexBuffer = m_renderer.createVertexBuffer(vbdesc); + RENDERER_ASSERT(m_vertexBuffer, "Failed to create Vertex Buffer."); + if(m_vertexBuffer) + { + PxU32 positionStride = 0; + void *positions = m_vertexBuffer->lockSemantic(RendererVertexBuffer::SEMANTIC_POSITION, positionStride); + PxU32 normalStride = 0; + void *normals = m_vertexBuffer->lockSemantic(RendererVertexBuffer::SEMANTIC_NORMAL, normalStride); + PxU32 uvStride = 0; + void *uvs = m_vertexBuffer->lockSemantic(RendererVertexBuffer::SEMANTIC_TEXCOORD0, uvStride); + if(positions && normals && uvs) + { + for(PxU32 i=0; i<6; i++) + { + const BoxFace &bf = g_BoxFaces[i]; + for(PxU32 j=0; j<4; j++) + { + PxVec3 &p = *(PxVec3*)positions; positions = ((PxU8*)positions) + positionStride; + PxVec3 &n = *(PxVec3*)normals; normals = ((PxU8*)normals) + normalStride; + PxF32 *uv = (PxF32*)uvs; uvs = ((PxU8*)uvs) + uvStride; + n = bf.normal; + p = bf.positions[j] * extents; + if(userUVs) + { + uv[0] = *userUVs++; + uv[1] = *userUVs++; + } + else + { + uv[0] = g_BoxUVs[j].x; + uv[1] = g_BoxUVs[j].y; + } + } + } + } + m_vertexBuffer->unlockSemantic(RendererVertexBuffer::SEMANTIC_TEXCOORD0); + m_vertexBuffer->unlockSemantic(RendererVertexBuffer::SEMANTIC_NORMAL); + m_vertexBuffer->unlockSemantic(RendererVertexBuffer::SEMANTIC_POSITION); + } + + RendererIndexBufferDesc ibdesc; + ibdesc.hint = RendererIndexBuffer::HINT_STATIC; + ibdesc.format = RendererIndexBuffer::FORMAT_UINT16; + ibdesc.maxIndices = numIndices; + m_indexBuffer = m_renderer.createIndexBuffer(ibdesc); + RENDERER_ASSERT(m_indexBuffer, "Failed to create Index Buffer."); + if(m_indexBuffer) + { + PxU16 *indices = (PxU16*)m_indexBuffer->lock(); + if(indices) + { + for(PxU8 i=0; i<6; i++) + { + const PxU16 base = i*4; + *(indices++) = base+0; + *(indices++) = base+1; + *(indices++) = base+2; + *(indices++) = base+0; + *(indices++) = base+2; + *(indices++) = base+3; + } + } + m_indexBuffer->unlock(); + } + + if(m_vertexBuffer && m_indexBuffer) + { + RendererMeshDesc meshdesc; + meshdesc.primitives = RendererMesh::PRIMITIVE_TRIANGLES; + meshdesc.vertexBuffers = &m_vertexBuffer; + meshdesc.numVertexBuffers = 1; + meshdesc.firstVertex = 0; + meshdesc.numVertices = numVerts; + meshdesc.indexBuffer = m_indexBuffer; + meshdesc.firstIndex = 0; + meshdesc.numIndices = numIndices; + m_mesh = m_renderer.createMesh(meshdesc); + RENDERER_ASSERT(m_mesh, "Failed to create Mesh."); + } +} + +RendererBoxShape::~RendererBoxShape(void) +{ + SAFE_RELEASE(m_vertexBuffer); + SAFE_RELEASE(m_indexBuffer); + SAFE_RELEASE(m_mesh); +} diff --git a/PhysX_3.4/Samples/SampleFramework/renderer/src/RendererCapsuleShape.cpp b/PhysX_3.4/Samples/SampleFramework/renderer/src/RendererCapsuleShape.cpp new file mode 100644 index 00000000..1d453131 --- /dev/null +++ b/PhysX_3.4/Samples/SampleFramework/renderer/src/RendererCapsuleShape.cpp @@ -0,0 +1,315 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved. +// +// RendererCapsuleShape : convenience class for generating a capsule mesh. +// + +#include <PsUtilities.h> + +#include <RendererCapsuleShape.h> + +#include <Renderer.h> + +#include <RendererVertexBuffer.h> +#include <RendererVertexBufferDesc.h> + +#include <RendererIndexBuffer.h> +#include <RendererIndexBufferDesc.h> + +#include <RendererMesh.h> +#include <RendererMeshDesc.h> + +#include <RendererMemoryMacros.h> +#include "PsUtilities.h" + +using namespace SampleRenderer; + +namespace +{ + +const PxU32 g_numSlices = 8; // along lines of longitude +const PxU32 g_numStacks = 16; // along lines of latitude + +const PxU32 g_numSphereVertices = (g_numSlices*2+1)*(g_numStacks+1); +const PxU32 g_numSphereIndices = g_numSlices*2*g_numStacks*6; + +const PxU32 g_numConeVertices = (g_numSlices*2+1)*2; +const PxU32 g_numConeIndices = g_numSlices*2*6; + +PxVec3 g_spherePositions[g_numSphereVertices]; +PxU16 g_sphereIndices[g_numSphereIndices]; + +PxVec3 g_conePositions[g_numConeVertices]; +PxU16 g_coneIndices[g_numConeIndices]; + +// total vertex count +const PxU32 g_numCapsuleVertices = 2*g_numSphereVertices + g_numConeVertices; +const PxU32 g_numCapsuleIndices = 2*g_numSphereIndices + g_numConeIndices; + +void generateSphereMesh(PxU16 slices, PxU16 stacks, PxVec3* positions, PxU16* indices) +{ + const PxF32 thetaStep = PxPi/stacks; + const PxF32 phiStep = PxTwoPi/(slices*2); + + PxF32 theta = 0.0f; + + // generate vertices + for (PxU16 y=0; y <= stacks; ++y) + { + PxF32 phi = 0.0f; + + PxF32 cosTheta = PxCos(theta); + PxF32 sinTheta = PxSin(theta); + + for (PxU16 x=0; x <= slices*2; ++x) + { + PxF32 cosPhi = PxCos(phi); + PxF32 sinPhi = PxSin(phi); + + PxVec3 p(cosPhi*sinTheta, cosTheta, sinPhi*sinTheta); + + // write vertex + *(positions++)= p; + + phi += phiStep; + } + + theta += thetaStep; + } + + const PxU16 numRingQuads = 2*slices; + const PxU16 numRingVerts = 2*slices+1; + + // add faces + for (PxU16 y=0; y < stacks; ++y) + { + for (PxU16 i=0; i < numRingQuads; ++i) + { + // add a quad + *(indices++) = (y+0)*numRingVerts + i; + *(indices++) = (y+1)*numRingVerts + i; + *(indices++) = (y+1)*numRingVerts + i + 1; + + *(indices++) = (y+1)*numRingVerts + i + 1; + *(indices++) = (y+0)*numRingVerts + i + 1; + *(indices++) = (y+0)*numRingVerts + i; + } + } +} + +void generateConeMesh(PxU16 slices, PxVec3* positions, PxU16* indices, PxU16 offset) +{ + // generate vertices + const PxF32 phiStep = PxTwoPi/(slices*2); + PxF32 phi = 0.0f; + + // generate two rings of vertices for the cone ends + for (int i=0; i < 2; ++i) + { + for (PxU16 x=0; x <= slices*2; ++x) + { + PxF32 cosPhi = PxCos(phi); + PxF32 sinPhi = PxSin(phi); + + PxVec3 p(cosPhi, 0.0f, sinPhi); + + // write vertex + *(positions++)= p; + + phi += phiStep; + } + } + + const PxU16 numRingQuads = 2*slices; + const PxU16 numRingVerts = 2*slices+1; + + // add faces + for (PxU16 i=0; i < numRingQuads; ++i) + { + // add a quad + *(indices++) = offset + i; + *(indices++) = offset + numRingVerts + i; + *(indices++) = offset + numRingVerts + i + 1; + + *(indices++) = offset + numRingVerts + i + 1; + *(indices++) = offset + i + 1; + *(indices++) = offset + i; + } +} + +void generateCapsuleMesh() +{ + generateSphereMesh(g_numSlices, g_numStacks, g_spherePositions, g_sphereIndices); + generateConeMesh(g_numSlices, g_conePositions, g_coneIndices, g_numSphereVertices*2); +} + +} // anonymous namespace + +RendererCapsuleShape::RendererCapsuleShape(Renderer &renderer, PxF32 halfHeight, PxF32 radius) : RendererShape(renderer) +{ + static bool meshValid = false; + if (!meshValid) + { + generateCapsuleMesh(); + meshValid = true; + } + + RendererVertexBufferDesc vbdesc; + vbdesc.hint = RendererVertexBuffer::HINT_STATIC; + vbdesc.semanticFormats[RendererVertexBuffer::SEMANTIC_POSITION] = RendererVertexBuffer::FORMAT_FLOAT3; + vbdesc.semanticFormats[RendererVertexBuffer::SEMANTIC_NORMAL] = RendererVertexBuffer::FORMAT_FLOAT3; + vbdesc.semanticFormats[RendererVertexBuffer::SEMANTIC_TEXCOORD0] = RendererVertexBuffer::FORMAT_FLOAT2; + vbdesc.maxVertices = g_numCapsuleVertices; + m_vertexBuffer = m_renderer.createVertexBuffer(vbdesc); + RENDERER_ASSERT(m_vertexBuffer, "Failed to create Vertex Buffer."); + + RendererIndexBufferDesc ibdesc; + ibdesc.hint = RendererIndexBuffer::HINT_STATIC; + ibdesc.format = RendererIndexBuffer::FORMAT_UINT16; + ibdesc.maxIndices = g_numCapsuleIndices; + m_indexBuffer = m_renderer.createIndexBuffer(ibdesc); + RENDERER_ASSERT(m_indexBuffer, "Failed to create Index Buffer."); + + // set position data + setDimensions(halfHeight, radius, radius); + + if(m_indexBuffer) + { + PxU16 *indices = (PxU16*)m_indexBuffer->lock(); + if(indices) + { + // first sphere + for (PxU32 i=0; i < g_numSphereIndices; ++i) + indices[i] = g_sphereIndices[i]; + + indices += g_numSphereIndices; + + // second sphere + for (PxU32 i=0; i < g_numSphereIndices; ++i) + indices[i] = g_sphereIndices[i] + g_numSphereVertices; + + indices += g_numSphereIndices; + + // cone indices + for (PxU32 i=0; i < g_numConeIndices; ++i) + indices[i] = g_coneIndices[i]; + } + m_indexBuffer->unlock(); + } + + if(m_vertexBuffer && m_indexBuffer) + { + RendererMeshDesc meshdesc; + meshdesc.primitives = RendererMesh::PRIMITIVE_TRIANGLES; + meshdesc.vertexBuffers = &m_vertexBuffer; + meshdesc.numVertexBuffers = 1; + meshdesc.firstVertex = 0; + meshdesc.numVertices = g_numCapsuleVertices; + meshdesc.indexBuffer = m_indexBuffer; + meshdesc.firstIndex = 0; + meshdesc.numIndices = g_numCapsuleIndices; + m_mesh = m_renderer.createMesh(meshdesc); + RENDERER_ASSERT(m_mesh, "Failed to create Mesh."); + } +} + +RendererCapsuleShape::~RendererCapsuleShape(void) +{ + SAFE_RELEASE(m_vertexBuffer); + SAFE_RELEASE(m_indexBuffer); + SAFE_RELEASE(m_mesh); +} + +void RendererCapsuleShape::setDimensions(PxF32 halfHeight, PxF32 radius0, PxF32 radius1) +{ + if(m_vertexBuffer) + { + PxU32 positionStride = 0; + PxVec3* positions = (PxVec3*)m_vertexBuffer->lockSemantic(RendererVertexBuffer::SEMANTIC_POSITION, positionStride); + + PxU32 normalStride = 0; + PxVec3* normals = (PxVec3*)m_vertexBuffer->lockSemantic(RendererVertexBuffer::SEMANTIC_NORMAL, normalStride); + + if (positions && normals) + { + const PxF32 radii[2] = { radius1, radius0}; + const PxF32 offsets[2] = { halfHeight, -halfHeight }; + + // write two copies of the sphere mesh scaled and offset appropriately + for (PxU32 s=0; s < 2; ++s) + { + const PxF32 r = radii[s]; + const PxF32 offset = offsets[s]; + + for (PxU32 i=0; i < g_numSphereVertices; ++i) + { + PxVec3 p = g_spherePositions[i]*r; + p.y += offset; + + *positions = p; + *normals = g_spherePositions[i]; + + positions = (PxVec3*)(((PxU8*)positions)+positionStride); + normals = (PxVec3*)(((PxU8*)normals)+normalStride); + } + } + + // calculate cone angle + PxF32 cosTheta = 0.0f; + + if (halfHeight > 0.0f) + cosTheta = (radius0-radius1)/(halfHeight*2.0f); + + // scale factor for normals to avoid re-normalizing each time + PxF32 nscale = PxSqrt(1.0f - cosTheta*cosTheta); + + for (PxU32 s=0; s < 2; ++s) + { + const PxF32 y = radii[s]*cosTheta; + const PxF32 r = PxSqrt(radii[s]*radii[s] - y*y); + const PxF32 offset = offsets[s] + y; + + for (PxU32 i=0; i < g_numConeVertices/2; ++i) + { + PxVec3 p = g_conePositions[i]*r; + p.y += offset; + *positions = p; + + PxVec3 n = g_conePositions[i]*nscale; + n.y = cosTheta; + *normals = n; + + positions = (PxVec3*)(((PxU8*)positions)+positionStride); + normals = (PxVec3*)(((PxU8*)normals)+normalStride); + } + } + } + + m_vertexBuffer->unlockSemantic(RendererVertexBuffer::SEMANTIC_POSITION); + m_vertexBuffer->unlockSemantic(RendererVertexBuffer::SEMANTIC_NORMAL); + } +} diff --git a/PhysX_3.4/Samples/SampleFramework/renderer/src/RendererClothShape.cpp b/PhysX_3.4/Samples/SampleFramework/renderer/src/RendererClothShape.cpp new file mode 100644 index 00000000..07d2e753 --- /dev/null +++ b/PhysX_3.4/Samples/SampleFramework/renderer/src/RendererClothShape.cpp @@ -0,0 +1,378 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved. + +#include <RendererClothShape.h> + +#include <Renderer.h> + +#include <RendererVertexBuffer.h> +#include <RendererVertexBufferDesc.h> + +#include <RendererIndexBuffer.h> +#include <RendererIndexBufferDesc.h> + +#include <RendererMesh.h> +#include <RendererMeshDesc.h> + +#include <RendererMemoryMacros.h> + +#if defined(RENDERER_ENABLE_CUDA_INTEROP) +#include <task/PxTask.h> +#include <cuda.h> + +// pre-compiled fatbin +#if defined(_M_X64) +#include "cuda/RenderClothNormals_x64.cuh" +#else +#include "cuda/RenderClothNormals_x86.cuh" +#endif + +namespace +{ + CUmodule gClothRenderModule; + CUfunction gClothRenderFunction; + + void checkSuccess(CUresult r) + { + PX_ASSERT(r == CUDA_SUCCESS); + } +} + +#endif + +using namespace SampleRenderer; + +RendererClothShape::RendererClothShape( Renderer& renderer, + const PxVec3* verts, PxU32 numVerts, + const PxVec3* normals, + const PxReal* uvs, + const PxU16* faces, PxU32 numFaces, bool flipWinding, + PxCudaContextManager* ctxMgr) : +RendererShape(renderer), m_numFaces(numFaces), m_ctxMgr(ctxMgr) +{ + PX_UNUSED(m_numFaces); + + { + RendererVertexBufferDesc vbdesc; + vbdesc.hint = RendererVertexBuffer::HINT_STATIC; + vbdesc.semanticFormats[RendererVertexBuffer::SEMANTIC_TEXCOORD0] = RendererVertexBuffer::FORMAT_FLOAT2; + vbdesc.maxVertices = numVerts; + m_vertexBuffer[STATIC_VB] = m_renderer.createVertexBuffer(vbdesc); + RENDERER_ASSERT(m_vertexBuffer[STATIC_VB], "Failed to create Vertex Buffer."); + } + { + RendererVertexBufferDesc vbdesc; + vbdesc.hint = RendererVertexBuffer::HINT_DYNAMIC; + vbdesc.semanticFormats[RendererVertexBuffer::SEMANTIC_POSITION] = RendererVertexBuffer::FORMAT_FLOAT3; + vbdesc.semanticFormats[RendererVertexBuffer::SEMANTIC_NORMAL] = RendererVertexBuffer::FORMAT_FLOAT3; + vbdesc.maxVertices = numVerts; + +#if defined(RENDERER_ENABLE_CUDA_INTEROP) + if (ctxMgr) + { + vbdesc.registerInCUDA = true; + vbdesc.interopContext = ctxMgr; + + ctxMgr->acquireContext(); + + // find module containing our kernel + CUresult success; + + success = cuModuleLoadDataEx(&gClothRenderModule, computeSmoothNormals, 0, NULL, NULL); + RENDERER_ASSERT(success == CUDA_SUCCESS, "Could not load cloth render CUDA module."); + + success = cuModuleGetFunction(&gClothRenderFunction, gClothRenderModule, "computeSmoothNormals"); + RENDERER_ASSERT(success == CUDA_SUCCESS, "Could not find cloth render CUDA function."); + + ctxMgr->releaseContext(); + } +#endif //RENDERER_ENABLE_CUDA_INTEROP + + m_vertexBuffer[DYNAMIC_VB] = m_renderer.createVertexBuffer(vbdesc); + RENDERER_ASSERT(m_vertexBuffer[DYNAMIC_VB], "Failed to create Vertex Buffer."); + } + + if(m_vertexBuffer[DYNAMIC_VB] && m_vertexBuffer[STATIC_VB]) + { + PxU32 positionStride = 0; + void* vertPositions = m_vertexBuffer[DYNAMIC_VB]->lockSemantic(RendererVertexBuffer::SEMANTIC_POSITION, positionStride); + + PxU32 normalStride = 0; + void* vertNormals = m_vertexBuffer[DYNAMIC_VB]->lockSemantic(RendererVertexBuffer::SEMANTIC_NORMAL, normalStride); + + PxU32 uvStride = 0; + void* vertUVs = m_vertexBuffer[STATIC_VB]->lockSemantic(RendererVertexBuffer::SEMANTIC_TEXCOORD0, uvStride); + + if(vertPositions && vertNormals && vertUVs) + { + for(PxU32 i=0; i<numVerts; i++) + { + memcpy(vertPositions, verts+i, sizeof(PxVec3)); + if(normals) + memcpy(vertNormals, normals+i, sizeof(PxVec3)); + else + memset(vertNormals, 0, sizeof(PxVec3)); + + if(uvs) + memcpy(vertUVs, uvs+i*2, sizeof(PxReal)*2); + else + memset(vertUVs, 0, sizeof(PxReal)*2); + + vertPositions = (void*)(((PxU8*)vertPositions) + positionStride); + vertNormals = (void*)(((PxU8*)vertNormals) + normalStride); + vertUVs = (void*)(((PxU8*)vertUVs) + uvStride); + } + } + m_vertexBuffer[DYNAMIC_VB]->unlockSemantic(RendererVertexBuffer::SEMANTIC_NORMAL); + m_vertexBuffer[DYNAMIC_VB]->unlockSemantic(RendererVertexBuffer::SEMANTIC_POSITION); + m_vertexBuffer[STATIC_VB]->unlockSemantic(RendererVertexBuffer::SEMANTIC_TEXCOORD0); + } + + const PxU32 numIndices = numFaces*3; + + RendererIndexBufferDesc ibdesc; + ibdesc.hint = RendererIndexBuffer::HINT_STATIC; + ibdesc.format = RendererIndexBuffer::FORMAT_UINT16; + ibdesc.maxIndices = numIndices; + +#if defined(RENDERER_ENABLE_CUDA_INTEROP) + if (ctxMgr) + { + ibdesc.registerInCUDA = true; + ibdesc.interopContext = ctxMgr; + ibdesc.hint = RendererIndexBuffer::HINT_DYNAMIC; + } +#endif // RENDERER_ENABLE_CUDA_INTEROP + + m_indexBuffer = m_renderer.createIndexBuffer(ibdesc); + RENDERER_ASSERT(m_indexBuffer, "Failed to create Index Buffer."); + if(m_indexBuffer) + { + PxU16* indices = (PxU16*)m_indexBuffer->lock(); + if(indices) + { + if(flipWinding) + { + for(PxU32 i=0;i<numFaces;i++) + { + indices[i*3+0] = faces[i*3+0]; + indices[i*3+1] = faces[i*3+2]; + indices[i*3+2] = faces[i*3+1]; + } + } + else + { + memcpy(indices, faces, sizeof(*faces)*numFaces*3); + } + } + m_indexBuffer->unlock(); + } + + if(m_vertexBuffer[DYNAMIC_VB] && m_vertexBuffer[STATIC_VB] && m_indexBuffer) + { + RendererMeshDesc meshdesc; + meshdesc.primitives = RendererMesh::PRIMITIVE_TRIANGLES; + meshdesc.vertexBuffers = m_vertexBuffer; + meshdesc.numVertexBuffers = NUM_VERTEX_BUFFERS; + meshdesc.firstVertex = 0; + meshdesc.numVertices = numVerts; + meshdesc.indexBuffer = m_indexBuffer; + meshdesc.firstIndex = 0; + meshdesc.numIndices = numIndices; + m_mesh = m_renderer.createMesh(meshdesc); + RENDERER_ASSERT(m_mesh, "Failed to create Mesh."); + } +} +namespace +{ + +#if defined(RENDERER_ENABLE_CUDA_INTEROP) + +PX_INLINE void cuuAlignUp(int* offset, int alignment) +{ + *offset = ((*offset) + (alignment) - 1) & ~((alignment) - 1); +} + +template <typename T, typename T2> CUresult +cuuParamSet(CUfunction hf, int* offset, const T2& var) +{ + cuuAlignUp(offset, __alignof(T)); + CUresult err = cuParamSetv(hf, *offset, (void*)&var, sizeof(T)); + *offset += sizeof(T); + return err; +} + +#endif // RENDERER_ENABLE_CUDA_INTEROP + +} // anonymous namespace + + +bool RendererClothShape::update(CUdeviceptr srcVerts, PxU32 numVerts) +{ +#if defined(RENDERER_ENABLE_CUDA_INTEROP) + + // note: CUDA context must be acquired, and buffers mapped at this point + + PX_ASSERT(m_ctxMgr); + PX_ASSERT(srcVerts); + + // get vertex buffer + CUgraphicsResource vbRes; + CUdeviceptr destVerts; + size_t destSize; + m_vertexBuffer[DYNAMIC_VB]->getInteropResourceHandle(vbRes); + cuGraphicsResourceGetMappedPointer(&destVerts, &destSize, vbRes); + + // get index buffer + CUgraphicsResource ibRes; + CUdeviceptr srcIndices; + size_t indicesSize; + m_indexBuffer->getInteropResourceHandle(ibRes); + cuGraphicsResourceGetMappedPointer(&srcIndices, &indicesSize, ibRes); + + // if either buffers could not be mapped revert to CPU + if (!destVerts || !srcIndices) + return false; + + const size_t ptrSize = sizeof(CUdeviceptr); + + int offset = 0; + checkSuccess(cuuParamSet<CUdeviceptr>(gClothRenderFunction, &offset, srcVerts)); + checkSuccess(cuuParamSet<CUdeviceptr>(gClothRenderFunction, &offset, srcIndices)); + checkSuccess(cuuParamSet<CUdeviceptr>(gClothRenderFunction, &offset, destVerts)); + checkSuccess(cuuParamSet<PxU32>(gClothRenderFunction, &offset, m_numFaces)); + checkSuccess(cuuParamSet<PxU32>(gClothRenderFunction, &offset, numVerts)); + checkSuccess(cuParamSetSize(gClothRenderFunction, offset)); + + const PxU32 blockSize = 512; + const PxU32 numBlocks = 1; + + checkSuccess(cuFuncSetBlockShape(gClothRenderFunction, blockSize, 1, 1)); + checkSuccess(cuLaunchGridAsync(gClothRenderFunction, numBlocks, 1, 0)); + + m_mesh->setVertexBufferRange(0, numVerts); + +#else + PX_ASSERT(0); +#endif + + return true; +} + +void RendererClothShape::mapShapes(RendererClothShape** shapes, PxU32 n) +{ + PX_UNUSED(shapes); + PX_UNUSED(n); + +#if defined(RENDERER_ENABLE_CUDA_INTEROP) + + if (n == 0) + return; + + PX_PROFILE_ZONE("RendererClothShape::mapGraphicsResource",0); + + std::vector<CUgraphicsResource> resources; + for (PxU32 i=0; i < n; ++i) + { + CUgraphicsResource vbRes, ibRes; + shapes[i]->m_vertexBuffer[DYNAMIC_VB]->getInteropResourceHandle(vbRes); + shapes[i]->m_indexBuffer->getInteropResourceHandle(ibRes); + + resources.push_back(vbRes); + resources.push_back(ibRes); + } + + checkSuccess(cuGraphicsMapResources(unsigned int(resources.size()), &resources[0], 0)); + +#else + PX_ASSERT(0); +#endif +} + +void RendererClothShape::unmapShapes(RendererClothShape** shapes, PxU32 n) +{ + PX_UNUSED(shapes); + PX_UNUSED(n); + +#if defined(RENDERER_ENABLE_CUDA_INTEROP) + + if (n == 0) + return; + + PX_PROFILE_ZONE("RendererClothShape::unmapGraphicsResource",0); + + std::vector<CUgraphicsResource> resources; + for (PxU32 i=0; i < n; ++i) + { + CUgraphicsResource vbRes, ibRes; + shapes[i]->m_vertexBuffer[DYNAMIC_VB]->getInteropResourceHandle(vbRes); + shapes[i]->m_indexBuffer->getInteropResourceHandle(ibRes); + + resources.push_back(vbRes); + resources.push_back(ibRes); + } + + checkSuccess(cuGraphicsUnmapResources(unsigned int(resources.size()), &resources[0], 0)); + +#else + PX_ASSERT(0); +#endif +} + +void RendererClothShape::update(const PxVec3* verts, PxU32 numVerts, const PxVec3* normals) +{ + PxU32 positionStride = 0, normalStride = 0; + + PxU8 *locked_positions = static_cast<PxU8*>(m_vertexBuffer[DYNAMIC_VB]->lockSemantic( + RendererVertexBuffer::SEMANTIC_POSITION, positionStride)); + PxU8 *locked_normals = static_cast<PxU8*>(m_vertexBuffer[DYNAMIC_VB]->lockSemantic( + RendererVertexBuffer::SEMANTIC_NORMAL, normalStride)); + + for(PxU32 i=0; i<numVerts; i++) + { + memcpy(locked_positions, verts + i, sizeof(PxVec3)); + memcpy(locked_normals, normals + i, sizeof(PxVec3)); + + locked_positions += positionStride; + locked_normals += normalStride; + } + + m_vertexBuffer[DYNAMIC_VB]->unlockSemantic(SampleRenderer::RendererVertexBuffer::SEMANTIC_NORMAL); + m_vertexBuffer[DYNAMIC_VB]->unlockSemantic(SampleRenderer::RendererVertexBuffer::SEMANTIC_POSITION); + + m_mesh->setVertexBufferRange(0, numVerts); +} + +RendererClothShape::~RendererClothShape(void) +{ + for(PxU32 i = 0; i < NUM_VERTEX_BUFFERS; i++ ) + { + SAFE_RELEASE(m_vertexBuffer[i]); + } + SAFE_RELEASE(m_indexBuffer); + SAFE_RELEASE(m_mesh); +} diff --git a/PhysX_3.4/Samples/SampleFramework/renderer/src/RendererColor.cpp b/PhysX_3.4/Samples/SampleFramework/renderer/src/RendererColor.cpp new file mode 100644 index 00000000..f0f9add6 --- /dev/null +++ b/PhysX_3.4/Samples/SampleFramework/renderer/src/RendererColor.cpp @@ -0,0 +1,57 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved. +#include <RendererColor.h> + +using namespace SampleRenderer; + +RendererColor::RendererColor(void) +{ + +} + +RendererColor::RendererColor(PxU8 _r, PxU8 _g, PxU8 _b, PxU8 _a) +{ + r=_r; + g=_g; + b=_b; + a=_a; +} + +RendererColor::RendererColor(PxU32 rgba) +{ + b = (PxU8)((rgba>>16) & 0xff); + g = (PxU8)((rgba>>8) & 0xff); + r = (PxU8)((rgba) & 0xff); + a = 255; +} + +void RendererColor::swizzleRB(void) +{ + PxU8 t = b; + b = r; + r = t; +} diff --git a/PhysX_3.4/Samples/SampleFramework/renderer/src/RendererDesc.cpp b/PhysX_3.4/Samples/SampleFramework/renderer/src/RendererDesc.cpp new file mode 100644 index 00000000..7253ceba --- /dev/null +++ b/PhysX_3.4/Samples/SampleFramework/renderer/src/RendererDesc.cpp @@ -0,0 +1,66 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved. +#include <RendererDesc.h> + +using namespace SampleRenderer; + +RendererDesc::RendererDesc(void) +{ +#if defined(RENDERER_ENABLE_OPENGL) + driver = Renderer::DRIVER_OPENGL; +#elif defined(RENDERER_ENABLE_GLES2) + driver = Renderer::DRIVER_GLES2; +#elif defined(RENDERER_ENABLE_DIRECT3D9) + driver = Renderer::DRIVER_DIRECT3D9; +#elif defined(RENDERER_ENABLE_DIRECT3D11) + driver = Renderer::DRIVER_DIRECT3D11; +#elif defined(RENDERER_ENABLE_LIBGCM) + driver = Renderer::DRIVER_LIBGCM; +#elif defined(RENDERER_ENABLE_LIBGNM) + driver = Renderer::DRIVER_LIBGNM; +#elif defined(RENDERER_ENABLE_GX2) + driver = Renderer::DRIVER_NULL; +#else +#error "No Renderer Drivers support!" +#endif + windowHandle = 0; + + errorCallback = 0; + + vsync = false; + + multipassDepthBias = false; +} + +bool RendererDesc::isValid(void) const +{ + bool ok = true; +#if defined(RENDERER_WINDOWS) + if(!windowHandle) ok = false; +#endif + return ok; +} diff --git a/PhysX_3.4/Samples/SampleFramework/renderer/src/RendererDirectionalLight.cpp b/PhysX_3.4/Samples/SampleFramework/renderer/src/RendererDirectionalLight.cpp new file mode 100644 index 00000000..c7739d3c --- /dev/null +++ b/PhysX_3.4/Samples/SampleFramework/renderer/src/RendererDirectionalLight.cpp @@ -0,0 +1,56 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved. +#include <RendererDirectionalLight.h> +#include <RendererDirectionalLightDesc.h> + +using namespace SampleRenderer; + +RendererDirectionalLight::RendererDirectionalLight(const RendererDirectionalLightDesc &desc) : +RendererLight(desc) +{ + setDirection(desc.direction); +} + +RendererDirectionalLight::~RendererDirectionalLight(void) +{ + +} + +const PxVec3 &RendererDirectionalLight::getDirection(void) const +{ + return m_direction; +} + +void RendererDirectionalLight::setDirection(const PxVec3 &dir) +{ + RENDERER_ASSERT(dir.magnitudeSquared() >= 0.1f, "Trying to give Direction Light invalid Direction value."); + if(dir.magnitudeSquared() >= 0.1f) + { + m_direction = dir; + m_direction.normalize(); + } +} diff --git a/PhysX_3.4/Samples/SampleFramework/renderer/src/RendererDirectionalLightDesc.cpp b/PhysX_3.4/Samples/SampleFramework/renderer/src/RendererDirectionalLightDesc.cpp new file mode 100644 index 00000000..d7122bc9 --- /dev/null +++ b/PhysX_3.4/Samples/SampleFramework/renderer/src/RendererDirectionalLightDesc.cpp @@ -0,0 +1,42 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved. +#include <RendererDirectionalLightDesc.h> + +using namespace SampleRenderer; + +RendererDirectionalLightDesc::RendererDirectionalLightDesc(void) : +RendererLightDesc(RendererLight::TYPE_DIRECTIONAL) +{ + direction = PxVec3(0,0,0); +} + +bool RendererDirectionalLightDesc::isValid(void) const +{ + bool ok = RendererLightDesc::isValid(); + if(direction.magnitudeSquared() < 0.1f) ok = false; + return ok; +} diff --git a/PhysX_3.4/Samples/SampleFramework/renderer/src/RendererGridShape.cpp b/PhysX_3.4/Samples/SampleFramework/renderer/src/RendererGridShape.cpp new file mode 100644 index 00000000..beaabd73 --- /dev/null +++ b/PhysX_3.4/Samples/SampleFramework/renderer/src/RendererGridShape.cpp @@ -0,0 +1,156 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved. +// +// RendererGridShape : convenience class for generating a grid mesh. +// +#include <RendererGridShape.h> + +#include <Renderer.h> + +#include <RendererVertexBuffer.h> +#include <RendererVertexBufferDesc.h> + +#include <RendererMesh.h> +#include <RendererMeshDesc.h> + +#include <RendererMemoryMacros.h> + +#include <foundation/PxStrideIterator.h> +#include <PsMathUtils.h> + +using namespace SampleRenderer; + +RendererGridShape::RendererGridShape(Renderer &renderer, PxU32 size, float cellSize, bool showAxis /*= false*/, UpAxis up/*= UP_Y*/) : +RendererShape(renderer), m_UpAxis(up) +{ + m_vertexBuffer = 0; + + const PxU32 numVerts = size*8 + 8; + + RendererVertexBufferDesc vbdesc; + vbdesc.hint = RendererVertexBuffer::HINT_STATIC; + vbdesc.semanticFormats[RendererVertexBuffer::SEMANTIC_POSITION] = RendererVertexBuffer::FORMAT_FLOAT3; + vbdesc.semanticFormats[RendererVertexBuffer::SEMANTIC_COLOR] = RendererVertexBuffer::FORMAT_COLOR_NATIVE; + vbdesc.maxVertices = numVerts; + m_vertexBuffer = m_renderer.createVertexBuffer(vbdesc); + + if(m_vertexBuffer) + { + RendererMeshDesc meshdesc; + meshdesc.primitives = RendererMesh::PRIMITIVE_LINES; + meshdesc.vertexBuffers = &m_vertexBuffer; + meshdesc.numVertexBuffers = 1; + meshdesc.firstVertex = 0; + meshdesc.numVertices = numVerts; + m_mesh = m_renderer.createMesh(meshdesc); + } + if(m_vertexBuffer && m_mesh) + { + PxU32 color1 = m_renderer.convertColor(RendererColor ( 94, 108, 127)); + PxU32 color2 = m_renderer.convertColor(RendererColor (120, 138, 163)); + PxU32 colorRed = m_renderer.convertColor(RendererColor (255, 0, 0)); + PxU32 colorGreen = m_renderer.convertColor(RendererColor ( 0, 255, 0)); + PxU32 colorBlue = m_renderer.convertColor(RendererColor ( 0, 0, 255)); + + PxStrideIterator<PxVec3> positions; + { + PxU32 positionStride = 0; + void* pos = m_vertexBuffer->lockSemantic(RendererVertexBuffer::SEMANTIC_POSITION, positionStride); + positions = PxMakeIterator((PxVec3*)pos, positionStride); + } + PxStrideIterator<PxU32> colors; + { + PxU32 colorStride = 0; + void* color = m_vertexBuffer->lockSemantic(RendererVertexBuffer::SEMANTIC_COLOR, colorStride); + colors = PxMakeIterator((PxU32*)color, colorStride); + } + + if(positions.ptr() && colors.ptr()) + { + PxVec3 upAxis(0.0f); + + PxU32 colorX1 = color1; + PxU32 colorX2 = color1; + PxU32 colorZ1 = color1; + PxU32 colorZ2 = color1; + + switch(up) + { + case UP_X: upAxis = PxVec3(1.0f, 0.0f, 0.0f); break; + case UP_Y: upAxis = PxVec3(0.0f, 1.0f, 0.0f); break; + case UP_Z: upAxis = PxVec3(0.0f, 0.0f, 1.0f); break; + } + PxMat33 rotation = physx::shdfnd::rotFrom2Vectors(PxVec3(0.0f, 1.0f, 0.0f), upAxis); + + if (showAxis) + { + switch(up) + { + case UP_X: colorX2 = colorGreen; colorZ1 = colorBlue; break; + case UP_Y: colorX1 = colorRed; colorZ1 = colorBlue; break; + case UP_Z: colorX1 = colorRed; colorZ2 = colorGreen; break; + } + } + + float radius = size*cellSize; + + positions[0] = rotation * PxVec3( 0.0f, 0.0f, 0.0f); colors[0] = colorX1; + positions[1] = rotation * PxVec3( radius, 0.0f, 0.0f); colors[1] = colorX1; + positions[2] = rotation * PxVec3( 0.0f, 0.0f, 0.0f); colors[2] = colorX2; + positions[3] = rotation * PxVec3(-radius, 0.0f, 0.0f); colors[3] = colorX2; + positions[4] = rotation * PxVec3( 0.0f, 0.0f, 0.0f); colors[4] = colorZ1; + positions[5] = rotation * PxVec3( 0.0f, 0.0f, radius); colors[5] = colorZ1; + positions[6] = rotation * PxVec3( 0.0f, 0.0f, 0.0f); colors[6] = colorZ2; + positions[7] = rotation * PxVec3( 0.0f, 0.0f,-radius); colors[7] = colorZ2; + + + for (PxU32 i = 1; i <= size; i++) + { + positions[i*8+0] = rotation * PxVec3(-radius, 0.0f, cellSize * i); + positions[i*8+1] = rotation * PxVec3( radius, 0.0f, cellSize * i); + positions[i*8+2] = rotation * PxVec3(-radius, 0.0f,-cellSize * i); + positions[i*8+3] = rotation * PxVec3( radius, 0.0f,-cellSize * i); + positions[i*8+4] = rotation * PxVec3( cellSize * i, 0.0f,-radius); + positions[i*8+5] = rotation * PxVec3( cellSize * i, 0.0f, radius); + positions[i*8+6] = rotation * PxVec3(-cellSize * i, 0.0f,-radius); + positions[i*8+7] = rotation * PxVec3(-cellSize * i, 0.0f, radius); + + for (PxU32 j = 0; j < 8; j++) + colors[i*8+j] = color2; + } + } + + m_vertexBuffer->unlockSemantic(RendererVertexBuffer::SEMANTIC_COLOR); + m_vertexBuffer->unlockSemantic(RendererVertexBuffer::SEMANTIC_POSITION); + } +} + +RendererGridShape::~RendererGridShape(void) +{ + SAFE_RELEASE(m_vertexBuffer); + SAFE_RELEASE(m_mesh); +} diff --git a/PhysX_3.4/Samples/SampleFramework/renderer/src/RendererIndexBuffer.cpp b/PhysX_3.4/Samples/SampleFramework/renderer/src/RendererIndexBuffer.cpp new file mode 100644 index 00000000..6060c966 --- /dev/null +++ b/PhysX_3.4/Samples/SampleFramework/renderer/src/RendererIndexBuffer.cpp @@ -0,0 +1,71 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved. +#include <RendererIndexBuffer.h> +#include <RendererIndexBufferDesc.h> + +using namespace SampleRenderer; + +PxU32 RendererIndexBuffer::getFormatByteSize(Format format) +{ + PxU32 size = 0; + switch(format) + { + case FORMAT_UINT16: size = sizeof(PxU16); break; + case FORMAT_UINT32: size = sizeof(PxU32); break; + default: break; + } + RENDERER_ASSERT(size, "Unable to determine size of format."); + return size; +} + +RendererIndexBuffer::RendererIndexBuffer(const RendererIndexBufferDesc &desc) : +RendererInteropableBuffer(desc.registerInCUDA, desc.interopContext), + m_hint(desc.hint), + m_format(desc.format) +{ + m_maxIndices = 0; +} + +RendererIndexBuffer::~RendererIndexBuffer(void) +{ + +} + +RendererIndexBuffer::Hint RendererIndexBuffer::getHint(void) const +{ + return m_hint; +} + +RendererIndexBuffer::Format RendererIndexBuffer::getFormat(void) const +{ + return m_format; +} + +PxU32 RendererIndexBuffer::getMaxIndices(void) const +{ + return m_maxIndices; +} diff --git a/PhysX_3.4/Samples/SampleFramework/renderer/src/RendererIndexBufferDesc.cpp b/PhysX_3.4/Samples/SampleFramework/renderer/src/RendererIndexBufferDesc.cpp new file mode 100644 index 00000000..b4c7e407 --- /dev/null +++ b/PhysX_3.4/Samples/SampleFramework/renderer/src/RendererIndexBufferDesc.cpp @@ -0,0 +1,49 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved. +#include <RendererIndexBufferDesc.h> + +using namespace SampleRenderer; + +RendererIndexBufferDesc::RendererIndexBufferDesc(void) +{ + hint = RendererIndexBuffer::HINT_STATIC; + format = RendererIndexBuffer::NUM_FORMATS; + maxIndices = 0; + canReadBack = false; + registerInCUDA = false; + interopContext = 0; +} + +bool RendererIndexBufferDesc::isValid(void) const +{ + bool ok = true; + if(format >= RendererIndexBuffer::NUM_FORMATS) ok = false; + if(maxIndices == 0) ok = false; + if(registerInCUDA && !interopContext) + ok = false; + return ok; +} diff --git a/PhysX_3.4/Samples/SampleFramework/renderer/src/RendererInstanceBuffer.cpp b/PhysX_3.4/Samples/SampleFramework/renderer/src/RendererInstanceBuffer.cpp new file mode 100644 index 00000000..e745723f --- /dev/null +++ b/PhysX_3.4/Samples/SampleFramework/renderer/src/RendererInstanceBuffer.cpp @@ -0,0 +1,140 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved. +#include <RendererInstanceBuffer.h> +#include <RendererInstanceBufferDesc.h> + +using namespace SampleRenderer; + +PxU32 RendererInstanceBuffer::getFormatByteSize(Format format) +{ + PxU32 size = 0; + switch(format) + { + case FORMAT_FLOAT1: size = sizeof(float)*1; break; + case FORMAT_FLOAT2: size = sizeof(float)*2; break; + case FORMAT_FLOAT3: size = sizeof(float)*3; break; + case FORMAT_FLOAT4: size = sizeof(float)*4; break; + default: break; + } + RENDERER_ASSERT(size, "Unable to determine size of Format."); + return size; +} + +RendererInstanceBuffer::RendererInstanceBuffer(const RendererInstanceBufferDesc &desc) : +RendererInteropableBuffer(desc.registerInCUDA, desc.interopContext), + m_hint(desc.hint) +{ + m_maxInstances = 0; + m_stride = 0; + m_lockedBuffer = 0; + m_numSemanticLocks = 0; + for(PxU32 i=0; i<NUM_SEMANTICS; i++) + { + Format format = desc.semanticFormats[i]; + if(format < NUM_FORMATS) + { + SemanticDesc &sm = m_semanticDescs[i]; + sm.format = format; + sm.offset = m_stride; + m_stride += getFormatByteSize(format); + } + } +} + +RendererInstanceBuffer::~RendererInstanceBuffer(void) +{ + RENDERER_ASSERT(m_lockedBuffer==0 && m_numSemanticLocks==0, "InstanceBuffer had outstanding locks during destruction!"); +} + +RendererInstanceBuffer::Hint RendererInstanceBuffer::getHint(void) const +{ + return m_hint; +} + +RendererInstanceBuffer::Format RendererInstanceBuffer::getFormatForSemantic(Semantic semantic) const +{ + return m_semanticDescs[semantic].format; +} + +PxU32 SampleRenderer::RendererInstanceBuffer::getMaxInstances(void) const +{ + return m_maxInstances; +} + +PxU32 RendererInstanceBuffer::getOffsetForSemantic(Semantic semantic) const +{ + return m_semanticDescs[semantic].offset; +} + +void *RendererInstanceBuffer::lockSemantic(Semantic semantic, PxU32 &stride) +{ + void *semanticBuffer = 0; + RENDERER_ASSERT(semantic < NUM_SEMANTICS, "Invalid InstanceBuffer Semantic!"); + if(semantic < NUM_SEMANTICS) + { + SemanticDesc &sm = m_semanticDescs[semantic]; + RENDERER_ASSERT(!sm.locked, "InstanceBuffer Semantic already locked."); + RENDERER_ASSERT(sm.format < NUM_FORMATS, "InstanceBuffer Semantic format not valid."); + if(!sm.locked && sm.format < NUM_FORMATS) + { + if(!m_lockedBuffer && !m_numSemanticLocks) + { + m_lockedBuffer = lock(); + } + RENDERER_ASSERT(m_lockedBuffer, "Unable to lock InstanceBuffer!"); + if(m_lockedBuffer) + { + m_numSemanticLocks++; + sm.locked = true; + semanticBuffer = ((PxU8*)m_lockedBuffer) + sm.offset; + stride = m_stride; + } + } + } + return semanticBuffer; +} + +void RendererInstanceBuffer::unlockSemantic(Semantic semantic) +{ + RENDERER_ASSERT(semantic < NUM_SEMANTICS, "Invalid InstanceBuffer Semantic!"); + if(semantic < NUM_SEMANTICS) + { + SemanticDesc &sm = m_semanticDescs[semantic]; + RENDERER_ASSERT(m_lockedBuffer && m_numSemanticLocks && sm.locked, "Trying to unlock a semantic that was not locked."); + if(m_lockedBuffer && m_numSemanticLocks && sm.locked) + { + sm.locked = false; + m_numSemanticLocks--; + } + if(m_lockedBuffer && m_numSemanticLocks == 0) + { + unlock(); + m_lockedBuffer = 0; + } + } +} + diff --git a/PhysX_3.4/Samples/SampleFramework/renderer/src/RendererInstanceBufferDesc.cpp b/PhysX_3.4/Samples/SampleFramework/renderer/src/RendererInstanceBufferDesc.cpp new file mode 100644 index 00000000..91297e6e --- /dev/null +++ b/PhysX_3.4/Samples/SampleFramework/renderer/src/RendererInstanceBufferDesc.cpp @@ -0,0 +1,69 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved. +#include <RendererInstanceBufferDesc.h> +#include "foundation/PxAssert.h" + +using namespace SampleRenderer; + +RendererInstanceBufferDesc::RendererInstanceBufferDesc(void) +{ + hint = RendererInstanceBuffer::HINT_STATIC; + for(PxU32 i=0; i<RendererInstanceBuffer::NUM_SEMANTICS; i++) + { + semanticFormats[i] = RendererInstanceBuffer::NUM_FORMATS; + } + maxInstances = 0; + canReadBack = false; + registerInCUDA = false; + interopContext = 0; +} + +bool RendererInstanceBufferDesc::isValid(void) const +{ + bool ok = true; + if(!maxInstances) ok = false; + + bool bValidTurbulence = ok; + if(semanticFormats[RendererInstanceBuffer::SEMANTIC_POSITION] != RendererInstanceBuffer::FORMAT_FLOAT3) ok = false; + if(semanticFormats[RendererInstanceBuffer::SEMANTIC_NORMALX] != RendererInstanceBuffer::FORMAT_FLOAT3) ok = false; + if(semanticFormats[RendererInstanceBuffer::SEMANTIC_NORMALY] != RendererInstanceBuffer::FORMAT_FLOAT3) ok = false; + if(semanticFormats[RendererInstanceBuffer::SEMANTIC_NORMALZ] != RendererInstanceBuffer::FORMAT_FLOAT3) ok = false; + + if(semanticFormats[RendererInstanceBuffer::SEMANTIC_POSITION] != RendererInstanceBuffer::FORMAT_FLOAT3) bValidTurbulence = false; + if(semanticFormats[RendererInstanceBuffer::SEMANTIC_VELOCITY_LIFE] != RendererInstanceBuffer::FORMAT_FLOAT4) bValidTurbulence = false; + + if((semanticFormats[RendererInstanceBuffer::SEMANTIC_UV_OFFSET] != RendererInstanceBuffer::FORMAT_FLOAT2) && + (semanticFormats[RendererInstanceBuffer::SEMANTIC_UV_OFFSET] != RendererInstanceBuffer::NUM_FORMATS)) ok = false; + if((semanticFormats[RendererInstanceBuffer::SEMANTIC_LOCAL_OFFSET] != RendererInstanceBuffer::FORMAT_FLOAT3) && + (semanticFormats[RendererInstanceBuffer::SEMANTIC_LOCAL_OFFSET] != RendererInstanceBuffer::NUM_FORMATS)) ok = false; + + if(registerInCUDA && !interopContext) + ok = false; + + PX_ASSERT(bValidTurbulence || ok); + return bValidTurbulence || ok; +} diff --git a/PhysX_3.4/Samples/SampleFramework/renderer/src/RendererLight.cpp b/PhysX_3.4/Samples/SampleFramework/renderer/src/RendererLight.cpp new file mode 100644 index 00000000..1e91d124 --- /dev/null +++ b/PhysX_3.4/Samples/SampleFramework/renderer/src/RendererLight.cpp @@ -0,0 +1,124 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved. +#include <RendererLight.h> +#include <RendererLightDesc.h> + +#include <Renderer.h> + +using namespace SampleRenderer; + +RendererLight::RendererLight(const RendererLightDesc &desc) : +m_type(desc.type), +m_shadowProjection(45, 1, 0.1f, 100.0f) +{ + m_renderer = 0; + setColor(desc.color); + setIntensity(desc.intensity); + setShadowMap(desc.shadowMap); + setShadowTransform(desc.shadowTransform); + setShadowProjection(desc.shadowProjection); +} + +RendererLight::~RendererLight(void) +{ + RENDERER_ASSERT(!isLocked(), "Light is locked by a Renderer during release."); +} + +void SampleRenderer::RendererLight::release(void) +{ + if (m_renderer) m_renderer->removeLightFromRenderQueue(*this); + delete this; +} + +RendererLight::Type RendererLight::getType(void) const +{ + return m_type; +} + +RendererMaterial::Pass RendererLight::getPass(void) const +{ + RendererMaterial::Pass pass = RendererMaterial::NUM_PASSES; + switch(m_type) + { + case TYPE_POINT: pass = RendererMaterial::PASS_POINT_LIGHT; break; + case TYPE_DIRECTIONAL: pass = RendererMaterial::PASS_DIRECTIONAL_LIGHT; break; + case TYPE_SPOT: pass = m_shadowMap != NULL ? RendererMaterial::PASS_SPOT_LIGHT : RendererMaterial::PASS_SPOT_LIGHT_NO_SHADOW; break; + default: break; + } + RENDERER_ASSERT(pass < RendererMaterial::NUM_PASSES, "Unable to compute the Pass for the Light."); + return pass; +} + +const RendererColor &RendererLight::getColor(void) const +{ + return m_color; +} + +void RendererLight::setColor(const RendererColor &color) +{ + m_color = color; +} + +float RendererLight::getIntensity(void) const +{ + return m_intensity; +} + +void RendererLight::setIntensity(float intensity) +{ + RENDERER_ASSERT(intensity >= 0, "Light intensity is negative."); + if(intensity >= 0) + { + m_intensity = intensity; + } +} + +bool RendererLight::isLocked(void) const +{ + return m_renderer ? true : false; +} + +RendererTexture2D *RendererLight::getShadowMap(void) const +{ + return m_shadowMap; +} + +void RendererLight::setShadowMap(RendererTexture2D *shadowMap) +{ + m_shadowMap = shadowMap; +} + +const RendererProjection &RendererLight::getShadowProjection(void) const +{ + return m_shadowProjection; +} + +void RendererLight::setShadowProjection(const RendererProjection &shadowProjection) +{ + m_shadowProjection = shadowProjection; +} + diff --git a/PhysX_3.4/Samples/SampleFramework/renderer/src/RendererLightDesc.cpp b/PhysX_3.4/Samples/SampleFramework/renderer/src/RendererLightDesc.cpp new file mode 100644 index 00000000..fa7f7582 --- /dev/null +++ b/PhysX_3.4/Samples/SampleFramework/renderer/src/RendererLightDesc.cpp @@ -0,0 +1,46 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved. +#include <RendererLightDesc.h> + +using namespace SampleRenderer; + +RendererLightDesc::RendererLightDesc(RendererLight::Type _type) : +type(_type), +shadowProjection(45, 1, 0.1f, 100.0f) +{ + color = RendererColor(0,0,0,0); + intensity = 0; + shadowMap = 0; + shadowTransform = physx::PxTransform(PxIdentity); +} + +bool RendererLightDesc::isValid(void) const +{ + bool ok = true; + if(intensity < 0) ok = false; + return ok; +} diff --git a/PhysX_3.4/Samples/SampleFramework/renderer/src/RendererMaterial.cpp b/PhysX_3.4/Samples/SampleFramework/renderer/src/RendererMaterial.cpp new file mode 100644 index 00000000..aec0c0b9 --- /dev/null +++ b/PhysX_3.4/Samples/SampleFramework/renderer/src/RendererMaterial.cpp @@ -0,0 +1,195 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved. +#include <RendererMaterial.h> + +#include <Renderer.h> +#include <RendererMaterialDesc.h> +#include <RendererMaterialInstance.h> + + +#include <PsString.h> +namespace Ps = physx::shdfnd; +#undef PxI32 + +using namespace SampleRenderer; + +static PxU32 getVariableTypeSize(RendererMaterial::VariableType type) +{ + PxU32 size = 0; + switch(type) + { + case RendererMaterial::VARIABLE_FLOAT: size = sizeof(float)*1; break; + case RendererMaterial::VARIABLE_FLOAT2: size = sizeof(float)*2; break; + case RendererMaterial::VARIABLE_FLOAT3: size = sizeof(float)*3; break; + case RendererMaterial::VARIABLE_FLOAT4: size = sizeof(float)*4; break; + case RendererMaterial::VARIABLE_FLOAT4x4: size = sizeof(float)*4*4; break; + case RendererMaterial::VARIABLE_INT: size = sizeof(int)*1; break; + case RendererMaterial::VARIABLE_SAMPLER2D: size = sizeof(RendererTexture2D*); break; + case RendererMaterial::VARIABLE_SAMPLER3D: size = sizeof(RendererTexture3D*); break; + default: break; + } + RENDERER_ASSERT(size>0, "Unable to compute Variable Type size."); + return size; +} + +RendererMaterial::Variable::Variable(const char *name, VariableType type, unsigned int offset) +{ + size_t len = strlen(name)+1; + m_name = new char[len]; + Ps::strlcpy(m_name, len, name); + m_type = type; + m_offset = offset; + m_size = -1; +} + +void RendererMaterial::Variable::setSize(PxU32 size) +{ + m_size = size; +} + +RendererMaterial::Variable::~Variable(void) +{ + if(m_name) delete [] m_name; +} + +const char *RendererMaterial::Variable::getName(void) const +{ + return m_name; +} + +RendererMaterial::VariableType RendererMaterial::Variable::getType(void) const +{ + return m_type; +} + +PxU32 RendererMaterial::Variable::getDataOffset(void) const +{ + return m_offset; +} + +PxU32 RendererMaterial::Variable::getDataSize(void) const +{ + return m_size != -1 ? m_size : getVariableTypeSize(m_type); +} + +const char *RendererMaterial::getPassName(Pass pass) +{ + const char *passName = 0; + switch(pass) + { + case PASS_UNLIT: passName="PASS_UNLIT"; break; + + case PASS_AMBIENT_LIGHT: passName="PASS_AMBIENT_LIGHT"; break; + case PASS_POINT_LIGHT: passName="PASS_POINT_LIGHT"; break; + case PASS_DIRECTIONAL_LIGHT: passName="PASS_DIRECTIONAL_LIGHT"; break; + case PASS_SPOT_LIGHT_NO_SHADOW: passName="PASS_SPOT_LIGHT_NO_SHADOW"; break; + case PASS_SPOT_LIGHT: passName="PASS_SPOT_LIGHT"; break; + + case PASS_NORMALS: passName="PASS_NORMALS"; break; + case PASS_DEPTH: passName="PASS_DEPTH"; break; + default: break; + + // LRR: The deferred pass causes compiles with the ARB_draw_buffers profile option, creating + // multiple color draw buffers. This doesn't work in OGL on ancient Intel parts. + //case PASS_DEFERRED: passName="PASS_DEFERRED"; break; + } + RENDERER_ASSERT(passName, "Unable to obtain name for the given Material Pass."); + return passName; +} + +RendererMaterial::RendererMaterial(const RendererMaterialDesc &desc, bool enableMaterialCaching) : + m_type(desc.type), + m_alphaTestFunc(desc.alphaTestFunc), + m_srcBlendFunc(desc.srcBlendFunc), + m_dstBlendFunc(desc.dstBlendFunc), + m_refCount(1), + mEnableMaterialCaching(enableMaterialCaching) +{ + m_alphaTestRef = desc.alphaTestRef; + m_blending = desc.blending; + m_variableBufferSize = 0; +} + +RendererMaterial::~RendererMaterial(void) +{ + RENDERER_ASSERT(m_refCount == 0, "RendererMaterial was not released as often as it was created"); + + PxU32 numVariables = (PxU32)m_variables.size(); + for(PxU32 i=0; i<numVariables; i++) + { + delete m_variables[i]; + } +} + +void RendererMaterial::release() +{ + m_refCount--; + + if (!mEnableMaterialCaching) + { + PX_ASSERT(m_refCount == 0); + delete this; + } +} + +void RendererMaterial::bind(RendererMaterial::Pass pass, RendererMaterialInstance *materialInstance, bool instanced) const +{ + if(materialInstance) + { + PxU32 numVariables = (PxU32)m_variables.size(); + for(PxU32 i = 0; i < numVariables; i++) + { + const Variable &variable = *m_variables[i]; + bindVariable(pass, variable, materialInstance->m_data+variable.getDataOffset()); + } + } +} + +bool RendererMaterial::rendererBlendingOverrideEnabled() const +{ + return getRenderer().blendingOverrideEnabled(); +} + +const RendererMaterial::Variable *RendererMaterial::findVariable(const char *name, RendererMaterial::VariableType varType) +{ + RendererMaterial::Variable *var = 0; + PxU32 numVariables = (PxU32)m_variables.size(); + for(PxU32 i=0; i<numVariables; i++) + { + RendererMaterial::Variable &v = *m_variables[i]; + if(!strcmp(v.getName(), name)) + { + var = &v; + break; + } + } + if(var && var->getType() != varType) + { + var = 0; + } + return var; +} diff --git a/PhysX_3.4/Samples/SampleFramework/renderer/src/RendererMaterialDesc.cpp b/PhysX_3.4/Samples/SampleFramework/renderer/src/RendererMaterialDesc.cpp new file mode 100644 index 00000000..ab726676 --- /dev/null +++ b/PhysX_3.4/Samples/SampleFramework/renderer/src/RendererMaterialDesc.cpp @@ -0,0 +1,64 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved. +#include <RendererMaterialDesc.h> + +using namespace SampleRenderer; + +RendererMaterialDesc::RendererMaterialDesc(void) +{ + type = RendererMaterial::TYPE_UNLIT; + alphaTestFunc = RendererMaterial::ALPHA_TEST_ALWAYS; + alphaTestRef = 0; + blending = false; + instanced = false; + srcBlendFunc = RendererMaterial::BLEND_ZERO; + dstBlendFunc = RendererMaterial::BLEND_ZERO; + geometryShaderPath = 0; + hullShaderPath = 0; + domainShaderPath = 0; + vertexShaderPath = 0; + fragmentShaderPath = 0; +} + +bool RendererMaterialDesc::isValid(void) const +{ + bool ok = true; + if(type >= RendererMaterial::NUM_TYPES) ok = false; + if(alphaTestRef < 0 || alphaTestRef > 1) ok = false; + // Note: Lighting and blending may not be properly supported, but that + // shouldn't crash the system, so this check is disabled for now + // if(blending && type != RendererMaterial::TYPE_UNLIT) ok = false; + if(geometryShaderPath || domainShaderPath || fragmentShaderPath) + { + // Note: These should be completely optional! Disabling for now. + //RENDERER_ASSERT(0, "Not implemented!"); + //ok = false; + } + if(!vertexShaderPath) ok = false; + if(!fragmentShaderPath) ok = false; + return ok; +} diff --git a/PhysX_3.4/Samples/SampleFramework/renderer/src/RendererMaterialInstance.cpp b/PhysX_3.4/Samples/SampleFramework/renderer/src/RendererMaterialInstance.cpp new file mode 100644 index 00000000..4b25dfe8 --- /dev/null +++ b/PhysX_3.4/Samples/SampleFramework/renderer/src/RendererMaterialInstance.cpp @@ -0,0 +1,77 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved. +#include <RendererMaterialInstance.h> +#include <RendererMaterial.h> +#include <foundation/PxAssert.h> + +using namespace SampleRenderer; + +RendererMaterialInstance::RendererMaterialInstance(RendererMaterial &material) : +m_material(material) +{ + m_data = 0; + PxU32 dataSize = m_material.getMaterialInstanceDataSize(); + if(dataSize > 0) + { + m_data = new PxU8[dataSize]; + memset(m_data, 0, dataSize); + } +} + +RendererMaterialInstance::RendererMaterialInstance(const RendererMaterialInstance& other) : +m_material(other.m_material) +{ + PxU32 dataSize = m_material.getMaterialInstanceDataSize(); + if (dataSize > 0) + { + m_data = new PxU8[dataSize]; + memcpy(m_data, other.m_data, dataSize); + } +} + +RendererMaterialInstance::~RendererMaterialInstance(void) +{ + if(m_data) delete [] m_data; +} + +void RendererMaterialInstance::writeData(const RendererMaterial::Variable &var, const void *data) +{ + if(m_data && data) + { + memcpy(m_data+var.getDataOffset(), data, var.getDataSize()); + } +} + +RendererMaterialInstance &RendererMaterialInstance::operator=(const RendererMaterialInstance &b) +{ + PX_ASSERT(&m_material == &b.m_material); + if(&m_material == &b.m_material) + { + memcpy(m_data, b.m_data, m_material.getMaterialInstanceDataSize()); + } + return *this; +} diff --git a/PhysX_3.4/Samples/SampleFramework/renderer/src/RendererMesh.cpp b/PhysX_3.4/Samples/SampleFramework/renderer/src/RendererMesh.cpp new file mode 100644 index 00000000..9a76579a --- /dev/null +++ b/PhysX_3.4/Samples/SampleFramework/renderer/src/RendererMesh.cpp @@ -0,0 +1,193 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved. +#include <RendererMesh.h> +#include <RendererMeshDesc.h> + +#include <Renderer.h> +#include <RendererVertexBuffer.h> +#include <RendererIndexBuffer.h> +#include <RendererInstanceBuffer.h> + + +using namespace SampleRenderer; + +RendererMesh::RendererMesh(const RendererMeshDesc &desc) +{ + m_primitives = desc.primitives; + + m_numVertexBuffers = desc.numVertexBuffers; + m_vertexBuffers = new RendererVertexBuffer*[m_numVertexBuffers]; + for(PxU32 i=0; i<m_numVertexBuffers; i++) + { + m_vertexBuffers[i] = desc.vertexBuffers[i]; + } + m_firstVertex = desc.firstVertex; + m_numVertices = desc.numVertices; + + m_indexBuffer = desc.indexBuffer; + m_firstIndex = desc.firstIndex; + m_numIndices = desc.numIndices; + + m_instanceBuffer = desc.instanceBuffer; + m_firstInstance = desc.firstInstance; + m_numInstances = desc.numInstances; +} + +RendererMesh::~RendererMesh(void) +{ + delete [] m_vertexBuffers; +} + +void SampleRenderer::RendererMesh::release(void) +{ + renderer().removeMeshFromRenderQueue(*this); + delete this; +} + +RendererMesh::Primitive RendererMesh::getPrimitives(void) const +{ + return m_primitives; +} + +PxU32 RendererMesh::getNumVertices(void) const +{ + return m_numVertices; +} + +PxU32 RendererMesh::getNumIndices(void) const +{ + return m_numIndices; +} + +PxU32 RendererMesh::getNumInstances(void) const +{ + return m_numInstances; +} + +void RendererMesh::setVertexBufferRange(PxU32 firstVertex, PxU32 numVertices) +{ + // TODO: Check for valid range... + m_firstVertex = firstVertex; + m_numVertices = numVertices; +} + +void RendererMesh::setIndexBufferRange(PxU32 firstIndex, PxU32 numIndices) +{ + // TODO: Check for valid range... + m_firstIndex = firstIndex; + m_numIndices = numIndices; +} + +void RendererMesh::setInstanceBufferRange(PxU32 firstInstance, PxU32 numInstances) +{ + // TODO: Check for valid range... + m_firstInstance = firstInstance; + m_numInstances = numInstances; +} + +PxU32 RendererMesh::getNumVertexBuffers(void) const +{ + return m_numVertexBuffers; +} + +const RendererVertexBuffer *const*RendererMesh::getVertexBuffers(void) const +{ + return m_vertexBuffers; +} + +const RendererIndexBuffer *RendererMesh::getIndexBuffer(void) const +{ + return m_indexBuffer; +} + +const RendererInstanceBuffer *RendererMesh::getInstanceBuffer(void) const +{ + return m_instanceBuffer; +} + +void RendererMesh::bind(void) const +{ + for(PxU32 i=0; i<m_numVertexBuffers; i++) + { + //RENDERER_ASSERT(m_vertexBuffers[i]->checkBufferWritten(), "Vertex buffer is empty!"); + if (m_vertexBuffers[i]->checkBufferWritten()) + { + m_vertexBuffers[i]->bind(i, m_firstVertex); + } + } + if(m_instanceBuffer) + { + m_instanceBuffer->bind(m_numVertexBuffers, m_firstInstance); + } + if(m_indexBuffer) + { + m_indexBuffer->bind(); + } +} + +void RendererMesh::render(RendererMaterial *material) const +{ + if(m_instanceBuffer) + { + if(m_indexBuffer) + { + renderIndicesInstanced(m_numVertices, m_firstIndex, m_numIndices, m_indexBuffer->getFormat(), material); + } + else if(m_numVertices) + { + renderVerticesInstanced(m_numVertices, material); + } + } + else + { + if(m_indexBuffer) + { + renderIndices(m_numVertices, m_firstIndex, m_numIndices, m_indexBuffer->getFormat(), material); + } + else if(m_numVertices) + { + renderVertices(m_numVertices, material); + } + } +} + +void RendererMesh::unbind(void) const +{ + if(m_indexBuffer) + { + m_indexBuffer->unbind(); + } + if(m_instanceBuffer) + { + m_instanceBuffer->unbind(m_numVertexBuffers); + } + for(PxU32 i=0; i<m_numVertexBuffers; i++) + { + m_vertexBuffers[i]->unbind(i); + } +} + diff --git a/PhysX_3.4/Samples/SampleFramework/renderer/src/RendererMeshContext.cpp b/PhysX_3.4/Samples/SampleFramework/renderer/src/RendererMeshContext.cpp new file mode 100644 index 00000000..8bbbfcea --- /dev/null +++ b/PhysX_3.4/Samples/SampleFramework/renderer/src/RendererMeshContext.cpp @@ -0,0 +1,56 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved. +#include <RendererMeshContext.h> + +using namespace SampleRenderer; + +RendererMeshContext::RendererMeshContext(void) +{ + mesh = 0; + material = 0; + materialInstance = 0; + transform = 0; + shaderData = 0; + boneMatrices = 0; + numBones = 0; + cullMode = CLOCKWISE; + screenSpace = false; + fillMode = SOLID; + negativeScale = false; +} + +RendererMeshContext::~RendererMeshContext(void) +{ +} + +bool RendererMeshContext::isValid(void) const +{ + bool ok = true; + if(!mesh) ok = false; + if(!material) ok = false; + return ok; +} diff --git a/PhysX_3.4/Samples/SampleFramework/renderer/src/RendererMeshDesc.cpp b/PhysX_3.4/Samples/SampleFramework/renderer/src/RendererMeshDesc.cpp new file mode 100644 index 00000000..2a461a36 --- /dev/null +++ b/PhysX_3.4/Samples/SampleFramework/renderer/src/RendererMeshDesc.cpp @@ -0,0 +1,57 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved. +#include <RendererMeshDesc.h> + +using namespace SampleRenderer; + +RendererMeshDesc::RendererMeshDesc(void) +{ + primitives = RendererMesh::PRIMITIVE_POINTS; + + vertexBuffers = 0; + numVertexBuffers = 0; + firstVertex = 0; + numVertices = 0; + + indexBuffer = 0; + firstIndex = 0; + numIndices = 0; + + instanceBuffer = 0; + firstInstance = 0; + numInstances = 0; +} + +bool RendererMeshDesc::isValid(void) const +{ + bool ok = true; + // remove vertexBuffer check for sprites + /* if(!vertexBuffers || !numVertexBuffers) ok = false; */ + if(numIndices && !indexBuffer) ok = false; + if(numInstances && !instanceBuffer) ok = false; + return ok; +} diff --git a/PhysX_3.4/Samples/SampleFramework/renderer/src/RendererMeshShape.cpp b/PhysX_3.4/Samples/SampleFramework/renderer/src/RendererMeshShape.cpp new file mode 100644 index 00000000..94e167bb --- /dev/null +++ b/PhysX_3.4/Samples/SampleFramework/renderer/src/RendererMeshShape.cpp @@ -0,0 +1,171 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved. + +#include <RendererMeshShape.h> + +#include <Renderer.h> + +#include <RendererVertexBuffer.h> +#include <RendererVertexBufferDesc.h> + +#include <RendererIndexBuffer.h> +#include <RendererIndexBufferDesc.h> + +#include <RendererMesh.h> +#include <RendererMeshDesc.h> + +#include <RendererMemoryMacros.h> + +using namespace SampleRenderer; + +RendererMeshShape::RendererMeshShape( Renderer& renderer, + const PxVec3* verts, PxU32 numVerts, + const PxVec3* normals, + const PxReal* uvs, + const PxU16* faces16, const PxU32* faces32, PxU32 numFaces, bool flipWinding) : +RendererShape(renderer) +{ + RENDERER_ASSERT((faces16 || faces32), "Needs either 16bit or 32bit indices."); + RendererVertexBufferDesc vbdesc; + vbdesc.hint = RendererVertexBuffer::HINT_STATIC; + vbdesc.semanticFormats[RendererVertexBuffer::SEMANTIC_POSITION] = RendererVertexBuffer::FORMAT_FLOAT3; + vbdesc.semanticFormats[RendererVertexBuffer::SEMANTIC_NORMAL] = RendererVertexBuffer::FORMAT_FLOAT3; + vbdesc.semanticFormats[RendererVertexBuffer::SEMANTIC_TEXCOORD0] = RendererVertexBuffer::FORMAT_FLOAT2; + vbdesc.maxVertices = numVerts; + m_vertexBuffer = m_renderer.createVertexBuffer(vbdesc); + RENDERER_ASSERT(m_vertexBuffer, "Failed to create Vertex Buffer."); + if(m_vertexBuffer) + { + PxU32 positionStride = 0; + void* vertPositions = m_vertexBuffer->lockSemantic(RendererVertexBuffer::SEMANTIC_POSITION, positionStride); + + PxU32 normalStride = 0; + void* vertNormals = m_vertexBuffer->lockSemantic(RendererVertexBuffer::SEMANTIC_NORMAL, normalStride); + + PxU32 uvStride = 0; + void* vertUVs = m_vertexBuffer->lockSemantic(RendererVertexBuffer::SEMANTIC_TEXCOORD0, uvStride); + + if(vertPositions && vertNormals && vertUVs) + { + for(PxU32 i=0; i<numVerts; i++) + { + memcpy(vertPositions, verts+i, sizeof(PxVec3)); + if(normals) + memcpy(vertNormals, normals+i, sizeof(PxVec3)); + else + memset(vertNormals, 0, sizeof(PxVec3)); + + if(uvs) + memcpy(vertUVs, uvs+i*2, sizeof(PxReal)*2); + else + memset(vertUVs, 0, sizeof(PxReal)*2); + + vertPositions = (void*)(((PxU8*)vertPositions) + positionStride); + vertNormals = (void*)(((PxU8*)vertNormals) + normalStride); + vertUVs = (void*)(((PxU8*)vertUVs) + uvStride); + } + } + m_vertexBuffer->unlockSemantic(RendererVertexBuffer::SEMANTIC_NORMAL); + m_vertexBuffer->unlockSemantic(RendererVertexBuffer::SEMANTIC_POSITION); + m_vertexBuffer->unlockSemantic(RendererVertexBuffer::SEMANTIC_TEXCOORD0); + } + + const PxU32 numIndices = numFaces*3; + + RendererIndexBufferDesc ibdesc; + ibdesc.hint = RendererIndexBuffer::HINT_STATIC; + ibdesc.format = faces16 ? RendererIndexBuffer::FORMAT_UINT16 : RendererIndexBuffer::FORMAT_UINT32; + ibdesc.maxIndices = numIndices; + m_indexBuffer = m_renderer.createIndexBuffer(ibdesc); + RENDERER_ASSERT(m_indexBuffer, "Failed to create Index Buffer."); + if(m_indexBuffer) + { + if(faces16) + { + PxU16* indices = (PxU16*)m_indexBuffer->lock(); + if(indices) + { + if(flipWinding) + { + for(PxU32 i=0;i<numFaces;i++) + { + indices[i*3+0] = faces16[i*3+0]; + indices[i*3+1] = faces16[i*3+2]; + indices[i*3+2] = faces16[i*3+1]; + } + } + else + { + memcpy(indices, faces16, sizeof(*faces16)*numFaces*3); + } + } + } + else + { + PxU32* indices = (PxU32*)m_indexBuffer->lock(); + if(indices) + { + if(flipWinding) + { + for(PxU32 i=0;i<numFaces;i++) + { + indices[i*3+0] = faces32[i*3+0]; + indices[i*3+1] = faces32[i*3+2]; + indices[i*3+2] = faces32[i*3+1]; + } + } + else + { + memcpy(indices, faces32, sizeof(*faces32)*numFaces*3); + } + } + } + m_indexBuffer->unlock(); + } + + if(m_vertexBuffer && m_indexBuffer) + { + RendererMeshDesc meshdesc; + meshdesc.primitives = RendererMesh::PRIMITIVE_TRIANGLES; + meshdesc.vertexBuffers = &m_vertexBuffer; + meshdesc.numVertexBuffers = 1; + meshdesc.firstVertex = 0; + meshdesc.numVertices = numVerts; + meshdesc.indexBuffer = m_indexBuffer; + meshdesc.firstIndex = 0; + meshdesc.numIndices = numIndices; + m_mesh = m_renderer.createMesh(meshdesc); + RENDERER_ASSERT(m_mesh, "Failed to create Mesh."); + } +} + +RendererMeshShape::~RendererMeshShape(void) +{ + SAFE_RELEASE(m_vertexBuffer); + SAFE_RELEASE(m_indexBuffer); + SAFE_RELEASE(m_mesh); +} diff --git a/PhysX_3.4/Samples/SampleFramework/renderer/src/RendererParticleSystemShape.cpp b/PhysX_3.4/Samples/SampleFramework/renderer/src/RendererParticleSystemShape.cpp new file mode 100644 index 00000000..06e62043 --- /dev/null +++ b/PhysX_3.4/Samples/SampleFramework/renderer/src/RendererParticleSystemShape.cpp @@ -0,0 +1,643 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved. +// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. +// Copyright (c) 2001-2004 NovodeX AG. All rights reserved. +#include <PsUtilities.h> + +#include <RendererParticleSystemShape.h> + +#include <Renderer.h> + +#include <RendererMemoryMacros.h> +#include <RendererIndexBuffer.h> +#include <RendererIndexBufferDesc.h> +#include <RendererVertexBuffer.h> +#include <RendererVertexBufferDesc.h> +#include <RendererInstanceBuffer.h> +#include <RendererInstanceBufferDesc.h> +#include <RendererMesh.h> +#include <RendererMeshDesc.h> +#include "PsUtilities.h" +#include "PsBitUtils.h" + +using namespace SampleRenderer; +using namespace physx::shdfnd; + +PxReal convexVertices[] = { 0.0f, 1.0f, 0.0f, // 1 up face + 0.5f, 0.0f, 0.5f, + 0.5f, 0.0f, -0.5f, + 0.0f, 1.0f, 0.0f, // 2 up face + 0.5f, 0.0f, -0.5f, + -0.5f, 0.0f, -0.5f, + 0.0f, 1.0f, 0.0f, // 3 up face + -0.5f, 0.0f, -0.5f, + -0.5f, 0.0f, 0.5f, + 0.0f, 1.0f, 0.0f, // 4 up face + -0.5f, 0.0f, 0.5f, + 0.5f, 0.0f, 0.5f, + 0.0f, -1.0f, 0.0f, // 1 down face + 0.5f, 0.0f, 0.5f, + 0.5f, 0.0f, -0.5f, + 0.0f, -1.0f, 0.0f, // 2 down face + 0.5f, 0.0f, -0.5f, + -0.5f, 0.0f, -0.5f, + 0.0f, -1.0f, 0.0f, // 3 down face + -0.5f, 0.0f, -0.5f, + -0.5f, 0.0f, 0.5f, + 0.0f, -1.0f, 0.0f, // 4 down face + -0.5f, 0.0f, 0.5f, + 0.5f, 0.0f, 0.5f }; +PxReal convexTexcoords[] = { 0.0f, 0.0f, // each face + 0.0f, 1.0f, + 1.0f, 0.0f }; +PxReal convexNormals[] = { 1.0f, -0.5f, 0.0f, // 1 up face + 1.0f, -0.5f, 0.0f, + 1.0f, -0.5f, 0.0f, + 0.0f, -0.5f, -1.0f, // 2 up face + 0.0f, -0.5f, -1.0f, + 0.0f, -0.5f, -1.0f, + -1.0f, -0.5f, 0.0f, // 3 up face + -1.0f, -0.5f, 0.0f, + -1.0f, -0.5f, 0.0f, + 0.0f, -0.5f, 1.0f, // 4 up face + 0.0f, -0.5f, 1.0f, + 0.0f, -0.5f, 1.0f, + 1.0f, 0.5f, 0.0f, // 1 down face + 1.0f, 0.5f, 0.0f, + 1.0f, 0.5f, 0.0f, + 0.0f, 0.5f, -1.0f, // 2 down face + 0.0f, 0.5f, -1.0f, + 0.0f, 0.5f, -1.0f, + -1.0f, -0.5f, 0.0f, // 3 down face + -1.0f, -0.5f, 0.0f, + -1.0f, -0.5f, 0.0f, + 0.0f, -0.5f, 1.0f, // 4 down face + 0.0f, -0.5f, 1.0f, + 0.0f, -0.5f, 1.0f }; +PxU32 convexIndices[] = { 0, 1, 2, + 3, 4, 5, + 6, 7, 8, + 9, 10, 11, + 12, 13, 14, + 15, 16, 17, + 18, 19, 20, + 21, 22, 23 }; + +const PxU32 convexVerticesCount = PX_ARRAY_SIZE(convexVertices) / 3 ; +const PxU32 convexIndicesCount = PX_ARRAY_SIZE(convexIndices); +//const PxU32 convexNormalsCount = PX_ARRAY_SIZE(convexNormals) / 3; +//const PxU32 convexTexcoordsCount = PX_ARRAY_SIZE(convexTexcoords) / 2; + +#if defined(RENDERER_ENABLE_CUDA_INTEROP) +#include <task/PxTask.h> +#include <cuda.h> + +// pre-compiled fatbin +#if defined(_M_X64) +#include "cuda/RenderParticles_x64.cuh" +#else +#include "cuda/RenderParticles_x86.cuh" +#endif + +namespace +{ + CUmodule gParticlesCuRenderModule; + CUfunction gParticlesCuUpdateInstanceFunc; + CUfunction gParticlesCuUpdateBillboardFunc; + + void checkSuccess(CUresult r) + { + PX_ASSERT(r == CUDA_SUCCESS); + } +} + +#endif // RENDERER_ENABLE_CUDA_INTEROP + +RendererParticleSystemShape::RendererParticleSystemShape(Renderer &renderer, + PxU32 _mMaxParticles, bool _mInstanced, bool _mFading, + PxReal fadingPeriod, PxReal debriScaleFactor, PxCudaContextManager* ctxMgr) : + RendererShape(renderer), + mInstanced(_mInstanced), + mFading(_mFading), + mFadingPeriod(fadingPeriod), + mMaxParticles(_mMaxParticles), + mInstanceBuffer(NULL), + mIndexBuffer(NULL), + mCtxMgr(ctxMgr) +{ + for(PxU32 i = 0; i < NUM_VERTEX_BUFFERS; i++ ) + { + mVertexBuffer[i] = NULL; + } + RendererVertexBufferDesc vbdesc; + +#if defined(RENDERER_ENABLE_CUDA_INTEROP) + if (ctxMgr) + { + vbdesc.registerInCUDA = true; + vbdesc.interopContext = ctxMgr; + + ctxMgr->acquireContext(); + + // find module containing our kernel + CUresult success; + + success = cuModuleLoadDataEx(&gParticlesCuRenderModule, updateParticleVertexBuffer, 0, NULL, NULL); + RENDERER_ASSERT(success == CUDA_SUCCESS, "Could not load cloth render CUDA module."); + + success = cuModuleGetFunction(&gParticlesCuUpdateInstanceFunc, gParticlesCuRenderModule, "updateInstancedVB"); + RENDERER_ASSERT(success == CUDA_SUCCESS, "Could not find cloth render CUDA function."); + + success = cuModuleGetFunction(&gParticlesCuUpdateBillboardFunc, gParticlesCuRenderModule, "updateBillboardVB"); + RENDERER_ASSERT(success == CUDA_SUCCESS, "Could not find cloth render CUDA function."); + + ctxMgr->releaseContext(); + } +#endif //RENDERER_ENABLE_CUDA_INTEROP + + if(mInstanced) + { + vbdesc.hint = RendererVertexBuffer::HINT_STATIC; + vbdesc.maxVertices = convexVerticesCount; + } + else + { +#if defined(RENDERER_TABLET) + vbdesc.hint = RendererVertexBuffer::HINT_STATIC; +#else + vbdesc.hint = RendererVertexBuffer::HINT_DYNAMIC; +#endif + vbdesc.maxVertices = mMaxParticles; + } + { + RendererVertexBufferDesc vbdesc_l = vbdesc; + vbdesc_l.semanticFormats[RendererVertexBuffer::SEMANTIC_POSITION] = RendererVertexBuffer::FORMAT_FLOAT3; + mVertexBuffer[DYNAMIC_POS_VB] = m_renderer.createVertexBuffer(vbdesc_l); + RENDERER_ASSERT(mVertexBuffer[DYNAMIC_POS_VB], "Failed to create Vertex Buffer."); + } + { + RendererVertexBufferDesc vbdesc_l = vbdesc; + vbdesc_l.semanticFormats[RendererVertexBuffer::SEMANTIC_COLOR] = RendererVertexBuffer::FORMAT_COLOR_NATIVE; + mVertexBuffer[DYNAMIC_COL_VB] = m_renderer.createVertexBuffer(vbdesc_l); + RENDERER_ASSERT(mVertexBuffer[DYNAMIC_COL_VB], "Failed to create Vertex Buffer."); + } + vbdesc.hint = RendererVertexBuffer::HINT_STATIC; + vbdesc.semanticFormats[RendererVertexBuffer::SEMANTIC_NORMAL] = RendererVertexBuffer::FORMAT_FLOAT3; + vbdesc.semanticFormats[RendererVertexBuffer::SEMANTIC_TEXCOORD0] = RendererVertexBuffer::FORMAT_FLOAT2; + mVertexBuffer[STATIC_VB] = m_renderer.createVertexBuffer(vbdesc); + RENDERER_ASSERT(mVertexBuffer[STATIC_VB], "Failed to create Vertex Buffer."); + // if enabled mInstanced meshes -> create instance buffer + if(mInstanced) + { + // create index buffer + RendererIndexBufferDesc inbdesc; + inbdesc.hint = RendererIndexBuffer::HINT_STATIC; + inbdesc.format = RendererIndexBuffer::FORMAT_UINT32; + inbdesc.maxIndices = convexIndicesCount; + mIndexBuffer = m_renderer.createIndexBuffer(inbdesc); + RENDERER_ASSERT(mIndexBuffer, "Failed to create Instance Buffer."); + // create instance buffer + RendererInstanceBufferDesc ibdesc; + ibdesc.hint = RendererInstanceBuffer::HINT_DYNAMIC; + ibdesc.semanticFormats[RendererInstanceBuffer::SEMANTIC_POSITION] = RendererInstanceBuffer::FORMAT_FLOAT3; + ibdesc.semanticFormats[RendererInstanceBuffer::SEMANTIC_NORMALX] = RendererInstanceBuffer::FORMAT_FLOAT3; + ibdesc.semanticFormats[RendererInstanceBuffer::SEMANTIC_NORMALY] = RendererInstanceBuffer::FORMAT_FLOAT3; + ibdesc.semanticFormats[RendererInstanceBuffer::SEMANTIC_NORMALZ] = RendererInstanceBuffer::FORMAT_FLOAT3; + ibdesc.semanticFormats[RendererInstanceBuffer::SEMANTIC_VELOCITY_LIFE] = RendererInstanceBuffer::FORMAT_FLOAT4; + ibdesc.maxInstances = mMaxParticles; + + if (ctxMgr) + { + ibdesc.registerInCUDA = true; + ibdesc.interopContext = ctxMgr; + } + + mInstanceBuffer = m_renderer.createInstanceBuffer(ibdesc); + RENDERER_ASSERT(mInstanceBuffer, "Failed to create Instance Buffer."); + } + PxU32 color = renderer.convertColor(RendererColor(255, 255, 255, 255)); + PxU32 numInstances = 0; + RendererMesh::Primitive primitive = RendererMesh::PRIMITIVE_POINT_SPRITES; + if(mInstanced) + { + numInstances = mMaxParticles; + initializeBuffersAsSimpleConvex(color, debriScaleFactor); + initializeInstanceBuffer(); + primitive = RendererMesh::PRIMITIVE_TRIANGLES; + } + else + { + initializeVertexBuffer(color); + } + if(mVertexBuffer[DYNAMIC_POS_VB] && mVertexBuffer[DYNAMIC_COL_VB] && mVertexBuffer[STATIC_VB]) + { + RendererMeshDesc meshdesc; + meshdesc.primitives = primitive; + meshdesc.vertexBuffers = mVertexBuffer; + meshdesc.numVertexBuffers = NUM_VERTEX_BUFFERS; + meshdesc.firstVertex = 0; + meshdesc.numVertices = mVertexBuffer[STATIC_VB]->getMaxVertices(); + meshdesc.indexBuffer = mIndexBuffer; + meshdesc.firstIndex = 0; + if(mIndexBuffer) + { + meshdesc.numIndices = mIndexBuffer->getMaxIndices(); + } + else + { + meshdesc.numIndices = 0; + } + meshdesc.instanceBuffer = mInstanceBuffer; + meshdesc.firstInstance = 0; + meshdesc.numInstances = numInstances; + m_mesh = m_renderer.createMesh(meshdesc); + RENDERER_ASSERT(m_mesh, "Failed to create Mesh."); + } +} + +RendererParticleSystemShape::~RendererParticleSystemShape(void) +{ + SAFE_RELEASE(mInstanceBuffer); + SAFE_RELEASE(mIndexBuffer); + for(PxU32 i = 0; i < NUM_VERTEX_BUFFERS; i++ ) + { + SAFE_RELEASE(mVertexBuffer[i]); + } + SAFE_RELEASE(m_mesh); +} + +void RendererParticleSystemShape::initializeBuffersAsSimpleConvex(PxU32 color, PxReal scaleFactor) +{ + // initialize vertex buffer + PxU32 positionStride = 0, colorStride = 0, texcoordStride = 0, normalStride = 0; + PxU8* locked_normals = static_cast<PxU8*>(mVertexBuffer[STATIC_VB]->lockSemantic(RendererVertexBuffer::SEMANTIC_NORMAL, normalStride)); + PxU8* locked_texcoords = static_cast<PxU8*>(mVertexBuffer[STATIC_VB]->lockSemantic(RendererVertexBuffer::SEMANTIC_TEXCOORD0, texcoordStride)); + PxU8* locked_positions = static_cast<PxU8*>(mVertexBuffer[DYNAMIC_POS_VB]->lockSemantic(RendererVertexBuffer::SEMANTIC_POSITION, positionStride)); + PxU8* locked_colors = static_cast<PxU8*>(mVertexBuffer[DYNAMIC_COL_VB]->lockSemantic(RendererVertexBuffer::SEMANTIC_COLOR, colorStride)); + PxU32 maxVertices = mVertexBuffer[STATIC_VB]->getMaxVertices(); + for(PxU32 i = 0; i < maxVertices; ++i, + locked_positions += positionStride, + locked_colors += colorStride, + locked_texcoords += texcoordStride, + locked_normals += normalStride) + { + PxReal localConvexVertices[] = { convexVertices[3 * i + 0] * scaleFactor, + convexVertices[3 * i + 1] * scaleFactor, + convexVertices[3 * i + 2] * scaleFactor }; + PxReal localConvexNormals[] = { convexNormals[3 * i + 0] / 2.25f, + convexNormals[3 * i + 1] / 2.25f, + convexNormals[3 * i + 2] / 2.25f }; + memcpy(locked_positions, localConvexVertices, sizeof(PxReal) * 3); + memcpy(locked_normals, localConvexNormals, sizeof(PxReal) * 3); + memcpy(locked_texcoords, convexTexcoords + 2 * (i % 3), sizeof(PxReal) * 2); + memset(locked_colors, color, sizeof(PxU32)); + } + mVertexBuffer[STATIC_VB]->unlockSemantic(RendererVertexBuffer::SEMANTIC_TEXCOORD0); + mVertexBuffer[STATIC_VB]->unlockSemantic(RendererVertexBuffer::SEMANTIC_NORMAL); + mVertexBuffer[DYNAMIC_COL_VB]->unlockSemantic(RendererVertexBuffer::SEMANTIC_COLOR); + mVertexBuffer[DYNAMIC_POS_VB]->unlockSemantic(RendererVertexBuffer::SEMANTIC_POSITION); + // initialize index buffer + PxU32* locked_indices = static_cast<PxU32*>(mIndexBuffer->lock()); + memcpy(locked_indices, convexIndices, mIndexBuffer->getMaxIndices() * sizeof(PxU32)); + mIndexBuffer->unlock(); +} + +void RendererParticleSystemShape::initializeVertexBuffer(PxU32 color) +{ + PxU32 positionStride = 0, colorStride = 0; + PxU8* locked_positions = static_cast<PxU8*>(mVertexBuffer[DYNAMIC_POS_VB]->lockSemantic(RendererVertexBuffer::SEMANTIC_POSITION, positionStride)); + PxU8* locked_colors = static_cast<PxU8*>(mVertexBuffer[DYNAMIC_COL_VB]->lockSemantic(RendererVertexBuffer::SEMANTIC_COLOR, colorStride)); + for(PxU32 i = 0; i < mMaxParticles; ++i, + locked_positions += positionStride, + locked_colors += colorStride) + { + memset(locked_positions, 0, sizeof(PxReal) * 3); + memset(locked_colors, color, sizeof(PxU32)); + } + mVertexBuffer[DYNAMIC_COL_VB]->unlockSemantic(RendererVertexBuffer::SEMANTIC_COLOR); + mVertexBuffer[DYNAMIC_POS_VB]->unlockSemantic(RendererVertexBuffer::SEMANTIC_POSITION); +} + +void RendererParticleSystemShape::initializeInstanceBuffer() +{ + PxU32 positionStride = 0, + normalXStride = 0, + normalYStride = 0, + normalZStride = 0, + velocityLifeStride = 0; + PxU8* locked_positions = static_cast<PxU8*>(mInstanceBuffer->lockSemantic( + RendererInstanceBuffer::SEMANTIC_POSITION, positionStride)); + PxU8* locked_normalsx = static_cast<PxU8*>(mInstanceBuffer->lockSemantic( + RendererInstanceBuffer::SEMANTIC_NORMALX, normalXStride)); + PxU8* locked_normalsy = static_cast<PxU8*>(mInstanceBuffer->lockSemantic( + RendererInstanceBuffer::SEMANTIC_NORMALY, normalYStride)); + PxU8* locked_normalsz = static_cast<PxU8*>(mInstanceBuffer->lockSemantic( + RendererInstanceBuffer::SEMANTIC_NORMALZ, normalZStride)); + PxU8* locked_velocitylife = static_cast<PxU8*>(mInstanceBuffer->lockSemantic( + RendererInstanceBuffer::SEMANTIC_VELOCITY_LIFE, velocityLifeStride)); + // fill buffer here + PxReal normalx[] = { 1.0f, 0.0f, 0.0f }; + PxReal normaly[] = { 0.0f, 1.0f, 0.0f }; + PxReal normalz[] = { 0.0f, 0.0f, 1.0f }; + for(PxU32 i = 0; i < mMaxParticles; ++i, + locked_positions += positionStride, + locked_normalsx += normalXStride, + locked_normalsy += normalYStride, + locked_normalsz += normalZStride, + locked_velocitylife += velocityLifeStride) + { + memset(locked_positions, 0, sizeof(PxReal) * 3); + memcpy(locked_normalsx, normalx, sizeof(physx::PxVec3)); + memcpy(locked_normalsy, normaly, sizeof(physx::PxVec3)); + memcpy(locked_normalsz, normalz, sizeof(physx::PxVec3)); + memset(locked_velocitylife, 0, sizeof(PxReal) * 4); + } + mInstanceBuffer->unlockSemantic(RendererInstanceBuffer::SEMANTIC_VELOCITY_LIFE); + mInstanceBuffer->unlockSemantic(RendererInstanceBuffer::SEMANTIC_NORMALZ); + mInstanceBuffer->unlockSemantic(RendererInstanceBuffer::SEMANTIC_NORMALY); + mInstanceBuffer->unlockSemantic(RendererInstanceBuffer::SEMANTIC_NORMALX); + mInstanceBuffer->unlockSemantic(RendererInstanceBuffer::SEMANTIC_POSITION); +} + +namespace +{ + +#if defined(RENDERER_ENABLE_CUDA_INTEROP) + + void cuuAlignUp(int* offset, int alignment) + { + *offset = ((*offset) + (alignment) - 1) & ~((alignment) - 1); + } + + template <typename T, typename T2> CUresult + cuuParamSet(CUfunction hf, int* offset, const T2& var) + { + cuuAlignUp(offset, __alignof(T)); + CUresult err = cuParamSetv(hf, *offset, (void*)&var, sizeof(T)); + *offset += sizeof(T); + return err; + } + +#endif // RENDERER_ENABLE_CUDA_INTEROP + +} // anonymous namespace + + +bool RendererParticleSystemShape::updateInstanced(PxU32 validParticleRange, + CUdeviceptr positions, + CUdeviceptr validParticleBitmap, + CUdeviceptr orientations, + PxU32 numParticles) +{ +#if defined(RENDERER_ENABLE_CUDA_INTEROP) + + CUgraphicsResource res; + if (mInstanceBuffer->getInteropResourceHandle(res)) + { + mCtxMgr->acquireContext(); + + checkSuccess(cuGraphicsMapResources(1, &res, 0)); + + CUdeviceptr destBuffer; + size_t destSize; + cuGraphicsResourceGetMappedPointer(&destBuffer, &destSize, res); + + // if either buffers could not be mapped abort + if (!destBuffer) + { + mCtxMgr->releaseContext(); + return false; + } + + int offset = 0; + checkSuccess(cuuParamSet<CUdeviceptr>(gParticlesCuUpdateInstanceFunc, &offset, destBuffer + mInstanceBuffer->getOffsetForSemantic(RendererInstanceBuffer::SEMANTIC_POSITION))); + checkSuccess(cuuParamSet<CUdeviceptr>(gParticlesCuUpdateInstanceFunc, &offset, destBuffer + mInstanceBuffer->getOffsetForSemantic(RendererInstanceBuffer::SEMANTIC_NORMALX))); + checkSuccess(cuuParamSet<CUdeviceptr>(gParticlesCuUpdateInstanceFunc, &offset, destBuffer + mInstanceBuffer->getOffsetForSemantic(RendererInstanceBuffer::SEMANTIC_NORMALY))); + checkSuccess(cuuParamSet<CUdeviceptr>(gParticlesCuUpdateInstanceFunc, &offset, destBuffer + mInstanceBuffer->getOffsetForSemantic(RendererInstanceBuffer::SEMANTIC_NORMALZ))); + checkSuccess(cuuParamSet<PxU32>(gParticlesCuUpdateInstanceFunc, &offset, mInstanceBuffer->getStride())); + checkSuccess(cuuParamSet<CUdeviceptr>(gParticlesCuUpdateInstanceFunc, &offset, positions)); + checkSuccess(cuuParamSet<CUdeviceptr>(gParticlesCuUpdateInstanceFunc, &offset, orientations)); + checkSuccess(cuuParamSet<CUdeviceptr>(gParticlesCuUpdateInstanceFunc, &offset, validParticleBitmap)); + checkSuccess(cuuParamSet<PxU32>(gParticlesCuUpdateInstanceFunc, &offset, validParticleRange)); + checkSuccess(cuParamSetSize(gParticlesCuUpdateInstanceFunc, offset)); + + const PxU32 blockSize = 512; + const PxU32 numBlocks = 1; + + checkSuccess(cuFuncSetBlockShape(gParticlesCuUpdateInstanceFunc, blockSize, 1, 1)); + checkSuccess(cuLaunchGridAsync(gParticlesCuUpdateInstanceFunc, numBlocks, 1, 0)); + + checkSuccess(cuGraphicsUnmapResources(1, &res, 0)); + + mCtxMgr->releaseContext(); + } + + m_mesh->setInstanceBufferRange(0, numParticles); + +#endif // RENDERER_ENABLE_CUDA_INTEROP + + return true; + +} + +bool RendererParticleSystemShape::updateBillboard(PxU32 validParticleRange, + CUdeviceptr positions, + CUdeviceptr validParticleBitmap, + CUdeviceptr lifetimes, + PxU32 numParticles) +{ + +#if defined(RENDERER_ENABLE_CUDA_INTEROP) + + CUgraphicsResource res[2]; + mVertexBuffer[DYNAMIC_POS_VB]->getInteropResourceHandle(res[0]); + mVertexBuffer[DYNAMIC_COL_VB]->getInteropResourceHandle(res[1]); + + if (res[0] && res[1]) + { + mCtxMgr->acquireContext(); + + checkSuccess(cuGraphicsMapResources(2, res, 0)); + + CUdeviceptr posBuffer, colBuffer; + size_t destSize; + checkSuccess(cuGraphicsResourceGetMappedPointer(&posBuffer, &destSize, res[0])); + checkSuccess(cuGraphicsResourceGetMappedPointer(&colBuffer, &destSize, res[1])); + + // if either buffers could not be mapped abort + if (!posBuffer || !colBuffer) + { + mCtxMgr->releaseContext(); + return false; + } + + int offset = 0; + checkSuccess(cuuParamSet<CUdeviceptr>(gParticlesCuUpdateBillboardFunc, &offset, posBuffer)); + checkSuccess(cuuParamSet<CUdeviceptr>(gParticlesCuUpdateBillboardFunc, &offset, colBuffer+3)); + checkSuccess(cuuParamSet<PxU32>(gParticlesCuUpdateBillboardFunc, &offset, mVertexBuffer[DYNAMIC_POS_VB]->getStride())); + checkSuccess(cuuParamSet<PxF32>(gParticlesCuUpdateBillboardFunc, &offset, mFadingPeriod)); + checkSuccess(cuuParamSet<CUdeviceptr>(gParticlesCuUpdateBillboardFunc, &offset, positions)); + checkSuccess(cuuParamSet<CUdeviceptr>(gParticlesCuUpdateBillboardFunc, &offset, lifetimes)); + checkSuccess(cuuParamSet<CUdeviceptr>(gParticlesCuUpdateBillboardFunc, &offset, validParticleBitmap)); + checkSuccess(cuuParamSet<PxU32>(gParticlesCuUpdateBillboardFunc, &offset, validParticleRange)); + checkSuccess(cuParamSetSize(gParticlesCuUpdateBillboardFunc, offset)); + + const PxU32 blockSize = 512; + const PxU32 numBlocks = 1; + + checkSuccess(cuFuncSetBlockShape(gParticlesCuUpdateBillboardFunc, blockSize, 1, 1)); + checkSuccess(cuLaunchGridAsync(gParticlesCuUpdateBillboardFunc, numBlocks, 1, 0)); + + checkSuccess(cuGraphicsUnmapResources(2, res, 0)); + + mCtxMgr->releaseContext(); + } + + m_mesh->setVertexBufferRange(0, numParticles); + +#endif // RENDERER_ENABLE_CUDA_INTEROP + + return true; + +} + + +void RendererParticleSystemShape::updateInstanced(PxU32 validParticleRange, + const PxVec3* positions, + const PxU32* validParticleBitmap, + const PxMat33* orientation) +{ + PxU32 positionStride = 0, + normalXStride = 0, + normalYStride = 0, + normalZStride = 0; + PxU8 *locked_positions = NULL, + *locked_normalsx = NULL, + *locked_normalsy = NULL, + *locked_normalsz = NULL; + locked_positions = static_cast<PxU8*>(mInstanceBuffer->lockSemantic( + RendererInstanceBuffer::SEMANTIC_POSITION, positionStride)); + locked_normalsx = static_cast<PxU8*>(mInstanceBuffer->lockSemantic( + RendererInstanceBuffer::SEMANTIC_NORMALX, normalXStride)); + locked_normalsy = static_cast<PxU8*>(mInstanceBuffer->lockSemantic( + RendererInstanceBuffer::SEMANTIC_NORMALY, normalYStride)); + locked_normalsz = static_cast<PxU8*>(mInstanceBuffer->lockSemantic( + RendererInstanceBuffer::SEMANTIC_NORMALZ, normalZStride)); + + // update vertex or instance buffer here + PxU32 numParticles = 0; + if(validParticleRange > 0) + { + for (PxU32 w = 0; w <= (validParticleRange-1) >> 5; w++) + { + for (PxU32 b = validParticleBitmap[w]; b; b &= b-1) + { + PxU32 index = (w << 5 | physx::shdfnd::lowestSetBit(b)); + + memcpy(locked_normalsx, &(orientation[index].column0), sizeof(PxVec3)); + memcpy(locked_normalsy, &(orientation[index].column1), sizeof(PxVec3)); + memcpy(locked_normalsz, &(orientation[index].column2), sizeof(PxVec3)); + memcpy(locked_positions, positions + index, sizeof(PxVec3)); + + locked_positions += positionStride; + locked_normalsx += normalXStride; + locked_normalsy += normalYStride; + locked_normalsz += normalZStride; + numParticles++; + } + } + } + + mInstanceBuffer->unlockSemantic(RendererInstanceBuffer::SEMANTIC_NORMALZ); + mInstanceBuffer->unlockSemantic(RendererInstanceBuffer::SEMANTIC_NORMALY); + mInstanceBuffer->unlockSemantic(RendererInstanceBuffer::SEMANTIC_NORMALX); + mInstanceBuffer->unlockSemantic(RendererInstanceBuffer::SEMANTIC_POSITION); + m_mesh->setInstanceBufferRange(0, numParticles); +} + +void RendererParticleSystemShape::updateBillboard(PxU32 validParticleRange, + const PxVec3* positions, + const PxU32* validParticleBitmap, + const PxReal* lifetime) +{ + PxU32 positionStride = 0, colorStride = 0; + PxU8 *locked_positions = NULL, *locked_colors = NULL; + locked_positions = static_cast<PxU8*>(mVertexBuffer[DYNAMIC_POS_VB]->lockSemantic( + RendererVertexBuffer::SEMANTIC_POSITION, positionStride)); + if(mFading && lifetime) + { + locked_colors = static_cast<PxU8*>(mVertexBuffer[DYNAMIC_COL_VB]->lockSemantic( + RendererVertexBuffer::SEMANTIC_COLOR, colorStride)); + // move ptr to alpha +#if !defined(RENDERER_XBOX360) + locked_colors += 3 * sizeof(PxU8); +#endif + } + // update vertex or instance buffer here + PxU32 numParticles = 0; + if(validParticleRange > 0) + { + for (PxU32 w = 0; w <= (validParticleRange-1) >> 5; w++) + { + for (PxU32 b = validParticleBitmap[w]; b; b &= b-1) + { + PxU32 index = (w << 5 | physx::shdfnd::lowestSetBit(b)); + *reinterpret_cast<PxVec3*>(locked_positions) = positions[index]; + locked_positions += positionStride; + if(mFading && lifetime) + { + PxU8 particle_lifetime = 0; + if(lifetime[index] >= mFadingPeriod) + { + particle_lifetime = 255; + } + else + { + if(lifetime[index] <= 0.0f) + { + particle_lifetime = 0; + } + else + { + particle_lifetime = static_cast<PxU8>(lifetime[index] * 255 / mFadingPeriod); + } + } + locked_colors[0] = particle_lifetime; + locked_colors += colorStride; + } + numParticles++; + } + } + } + + if(mFading && lifetime) + { + mVertexBuffer[DYNAMIC_COL_VB]->unlockSemantic(RendererVertexBuffer::SEMANTIC_COLOR); + } + mVertexBuffer[DYNAMIC_POS_VB]->unlockSemantic(RendererVertexBuffer::SEMANTIC_POSITION); + m_mesh->setVertexBufferRange(0, numParticles); +} diff --git a/PhysX_3.4/Samples/SampleFramework/renderer/src/RendererProjection.cpp b/PhysX_3.4/Samples/SampleFramework/renderer/src/RendererProjection.cpp new file mode 100644 index 00000000..14a36df6 --- /dev/null +++ b/PhysX_3.4/Samples/SampleFramework/renderer/src/RendererProjection.cpp @@ -0,0 +1,232 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved. +#include <RendererProjection.h> +#include <math.h> + +using namespace SampleRenderer; + +RendererProjection::RendererProjection(float fov, float aspectRatio, float nearPlane, float farPlane) +{ + RENDERER_ASSERT(farPlane > nearPlane, "Cannot construct a Projection Matrix whose nearPlane is further than the farPlane."); + memset(m_matrix, 0, sizeof(m_matrix)); + + float fd = 1/tanf(fov/2); + m_matrix[0] = fd; + m_matrix[5] = fd*aspectRatio; + m_matrix[10] = (farPlane + nearPlane)/(nearPlane - farPlane); + m_matrix[11] = -1; + m_matrix[14] = (2 * farPlane * nearPlane)/(nearPlane - farPlane); +} + +RendererProjection::RendererProjection(float left, float right, float bottom, float top, float nearPlane, float farPlane) +{ + memset(m_matrix, 0, sizeof(m_matrix)); + m_matrix[0] = 2/(right - left); + m_matrix[5] = 2/(top - bottom); + m_matrix[10] = -2/(farPlane - nearPlane); + m_matrix[12] = - (right + left) / (right - left); + m_matrix[13] = - (top + bottom) / (top - bottom); + m_matrix[14] = - (farPlane + nearPlane) / (farPlane - nearPlane); + m_matrix[15] = 1; +} + +RendererProjection::RendererProjection(const PxMat44 mat) +{ + getPxMat44() = mat; +} + +void RendererProjection::getColumnMajor44(float *f) const +{ + if(f) memcpy(f, m_matrix, sizeof(m_matrix)); +} + +void RendererProjection::getRowMajor44(float *f) const +{ + getColumnMajor44(f); + for (int i = 0; i < 4; i++) { + for (int j = i + 1; j < 4; j++) { + float save = f[4 * i + j]; + f[4 * i + j] = f[4 * j + i]; + f[4 * j + i] = save; + } + } +} + +class vec4 +{ +public: + vec4(void) {} + + vec4(const PxVec3& v3) + { + x=v3.x; + y=v3.y; + z=v3.z; + w=1.0f; + } + + vec4(PxF32 _x, PxF32 _y, PxF32 _z, PxF32 _w) + { + x=_x; + y=_y; + z=_z; + w=_w; + } + + vec4 operator*=(PxF32 f) + { + x*=f; + y*=f; + z*=f; + w*=f; + return *this; + } + +public: + PxF32 x, y, z, w; +}; + +class mat4x4 +{ +public: + mat4x4(void){} + + mat4x4(const physx::PxTransform &m) + { + PxMat44 mat44(m); + memcpy(&x.x, mat44.front(), 4 * 4 * sizeof (PxReal)); + } + + mat4x4(const RendererProjection &m) + { + m.getColumnMajor44(&x.x); + } + +public: + vec4 x; + vec4 y; + vec4 z; + vec4 w; +}; + +mat4x4 invert(const mat4x4 &m) +{ + mat4x4 inv; + +#define det3x3(a0, a1, a2, a3, a4, a5, a6, a7, a8) \ +(a0 * (a4*a8 - a7*a5) - a1 * (a3*a8 - a6*a5) + a2 * (a3*a7 - a6*a4)) + + inv.x.x = det3x3(m.y.y, m.y.z, m.y.w, m.z.y, m.z.z, m.z.w, m.w.y, m.w.z, m.w.w); + inv.x.y = -det3x3(m.x.y, m.x.z, m.x.w, m.z.y, m.z.z, m.z.w, m.w.y, m.w.z, m.w.w); + inv.x.z = det3x3(m.x.y, m.x.z, m.x.w, m.y.y, m.y.z, m.y.w, m.w.y, m.w.z, m.w.w); + inv.x.w = -det3x3(m.x.y, m.x.z, m.x.w, m.y.y, m.y.z, m.y.w, m.z.y, m.z.z, m.z.w); + + inv.y.x = -det3x3(m.y.x, m.y.z, m.y.w, m.z.x, m.z.z, m.z.w, m.w.x, m.w.z, m.w.w); + inv.y.y = det3x3(m.x.x, m.x.z, m.x.w, m.z.x, m.z.z, m.z.w, m.w.x, m.w.z, m.w.w); + inv.y.z = -det3x3(m.x.x, m.x.z, m.x.w, m.y.x, m.y.z, m.y.w, m.w.x, m.w.z, m.w.w); + inv.y.w = det3x3(m.x.x, m.x.z, m.x.w, m.y.x, m.y.z, m.y.w, m.z.x, m.z.z, m.z.w); + + inv.z.x = det3x3(m.y.x, m.y.y, m.y.w, m.z.x, m.z.y, m.z.w, m.w.x, m.w.y, m.w.w); + inv.z.y = -det3x3(m.x.x, m.x.y, m.x.w, m.z.x, m.z.y, m.z.w, m.w.x, m.w.y, m.w.w); + inv.z.z = det3x3(m.x.x, m.x.y, m.x.w, m.y.x, m.y.y, m.y.w, m.w.x, m.w.y, m.w.w); + inv.z.w = -det3x3(m.x.x, m.x.y, m.x.w, m.y.x, m.y.y, m.y.w, m.z.x, m.z.y, m.z.w); + + inv.w.x = -det3x3(m.y.x, m.y.y, m.y.z, m.z.x, m.z.y, m.z.z, m.w.x, m.w.y, m.w.z); + inv.w.y = det3x3(m.x.x, m.x.y, m.x.z, m.z.x, m.z.y, m.z.z, m.w.x, m.w.y, m.w.z); + inv.w.z = -det3x3(m.x.x, m.x.y, m.x.z, m.y.x, m.y.y, m.y.z, m.w.x, m.w.y, m.w.z); + inv.w.w = det3x3(m.x.x, m.x.y, m.x.z, m.y.x, m.y.y, m.y.z, m.z.x, m.z.y, m.z.z); + +#undef det3x3 + + PxF32 det = m.x.x*inv.x.x + m.y.x*inv.x.y + m.z.x*inv.x.z + m.w.x*inv.x.w; + RENDERER_ASSERT(det, "Matrix inversion failed!"); + if(!det) det = 1; + PxF32 invDet = 1 / det; + + inv.x *= invDet; + inv.y *= invDet; + inv.z *= invDet; + inv.w *= invDet; + + return inv; +} + +mat4x4 operator*(const mat4x4 &a, const mat4x4 &b) +{ + mat4x4 t; +#define VECMUL(_r, _c) \ +t._c ._r = a._c.x * b.x._r + \ +a._c.y * b.y._r + \ +a._c.z * b.z._r + \ +a._c.w * b.w._r; + VECMUL(x,x); VECMUL(x,y); VECMUL(x,z); VECMUL(x,w); + VECMUL(y,x); VECMUL(y,y); VECMUL(y,z); VECMUL(y,w); + VECMUL(z,x); VECMUL(z,y); VECMUL(z,z); VECMUL(z,w); + VECMUL(w,x); VECMUL(w,y); VECMUL(w,z); VECMUL(w,w); +#undef VECMUL + return t; +} + +vec4 operator*(const mat4x4 &a, const vec4 &b) +{ + vec4 v; + v.x = a.x.x * b.x + a.y.x * b.y + a.z.x * b.z + a.w.x; + v.y = a.x.y * b.x + a.y.y * b.y + a.z.y * b.z + a.w.y; + v.z = a.x.z * b.x + a.y.z * b.y + a.z.z * b.z + a.w.z; + v.w = a.x.w * b.x + a.y.w * b.y + a.z.w * b.z + a.w.w; + return v; +} + +void SampleRenderer::buildProjectMatrix(float *dst, const RendererProjection &proj, const physx::PxTransform &view) +{ + mat4x4 projview = invert(mat4x4(view)) * mat4x4(proj); + memcpy(dst, &projview.x.x, sizeof(float)*16); +} + +void SampleRenderer::buildUnprojectMatrix(float *dst, const RendererProjection &proj, const physx::PxTransform &view) +{ + mat4x4 invprojview = invert(mat4x4(view) * mat4x4(proj)); + memcpy(dst, &invprojview.x.x, sizeof(float)*16); +} + +PxVec3 SampleRenderer::unproject(const RendererProjection &proj, const physx::PxTransform &view, PxF32 x, PxF32 y, PxF32 z) +{ + vec4 screenPoint(x, y, z, 1); + mat4x4 invprojview = invert(mat4x4(view) * mat4x4(proj)); + vec4 nearPoint = invprojview * screenPoint; + RENDERER_ASSERT(nearPoint.w, "Unproject failed!"); + if(nearPoint.w) nearPoint *= 1.0f / nearPoint.w; + return PxVec3(nearPoint.x, nearPoint.y, nearPoint.z); +} + +PxVec3 SampleRenderer::project( const RendererProjection &proj, const physx::PxTransform &view, const PxVec3& pos) +{ + mat4x4 projView = mat4x4(view) * mat4x4(proj); + vec4 screenPoint = projView * vec4(pos); + float rw = 1.0f / screenPoint.w; + return PxVec3( screenPoint.x, -screenPoint.y, screenPoint.z ) * rw; +} diff --git a/PhysX_3.4/Samples/SampleFramework/renderer/src/RendererShape.cpp b/PhysX_3.4/Samples/SampleFramework/renderer/src/RendererShape.cpp new file mode 100644 index 00000000..2061f366 --- /dev/null +++ b/PhysX_3.4/Samples/SampleFramework/renderer/src/RendererShape.cpp @@ -0,0 +1,49 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved. +// +// RendererShape : base class for convenience classes for generating meshes based on shapes. +// +#include <RendererShape.h> + +using namespace SampleRenderer; + +RendererShape::RendererShape(Renderer& renderer) : + m_renderer (renderer), + m_mesh (NULL), + m_userData (NULL) +{ +} + +RendererShape::~RendererShape(void) +{ + RENDERER_ASSERT(m_mesh==0, "Mesh was not properly released before Shape destruction."); +} + +RendererMesh* RendererShape::getMesh(void) +{ + return m_mesh; +} diff --git a/PhysX_3.4/Samples/SampleFramework/renderer/src/RendererSimpleParticleSystemShape.cpp b/PhysX_3.4/Samples/SampleFramework/renderer/src/RendererSimpleParticleSystemShape.cpp new file mode 100644 index 00000000..7520893d --- /dev/null +++ b/PhysX_3.4/Samples/SampleFramework/renderer/src/RendererSimpleParticleSystemShape.cpp @@ -0,0 +1,206 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved. +// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. +// Copyright (c) 2001-2004 NovodeX AG. All rights reserved. +#include <PsUtilities.h> + +#include <RendererSimpleParticleSystemShape.h> + +#include <Renderer.h> + +#include <RendererMemoryMacros.h> +#include <RendererIndexBuffer.h> +#include <RendererIndexBufferDesc.h> +#include <RendererVertexBuffer.h> +#include <RendererVertexBufferDesc.h> +#include <RendererMesh.h> +#include <RendererMeshDesc.h> +#include "PsUtilities.h" +#include "PsBitUtils.h" + +using namespace SampleRenderer; +using namespace physx::shdfnd; + +RendererSimpleParticleSystemShape::RendererSimpleParticleSystemShape(Renderer &renderer, + PxU32 _mMaxParticles) : + RendererShape(renderer), + mMaxParticles(_mMaxParticles), + mVertexBuffer(NULL), + mIndexBuffer(NULL) +{ + RendererVertexBufferDesc vbdesc; + + vbdesc.maxVertices = mMaxParticles*4; + vbdesc.hint = RendererVertexBuffer::HINT_DYNAMIC; + vbdesc.semanticFormats[RendererVertexBuffer::SEMANTIC_POSITION] = RendererVertexBuffer::FORMAT_FLOAT3; + vbdesc.semanticFormats[RendererVertexBuffer::SEMANTIC_COLOR] = RendererVertexBuffer::FORMAT_COLOR_NATIVE; + vbdesc.semanticFormats[RendererVertexBuffer::SEMANTIC_TEXCOORD0] = RendererVertexBuffer::FORMAT_FLOAT2; + mVertexBuffer = m_renderer.createVertexBuffer(vbdesc); + RENDERER_ASSERT(mVertexBuffer, "Failed to create Vertex Buffer."); + // if enabled mInstanced meshes -> create instance buffer + PxU32 color = renderer.convertColor(RendererColor(255, 255, 255, 255)); + RendererMesh::Primitive primitive = RendererMesh::PRIMITIVE_TRIANGLES; + initializeVertexBuffer(color); + + if(mVertexBuffer) + { + RendererMeshDesc meshdesc; + meshdesc.primitives = primitive; + meshdesc.vertexBuffers = &mVertexBuffer; + meshdesc.numVertexBuffers = 1; + meshdesc.firstVertex = 0; + meshdesc.numVertices = mVertexBuffer->getMaxVertices(); + meshdesc.indexBuffer = mIndexBuffer; + meshdesc.firstIndex = 0; + if(mIndexBuffer) + { + meshdesc.numIndices = mIndexBuffer->getMaxIndices(); + } + else + { + meshdesc.numIndices = 0; + } + meshdesc.instanceBuffer = NULL; + meshdesc.firstInstance = 0; + meshdesc.numInstances = 0; + m_mesh = m_renderer.createMesh(meshdesc); + RENDERER_ASSERT(m_mesh, "Failed to create Mesh."); + } +} + +RendererSimpleParticleSystemShape::~RendererSimpleParticleSystemShape(void) +{ + SAFE_RELEASE(mIndexBuffer); + SAFE_RELEASE(mVertexBuffer); + SAFE_RELEASE(m_mesh); +} + +void RendererSimpleParticleSystemShape::initializeVertexBuffer(PxU32 color) +{ + PxU32 positionStride = 0, colorStride = 0, uvStride = 0; + PxU8* locked_positions = static_cast<PxU8*>(mVertexBuffer->lockSemantic(RendererVertexBuffer::SEMANTIC_POSITION, positionStride)); + PxU8* locked_colors = static_cast<PxU8*>(mVertexBuffer->lockSemantic(RendererVertexBuffer::SEMANTIC_COLOR, colorStride)); + PxU8* locked_uvs_base = static_cast<PxU8*>(mVertexBuffer->lockSemantic(RendererVertexBuffer::SEMANTIC_TEXCOORD0, uvStride)); + for(PxU32 i = 0; i < mMaxParticles; ++i) + { + + for (PxU32 j = 0;j < 4; j++) + { + memset(locked_colors, color, sizeof(PxU32)); + memset(locked_positions, 0, sizeof(PxReal) * 3); + locked_colors += colorStride; + locked_positions += positionStride; + } + + PxReal* locked_uvs = reinterpret_cast<PxReal*> (locked_uvs_base); + *locked_uvs = 0.0f; + locked_uvs++; + *locked_uvs = 0.0f; + locked_uvs_base += uvStride; + + locked_uvs = reinterpret_cast<PxReal*> (locked_uvs_base); + *locked_uvs = 1.0f; + locked_uvs++; + *locked_uvs = 0.0f; + locked_uvs_base += uvStride; + + locked_uvs = reinterpret_cast<PxReal*> (locked_uvs_base); + *locked_uvs = 0.0f; + locked_uvs++; + *locked_uvs = 1.0f; + locked_uvs_base += uvStride; + + locked_uvs = reinterpret_cast<PxReal*> (locked_uvs_base); + *locked_uvs = 1.0f; + locked_uvs++; + *locked_uvs = 1.0f; + locked_uvs_base += uvStride; + } + mVertexBuffer->unlockSemantic(RendererVertexBuffer::SEMANTIC_COLOR); + mVertexBuffer->unlockSemantic(RendererVertexBuffer::SEMANTIC_POSITION); + mVertexBuffer->unlockSemantic(RendererVertexBuffer::SEMANTIC_TEXCOORD0); + + RendererIndexBufferDesc inbdesc; + inbdesc.hint = RendererIndexBuffer::HINT_STATIC; + inbdesc.format = RendererIndexBuffer::FORMAT_UINT16; + inbdesc.maxIndices = mMaxParticles*6; + mIndexBuffer = m_renderer.createIndexBuffer(inbdesc); + + PxU16* ib = (PxU16*) mIndexBuffer->lock(); + for (PxU16 i = 0; i<mMaxParticles; i++) + { + ib[i * 6 + 0] = i * 4 + 0; + ib[i * 6 + 1] = i * 4 + 1; + ib[i * 6 + 2] = i * 4 + 2; + ib[i * 6 + 3] = i * 4 + 1; + ib[i * 6 + 4] = i * 4 + 3; + ib[i * 6 + 5] = i * 4 + 2; + } + mIndexBuffer->unlock(); +} + +void RendererSimpleParticleSystemShape::updateBillboard(PxU32 validParticleRange, + const PxVec3* positions, + const PxU32* validParticleBitmap, + const PxReal* lifetime) +{ + PxU32 positionStride = 0; + PxU8 *locked_positions = NULL; + locked_positions = static_cast<PxU8*>(mVertexBuffer->lockSemantic( + RendererVertexBuffer::SEMANTIC_POSITION, positionStride)); + // update vertex buffer here + PxU32 numParticles = 0; + if(validParticleRange > 0) + { + for (PxU32 w = 0; w <= (validParticleRange-1) >> 5; w++) + { + for (PxU32 b = validParticleBitmap[w]; b; b &= b-1) + { + PxU32 index = (w << 5 | physx::shdfnd::lowestSetBit(b)); + const PxVec3& basePos = positions[index]; + const float particleSize = 1.0f; + PxVec3 offsets[4] = + { + PxVec3(-particleSize, particleSize, 0.0f), + PxVec3( particleSize, particleSize, 0.0f), + PxVec3(-particleSize, -particleSize, 0.0f), + PxVec3( particleSize, -particleSize, 0.0f) + }; + + for (int p = 0; p < 4; p++) + { + *reinterpret_cast<PxVec3*>(locked_positions) = basePos + offsets[p]; + locked_positions += positionStride; + } + numParticles++; + } + } + } + + mVertexBuffer->unlockSemantic(RendererVertexBuffer::SEMANTIC_POSITION); + m_mesh->setVertexBufferRange(0, numParticles*4); +} diff --git a/PhysX_3.4/Samples/SampleFramework/renderer/src/RendererSpotLight.cpp b/PhysX_3.4/Samples/SampleFramework/renderer/src/RendererSpotLight.cpp new file mode 100644 index 00000000..79aeb1c3 --- /dev/null +++ b/PhysX_3.4/Samples/SampleFramework/renderer/src/RendererSpotLight.cpp @@ -0,0 +1,109 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved. +#include <RendererSpotLight.h> +#include <RendererSpotLightDesc.h> + +using namespace SampleRenderer; + +RendererSpotLight::RendererSpotLight(const RendererSpotLightDesc &desc) : + RendererLight(desc) +{ + setPosition(desc.position); + setDirection(desc.direction); + setRadius(desc.innerRadius, desc.outerRadius); + setCone(desc.innerCone, desc.outerCone); +} + +RendererSpotLight::~RendererSpotLight(void) +{ + +} + +const PxVec3 &RendererSpotLight::getPosition(void) const +{ + return m_position; +} + +void RendererSpotLight::setPosition(const PxVec3 &pos) +{ + m_position = pos; +} + +const PxVec3 &RendererSpotLight::getDirection(void) const +{ + return m_direction; +} + +void RendererSpotLight::setDirection(const PxVec3 &dir) +{ + RENDERER_ASSERT(dir.magnitudeSquared() >= 0.1f, "Trying to give Direction Light invalid Direction value."); + if(dir.magnitudeSquared() >= 0.1f) + { + m_direction = dir; + m_direction.normalize(); + } +} + +PxF32 RendererSpotLight::getInnerRadius(void) const +{ + return m_innerRadius; +} + +PxF32 RendererSpotLight::getOuterRadius(void) const +{ + return m_outerRadius; +} + +void RendererSpotLight::setRadius(PxF32 innerRadius, PxF32 outerRadius) +{ + RENDERER_ASSERT(innerRadius>=0 && innerRadius<=outerRadius, "Invalid Spot Light radius values."); + if(innerRadius>=0 && innerRadius<=outerRadius) + { + m_innerRadius = innerRadius; + m_outerRadius = outerRadius; + } +} + +PxF32 RendererSpotLight::getInnerCone(void) const +{ + return m_innerCone; +} + +PxF32 RendererSpotLight::getOuterCone(void) const +{ + return m_outerCone; +} + +void RendererSpotLight::setCone(PxF32 innerCone, PxF32 outerCone) +{ + RENDERER_ASSERT(innerCone<=1 && innerCone>=outerCone, "Invalid Spot Light cone values."); + if(innerCone<=1 && innerCone>=outerCone) + { + m_innerCone = innerCone; + m_outerCone = outerCone; + } +} diff --git a/PhysX_3.4/Samples/SampleFramework/renderer/src/RendererSpotLightDesc.cpp b/PhysX_3.4/Samples/SampleFramework/renderer/src/RendererSpotLightDesc.cpp new file mode 100644 index 00000000..cd2544a4 --- /dev/null +++ b/PhysX_3.4/Samples/SampleFramework/renderer/src/RendererSpotLightDesc.cpp @@ -0,0 +1,51 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved. +#include <RendererSpotLightDesc.h> + +using namespace SampleRenderer; + +RendererSpotLightDesc::RendererSpotLightDesc(void) : + RendererLightDesc(RendererLight::TYPE_SPOT) +{ + position = PxVec3(0,0,0); + direction = PxVec3(0,0,0); + innerRadius = 0; + outerRadius = 0; + innerCone = 0; + outerCone = 0; +} + +bool RendererSpotLightDesc::isValid(void) const +{ + bool ok = RendererLightDesc::isValid(); + if(direction.magnitudeSquared() < 0.1f) ok = false; + if(innerRadius < 0) ok = false; + if(outerRadius < innerRadius) ok = false; + if(innerCone > 1) ok = false; + if(outerCone > innerCone) ok = false; + return ok; +} diff --git a/PhysX_3.4/Samples/SampleFramework/renderer/src/RendererTarget.cpp b/PhysX_3.4/Samples/SampleFramework/renderer/src/RendererTarget.cpp new file mode 100644 index 00000000..8c302c4a --- /dev/null +++ b/PhysX_3.4/Samples/SampleFramework/renderer/src/RendererTarget.cpp @@ -0,0 +1,37 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved. +#include <RendererTarget.h> + +using namespace SampleRenderer; + +RendererTarget::RendererTarget(void) +{ +} + +RendererTarget::~RendererTarget(void) +{ +} diff --git a/PhysX_3.4/Samples/SampleFramework/renderer/src/RendererTargetDesc.cpp b/PhysX_3.4/Samples/SampleFramework/renderer/src/RendererTargetDesc.cpp new file mode 100644 index 00000000..094345a4 --- /dev/null +++ b/PhysX_3.4/Samples/SampleFramework/renderer/src/RendererTargetDesc.cpp @@ -0,0 +1,81 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved. +#include <RendererTargetDesc.h> +#include <RendererTexture2D.h> + +using namespace SampleRenderer; + +RendererTargetDesc::RendererTargetDesc(void) +{ + textures = 0; + numTextures = 0; + depthStencilSurface = 0; +} + +bool RendererTargetDesc::isValid(void) const +{ + bool ok = true; + PxU32 width = 0; + PxU32 height = 0; + if(numTextures != 1) ok = false; // for now we only support single render targets at the moment. + if(textures) + { + if(textures[0]) + { + width = textures[0]->getWidth(); + height = textures[0]->getHeight(); + } + for(PxU32 i=0; i<numTextures; i++) + { + if(!textures[i]) ok = false; + else + { + if(width != textures[i]->getWidth()) ok = false; + if(height != textures[i]->getHeight()) ok = false; + const RendererTexture2D::Format format = textures[i]->getFormat(); + if( format == RendererTexture2D::FORMAT_DXT1) ok = false; + else if(format == RendererTexture2D::FORMAT_DXT3) ok = false; + else if(format == RendererTexture2D::FORMAT_DXT5) ok = false; + } + } + } + else + { + ok = false; + } + if(depthStencilSurface) + { + if(width != depthStencilSurface->getWidth()) ok = false; + if(height != depthStencilSurface->getHeight()) ok = false; + if(!RendererTexture2D::isDepthStencilFormat(depthStencilSurface->getFormat())) ok = false; + } + else + { + ok = false; + } + return ok; +} diff --git a/PhysX_3.4/Samples/SampleFramework/renderer/src/RendererTerrainShape.cpp b/PhysX_3.4/Samples/SampleFramework/renderer/src/RendererTerrainShape.cpp new file mode 100644 index 00000000..716ed066 --- /dev/null +++ b/PhysX_3.4/Samples/SampleFramework/renderer/src/RendererTerrainShape.cpp @@ -0,0 +1,128 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved. +// +// RendererTerrainShape : convenience class for generating a box mesh. +// +#include <RendererTerrainShape.h> + +#include <Renderer.h> + +#include <RendererVertexBuffer.h> +#include <RendererVertexBufferDesc.h> + +#include <RendererIndexBuffer.h> +#include <RendererIndexBufferDesc.h> + +#include <RendererMesh.h> +#include <RendererMeshDesc.h> + +#include <RendererMemoryMacros.h> + +using namespace SampleRenderer; + +RendererTerrainShape::RendererTerrainShape(Renderer &renderer, + PxVec3 *verts, PxU32 numVerts, + PxVec3 *normals, PxU32 numNorms, + PxU16 *faces, PxU32 numFaces, + PxF32 uvScale) : +RendererShape(renderer) +{ + RendererVertexBufferDesc vbdesc; + vbdesc.hint = RendererVertexBuffer::HINT_STATIC; + vbdesc.semanticFormats[RendererVertexBuffer::SEMANTIC_POSITION] = RendererVertexBuffer::FORMAT_FLOAT3; + vbdesc.semanticFormats[RendererVertexBuffer::SEMANTIC_NORMAL] = RendererVertexBuffer::FORMAT_FLOAT3; + vbdesc.semanticFormats[RendererVertexBuffer::SEMANTIC_TEXCOORD0] = RendererVertexBuffer::FORMAT_FLOAT2; + vbdesc.maxVertices = numVerts; + m_vertexBuffer = m_renderer.createVertexBuffer(vbdesc); + RENDERER_ASSERT(m_vertexBuffer, "Failed to create Vertex Buffer."); + if(m_vertexBuffer) + { + PxU32 positionStride = 0; + void *vertPositions = m_vertexBuffer->lockSemantic(RendererVertexBuffer::SEMANTIC_POSITION, positionStride); + PxU32 normalStride = 0; + void *vertNormals = m_vertexBuffer->lockSemantic(RendererVertexBuffer::SEMANTIC_NORMAL, normalStride); + PxU32 uvStride = 0; + void *vertUVs = m_vertexBuffer->lockSemantic(RendererVertexBuffer::SEMANTIC_TEXCOORD0, uvStride); + if(vertPositions && vertNormals) + { + for(PxU32 i=0; i<numVerts; i++) + { + memcpy(vertPositions, verts+i, sizeof(PxVec3)); + memcpy(vertNormals, normals+i, sizeof(PxVec3)); + ((PxF32*)vertUVs)[0] = verts[i].x * uvScale; + ((PxF32*)vertUVs)[1] = verts[i].z * uvScale; + + vertPositions = (void*)(((PxU8*)vertPositions) + positionStride); + vertNormals = (void*)(((PxU8*)vertNormals) + normalStride); + vertUVs = (void*)(((PxU8*)vertUVs) + uvStride); + } + } + m_vertexBuffer->unlockSemantic(RendererVertexBuffer::SEMANTIC_NORMAL); + m_vertexBuffer->unlockSemantic(RendererVertexBuffer::SEMANTIC_POSITION); + m_vertexBuffer->unlockSemantic(RendererVertexBuffer::SEMANTIC_TEXCOORD0); + } + + PxU32 numIndices = numFaces*3; + + RendererIndexBufferDesc ibdesc; + ibdesc.hint = RendererIndexBuffer::HINT_STATIC; + ibdesc.format = RendererIndexBuffer::FORMAT_UINT16; + ibdesc.maxIndices = numIndices; + m_indexBuffer = m_renderer.createIndexBuffer(ibdesc); + RENDERER_ASSERT(m_indexBuffer, "Failed to create Index Buffer."); + if(m_indexBuffer) + { + PxU16 *indices = (PxU16*)m_indexBuffer->lock(); + if(indices) + { + memcpy(indices, faces, sizeof(*faces)*numFaces*3); + } + m_indexBuffer->unlock(); + } + + if(m_vertexBuffer && m_indexBuffer) + { + RendererMeshDesc meshdesc; + meshdesc.primitives = RendererMesh::PRIMITIVE_TRIANGLES; + meshdesc.vertexBuffers = &m_vertexBuffer; + meshdesc.numVertexBuffers = 1; + meshdesc.firstVertex = 0; + meshdesc.numVertices = numVerts; + meshdesc.indexBuffer = m_indexBuffer; + meshdesc.firstIndex = 0; + meshdesc.numIndices = numIndices; + m_mesh = m_renderer.createMesh(meshdesc); + RENDERER_ASSERT(m_mesh, "Failed to create Mesh."); + } +} + +RendererTerrainShape::~RendererTerrainShape(void) +{ + SAFE_RELEASE(m_vertexBuffer); + SAFE_RELEASE(m_indexBuffer); + SAFE_RELEASE(m_mesh); +} diff --git a/PhysX_3.4/Samples/SampleFramework/renderer/src/RendererTexture.cpp b/PhysX_3.4/Samples/SampleFramework/renderer/src/RendererTexture.cpp new file mode 100644 index 00000000..44b65c76 --- /dev/null +++ b/PhysX_3.4/Samples/SampleFramework/renderer/src/RendererTexture.cpp @@ -0,0 +1,163 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved. +#include <RendererTexture.h> +#include <RendererTextureDesc.h> +#include "foundation/PxMath.h" + +using namespace SampleRenderer; + +static PxU32 computeCompressedDimension(PxU32 dimension) +{ + if(dimension < 4) + { + dimension = 4; + } + else + { + PxU32 mod = dimension % 4; + if(mod) dimension += 4 - mod; + } + return dimension; +} + +PxU32 RendererTexture::computeImageByteSize(PxU32 width, PxU32 height, PxU32 depth, RendererTexture::Format format) +{ + PxU32 size = 0; + PxU32 numPixels = width * height * depth; + switch(format) + { + case RendererTexture::FORMAT_B8G8R8A8: + case RendererTexture::FORMAT_R8G8B8A8: + size = numPixels * sizeof(PxU8) * 4; + break; + case RendererTexture::FORMAT_A8: + size = numPixels * sizeof(PxU8) * 1; + break; + case RendererTexture::FORMAT_R32F: + size = numPixels * sizeof(float); + break; + case RendererTexture::FORMAT_DXT1: + width = computeCompressedDimension(width); + height = computeCompressedDimension(height); + size = computeImageByteSize(width, height, depth, RendererTexture::FORMAT_B8G8R8A8) / 8; + break; + case RendererTexture::FORMAT_DXT3: + case RendererTexture::FORMAT_DXT5: + width = computeCompressedDimension(width); + height = computeCompressedDimension(height); + size = computeImageByteSize(width, height, depth, RendererTexture::FORMAT_B8G8R8A8) / 4; + break; + case RendererTexture::FORMAT_PVR_2BPP: + { + PxU32 bytesPerBlock = 8 * 4 * 2; //8 by 4 pixels times bytes per pixel + width = PxMax(PxI32(width / 8), 2); + height = PxMax(PxI32(height / 4), 2); + size = width*height*bytesPerBlock / 8; + } + break; + case RendererTexture::FORMAT_PVR_4BPP: + { + PxU32 bytesPerBlock = 4 * 4 * 4; //4 by 4 pixels times bytes per pixel + width = PxMax(PxI32(width / 4), 2); + height = PxMax(PxI32(height / 4), 2); + size = width*height*bytesPerBlock / 8; + } + break; + default: break; + } + RENDERER_ASSERT(size, "Unable to compute Image Size."); + return size; +} + +PxU32 RendererTexture::getLevelDimension(PxU32 dimension, PxU32 level) +{ + dimension >>=level; + if(!dimension) dimension=1; + return dimension; +} + +bool RendererTexture::isCompressedFormat(Format format) +{ + return (format >= FORMAT_DXT1 && format <= FORMAT_DXT5) || (format == FORMAT_PVR_2BPP) || (format == FORMAT_PVR_4BPP); +} + +bool RendererTexture::isDepthStencilFormat(Format format) +{ + return (format >= FORMAT_D16 && format <= FORMAT_D24S8); +} + +PxU32 RendererTexture::getFormatNumBlocks(PxU32 dimension, Format format) +{ + PxU32 blockDimension = 0; + if(isCompressedFormat(format)) + { + blockDimension = dimension / 4; + if(dimension % 4) blockDimension++; + } + else + { + blockDimension = dimension; + } + return blockDimension; +} + +PxU32 RendererTexture::getFormatBlockSize(Format format) +{ + return computeImageByteSize(1, 1, 1, format); +} + +RendererTexture::RendererTexture(const RendererTextureDesc &desc) +{ + m_format = desc.format; + m_filter = desc.filter; + m_addressingU = desc.addressingU; + m_addressingV = desc.addressingV; + m_width = desc.width; + m_height = desc.height; + m_depth = desc.depth; + m_numLevels = desc.numLevels; +} + +RendererTexture::~RendererTexture(void) +{ + +} + +PxU32 RendererTexture::getWidthInBlocks(void) const +{ + return getFormatNumBlocks(getWidth(), getFormat()); +} + +PxU32 RendererTexture::getHeightInBlocks(void) const +{ + return getFormatNumBlocks(getHeight(), getFormat()); +} + +PxU32 RendererTexture::getBlockSize(void) const +{ + return getFormatBlockSize(getFormat()); +} diff --git a/PhysX_3.4/Samples/SampleFramework/renderer/src/RendererTexture2D.cpp b/PhysX_3.4/Samples/SampleFramework/renderer/src/RendererTexture2D.cpp new file mode 100644 index 00000000..46c0b1ab --- /dev/null +++ b/PhysX_3.4/Samples/SampleFramework/renderer/src/RendererTexture2D.cpp @@ -0,0 +1,30 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved. +#include <RendererTexture2D.h> +#include <RendererTexture2DDesc.h> + +using namespace SampleRenderer; diff --git a/PhysX_3.4/Samples/SampleFramework/renderer/src/RendererTexture2DDesc.cpp b/PhysX_3.4/Samples/SampleFramework/renderer/src/RendererTexture2DDesc.cpp new file mode 100644 index 00000000..709e6b8b --- /dev/null +++ b/PhysX_3.4/Samples/SampleFramework/renderer/src/RendererTexture2DDesc.cpp @@ -0,0 +1,27 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved. +#include <RendererTexture2DDesc.h> diff --git a/PhysX_3.4/Samples/SampleFramework/renderer/src/RendererTextureDesc.cpp b/PhysX_3.4/Samples/SampleFramework/renderer/src/RendererTextureDesc.cpp new file mode 100644 index 00000000..3308d283 --- /dev/null +++ b/PhysX_3.4/Samples/SampleFramework/renderer/src/RendererTextureDesc.cpp @@ -0,0 +1,64 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved. +#include <RendererTextureDesc.h> + +using namespace SampleRenderer; + +RendererTextureDesc::RendererTextureDesc(void) +{ + format = RendererTexture::NUM_FORMATS; + filter = RendererTexture::FILTER_LINEAR; + addressingU = RendererTexture::ADDRESSING_WRAP; + addressingV = RendererTexture::ADDRESSING_WRAP; + addressingW = RendererTexture::ADDRESSING_WRAP; + width = 0; + height = 0; + depth = 1; + numLevels = 0; + renderTarget = false; + data = NULL; +} + + +bool RendererTextureDesc::isValid(void) const +{ + bool ok = true; + if(format >= RendererTexture2D::NUM_FORMATS) ok = false; + if(filter >= RendererTexture2D::NUM_FILTERS) ok = false; + if(addressingU >= RendererTexture2D::NUM_ADDRESSING) ok = false; + if(addressingV >= RendererTexture2D::NUM_ADDRESSING) ok = false; + if(width <= 0 || height <= 0 || depth <= 0) ok = false; // TODO: check for power of two. + if(numLevels <= 0) ok = false; + if(renderTarget) + { + if(depth > 1) ok = false; + if(format == RendererTexture2D::FORMAT_DXT1) ok = false; + if(format == RendererTexture2D::FORMAT_DXT3) ok = false; + if(format == RendererTexture2D::FORMAT_DXT5) ok = false; + } + return ok; +} diff --git a/PhysX_3.4/Samples/SampleFramework/renderer/src/RendererVertexBuffer.cpp b/PhysX_3.4/Samples/SampleFramework/renderer/src/RendererVertexBuffer.cpp new file mode 100644 index 00000000..c6bb4528 --- /dev/null +++ b/PhysX_3.4/Samples/SampleFramework/renderer/src/RendererVertexBuffer.cpp @@ -0,0 +1,156 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved. +#include <RendererVertexBuffer.h> +#include <RendererVertexBufferDesc.h> + +using namespace SampleRenderer; + +PxU32 RendererVertexBuffer::getFormatByteSize(Format format) +{ + PxU32 size = 0; + switch(format) + { + case FORMAT_FLOAT1: size = sizeof(float) * 1; break; + case FORMAT_FLOAT2: size = sizeof(float) * 2; break; + case FORMAT_FLOAT3: size = sizeof(float) * 3; break; + case FORMAT_FLOAT4: size = sizeof(float) * 4; break; + case FORMAT_UBYTE4: size = sizeof(PxU8) * 4; break; + case FORMAT_USHORT4: size = sizeof(PxU16) * 4; break; + case FORMAT_COLOR_BGRA: size = sizeof(PxU8) * 4; break; + case FORMAT_COLOR_RGBA: size = sizeof(PxU8) * 4; break; + case FORMAT_COLOR_NATIVE: size = sizeof(PxU8) * 4; break; + default: break; + } + RENDERER_ASSERT(size, "Unable to determine size of Format."); + return size; +} + +RendererVertexBuffer::RendererVertexBuffer(const RendererVertexBufferDesc &desc) : +RendererInteropableBuffer(desc.registerInCUDA, desc.interopContext), + m_hint(desc.hint), + m_deferredUnlock(desc.interopContext == NULL) +{ + m_maxVertices = 0; + m_stride = 0; + m_lockedBuffer = 0; + m_numSemanticLocks = 0; + + for(PxU32 i=0; i<NUM_SEMANTICS; i++) + { + Format format = desc.semanticFormats[i]; + if(format < NUM_FORMATS) + { + SemanticDesc &sm = m_semanticDescs[i]; + sm.format = format; + sm.offset = m_stride; + m_stride += getFormatByteSize(format); + } + } +} + +RendererVertexBuffer::~RendererVertexBuffer(void) +{ + RENDERER_ASSERT(m_numSemanticLocks==0, "VertexBuffer had outstanding locks during destruction!"); +} + +PxU32 RendererVertexBuffer::getMaxVertices(void) const +{ + return m_maxVertices; +} + +RendererVertexBuffer::Hint RendererVertexBuffer::getHint(void) const +{ + return m_hint; +} + +RendererVertexBuffer::Format RendererVertexBuffer::getFormatForSemantic(Semantic semantic) const +{ + RENDERER_ASSERT(semantic < NUM_SEMANTICS, "Invalid VertexBuffer Semantic!"); + return m_semanticDescs[semantic].format; +} + +void *RendererVertexBuffer::lockSemantic(Semantic semantic, PxU32 &stride) +{ + void *semanticBuffer = 0; + RENDERER_ASSERT(semantic < NUM_SEMANTICS, "Invalid VertexBuffer Semantic!"); + if(semantic < NUM_SEMANTICS) + { + SemanticDesc &sm = m_semanticDescs[semantic]; + RENDERER_ASSERT(!sm.locked, "VertexBuffer Semantic already locked."); + RENDERER_ASSERT(sm.format < NUM_FORMATS, "VertexBuffer does not use this semantic."); + if(!sm.locked && sm.format < NUM_FORMATS) + { + if(!m_lockedBuffer && !m_numSemanticLocks) + { + m_lockedBuffer = lock(); + } + RENDERER_ASSERT(m_lockedBuffer, "Unable to lock VertexBuffer!"); + if(m_lockedBuffer) + { + m_numSemanticLocks++; + sm.locked = true; + semanticBuffer = ((PxU8*)m_lockedBuffer) + sm.offset; + stride = m_stride; + } + } + } + return semanticBuffer; +} + +void RendererVertexBuffer::unlockSemantic(Semantic semantic) +{ + RENDERER_ASSERT(semantic < NUM_SEMANTICS, "Invalid VertexBuffer Semantic!"); + if(semantic < NUM_SEMANTICS) + { + SemanticDesc &sm = m_semanticDescs[semantic]; + RENDERER_ASSERT(m_lockedBuffer && m_numSemanticLocks && sm.locked, "Trying to unlock a semantic that was not locked."); + if(m_lockedBuffer && m_numSemanticLocks && sm.locked) + { + if(m_lockedBuffer && semantic == SEMANTIC_COLOR) + { + swizzleColor(((PxU8*)m_lockedBuffer)+sm.offset, m_stride, m_maxVertices, sm.format); + } + sm.locked = false; + m_numSemanticLocks--; + } + if(m_lockedBuffer && m_numSemanticLocks == 0 && m_deferredUnlock == false) + { + unlock(); + m_lockedBuffer = 0; + } + } +} + +void RendererVertexBuffer::prepareForRender(void) +{ + if(m_lockedBuffer && m_numSemanticLocks == 0) + { + unlock(); + m_lockedBuffer = 0; + } + RENDERER_ASSERT(m_lockedBuffer==0, "Vertex Buffer locked during usage!"); +} diff --git a/PhysX_3.4/Samples/SampleFramework/renderer/src/RendererVertexBufferDesc.cpp b/PhysX_3.4/Samples/SampleFramework/renderer/src/RendererVertexBufferDesc.cpp new file mode 100644 index 00000000..73cd4b06 --- /dev/null +++ b/PhysX_3.4/Samples/SampleFramework/renderer/src/RendererVertexBufferDesc.cpp @@ -0,0 +1,52 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved. +#include <RendererVertexBufferDesc.h> + +using namespace SampleRenderer; + +RendererVertexBufferDesc::RendererVertexBufferDesc(void) +{ + hint = RendererVertexBuffer::HINT_STATIC; + for(PxU32 i=0; i<RendererVertexBuffer::NUM_SEMANTICS; i++) + { + semanticFormats[i] = RendererVertexBuffer::NUM_FORMATS; + } + maxVertices = 0; + canReadBack = false; + registerInCUDA = false; + interopContext = 0; +} + +bool RendererVertexBufferDesc::isValid(void) const +{ + bool ok = true; + // TODO: make sure at least "some" of the semanticFormats are set. + if(!maxVertices) ok = false; + if(registerInCUDA && !interopContext) + ok = false; + return ok; +} diff --git a/PhysX_3.4/Samples/SampleFramework/renderer/src/RendererWindow.cpp b/PhysX_3.4/Samples/SampleFramework/renderer/src/RendererWindow.cpp new file mode 100644 index 00000000..c946419f --- /dev/null +++ b/PhysX_3.4/Samples/SampleFramework/renderer/src/RendererWindow.cpp @@ -0,0 +1,115 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved. +#include <RendererWindow.h> +#include <RendererMemoryMacros.h> +#include <SamplePlatform.h> +#include <stdio.h> + +using namespace SampleRenderer; + +RendererWindow::RendererWindow(void) : m_platform(NULL), m_isOpen(false) +{ + m_platform = SampleFramework::createPlatform(this); +} + +bool RendererWindow::hasFocus() const +{ + return m_platform->hasFocus(); +} + +void RendererWindow::setFocus(bool b) +{ + m_platform->setFocus(b); +} + +RendererWindow::~RendererWindow(void) +{ + DELETESINGLE(m_platform); +} + +bool RendererWindow::open(PxU32 width, PxU32 height, const char *title, bool fullscreen) +{ + bool ok = false; + RENDERER_ASSERT(width && height, "Attempting to open a window with invalid width and/or height."); + if(width && height) + { + ok = m_platform->openWindow(width, height, title, fullscreen); +#if !defined(RENDERER_WINDOWS) + m_isOpen = true; +#endif + } + return ok; +} + +void RendererWindow::close(void) +{ + m_platform->closeWindow(); +#if !defined(RENDERER_WINDOWS) + if(isOpen()) + { + m_isOpen = false; + onClose(); + } +#endif +} + +bool RendererWindow::isOpen(void) const +{ + bool open = m_platform->isOpen(); +#if !defined(RENDERER_WINDOWS) + open = m_isOpen; +#endif + return open; +} + +// update the window's state... handle messages, etc. +void RendererWindow::update(void) +{ + m_platform->update(); + +#if defined(RENDERER_ANDROID) + if (!m_platform->isOpen()) + return; +#endif +} + +void RendererWindow::setSize(PxU32 width, PxU32 height) +{ + m_platform->setWindowSize(width, height); +} + +// get the window's title... +void RendererWindow::getTitle(char *title, PxU32 maxLength) const +{ + m_platform->getTitle(title, maxLength); +} + +// set the window's title... +void RendererWindow::setTitle(const char *title) +{ + m_platform->setTitle(title); +} diff --git a/PhysX_3.4/Samples/SampleFramework/renderer/src/cuda/RenderClothNormals.cu b/PhysX_3.4/Samples/SampleFramework/renderer/src/cuda/RenderClothNormals.cu new file mode 100644 index 00000000..1140a11b --- /dev/null +++ b/PhysX_3.4/Samples/SampleFramework/renderer/src/cuda/RenderClothNormals.cu @@ -0,0 +1,113 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved. + +#include "PxPhysics.h" +#include "PxVec4.h" +#include "PxVec3.h" +#include "PxVec2.h" + +#include "cloth/PxClothTypes.h" + +namespace physx +{ + +// interleaved format must match that used by RendererClothShape +struct Vertex +{ + PxVec3 position; + PxVec3 normal; +}; + +namespace +{ + __device__ inline void PxAtomicFloatAdd(float* dest, float x) + { +#if __CUDA_ARCH__ >= 200 + atomicAdd(dest, x); +#else + union bits { float f; unsigned int i; }; + bits oldVal, newVal; + + do + { + // emulate atomic float add on 1.1 arch + oldVal.f = *dest; + newVal.f = oldVal.f + x; + } + while (atomicCAS((unsigned int*)dest, oldVal.i, newVal.i) != oldVal.i); +#endif + } + + + __device__ void PxAtomicVec3Add(PxVec3& dest, PxVec3 inc) + { + PxAtomicFloatAdd(&dest.x, inc.x); + PxAtomicFloatAdd(&dest.y, inc.y); + PxAtomicFloatAdd(&dest.z, inc.z); + } +} + +extern "C" __global__ void computeSmoothNormals( + const PxClothParticle* particles, + const PxU16* indices, + Vertex* vertices, + PxU32 numTris, + PxU32 numParticles) +{ + // zero old normals + for (PxU32 i=threadIdx.x; i < numParticles; i += blockDim.x) + vertices[i].normal = PxVec3(0.0f); + + __syncthreads(); + + for (PxU32 i=threadIdx.x; i < numTris; i += blockDim.x) + { + PxU16 a = indices[i*3]; + PxU16 b = indices[i*3+1]; + PxU16 c = indices[i*3+2]; + + // calculate face normal + PxVec3 e1 = particles[b].pos-particles[a].pos; + PxVec3 e2 = particles[c].pos-particles[a].pos; + PxVec3 n = e2.cross(e1); + + PxAtomicVec3Add(vertices[a].normal, n); + PxAtomicVec3Add(vertices[b].normal, n); + PxAtomicVec3Add(vertices[c].normal, n); + } + + __syncthreads(); + + // update vertex buffer + for (PxU32 i=threadIdx.x; i < numParticles; i += blockDim.x) + { + vertices[i].position = particles[i].pos; + vertices[i].normal = vertices[i].normal.getNormalized(); + } +} + +}
\ No newline at end of file diff --git a/PhysX_3.4/Samples/SampleFramework/renderer/src/cuda/RenderClothNormals_x64.cuh b/PhysX_3.4/Samples/SampleFramework/renderer/src/cuda/RenderClothNormals_x64.cuh new file mode 100644 index 00000000..42a0ca22 --- /dev/null +++ b/PhysX_3.4/Samples/SampleFramework/renderer/src/cuda/RenderClothNormals_x64.cuh @@ -0,0 +1,841 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved. + +#ifdef __cplusplus +extern "C" { +#endif + +unsigned char computeSmoothNormals[] = { +0x50,0xed,0x55,0xba,0x01,0x00,0x10,0x00,0x20,0x32,0x00,0x00,0x00,0x00,0x00,0x00, +0x02,0x00,0x01,0x01,0x58,0x00,0x00,0x00,0x80,0x0d,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x00,0x01,0x00,0x0b,0x00,0x00,0x00, +0x40,0x00,0x00,0x00,0x15,0x00,0x00,0x00,0x45,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x52,0x65,0x6e,0x64,0x65,0x72,0x43,0x6c,0x6f,0x74,0x68,0x4e,0x6f,0x72,0x6d,0x61, +0x6c,0x73,0x2e,0x63,0x75,0x00,0x00,0x00,0x7f,0x45,0x4c,0x46,0x02,0x01,0x01,0x33, +0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x00,0xbe,0x00,0x01,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xd8,0x0c,0x00,0x00,0x00,0x00,0x00,0x00, +0x98,0x0a,0x00,0x00,0x00,0x00,0x00,0x00,0x0b,0x01,0x0b,0x00,0x40,0x00,0x38,0x00, +0x03,0x00,0x40,0x00,0x09,0x00,0x01,0x00,0x00,0x2e,0x73,0x68,0x73,0x74,0x72,0x74, +0x61,0x62,0x00,0x2e,0x73,0x74,0x72,0x74,0x61,0x62,0x00,0x2e,0x73,0x79,0x6d,0x74, +0x61,0x62,0x00,0x2e,0x74,0x65,0x78,0x74,0x2e,0x63,0x6f,0x6d,0x70,0x75,0x74,0x65, +0x53,0x6d,0x6f,0x6f,0x74,0x68,0x4e,0x6f,0x72,0x6d,0x61,0x6c,0x73,0x00,0x2e,0x6e, +0x76,0x2e,0x69,0x6e,0x66,0x6f,0x2e,0x63,0x6f,0x6d,0x70,0x75,0x74,0x65,0x53,0x6d, +0x6f,0x6f,0x74,0x68,0x4e,0x6f,0x72,0x6d,0x61,0x6c,0x73,0x00,0x2e,0x6e,0x76,0x2e, +0x73,0x68,0x61,0x72,0x65,0x64,0x2e,0x63,0x6f,0x6d,0x70,0x75,0x74,0x65,0x53,0x6d, +0x6f,0x6f,0x74,0x68,0x4e,0x6f,0x72,0x6d,0x61,0x6c,0x73,0x00,0x2e,0x6e,0x76,0x2e, +0x63,0x6f,0x6e,0x73,0x74,0x61,0x6e,0x74,0x31,0x2e,0x63,0x6f,0x6d,0x70,0x75,0x74, +0x65,0x53,0x6d,0x6f,0x6f,0x74,0x68,0x4e,0x6f,0x72,0x6d,0x61,0x6c,0x73,0x00,0x2e, +0x6e,0x76,0x2e,0x6c,0x6f,0x63,0x61,0x6c,0x2e,0x63,0x6f,0x6d,0x70,0x75,0x74,0x65, +0x53,0x6d,0x6f,0x6f,0x74,0x68,0x4e,0x6f,0x72,0x6d,0x61,0x6c,0x73,0x00,0x00,0x2e, +0x73,0x68,0x73,0x74,0x72,0x74,0x61,0x62,0x00,0x2e,0x73,0x74,0x72,0x74,0x61,0x62, +0x00,0x2e,0x73,0x79,0x6d,0x74,0x61,0x62,0x00,0x63,0x6f,0x6d,0x70,0x75,0x74,0x65, +0x53,0x6d,0x6f,0x6f,0x74,0x68,0x4e,0x6f,0x72,0x6d,0x61,0x6c,0x73,0x00,0x2e,0x74, +0x65,0x78,0x74,0x2e,0x63,0x6f,0x6d,0x70,0x75,0x74,0x65,0x53,0x6d,0x6f,0x6f,0x74, +0x68,0x4e,0x6f,0x72,0x6d,0x61,0x6c,0x73,0x00,0x2e,0x6e,0x76,0x2e,0x69,0x6e,0x66, +0x6f,0x2e,0x63,0x6f,0x6d,0x70,0x75,0x74,0x65,0x53,0x6d,0x6f,0x6f,0x74,0x68,0x4e, +0x6f,0x72,0x6d,0x61,0x6c,0x73,0x00,0x2e,0x6e,0x76,0x2e,0x73,0x68,0x61,0x72,0x65, +0x64,0x2e,0x63,0x6f,0x6d,0x70,0x75,0x74,0x65,0x53,0x6d,0x6f,0x6f,0x74,0x68,0x4e, +0x6f,0x72,0x6d,0x61,0x6c,0x73,0x00,0x2e,0x6e,0x76,0x2e,0x63,0x6f,0x6e,0x73,0x74, +0x61,0x6e,0x74,0x31,0x2e,0x63,0x6f,0x6d,0x70,0x75,0x74,0x65,0x53,0x6d,0x6f,0x6f, +0x74,0x68,0x4e,0x6f,0x72,0x6d,0x61,0x6c,0x73,0x00,0x63,0x6f,0x6e,0x73,0x74,0x00, +0x2e,0x6e,0x76,0x2e,0x6c,0x6f,0x63,0x61,0x6c,0x2e,0x63,0x6f,0x6d,0x70,0x75,0x74, +0x65,0x53,0x6d,0x6f,0x6f,0x74,0x68,0x4e,0x6f,0x72,0x6d,0x61,0x6c,0x73,0x00,0x24, +0x63,0x6f,0x6d,0x70,0x75,0x74,0x65,0x53,0x6d,0x6f,0x6f,0x74,0x68,0x4e,0x6f,0x72, +0x6d,0x61,0x6c,0x73,0x24,0x6c,0x6f,0x63,0x61,0x6c,0x00,0x5f,0x5f,0x63,0x75,0x64, +0x61,0x70,0x61,0x72,0x6d,0x5f,0x63,0x6f,0x6d,0x70,0x75,0x74,0x65,0x53,0x6d,0x6f, +0x6f,0x74,0x68,0x4e,0x6f,0x72,0x6d,0x61,0x6c,0x73,0x5f,0x70,0x61,0x72,0x74,0x69, +0x63,0x6c,0x65,0x73,0x00,0x5f,0x5f,0x63,0x75,0x64,0x61,0x70,0x61,0x72,0x6d,0x5f, +0x63,0x6f,0x6d,0x70,0x75,0x74,0x65,0x53,0x6d,0x6f,0x6f,0x74,0x68,0x4e,0x6f,0x72, +0x6d,0x61,0x6c,0x73,0x5f,0x69,0x6e,0x64,0x69,0x63,0x65,0x73,0x00,0x5f,0x5f,0x63, +0x75,0x64,0x61,0x70,0x61,0x72,0x6d,0x5f,0x63,0x6f,0x6d,0x70,0x75,0x74,0x65,0x53, +0x6d,0x6f,0x6f,0x74,0x68,0x4e,0x6f,0x72,0x6d,0x61,0x6c,0x73,0x5f,0x76,0x65,0x72, +0x74,0x69,0x63,0x65,0x73,0x00,0x5f,0x5f,0x63,0x75,0x64,0x61,0x70,0x61,0x72,0x6d, +0x5f,0x63,0x6f,0x6d,0x70,0x75,0x74,0x65,0x53,0x6d,0x6f,0x6f,0x74,0x68,0x4e,0x6f, +0x72,0x6d,0x61,0x6c,0x73,0x5f,0x6e,0x75,0x6d,0x54,0x72,0x69,0x73,0x00,0x5f,0x5f, +0x63,0x75,0x64,0x61,0x70,0x61,0x72,0x6d,0x5f,0x63,0x6f,0x6d,0x70,0x75,0x74,0x65, +0x53,0x6d,0x6f,0x6f,0x74,0x68,0x4e,0x6f,0x72,0x6d,0x61,0x6c,0x73,0x5f,0x6e,0x75, +0x6d,0x50,0x61,0x72,0x74,0x69,0x63,0x6c,0x65,0x73,0x00,0x24,0x5f,0x5f,0x5f,0x5f, +0x63,0x75,0x64,0x61,0x5f,0x5f,0x5f,0x63,0x75,0x64,0x61,0x5f,0x5f,0x5f,0x54,0x32, +0x31,0x36,0x5f,0x35,0x36,0x33,0x32,0x5f,0x5f,0x37,0x31,0x00,0x24,0x5f,0x5f,0x5f, +0x5f,0x63,0x75,0x64,0x61,0x5f,0x5f,0x5f,0x63,0x75,0x64,0x61,0x5f,0x5f,0x5f,0x54, +0x32,0x32,0x31,0x5f,0x36,0x38,0x34,0x34,0x5f,0x5f,0x37,0x32,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x00,0x00,0x00,0x03,0x00,0x06,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x69,0x00,0x00,0x00,0x03,0x00,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x89,0x00,0x00,0x00,0x03,0x00,0x05,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0xb2,0x00,0x00,0x00,0x03,0x00,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1b,0x00,0x00,0x00,0x12,0x10,0x06,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xa8,0x06,0x00,0x00,0x00,0x00,0x00,0x00, +0x03,0x18,0x20,0x00,0x04,0x17,0x0c,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x1c,0x00, +0x00,0xf0,0x13,0x00,0x04,0x17,0x0c,0x00,0x00,0x00,0x00,0x00,0x03,0x00,0x18,0x00, +0x00,0xf0,0x13,0x00,0x04,0x17,0x0c,0x00,0x00,0x00,0x00,0x00,0x02,0x00,0x10,0x00, +0x00,0xf0,0x23,0x00,0x04,0x17,0x0c,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x08,0x00, +0x00,0xf0,0x23,0x00,0x04,0x17,0x0c,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0xf0,0x23,0x00,0x03,0x1b,0x01,0x00,0x04,0x1e,0x04,0x00,0x10,0x01,0x00,0x00, +0x18,0x00,0x00,0x00,0x10,0x00,0x00,0x00,0x0d,0x00,0x00,0xa0,0x80,0x07,0x00,0x04, +0x01,0xd6,0x03,0x30,0xd0,0x07,0x21,0x64,0xfd,0x01,0x00,0xa0,0xc8,0x47,0x01,0x0c, +0x03,0x50,0x01,0xa0,0x00,0x00,0x00,0x00,0x03,0x50,0x01,0x10,0x00,0x11,0x00,0x00, +0x01,0xd6,0x04,0x30,0x80,0x07,0x30,0xc4,0x05,0xd6,0x03,0x30,0x80,0x07,0x30,0xc4, +0x05,0x00,0x00,0x20,0x80,0x47,0x00,0x04,0x01,0x06,0x58,0x40,0x03,0x00,0x00,0x00, +0x09,0x22,0x18,0x41,0x03,0x00,0x00,0x00,0x15,0xd0,0x00,0x20,0x80,0x07,0x20,0x04, +0x11,0x80,0x00,0x10,0x03,0x00,0x00,0x00,0x19,0x8a,0x0c,0x20,0x03,0x00,0x00,0x00, +0x11,0x0c,0x0e,0xd0,0x80,0x07,0xc0,0xa0,0x19,0x8a,0x10,0x20,0x03,0x00,0x00,0x00, +0x01,0x00,0x00,0x20,0x80,0x87,0x00,0x04,0x11,0x0c,0x0e,0xd0,0x80,0x07,0xc0,0xa0, +0x15,0x8a,0x14,0x20,0x03,0x00,0x00,0x00,0xfd,0x01,0x01,0x30,0xd8,0x47,0x00,0x64, +0x11,0x0a,0x0e,0xd0,0x80,0x07,0xc0,0xa0,0x03,0xa0,0x00,0x10,0x80,0x12,0x00,0x00, +0x01,0x00,0x00,0xf0,0x02,0x00,0x00,0xe0,0x03,0xfe,0x1f,0x86,0x00,0x00,0x00,0x00, +0xfd,0xd5,0x03,0x30,0xd8,0xc7,0x20,0x64,0x03,0x80,0x09,0xa0,0x00,0x00,0x00,0x00, +0x03,0x80,0x09,0x10,0x80,0x12,0x00,0x00,0x01,0xd4,0x02,0x30,0x80,0x07,0x30,0xc4, +0x05,0xd4,0x01,0x30,0x80,0x07,0x30,0xc4,0x15,0x00,0x00,0x20,0x80,0x47,0x00,0x04, +0x11,0x06,0x46,0x40,0x03,0x00,0x00,0x00,0x19,0x22,0x06,0x41,0x03,0x00,0x00,0x00, +0x01,0xcc,0x00,0x20,0x80,0x07,0x21,0x04,0x25,0x00,0x0e,0xd0,0x80,0x07,0x40,0x80, +0x05,0x80,0x02,0x20,0x03,0x00,0x00,0x00,0x1d,0x02,0x0e,0xd0,0x80,0x07,0x40,0x80, +0x01,0x80,0x04,0x20,0x03,0x00,0x00,0x00,0x21,0x00,0x0e,0xd0,0x80,0x07,0x40,0x80, +0x01,0x08,0x00,0x10,0x80,0xc7,0x00,0x44,0x09,0x24,0x82,0x60,0x80,0x07,0x40,0x00, +0x2d,0x04,0x0e,0xd0,0x80,0x07,0xc0,0x80,0x05,0x1c,0x82,0x60,0x80,0x07,0x40,0x00, +0x29,0x02,0x0e,0xd0,0x80,0x07,0xc0,0x80,0x01,0x20,0x10,0x60,0x03,0x00,0x00,0x00, +0x39,0x00,0x0e,0xd0,0x80,0x07,0xc0,0x80,0x31,0x84,0x04,0x20,0x03,0x00,0x00,0x00, +0x31,0x18,0x0e,0xd0,0x80,0x07,0xc0,0x80,0x35,0x82,0x04,0x20,0x03,0x00,0x00,0x00, +0x35,0x1a,0x0e,0xd0,0x80,0x07,0xc0,0x80,0x28,0x14,0x4b,0xb0,0x2c,0x96,0x0e,0xb0, +0x09,0x84,0x08,0x20,0x03,0x00,0x00,0x00,0x09,0x04,0x0e,0xd0,0x80,0x07,0xc0,0x80, +0x05,0x82,0x08,0x20,0x03,0x00,0x00,0x00,0x05,0x02,0x0e,0xd0,0x80,0x07,0xc0,0x80, +0x39,0x80,0x04,0x20,0x03,0x00,0x00,0x00,0x39,0x1c,0x0e,0xd0,0x80,0x07,0xc0,0x80, +0x01,0x80,0x08,0x20,0x03,0x00,0x00,0x00,0x01,0x00,0x0e,0xd0,0x80,0x07,0xc0,0x80, +0x34,0x1a,0x4c,0xb0,0x30,0x98,0x0e,0xb0,0x38,0x02,0x42,0xb0,0x3c,0x84,0x00,0xb0, +0x01,0x10,0x00,0x10,0x80,0xc7,0x00,0x44,0x05,0x24,0x80,0x60,0x80,0x07,0x40,0x00, +0x08,0x1a,0x0f,0xc0,0x00,0x20,0x00,0x10,0x05,0x1c,0x00,0x10,0x80,0xc7,0x03,0x00, +0x1d,0x82,0x0c,0x20,0x03,0x00,0x00,0x00,0x09,0x1c,0x0c,0xe0,0x80,0x87,0x00,0x08, +0x03,0x80,0x04,0xa0,0x00,0x00,0x00,0x00,0x21,0x82,0x0c,0x20,0x03,0x00,0x00,0x00, +0x21,0x10,0x0e,0xd0,0x80,0x07,0xc0,0x80,0x25,0x10,0x00,0xb0,0x80,0x87,0x00,0x00, +0x25,0x0e,0x08,0xd7,0x88,0x47,0xc2,0xe0,0xfd,0x13,0x08,0x30,0xd8,0x47,0x01,0x64, +0x03,0x20,0x04,0x10,0x80,0x12,0x00,0x00,0x1d,0x1c,0x0b,0xc0,0x82,0x07,0x00,0x00, +0x1d,0x14,0x0f,0xe0,0x80,0xc7,0x01,0x08,0x03,0x20,0x05,0xa0,0x00,0x00,0x00,0x00, +0x21,0x82,0x10,0x20,0x03,0x00,0x00,0x00,0x25,0x82,0x10,0x20,0x03,0x00,0x00,0x00, +0x25,0x12,0x0e,0xd0,0x80,0x07,0xc0,0x80,0x39,0x12,0x00,0xb0,0x80,0xc7,0x01,0x00, +0x39,0x10,0x09,0xd7,0x88,0x87,0xc3,0xe0,0xfd,0x1d,0x09,0x30,0xd8,0x47,0x01,0x64, +0x03,0xc0,0x04,0x10,0x80,0x12,0x00,0x00,0x21,0x14,0x0c,0xc0,0x82,0x07,0x00,0x00, +0x21,0x1a,0x0b,0xe0,0x80,0x07,0x02,0x08,0x03,0xc0,0x05,0xa0,0x00,0x00,0x00,0x00, +0x25,0x82,0x14,0x20,0x03,0x00,0x00,0x00,0x29,0x82,0x14,0x20,0x03,0x00,0x00,0x00, +0x29,0x14,0x0e,0xd0,0x80,0x07,0xc0,0x80,0x2d,0x14,0x00,0xb0,0x80,0x07,0x02,0x00, +0x2d,0x12,0x0a,0xd7,0x88,0xc7,0xc2,0xe0,0xfd,0x17,0x0a,0x30,0xd8,0x47,0x01,0x64, +0x03,0x60,0x05,0x10,0x80,0x12,0x00,0x00,0x05,0x10,0x00,0x10,0x82,0xc7,0x00,0x44, +0x05,0x02,0x18,0x60,0x03,0x00,0x00,0x00,0x03,0x60,0x06,0xa0,0x00,0x00,0x00,0x00, +0x25,0x82,0x0c,0x20,0x03,0x00,0x00,0x00,0x29,0x82,0x0c,0x20,0x03,0x00,0x00,0x00, +0x29,0x14,0x0e,0xd0,0x80,0x07,0xc0,0x80,0x2d,0x14,0x00,0xb0,0x80,0x87,0x00,0x00, +0x2d,0x12,0x0a,0xd7,0x88,0xc7,0xc2,0xe0,0xfd,0x17,0x0a,0x30,0xd8,0x47,0x01,0x64, +0x03,0x00,0x06,0x10,0x80,0x12,0x00,0x00,0x01,0x00,0x00,0xf0,0x02,0x00,0x00,0xe0, +0x03,0xf0,0x06,0xa0,0x00,0x00,0x00,0x00,0x25,0x82,0x10,0x20,0x03,0x00,0x00,0x00, +0x29,0x82,0x10,0x20,0x03,0x00,0x00,0x00,0x29,0x14,0x0e,0xd0,0x80,0x07,0xc0,0x80, +0x2d,0x14,0x00,0xb0,0x80,0xc7,0x01,0x00,0x2d,0x12,0x0a,0xd7,0x88,0xc7,0xc2,0xe0, +0xfd,0x17,0x0a,0x30,0xd8,0x47,0x01,0x64,0x03,0x90,0x06,0x10,0x80,0x12,0x00,0x00, +0x01,0x00,0x00,0xf0,0x02,0x00,0x00,0xe0,0x03,0x80,0x07,0xa0,0x00,0x00,0x00,0x00, +0x25,0x82,0x14,0x20,0x03,0x00,0x00,0x00,0x29,0x82,0x14,0x20,0x03,0x00,0x00,0x00, +0x29,0x14,0x0e,0xd0,0x80,0x07,0xc0,0x80,0x2d,0x14,0x00,0xb0,0x80,0x07,0x02,0x00, +0x2d,0x12,0x0a,0xd7,0x88,0xc7,0xc2,0xe0,0xfd,0x17,0x0a,0x30,0xd8,0x47,0x01,0x64, +0x03,0x20,0x07,0x10,0x80,0x12,0x00,0x00,0x05,0x10,0x00,0x10,0x82,0xc7,0x00,0x44, +0x01,0x00,0x80,0x60,0x80,0x47,0x40,0x00,0x03,0x20,0x08,0xa0,0x00,0x00,0x00,0x00, +0x05,0x80,0x0c,0x20,0x03,0x00,0x00,0x00,0x25,0x80,0x0c,0x20,0x03,0x00,0x00,0x00, +0x25,0x12,0x0e,0xd0,0x80,0x07,0xc0,0x80,0x29,0x12,0x00,0xb0,0x80,0x87,0x00,0x00, +0x29,0x02,0x09,0xd7,0x88,0x87,0xc2,0xe0,0xfd,0x15,0x09,0x30,0xd8,0x47,0x01,0x64, +0x03,0xc0,0x07,0x10,0x80,0x12,0x00,0x00,0x01,0x00,0x00,0xf0,0x02,0x00,0x00,0xe0, +0x03,0xb0,0x08,0xa0,0x00,0x00,0x00,0x00,0x05,0x80,0x10,0x20,0x03,0x00,0x00,0x00, +0x09,0x80,0x10,0x20,0x03,0x00,0x00,0x00,0x09,0x04,0x0e,0xd0,0x80,0x07,0xc0,0x80, +0x25,0x04,0x00,0xb0,0x80,0xc7,0x01,0x00,0x25,0x02,0x02,0xd7,0x88,0x47,0xc2,0xe0, +0xfd,0x13,0x02,0x30,0xd8,0x47,0x01,0x64,0x03,0x50,0x08,0x10,0x80,0x12,0x00,0x00, +0x01,0x00,0x00,0xf0,0x02,0x00,0x00,0xe0,0x03,0x40,0x09,0xa0,0x00,0x00,0x00,0x00, +0x05,0x80,0x14,0x20,0x03,0x00,0x00,0x00,0x09,0x80,0x14,0x20,0x03,0x00,0x00,0x00, +0x09,0x04,0x0e,0xd0,0x80,0x07,0xc0,0x80,0x1d,0x04,0x00,0xb0,0x80,0x07,0x02,0x00, +0x1d,0x02,0x02,0xd7,0x88,0xc7,0xc1,0xe0,0xfd,0x0f,0x02,0x30,0xd8,0x47,0x01,0x64, +0x03,0xe0,0x08,0x10,0x80,0x12,0x00,0x00,0x01,0x00,0x00,0xf0,0x02,0x00,0x00,0xe0, +0x11,0x08,0x00,0x20,0x80,0x87,0x01,0x04,0xfd,0x09,0x05,0x30,0xd8,0x47,0x00,0x64, +0x03,0xf0,0x01,0x10,0x80,0x12,0x00,0x00,0x01,0x00,0x00,0xf0,0x02,0x00,0x00,0xe0, +0x03,0xfe,0x1f,0x86,0x00,0x00,0x00,0x00,0x03,0x00,0x00,0x30,0x00,0x01,0x00,0x00, +0x01,0x06,0x04,0x30,0x80,0x07,0x10,0xc4,0x0d,0x06,0x58,0x40,0x03,0x00,0x00,0x00, +0x05,0xd6,0x04,0x30,0x80,0x07,0x30,0xc4,0x09,0x22,0x10,0x41,0x03,0x00,0x00,0x00, +0x11,0x22,0x18,0x41,0x03,0x00,0x00,0x00,0x1d,0xc8,0x00,0x20,0x80,0x07,0x20,0x04, +0x19,0x0e,0x0e,0xd0,0x80,0x07,0xc0,0x80,0x15,0xd0,0x00,0x20,0x80,0xc7,0x20,0x04, +0x19,0x0a,0x0e,0xd0,0x80,0x07,0xc0,0xa0,0x19,0x8e,0x04,0x20,0x03,0x00,0x00,0x00, +0x19,0x0c,0x0e,0xd0,0x80,0x07,0xc0,0x80,0x21,0x8a,0x04,0x20,0x03,0x00,0x00,0x00, +0x19,0x10,0x0e,0xd0,0x80,0x07,0xc0,0xa0,0x19,0x8e,0x08,0x20,0x03,0x00,0x00,0x00, +0x19,0x0c,0x0e,0xd0,0x80,0x07,0xc0,0x80,0x1d,0x8a,0x08,0x20,0x03,0x00,0x00,0x00, +0x19,0x0e,0x0e,0xd0,0x80,0x07,0xc0,0xa0,0x19,0x8a,0x10,0x20,0x03,0x00,0x00,0x00, +0x19,0x0c,0x0e,0xd0,0x80,0x07,0xc0,0x80,0x03,0x70,0x0c,0xa0,0x00,0x00,0x00,0x00, +0x1d,0x8a,0x0c,0x20,0x03,0x00,0x00,0x00,0x21,0x0e,0x0e,0xd0,0x80,0x07,0xc0,0x80, +0x1d,0x8a,0x14,0x20,0x03,0x00,0x00,0x00,0x1d,0x0e,0x0e,0xd0,0x80,0x07,0xc0,0x80, +0x25,0x0c,0x06,0xc0,0x80,0x07,0x00,0x00,0x25,0x10,0x08,0xe0,0x80,0x47,0x02,0x00, +0x25,0x0e,0x07,0xe0,0x80,0x47,0x02,0x00,0xfd,0x13,0x7c,0xb0,0xc8,0x07,0x01,0x60, +0x03,0x10,0x0c,0x10,0x00,0x01,0x00,0x00,0x25,0x12,0x00,0x90,0x80,0x07,0x00,0x40, +0x24,0x12,0x00,0x90,0x24,0x12,0x00,0x90,0x21,0x12,0x08,0xc0,0x80,0x07,0x00,0x00, +0x21,0x00,0x00,0xd0,0x80,0x07,0xc0,0x60,0x18,0x12,0x06,0xc0,0x1c,0x12,0x07,0xc0, +0x19,0x08,0x00,0xd0,0x80,0x07,0xc0,0x60,0x1d,0x10,0x00,0xd0,0x80,0x07,0xc0,0x60, +0x05,0xf8,0x00,0x00,0x80,0x07,0x00,0xc0,0x03,0x70,0x0c,0x10,0x80,0x07,0x00,0x00, +0x19,0x80,0x00,0x10,0x03,0x00,0x00,0x00,0x19,0x18,0x00,0xd0,0x80,0x07,0xc0,0x60, +0x19,0x20,0x00,0xd0,0x80,0x07,0xc0,0x60,0x1d,0x80,0x0c,0x10,0x03,0x00,0x00,0x00, +0x19,0x28,0x00,0xd0,0x80,0x07,0xc0,0x60,0x05,0x0e,0x00,0x00,0x80,0x07,0x00,0xc0, +0x19,0x00,0x00,0xd4,0x82,0x07,0xc0,0x40,0x21,0x08,0x00,0xd4,0x80,0x07,0xc0,0x40, +0x1d,0x10,0x00,0xd4,0x80,0x07,0xc0,0x40,0x25,0x8a,0x0c,0x20,0x03,0x00,0x00,0x00, +0x19,0x12,0x0e,0xd0,0x80,0x07,0xc0,0xa0,0x19,0x8a,0x10,0x20,0x03,0x00,0x00,0x00, +0x01,0x00,0x00,0x20,0x80,0x87,0x00,0x04,0x21,0x0c,0x0e,0xd0,0x80,0x07,0xc0,0xa0, +0x15,0x8a,0x14,0x20,0x03,0x00,0x00,0x00,0xfd,0x01,0x01,0x30,0xc8,0x47,0x00,0x64, +0x1d,0x0a,0x0e,0xd0,0x80,0x07,0xc0,0xa0,0x0d,0x06,0x00,0x20,0x80,0x07,0x01,0x04, +0x03,0x00,0x0a,0x10,0x80,0x02,0x00,0x00,0x01,0x00,0x00,0xf0,0x01,0x00,0x00,0xe0, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x01,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0xb6,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x0b,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf6,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0xff,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x13,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf8,0x02,0x00,0x00,0x00,0x00,0x00,0x00, +0x90,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x04,0x00,0x00,0x00, +0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x36,0x00,0x00,0x00,0x00,0x00,0x00,0x70,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x88,0x03,0x00,0x00,0x00,0x00,0x00,0x00, +0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x06,0x00,0x00,0x00, +0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x74,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xe8,0x03,0x00,0x00,0x00,0x00,0x00,0x00, +0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x06,0x00,0x00,0x00, +0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x1b,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x06,0x00,0x10,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0x03,0x00,0x00,0x00,0x00,0x00,0x00, +0xa8,0x06,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x05,0x00,0x00,0x10, +0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x54,0x00,0x00,0x00,0x08,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x98,0x0a,0x00,0x00,0x00,0x00,0x00,0x00, +0x30,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x06,0x00,0x00,0x00, +0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x97,0x00,0x00,0x00,0x08,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x98,0x0a,0x00,0x00,0x00,0x00,0x00,0x00, +0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x06,0x00,0x00,0x00, +0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x06,0x00,0x00,0x00,0x05,0x00,0x00,0x00,0xd8,0x0c,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0xa8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xa8,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x05,0x00,0x00,0x00, +0xe8,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xb0,0x06,0x00,0x00,0x00,0x00,0x00,0x00, +0xb0,0x06,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x01,0x00,0x00,0x00,0x06,0x00,0x00,0x00,0x98,0x0a,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x00,0x01,0x01,0x58,0x00,0x00,0x00, +0x70,0x09,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x07,0x00,0x01,0x00,0x14,0x00,0x00,0x00,0x40,0x00,0x00,0x00,0x15,0x00,0x00,0x00, +0x45,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x52,0x65,0x6e,0x64,0x65,0x72,0x43,0x6c, +0x6f,0x74,0x68,0x4e,0x6f,0x72,0x6d,0x61,0x6c,0x73,0x2e,0x63,0x75,0x00,0x00,0x00, +0x7f,0x45,0x4c,0x46,0x02,0x01,0x01,0x33,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x02,0x00,0xbe,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0xc8,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0xc8,0x06,0x00,0x00,0x00,0x00,0x00,0x00, +0x14,0x05,0x14,0x00,0x40,0x00,0x38,0x00,0x03,0x00,0x40,0x00,0x08,0x00,0x01,0x00, +0x00,0x2e,0x73,0x68,0x73,0x74,0x72,0x74,0x61,0x62,0x00,0x2e,0x73,0x74,0x72,0x74, +0x61,0x62,0x00,0x2e,0x73,0x79,0x6d,0x74,0x61,0x62,0x00,0x2e,0x74,0x65,0x78,0x74, +0x2e,0x63,0x6f,0x6d,0x70,0x75,0x74,0x65,0x53,0x6d,0x6f,0x6f,0x74,0x68,0x4e,0x6f, +0x72,0x6d,0x61,0x6c,0x73,0x00,0x2e,0x6e,0x76,0x2e,0x69,0x6e,0x66,0x6f,0x2e,0x63, +0x6f,0x6d,0x70,0x75,0x74,0x65,0x53,0x6d,0x6f,0x6f,0x74,0x68,0x4e,0x6f,0x72,0x6d, +0x61,0x6c,0x73,0x00,0x2e,0x6e,0x76,0x2e,0x73,0x68,0x61,0x72,0x65,0x64,0x2e,0x63, +0x6f,0x6d,0x70,0x75,0x74,0x65,0x53,0x6d,0x6f,0x6f,0x74,0x68,0x4e,0x6f,0x72,0x6d, +0x61,0x6c,0x73,0x00,0x2e,0x6e,0x76,0x2e,0x69,0x6e,0x66,0x6f,0x00,0x2e,0x6e,0x76, +0x2e,0x63,0x6f,0x6e,0x73,0x74,0x61,0x6e,0x74,0x30,0x2e,0x63,0x6f,0x6d,0x70,0x75, +0x74,0x65,0x53,0x6d,0x6f,0x6f,0x74,0x68,0x4e,0x6f,0x72,0x6d,0x61,0x6c,0x73,0x00, +0x00,0x2e,0x73,0x68,0x73,0x74,0x72,0x74,0x61,0x62,0x00,0x2e,0x73,0x74,0x72,0x74, +0x61,0x62,0x00,0x2e,0x73,0x79,0x6d,0x74,0x61,0x62,0x00,0x63,0x6f,0x6d,0x70,0x75, +0x74,0x65,0x53,0x6d,0x6f,0x6f,0x74,0x68,0x4e,0x6f,0x72,0x6d,0x61,0x6c,0x73,0x00, +0x2e,0x74,0x65,0x78,0x74,0x2e,0x63,0x6f,0x6d,0x70,0x75,0x74,0x65,0x53,0x6d,0x6f, +0x6f,0x74,0x68,0x4e,0x6f,0x72,0x6d,0x61,0x6c,0x73,0x00,0x2e,0x6e,0x76,0x2e,0x69, +0x6e,0x66,0x6f,0x2e,0x63,0x6f,0x6d,0x70,0x75,0x74,0x65,0x53,0x6d,0x6f,0x6f,0x74, +0x68,0x4e,0x6f,0x72,0x6d,0x61,0x6c,0x73,0x00,0x2e,0x6e,0x76,0x2e,0x73,0x68,0x61, +0x72,0x65,0x64,0x2e,0x63,0x6f,0x6d,0x70,0x75,0x74,0x65,0x53,0x6d,0x6f,0x6f,0x74, +0x68,0x4e,0x6f,0x72,0x6d,0x61,0x6c,0x73,0x00,0x2e,0x6e,0x76,0x2e,0x69,0x6e,0x66, +0x6f,0x00,0x2e,0x6e,0x76,0x2e,0x63,0x6f,0x6e,0x73,0x74,0x61,0x6e,0x74,0x30,0x2e, +0x63,0x6f,0x6d,0x70,0x75,0x74,0x65,0x53,0x6d,0x6f,0x6f,0x74,0x68,0x4e,0x6f,0x72, +0x6d,0x61,0x6c,0x73,0x00,0x5f,0x70,0x61,0x72,0x61,0x6d,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x00,0x00,0x00,0x03,0x00,0x07,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x92,0x00,0x00,0x00,0x03,0x00,0x06,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1b,0x00,0x00,0x00,0x12,0x10,0x07,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x04,0x00,0x00,0x00,0x00,0x00,0x00, +0x04,0x0a,0x08,0x00,0x02,0x00,0x00,0x00,0x20,0x00,0x20,0x00,0x03,0x19,0x20,0x00, +0x04,0x17,0x0c,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x1c,0x00,0x00,0xf0,0x11,0x00, +0x04,0x17,0x0c,0x00,0x00,0x00,0x00,0x00,0x03,0x00,0x18,0x00,0x00,0xf0,0x11,0x00, +0x04,0x17,0x0c,0x00,0x00,0x00,0x00,0x00,0x02,0x00,0x10,0x00,0x00,0xf0,0x21,0x00, +0x04,0x17,0x0c,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x08,0x00,0x00,0xf0,0x21,0x00, +0x04,0x17,0x0c,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0x21,0x00, +0x04,0x1e,0x04,0x00,0x8c,0x01,0x00,0x00,0x04,0x12,0x08,0x00,0x03,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x04,0x11,0x08,0x00,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0xe4,0x5d,0x00,0x00,0x04,0x44,0x00,0x28,0x04,0x1c,0x04,0x84,0x00,0x00,0x00,0x2c, +0x07,0x00,0x00,0xc0,0x01,0x00,0x00,0x60,0x03,0xdc,0x01,0xf1,0x00,0x40,0x0e,0x1b, +0xe7,0x01,0x00,0x60,0x01,0x00,0x00,0x40,0xe4,0x1d,0x00,0x40,0x00,0x00,0x00,0x28, +0xe2,0x1d,0x01,0x60,0x00,0x00,0x00,0x18,0x03,0xdc,0x1f,0xfc,0x00,0x00,0x7e,0x20, +0x03,0x9c,0x00,0xc0,0x00,0x80,0x09,0x20,0x43,0xdc,0x00,0xd0,0x00,0x80,0x88,0x20, +0x03,0x1c,0x00,0x20,0x00,0x40,0x00,0x48,0x85,0xdc,0x2f,0x30,0x00,0x00,0x00,0x94, +0x03,0xdc,0x01,0xf0,0x00,0x40,0x8e,0x18,0x85,0xdc,0x2f,0x40,0x00,0x00,0x00,0x94, +0x85,0xdc,0x2f,0x50,0x00,0x00,0x00,0x94,0xe7,0x01,0x00,0x00,0xff,0xff,0x03,0x40, +0x13,0xdc,0x1f,0xfc,0x00,0x00,0x7e,0x20,0x07,0x00,0x00,0x20,0x09,0x00,0x00,0x60, +0x04,0xdc,0xff,0xff,0x00,0x00,0xee,0x50,0x03,0xdc,0x01,0xe1,0x00,0x40,0x0e,0x1b, +0xe7,0x01,0x00,0xa0,0x08,0x00,0x00,0x40,0xe4,0x1d,0x00,0x40,0x00,0x00,0x00,0x28, +0xe2,0x5d,0x04,0x08,0x00,0x00,0x00,0x18,0xe2,0x9d,0x04,0x40,0x00,0x00,0x00,0x18, +0xa3,0xdc,0x00,0x0c,0x00,0xc0,0x00,0x50,0x03,0x1c,0x00,0x20,0x00,0x40,0x00,0x48, +0x03,0x9c,0x31,0xa0,0x00,0x80,0x23,0x20,0x03,0x5c,0x31,0x04,0x00,0xc0,0x00,0x48, +0x03,0x1c,0x31,0x08,0x00,0xc0,0x00,0x48,0x43,0xdc,0x31,0xb0,0x00,0x80,0xa2,0x20, +0x03,0x9c,0x50,0xa0,0x00,0x80,0x23,0x20,0x03,0xdc,0x01,0xe0,0x00,0x40,0x8e,0x18, +0x45,0x1c,0x65,0x00,0x00,0x00,0x00,0x84,0x43,0xdc,0x50,0xb0,0x00,0x80,0xa2,0x20, +0x03,0x1c,0x42,0xa0,0x00,0x80,0x23,0x20,0x45,0xdc,0x23,0x00,0x00,0x00,0x00,0x84, +0x43,0x5c,0x42,0xb0,0x00,0x80,0xa2,0x20,0x45,0x9c,0x83,0x00,0x00,0x00,0x00,0x84, +0x03,0x1c,0x41,0x81,0x00,0x80,0x25,0x20,0x43,0x5c,0x41,0x91,0x00,0x80,0xa4,0x20, +0x03,0x9c,0xf1,0x80,0x00,0x80,0x25,0x20,0x85,0x5c,0x43,0x10,0x00,0x00,0x00,0x84, +0x43,0xdc,0xf1,0x90,0x00,0x80,0xa4,0x20,0x03,0x9c,0xe0,0x80,0x00,0x80,0x25,0x20, +0x85,0x9c,0x42,0x20,0x00,0x00,0x00,0x84,0x85,0x1c,0x63,0x10,0x00,0x00,0x00,0x84, +0x43,0xdc,0xe0,0x90,0x00,0x80,0xa4,0x20,0x85,0x5c,0x62,0x20,0x00,0x00,0x00,0x84, +0x85,0xdc,0x44,0x00,0x00,0x00,0x00,0x84,0x85,0xdc,0x22,0x10,0x00,0x00,0x00,0x84, +0x85,0x1c,0x22,0x20,0x00,0x00,0x00,0x84,0x85,0x5c,0x65,0x00,0x00,0x00,0x00,0x84, +0x85,0x9c,0x25,0x00,0x00,0x00,0x00,0x84,0x03,0xdc,0x45,0x61,0x00,0xc0,0x01,0x50, +0x43,0x1c,0x45,0x61,0x00,0xc0,0xff,0x20,0x03,0x5c,0xf1,0x63,0x00,0xc0,0xa8,0x20, +0x03,0x1c,0x71,0xc1,0x00,0x40,0x01,0x48,0x43,0x5c,0x51,0xd0,0x00,0x40,0x00,0x48, +0x03,0x9c,0xf0,0x60,0x00,0xc0,0x01,0x50,0x43,0x9c,0xf1,0x60,0x00,0xc0,0xff,0x20, +0x03,0x9c,0xf1,0x63,0x00,0xc0,0x8c,0x20,0x03,0xdc,0xe1,0x60,0x00,0xc0,0x01,0x50, +0x43,0x9c,0xe3,0x60,0x00,0xc0,0xff,0x20,0x20,0x1d,0xc3,0x34,0x00,0x00,0x00,0x50, +0x20,0xdd,0x90,0x28,0x00,0x00,0x00,0x50,0x20,0x5d,0xb3,0x34,0x00,0x00,0x00,0x50, +0x20,0x9d,0x82,0x28,0x00,0x00,0x00,0x50,0x20,0x1d,0x52,0x4d,0x00,0x00,0x00,0x50, +0x40,0x5c,0xd2,0x0c,0x00,0x00,0x00,0x58,0x20,0xdd,0x64,0x4d,0x00,0x00,0x00,0x50, +0x40,0xdc,0xa2,0x20,0x00,0x00,0x00,0x58,0x40,0x5e,0xa2,0x30,0x00,0x00,0x12,0x30, +0x03,0x9c,0xf2,0x63,0x00,0xc0,0x9c,0x20,0x03,0x9c,0x20,0xc0,0x00,0x40,0x01,0x48, +0x40,0x1c,0x33,0x31,0x00,0x00,0x00,0x58,0x40,0xde,0x32,0x0d,0x00,0x00,0x16,0x30, +0x43,0xdc,0x60,0xd0,0x00,0x40,0x00,0x48,0x40,0x1e,0xd2,0x20,0x00,0x00,0x18,0x30, +0x03,0x9c,0x71,0xc0,0x00,0x40,0x01,0x48,0x05,0x5e,0x42,0x30,0x00,0x00,0x00,0x2c, +0x05,0xde,0x42,0x40,0x00,0x00,0x00,0x2c,0x05,0x1e,0x42,0x50,0x00,0x00,0x00,0x2c, +0x43,0xdc,0xa1,0xd0,0x00,0x40,0x00,0x48,0x05,0x5e,0x22,0x30,0x00,0x00,0x00,0x2c, +0x05,0xde,0x22,0x40,0x00,0x00,0x00,0x2c,0x05,0x1e,0x22,0x50,0x00,0x00,0x00,0x2c, +0x05,0x5e,0x62,0x30,0x00,0x00,0x00,0x2c,0x05,0xde,0x62,0x40,0x00,0x00,0x00,0x2c, +0x05,0x1e,0x62,0x50,0x00,0x00,0x00,0x2c,0xe7,0x01,0x00,0xc0,0xf7,0xff,0x03,0x40, +0x13,0xdc,0x01,0xf1,0x00,0x40,0x8e,0x18,0x04,0xdc,0xff,0x07,0x00,0xc0,0x00,0x30, +0x04,0xdc,0xff,0xff,0x00,0x00,0xee,0x50,0xe7,0x21,0x00,0x00,0x00,0x00,0x00,0x80, +0xe2,0x1d,0x00,0x40,0x00,0x00,0x00,0x18,0xe2,0x9d,0x01,0x60,0x00,0x00,0x00,0x18, +0x03,0x1c,0x01,0x81,0x00,0x80,0x01,0x20,0x43,0x5c,0x01,0x91,0x00,0x80,0x80,0x20, +0x03,0x9c,0x00,0xc1,0x00,0x80,0x0d,0x20,0x85,0xdc,0x42,0x00,0x00,0x00,0x00,0x84, +0x43,0xdc,0x00,0xd1,0x00,0x80,0x8c,0x20,0x85,0xdc,0x22,0x00,0x00,0x00,0x00,0x94, +0x85,0x9c,0x42,0x10,0x00,0x00,0x00,0x84,0x85,0x1c,0x22,0x40,0x00,0x00,0x00,0x84, +0x85,0x5c,0x22,0x30,0x00,0x00,0x00,0x84,0x85,0xdc,0x21,0x50,0x00,0x00,0x00,0x84, +0x85,0x9c,0x22,0x10,0x00,0x00,0x00,0x94,0x85,0x1c,0x41,0x20,0x00,0x00,0x00,0x84, +0x40,0xdc,0x82,0x20,0x00,0x00,0x00,0x58,0x40,0xdc,0x92,0x24,0x00,0x00,0x16,0x30, +0x40,0xdc,0x72,0x1c,0x00,0x00,0x16,0x30,0x00,0xdc,0xb1,0xfc,0x00,0x00,0x0e,0x2a, +0x85,0x1c,0x21,0x20,0x00,0x00,0x00,0x94,0xe7,0x81,0x00,0x80,0x00,0x00,0x00,0x40, +0xe4,0x21,0x01,0xfc,0x00,0x00,0x00,0x28,0xe4,0x61,0x01,0xfc,0x00,0x00,0x00,0x28, +0xe4,0xe1,0x01,0xfc,0x00,0x00,0x00,0x28,0xe7,0xa1,0x00,0x80,0x00,0x00,0x00,0x40, +0x00,0x80,0xb2,0x14,0x00,0x00,0x00,0xc8,0x40,0x00,0x91,0x28,0x00,0x00,0x00,0x58, +0x40,0x40,0x81,0x28,0x00,0x00,0x00,0x58,0x40,0xc0,0x71,0x28,0x00,0x00,0x00,0x58, +0x03,0x1c,0x04,0x21,0x00,0x40,0x00,0x48,0x85,0x1c,0x21,0x30,0x00,0x00,0x00,0x94, +0x85,0x5c,0x21,0x40,0x00,0x00,0x00,0x94,0x03,0xdc,0x01,0xf1,0x00,0x40,0x8e,0x18, +0x85,0xdc,0x21,0x50,0x00,0x00,0x00,0x94,0xe7,0x01,0x00,0x00,0xfc,0xff,0x03,0x40, +0xe7,0x1d,0x00,0x00,0x00,0x00,0x00,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x03,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xa0,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0b,0x00,0x00,0x00,0x03,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0xe0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xbc,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x13,0x00,0x00,0x00,0x02,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0xa0,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x02,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x36,0x00,0x00,0x00,0x00,0x00,0x00,0x70, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x68,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x03,0x00,0x00,0x00,0x07,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x74,0x00,0x00,0x00,0x00,0x00,0x00,0x70, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x68,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7d,0x00,0x00,0x00,0x01,0x00,0x00,0x00, +0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x80,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x07,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1b,0x00,0x00,0x00,0x01,0x00,0x00,0x00, +0x06,0x00,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0xc0,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x04,0x00,0x00,0x00,0x00,0x00,0x00, +0x03,0x00,0x00,0x00,0x03,0x00,0x00,0x18,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x06,0x00,0x00,0x00,0x05,0x00,0x00,0x00, +0xc8,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xa8,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0xa8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x01,0x00,0x00,0x00,0x05,0x00,0x00,0x00,0x80,0x02,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x48,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x48,0x04,0x00,0x00,0x00,0x00,0x00,0x00, +0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x06,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x02,0x00,0x01,0x01,0x58,0x00,0x00,0x00,0x68,0x0b,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0x00,0x01,0x00,0x1e,0x00,0x00,0x00, +0x40,0x00,0x00,0x00,0x15,0x00,0x00,0x00,0x45,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x52,0x65,0x6e,0x64,0x65,0x72,0x43,0x6c,0x6f,0x74,0x68,0x4e,0x6f,0x72,0x6d,0x61, +0x6c,0x73,0x2e,0x63,0x75,0x00,0x00,0x00,0x7f,0x45,0x4c,0x46,0x02,0x01,0x01,0x33, +0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x00,0xbe,0x00,0x01,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc0,0x0a,0x00,0x00,0x00,0x00,0x00,0x00, +0xc0,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x1e,0x05,0x1e,0x00,0x40,0x00,0x38,0x00, +0x03,0x00,0x40,0x00,0x08,0x00,0x01,0x00,0x00,0x2e,0x73,0x68,0x73,0x74,0x72,0x74, +0x61,0x62,0x00,0x2e,0x73,0x74,0x72,0x74,0x61,0x62,0x00,0x2e,0x73,0x79,0x6d,0x74, +0x61,0x62,0x00,0x2e,0x74,0x65,0x78,0x74,0x2e,0x63,0x6f,0x6d,0x70,0x75,0x74,0x65, +0x53,0x6d,0x6f,0x6f,0x74,0x68,0x4e,0x6f,0x72,0x6d,0x61,0x6c,0x73,0x00,0x2e,0x6e, +0x76,0x2e,0x69,0x6e,0x66,0x6f,0x2e,0x63,0x6f,0x6d,0x70,0x75,0x74,0x65,0x53,0x6d, +0x6f,0x6f,0x74,0x68,0x4e,0x6f,0x72,0x6d,0x61,0x6c,0x73,0x00,0x2e,0x6e,0x76,0x2e, +0x73,0x68,0x61,0x72,0x65,0x64,0x2e,0x63,0x6f,0x6d,0x70,0x75,0x74,0x65,0x53,0x6d, +0x6f,0x6f,0x74,0x68,0x4e,0x6f,0x72,0x6d,0x61,0x6c,0x73,0x00,0x2e,0x6e,0x76,0x2e, +0x69,0x6e,0x66,0x6f,0x00,0x2e,0x6e,0x76,0x2e,0x63,0x6f,0x6e,0x73,0x74,0x61,0x6e, +0x74,0x30,0x2e,0x63,0x6f,0x6d,0x70,0x75,0x74,0x65,0x53,0x6d,0x6f,0x6f,0x74,0x68, +0x4e,0x6f,0x72,0x6d,0x61,0x6c,0x73,0x00,0x00,0x2e,0x73,0x68,0x73,0x74,0x72,0x74, +0x61,0x62,0x00,0x2e,0x73,0x74,0x72,0x74,0x61,0x62,0x00,0x2e,0x73,0x79,0x6d,0x74, +0x61,0x62,0x00,0x63,0x6f,0x6d,0x70,0x75,0x74,0x65,0x53,0x6d,0x6f,0x6f,0x74,0x68, +0x4e,0x6f,0x72,0x6d,0x61,0x6c,0x73,0x00,0x2e,0x74,0x65,0x78,0x74,0x2e,0x63,0x6f, +0x6d,0x70,0x75,0x74,0x65,0x53,0x6d,0x6f,0x6f,0x74,0x68,0x4e,0x6f,0x72,0x6d,0x61, +0x6c,0x73,0x00,0x2e,0x6e,0x76,0x2e,0x69,0x6e,0x66,0x6f,0x2e,0x63,0x6f,0x6d,0x70, +0x75,0x74,0x65,0x53,0x6d,0x6f,0x6f,0x74,0x68,0x4e,0x6f,0x72,0x6d,0x61,0x6c,0x73, +0x00,0x2e,0x6e,0x76,0x2e,0x73,0x68,0x61,0x72,0x65,0x64,0x2e,0x63,0x6f,0x6d,0x70, +0x75,0x74,0x65,0x53,0x6d,0x6f,0x6f,0x74,0x68,0x4e,0x6f,0x72,0x6d,0x61,0x6c,0x73, +0x00,0x2e,0x6e,0x76,0x2e,0x69,0x6e,0x66,0x6f,0x00,0x2e,0x6e,0x76,0x2e,0x63,0x6f, +0x6e,0x73,0x74,0x61,0x6e,0x74,0x30,0x2e,0x63,0x6f,0x6d,0x70,0x75,0x74,0x65,0x53, +0x6d,0x6f,0x6f,0x74,0x68,0x4e,0x6f,0x72,0x6d,0x61,0x6c,0x73,0x00,0x5f,0x70,0x61, +0x72,0x61,0x6d,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x30,0x00,0x00,0x00,0x03,0x00,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x92,0x00,0x00,0x00,0x03,0x00,0x06,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x1b,0x00,0x00,0x00,0x12,0x10,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0xc0,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x0a,0x08,0x00,0x02,0x00,0x00,0x00, +0x40,0x01,0x20,0x00,0x03,0x19,0x20,0x00,0x04,0x17,0x0c,0x00,0x00,0x00,0x00,0x00, +0x04,0x00,0x1c,0x00,0x00,0xf0,0x11,0x00,0x04,0x17,0x0c,0x00,0x00,0x00,0x00,0x00, +0x03,0x00,0x18,0x00,0x00,0xf0,0x11,0x00,0x04,0x17,0x0c,0x00,0x00,0x00,0x00,0x00, +0x02,0x00,0x10,0x00,0x00,0xf0,0x21,0x00,0x04,0x17,0x0c,0x00,0x00,0x00,0x00,0x00, +0x01,0x00,0x08,0x00,0x00,0xf0,0x21,0x00,0x04,0x17,0x0c,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0xf0,0x21,0x00,0x04,0x1e,0x04,0x00,0x10,0x02,0x00,0x00, +0x04,0x12,0x08,0x00,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x11,0x08,0x00, +0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf7,0x42,0x80,0xc2,0x22,0x42,0x00,0x20, +0xe4,0x5d,0x00,0x10,0x01,0x40,0x00,0x28,0x04,0x1c,0x00,0x84,0x00,0x00,0x00,0x2c, +0x07,0x00,0x00,0xe0,0x01,0x00,0x00,0x60,0x03,0xdc,0x01,0x70,0x05,0x40,0x0e,0x1b, +0xe7,0x01,0x00,0x80,0x01,0x00,0x00,0x40,0xe4,0x9d,0x00,0x00,0x00,0x00,0x00,0x28, +0xe2,0xdd,0x00,0x60,0x00,0x00,0x00,0x18,0xc7,0x82,0x42,0xe0,0x42,0xe0,0x02,0x22, +0x03,0x1c,0x21,0x40,0x05,0x80,0x07,0x20,0x43,0x5c,0x21,0x50,0x05,0x80,0x86,0x20, +0x03,0x9c,0x20,0xa0,0x00,0x40,0x00,0x48,0x85,0xdc,0x4f,0x30,0x00,0x00,0x00,0x94, +0x03,0xdc,0x21,0x70,0x05,0x40,0x8e,0x18,0x85,0xdc,0x4f,0x40,0x00,0x00,0x00,0x94, +0x85,0xdc,0x4f,0x50,0x00,0x00,0x00,0x94,0xe7,0x02,0x10,0x43,0xc0,0x22,0x02,0x22, +0xe7,0x01,0x00,0xc0,0xfe,0xff,0x03,0x40,0xf4,0x1d,0x00,0x00,0x00,0x00,0x00,0x40, +0x04,0x1c,0x00,0x00,0x00,0xc0,0x0e,0x50,0x03,0xdc,0x01,0x60,0x05,0x40,0x0e,0x1b, +0x07,0x00,0x00,0x20,0x0a,0x00,0x00,0x60,0xe7,0x01,0x00,0xe0,0x09,0x00,0x00,0x40, +0xe4,0x1d,0x02,0x00,0x00,0x00,0x00,0x28,0x47,0x00,0x80,0x42,0xc0,0x42,0x30,0x22, +0xe2,0x5d,0x02,0x08,0x00,0x00,0x00,0x18,0xe2,0x9d,0x02,0x40,0x00,0x00,0x00,0x18, +0xa3,0x9c,0x80,0x0c,0x00,0xc0,0x00,0x50,0x03,0x9c,0x21,0x20,0x05,0x80,0x13,0x20, +0x03,0x1c,0x21,0x04,0x00,0xc0,0x00,0x48,0x43,0xdc,0x21,0x30,0x05,0x80,0x92,0x20, +0x03,0x9c,0x20,0x08,0x00,0xc0,0x00,0x48,0x47,0x72,0x32,0x42,0x72,0x32,0x42,0x22, +0x03,0x1c,0x44,0x20,0x05,0x80,0x13,0x20,0x45,0x1c,0x65,0x00,0x00,0x00,0x00,0x84, +0x43,0x5c,0x44,0x30,0x05,0x80,0x92,0x20,0x03,0x1c,0x23,0x20,0x05,0x80,0x13,0x20, +0x45,0xdc,0x02,0x01,0x00,0x00,0x00,0x84,0x43,0x5c,0x23,0x30,0x05,0x80,0x92,0x20, +0x03,0x9c,0x41,0x01,0x05,0x80,0x15,0x20,0x77,0x82,0x42,0xc0,0x32,0x02,0xb2,0x22, +0x45,0x9c,0xc3,0x00,0x00,0x00,0x00,0x84,0x43,0xdc,0x41,0x11,0x05,0x80,0x94,0x20, +0x03,0x1c,0xb1,0x00,0x05,0x80,0x15,0x20,0x85,0xdc,0x64,0x20,0x00,0x00,0x00,0x84, +0x43,0x5c,0xb1,0x10,0x05,0x80,0x94,0x20,0x03,0x9c,0xe0,0x00,0x05,0x80,0x15,0x20, +0x85,0x5c,0x65,0x10,0x00,0x00,0x00,0x84,0x07,0x72,0x42,0x30,0x42,0x30,0x42,0x22, +0x43,0xdc,0xe0,0x10,0x05,0x80,0x94,0x20,0x85,0x1c,0x44,0x20,0x00,0x00,0x00,0x84, +0x85,0x5c,0x24,0x10,0x00,0x00,0x00,0x84,0x03,0x1c,0x46,0x61,0x00,0xc0,0x01,0x50, +0x85,0x1c,0x43,0x10,0x00,0x00,0x00,0x84,0x03,0x1c,0x82,0xa0,0x00,0x40,0x00,0x48, +0x85,0x5c,0x23,0x20,0x00,0x00,0x00,0x84,0x27,0x42,0x30,0x42,0x30,0x02,0x22,0x23, +0x43,0x9c,0x45,0x61,0x00,0xc0,0xff,0x20,0x85,0xdc,0x63,0x00,0x00,0x00,0x00,0x84, +0x20,0x1d,0x05,0x4d,0x00,0x00,0x00,0x50,0x85,0x9c,0x44,0x00,0x00,0x00,0x00,0x84, +0x03,0xdc,0x81,0x60,0x05,0x40,0x8e,0x18,0x20,0x1d,0x14,0x55,0x00,0x00,0x00,0x50, +0x85,0x5c,0x24,0x00,0x00,0x00,0x00,0x84,0x47,0x00,0x42,0x00,0x42,0x20,0x82,0x22, +0x03,0xdc,0xf5,0x63,0x00,0xc0,0xac,0x20,0x20,0x5d,0x26,0x3d,0x00,0x00,0x00,0x50, +0x20,0x9d,0xc5,0x54,0x00,0x00,0x00,0x50,0x03,0x1c,0x83,0x41,0x05,0x40,0x01,0x48, +0x20,0x5d,0xd5,0x4c,0x00,0x00,0x00,0x50,0x40,0xdc,0x04,0x51,0x00,0x00,0x00,0x58, +0x20,0x5d,0x14,0x3d,0x00,0x00,0x00,0x50,0x07,0x02,0x72,0x02,0x32,0x02,0xb2,0x22, +0x43,0x5c,0x73,0x51,0x05,0x40,0x00,0x48,0x40,0x5c,0x51,0x65,0x00,0x00,0x00,0x58, +0x03,0xdc,0xb1,0x60,0x00,0xc0,0x01,0x50,0x40,0x9e,0x10,0x51,0x00,0x00,0x0a,0x30, +0x40,0x5c,0x11,0x59,0x00,0x00,0x00,0x58,0x43,0x9c,0xb1,0x60,0x00,0xc0,0xff,0x20, +0x40,0x1e,0x51,0x59,0x00,0x00,0x26,0x30,0x47,0x00,0x42,0xc0,0x42,0x10,0xa2,0x22, +0x40,0xde,0x00,0x65,0x00,0x00,0x0a,0x30,0x03,0x5c,0xf1,0x63,0x00,0xc0,0x8c,0x20, +0x03,0x9c,0x71,0x40,0x05,0x40,0x01,0x48,0x05,0x1e,0xc1,0x30,0x00,0x00,0x00,0x2c, +0x43,0xdc,0x51,0x50,0x05,0x40,0x00,0x48,0x03,0xdc,0xe2,0x60,0x00,0xc0,0x01,0x50, +0x05,0x9e,0xc0,0x40,0x00,0x00,0x00,0x2c,0x37,0xe2,0x42,0xc0,0x42,0xe0,0xe2,0x22, +0x43,0x5c,0xe1,0x60,0x00,0xc0,0xff,0x20,0x05,0xde,0xc0,0x50,0x00,0x00,0x00,0x2c, +0x03,0x5c,0xf1,0x63,0x00,0xc0,0x8a,0x20,0x03,0x1c,0xb3,0x40,0x05,0x40,0x01,0x48, +0x05,0x1e,0x61,0x30,0x00,0x00,0x00,0x2c,0x43,0x5c,0x53,0x50,0x05,0x40,0x00,0x48, +0x05,0x9e,0x60,0x40,0x00,0x00,0x00,0x2c,0xe7,0xe2,0xe2,0x42,0xe0,0xf2,0x12,0x23, +0x05,0xde,0x60,0x50,0x00,0x00,0x00,0x2c,0x05,0x1e,0xc1,0x30,0x00,0x00,0x00,0x2c, +0x05,0x9e,0xc0,0x40,0x00,0x00,0x00,0x2c,0x05,0xde,0xc0,0x50,0x00,0x00,0x00,0x2c, +0xe7,0x01,0x00,0xa0,0xf6,0xff,0x03,0x40,0x13,0xdc,0x01,0x70,0x05,0x40,0x8e,0x18, +0x04,0x1c,0x00,0x00,0x00,0xc0,0x0e,0x50,0xe7,0x42,0x00,0xc0,0x82,0x02,0xc2,0x22, +0xe7,0x21,0x00,0x00,0x00,0x00,0x00,0x80,0xe2,0x5d,0x02,0x40,0x00,0x00,0x00,0x18, +0xe2,0x1d,0x03,0x60,0x00,0x00,0x00,0x18,0x03,0x9c,0x02,0x00,0x05,0x80,0x13,0x20, +0x43,0xdc,0x02,0x10,0x05,0x80,0x92,0x20,0x85,0x1c,0xa1,0x00,0x00,0x00,0x00,0x84, +0x03,0x9c,0x00,0x40,0x05,0x80,0x19,0x20,0x97,0xe2,0x72,0xe3,0x32,0x32,0xf2,0x22, +0x43,0xdc,0x00,0x50,0x05,0x80,0x98,0x20,0x85,0x1c,0x21,0x00,0x00,0x00,0x00,0x94, +0x85,0xdc,0xa1,0x10,0x00,0x00,0x00,0x84,0x85,0xdc,0x21,0x10,0x00,0x00,0x00,0x94, +0x85,0x5c,0x21,0x40,0x00,0x00,0x00,0x84,0x85,0x1c,0x21,0x30,0x00,0x00,0x00,0x84, +0x85,0x9c,0x21,0x50,0x00,0x00,0x00,0x84,0x47,0x80,0xe2,0x02,0x82,0xc2,0x02,0x20, +0x40,0x1c,0x52,0x14,0x00,0x00,0x00,0x58,0x85,0xdc,0xa1,0x20,0x00,0x00,0x00,0x84, +0x40,0x1c,0x42,0x10,0x00,0x00,0x10,0x30,0x85,0xdc,0x21,0x20,0x00,0x00,0x00,0x94, +0x40,0x1c,0x62,0x18,0x00,0x00,0x10,0x30,0x00,0xdc,0x81,0xfc,0x00,0x00,0x0e,0x2a, +0xe7,0x81,0x00,0xa0,0x00,0x00,0x00,0x40,0x47,0x00,0x42,0x00,0x80,0x42,0x00,0x22, +0xe4,0x21,0x01,0xfc,0x00,0x00,0x00,0x28,0xe4,0x61,0x01,0xfc,0x00,0x00,0x00,0x28, +0xe4,0xa1,0x01,0xfc,0x00,0x00,0x00,0x28,0xe7,0xa1,0x00,0xa0,0x00,0x00,0x00,0x40, +0x00,0x00,0x82,0x14,0x00,0x00,0x00,0xc8,0x40,0x00,0x41,0x20,0x00,0x00,0x00,0x58, +0x40,0x40,0x51,0x20,0x00,0x00,0x00,0x58,0x07,0x00,0x72,0x62,0xe2,0x42,0xe0,0x22, +0x40,0x80,0x61,0x20,0x00,0x00,0x00,0x58,0x03,0x1c,0x00,0xa0,0x00,0x40,0x00,0x48, +0x85,0x1c,0x21,0x30,0x00,0x00,0x00,0x94,0x03,0xdc,0x01,0x70,0x05,0x40,0x8e,0x18, +0x85,0x5c,0x21,0x40,0x00,0x00,0x00,0x94,0x85,0x9c,0x21,0x50,0x00,0x00,0x00,0x94, +0xe7,0x01,0x00,0x80,0xfb,0xff,0x03,0x40,0xe7,0x02,0x00,0x00,0x00,0x00,0x00,0x20, +0xe7,0x1d,0x00,0x00,0x00,0x00,0x00,0x80,0xe7,0x1d,0x00,0xe0,0xff,0xff,0x03,0x40, +0xe4,0x1d,0x00,0x00,0x00,0x00,0x00,0x40,0xe4,0x1d,0x00,0x00,0x00,0x00,0x00,0x40, +0xe4,0x1d,0x00,0x00,0x00,0x00,0x00,0x40,0xe4,0x1d,0x00,0x00,0x00,0x00,0x00,0x40, +0xe4,0x1d,0x00,0x00,0x00,0x00,0x00,0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x03,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xa0,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0b,0x00,0x00,0x00,0x03,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0xe0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xbc,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x13,0x00,0x00,0x00,0x02,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0xa0,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x02,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x36,0x00,0x00,0x00,0x00,0x00,0x00,0x70, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x68,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x03,0x00,0x00,0x00,0x07,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x74,0x00,0x00,0x00,0x00,0x00,0x00,0x70, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x68,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7d,0x00,0x00,0x00,0x01,0x00,0x00,0x00, +0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x80,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x60,0x01,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x07,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1b,0x00,0x00,0x00,0x01,0x00,0x00,0x00, +0x06,0x00,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0xc0,0x04,0x00,0x00,0x00,0x00,0x00,0x00, +0x03,0x00,0x00,0x00,0x03,0x00,0x00,0x1a,0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x06,0x00,0x00,0x00,0x05,0x00,0x00,0x00, +0xc0,0x0a,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xa8,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0xa8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x01,0x00,0x00,0x00,0x05,0x00,0x00,0x00,0x80,0x02,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x20,0x06,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x06,0x00,0x00,0x00,0x00,0x00,0x00, +0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x06,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x02,0x00,0x01,0x01,0x58,0x00,0x00,0x00,0x68,0x0e,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0x00,0x01,0x00,0x32,0x00,0x00,0x00, +0x40,0x00,0x00,0x00,0x15,0x00,0x00,0x00,0x45,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x52,0x65,0x6e,0x64,0x65,0x72,0x43,0x6c,0x6f,0x74,0x68,0x4e,0x6f,0x72,0x6d,0x61, +0x6c,0x73,0x2e,0x63,0x75,0x00,0x00,0x00,0x7f,0x45,0x4c,0x46,0x02,0x01,0x01,0x33, +0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x00,0xbe,0x00,0x01,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc0,0x0d,0x00,0x00,0x00,0x00,0x00,0x00, +0xc0,0x0b,0x00,0x00,0x00,0x00,0x00,0x00,0x32,0x05,0x32,0x00,0x40,0x00,0x38,0x00, +0x03,0x00,0x40,0x00,0x08,0x00,0x01,0x00,0x00,0x2e,0x73,0x68,0x73,0x74,0x72,0x74, +0x61,0x62,0x00,0x2e,0x73,0x74,0x72,0x74,0x61,0x62,0x00,0x2e,0x73,0x79,0x6d,0x74, +0x61,0x62,0x00,0x2e,0x74,0x65,0x78,0x74,0x2e,0x63,0x6f,0x6d,0x70,0x75,0x74,0x65, +0x53,0x6d,0x6f,0x6f,0x74,0x68,0x4e,0x6f,0x72,0x6d,0x61,0x6c,0x73,0x00,0x2e,0x6e, +0x76,0x2e,0x69,0x6e,0x66,0x6f,0x2e,0x63,0x6f,0x6d,0x70,0x75,0x74,0x65,0x53,0x6d, +0x6f,0x6f,0x74,0x68,0x4e,0x6f,0x72,0x6d,0x61,0x6c,0x73,0x00,0x2e,0x6e,0x76,0x2e, +0x73,0x68,0x61,0x72,0x65,0x64,0x2e,0x63,0x6f,0x6d,0x70,0x75,0x74,0x65,0x53,0x6d, +0x6f,0x6f,0x74,0x68,0x4e,0x6f,0x72,0x6d,0x61,0x6c,0x73,0x00,0x2e,0x6e,0x76,0x2e, +0x69,0x6e,0x66,0x6f,0x00,0x2e,0x6e,0x76,0x2e,0x63,0x6f,0x6e,0x73,0x74,0x61,0x6e, +0x74,0x30,0x2e,0x63,0x6f,0x6d,0x70,0x75,0x74,0x65,0x53,0x6d,0x6f,0x6f,0x74,0x68, +0x4e,0x6f,0x72,0x6d,0x61,0x6c,0x73,0x00,0x00,0x2e,0x73,0x68,0x73,0x74,0x72,0x74, +0x61,0x62,0x00,0x2e,0x73,0x74,0x72,0x74,0x61,0x62,0x00,0x2e,0x73,0x79,0x6d,0x74, +0x61,0x62,0x00,0x63,0x6f,0x6d,0x70,0x75,0x74,0x65,0x53,0x6d,0x6f,0x6f,0x74,0x68, +0x4e,0x6f,0x72,0x6d,0x61,0x6c,0x73,0x00,0x2e,0x74,0x65,0x78,0x74,0x2e,0x63,0x6f, +0x6d,0x70,0x75,0x74,0x65,0x53,0x6d,0x6f,0x6f,0x74,0x68,0x4e,0x6f,0x72,0x6d,0x61, +0x6c,0x73,0x00,0x2e,0x6e,0x76,0x2e,0x69,0x6e,0x66,0x6f,0x2e,0x63,0x6f,0x6d,0x70, +0x75,0x74,0x65,0x53,0x6d,0x6f,0x6f,0x74,0x68,0x4e,0x6f,0x72,0x6d,0x61,0x6c,0x73, +0x00,0x2e,0x6e,0x76,0x2e,0x73,0x68,0x61,0x72,0x65,0x64,0x2e,0x63,0x6f,0x6d,0x70, +0x75,0x74,0x65,0x53,0x6d,0x6f,0x6f,0x74,0x68,0x4e,0x6f,0x72,0x6d,0x61,0x6c,0x73, +0x00,0x2e,0x6e,0x76,0x2e,0x69,0x6e,0x66,0x6f,0x00,0x2e,0x6e,0x76,0x2e,0x63,0x6f, +0x6e,0x73,0x74,0x61,0x6e,0x74,0x30,0x2e,0x63,0x6f,0x6d,0x70,0x75,0x74,0x65,0x53, +0x6d,0x6f,0x6f,0x74,0x68,0x4e,0x6f,0x72,0x6d,0x61,0x6c,0x73,0x00,0x5f,0x70,0x61, +0x72,0x61,0x6d,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x30,0x00,0x00,0x00,0x03,0x00,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x92,0x00,0x00,0x00,0x03,0x00,0x06,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x1b,0x00,0x00,0x00,0x12,0x10,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0xc0,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x0a,0x08,0x00,0x02,0x00,0x00,0x00, +0x40,0x01,0x20,0x00,0x03,0x19,0x20,0x00,0x04,0x17,0x0c,0x00,0x00,0x00,0x00,0x00, +0x04,0x00,0x1c,0x00,0x00,0xf0,0x11,0x00,0x04,0x17,0x0c,0x00,0x00,0x00,0x00,0x00, +0x03,0x00,0x18,0x00,0x00,0xf0,0x11,0x00,0x04,0x17,0x0c,0x00,0x00,0x00,0x00,0x00, +0x02,0x00,0x10,0x00,0x00,0xf0,0x21,0x00,0x04,0x17,0x0c,0x00,0x00,0x00,0x00,0x00, +0x01,0x00,0x08,0x00,0x00,0xf0,0x21,0x00,0x04,0x17,0x0c,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0xf0,0x21,0x00,0x04,0x1e,0x04,0x00,0x10,0x02,0x00,0x00, +0x04,0x1c,0x10,0x00,0x30,0x04,0x00,0x00,0x98,0x05,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x04,0x12,0x08,0x00,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x04,0x11,0x08,0x00,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xe6,0x07,0x20,0xe2,0x00,0xf4,0x1f,0x00, +0x01,0x00,0x87,0x00,0x80,0x07,0x98,0x4c,0x00,0x00,0x17,0x02,0x00,0x00,0xc8,0xf0, +0x00,0x00,0x80,0x0d,0x00,0x00,0x90,0xe2,0xed,0x0f,0xa0,0xff,0x00,0x98,0x1f,0x00, +0x07,0x00,0x77,0x05,0x80,0x03,0x6c,0x4b,0x0f,0x00,0x80,0x0b,0x00,0x00,0x40,0xe2, +0x02,0x00,0x07,0x00,0x80,0x07,0x98,0x5c,0xe1,0x07,0x20,0xfc,0x00,0x90,0x1f,0x00, +0x05,0xf0,0x87,0x01,0x00,0x00,0x00,0x01,0x03,0x02,0x87,0x01,0x80,0x7f,0x00,0x36, +0x07,0x02,0x87,0x01,0x80,0x7f,0x00,0x36,0xe1,0x07,0x20,0xfc,0x00,0x84,0x1f,0x00, +0x04,0x02,0x57,0x00,0x88,0x7f,0x00,0x5b,0x06,0x02,0x87,0x01,0x80,0x01,0x28,0x36, +0x05,0x02,0x57,0x00,0x88,0x7f,0x20,0x5b,0xe1,0x07,0x80,0xfc,0x00,0x84,0x1f,0x00, +0x03,0x02,0x87,0x01,0x90,0x03,0x20,0x36,0x02,0x02,0x27,0x00,0x00,0x00,0x10,0x4c, +0x04,0x06,0x47,0x00,0xa0,0x02,0xc0,0x5c,0xe1,0x07,0x80,0xfd,0x00,0x88,0x1f,0x00, +0x06,0x03,0x47,0x05,0x00,0x80,0x10,0x4c,0x07,0x02,0x77,0x05,0x80,0x03,0x62,0x4b, +0x07,0x04,0x57,0x05,0x00,0x08,0x10,0x4c,0xf1,0x00,0x20,0x3e,0x00,0xf4,0x0b,0x00, +0xff,0x06,0xc7,0x00,0x00,0x20,0xdc,0xee,0xff,0x06,0x07,0x01,0x00,0x20,0xdc,0xee, +0xff,0x06,0x47,0x01,0x00,0x20,0xdc,0xee,0xfd,0x3f,0xa0,0xff,0x00,0xfc,0x1f,0x00, +0x0f,0x00,0x80,0xf5,0xff,0x0f,0x40,0xe2,0x0f,0x00,0x07,0x00,0x00,0x00,0xf8,0xf0, +0x00,0x00,0x07,0x00,0x80,0x1b,0xa8,0xf0,0xf0,0x07,0xa0,0xfd,0x00,0xf4,0x1f,0x00, +0x07,0x00,0x67,0x05,0x80,0x03,0x6c,0x4b,0x00,0x00,0x00,0x47,0x00,0x00,0x90,0xe2, +0x0f,0x00,0x80,0x45,0x00,0x00,0x40,0xe2,0xe6,0x07,0xc0,0xfc,0x00,0x98,0x1f,0x00, +0x06,0x00,0x07,0x00,0x80,0x07,0x98,0x5c,0x03,0x06,0x37,0x00,0x80,0x7f,0x00,0x36, +0x02,0x06,0x37,0x00,0x90,0x01,0x20,0x36,0xe1,0x07,0x20,0xfc,0x00,0x90,0x1f,0x00, +0x03,0x02,0x17,0x00,0x80,0x00,0x48,0x38,0x05,0x02,0x17,0x00,0x00,0x00,0x10,0x38, +0x04,0x02,0xf7,0x01,0x00,0x00,0x28,0x38,0xe1,0x07,0x20,0xfc,0x00,0x84,0x1f,0x00, +0x0a,0x03,0x27,0x05,0x00,0x80,0x10,0x4c,0x07,0x05,0x17,0x00,0x80,0x00,0x48,0x38, +0x02,0x02,0x27,0x00,0x00,0x00,0x10,0x38,0xea,0x07,0x40,0xfc,0x00,0xc0,0x1f,0x00, +0x08,0x05,0xf7,0x01,0x00,0x00,0x28,0x38,0x0b,0x04,0x37,0x05,0x00,0x08,0x10,0x4c, +0x0c,0x07,0x27,0x05,0x00,0x80,0x10,0x4c,0xb2,0x07,0x40,0xfc,0x00,0xa4,0x1f,0x00, +0x04,0x0a,0x07,0x00,0x00,0x20,0xd2,0xee,0x05,0x02,0x17,0x00,0x80,0x00,0x48,0x38, +0x03,0x02,0xf7,0x01,0x00,0x00,0x28,0x38,0xe2,0x07,0x20,0xf6,0x00,0xb4,0x1f,0x00, +0x0d,0x08,0x37,0x05,0x00,0x08,0x10,0x4c,0x02,0x0c,0x07,0x00,0x00,0x20,0xd2,0xee, +0x08,0x05,0x27,0x05,0x00,0x80,0x10,0x4c,0xe2,0x07,0x40,0xf6,0x00,0x50,0x1c,0x04, +0x09,0x03,0x37,0x05,0x00,0x08,0x10,0x4c,0x03,0x08,0x07,0x00,0x00,0x20,0xd2,0xee, +0x0f,0x06,0x47,0x00,0x00,0x00,0xe0,0x5c,0x5d,0x01,0x00,0xfe,0x01,0x48,0x1c,0x00, +0x0e,0x06,0x27,0x00,0x00,0x00,0xe0,0x5c,0x04,0x0f,0x47,0x00,0xc0,0x7f,0xf8,0x36, +0x0b,0x06,0x37,0x00,0x00,0x00,0xe0,0x5c,0xe2,0x17,0x80,0xfc,0x04,0x84,0x1f,0x00, +0x02,0x0f,0x47,0x00,0x00,0x00,0x48,0x38,0x05,0x0e,0x47,0x00,0x00,0x00,0x48,0x38, +0x0c,0x02,0x07,0x05,0x00,0x80,0x10,0x4c,0xe2,0x07,0x40,0xfd,0x01,0x88,0x1f,0x00, +0x07,0x0e,0x47,0x00,0xc0,0x7f,0xf8,0x36,0x02,0x0b,0x47,0x00,0x00,0x00,0x48,0x38, +0x0d,0x04,0x17,0x05,0x00,0x08,0x10,0x4c,0xf0,0x07,0x40,0xfe,0x00,0xac,0x1f,0x00, +0x04,0x05,0x07,0x05,0x00,0x80,0x10,0x4c,0x08,0x0c,0x87,0x00,0x00,0x20,0xd4,0xee, +0x03,0x0b,0x47,0x00,0xc0,0x7f,0xf8,0x36,0xf0,0x07,0x20,0xfe,0x00,0xc0,0x1f,0x00, +0x05,0x07,0x17,0x05,0x00,0x08,0x10,0x4c,0x09,0x0c,0x47,0x00,0x00,0x20,0xd4,0xee, +0x02,0x02,0x07,0x05,0x00,0x80,0x10,0x4c,0xf1,0x00,0x20,0xf6,0x00,0xec,0x1e,0x00, +0x07,0x0c,0x07,0x00,0x00,0x20,0xd4,0xee,0x11,0x04,0x87,0x00,0x00,0x20,0xd4,0xee, +0x0a,0x04,0x07,0x00,0x00,0x20,0xd4,0xee,0xf0,0x07,0x40,0x3e,0x00,0xc4,0x1e,0x00, +0x03,0x03,0x17,0x05,0x00,0x08,0x10,0x4c,0x10,0x04,0x47,0x00,0x00,0x20,0xd4,0xee, +0x13,0x02,0x47,0x00,0x00,0x20,0xd4,0xee,0xb1,0x07,0x20,0x56,0x00,0x84,0x1f,0x00, +0x12,0x02,0x87,0x00,0x00,0x20,0xd4,0xee,0x14,0x02,0x07,0x00,0x00,0x20,0xd4,0xee, +0x16,0xf0,0x87,0x01,0x00,0x00,0x00,0x01,0xe1,0x07,0x20,0xfc,0x00,0x84,0x1f,0x00, +0x15,0x00,0xf7,0x0f,0x80,0x07,0x98,0x5c,0x18,0x00,0xf7,0x0f,0x80,0x07,0x98,0x5c, +0x19,0x00,0xf7,0x0f,0x80,0x07,0x98,0x5c,0xe2,0x07,0x20,0xfc,0x01,0x84,0x1f,0x00, +0x17,0x00,0xf7,0x0f,0x80,0x07,0x98,0x5c,0x0c,0xff,0x67,0x01,0x88,0x7f,0x00,0x5b, +0x16,0x0f,0x87,0x01,0x80,0x8a,0x20,0x36,0xe1,0x07,0x60,0xfd,0x02,0x84,0x1f,0x00, +0x0d,0x0f,0x87,0x01,0x80,0x7f,0x04,0x36,0x05,0x00,0xf7,0x0f,0x80,0x07,0x98,0x5c, +0x04,0x19,0xc7,0x00,0x00,0x0c,0xc1,0x5c,0xe1,0x27,0x20,0xfc,0x00,0x84,0x1f,0x00, +0x03,0xff,0x87,0x01,0x80,0x0b,0x00,0x36,0x02,0x16,0xd7,0x00,0x00,0x88,0xd7,0x5b, +0x0f,0x00,0xf7,0x0f,0x80,0x07,0x98,0x5c,0xeb,0x07,0x20,0xfc,0x00,0x84,0x1f,0x00, +0x0d,0x00,0xf7,0x0f,0x80,0x07,0x98,0x5c,0x03,0x16,0x37,0x00,0x41,0x02,0xdf,0x5b, +0x05,0x0e,0x87,0x01,0x80,0x82,0x20,0x36,0xe1,0x07,0x60,0xfd,0x00,0x84,0x1f,0x00, +0x04,0x00,0xf7,0x0f,0x80,0x07,0x98,0x5c,0x16,0x00,0xf7,0x0f,0x80,0x07,0x98,0x5c, +0x0f,0x0d,0xc7,0x00,0x80,0x07,0xc1,0x5c,0xe1,0x07,0x20,0xfc,0x00,0x84,0x1f,0x00, +0x0d,0x0b,0x87,0x01,0x00,0x82,0x20,0x36,0x04,0x0e,0x87,0x01,0x80,0x7f,0x04,0x36, +0x0e,0x00,0xf7,0x0f,0x80,0x07,0x98,0x5c,0xea,0x07,0x20,0xfc,0x00,0x84,0x1f,0x00, +0x0b,0x0b,0x87,0x01,0x80,0x7f,0x04,0x36,0x16,0x16,0xc7,0x00,0x80,0x0b,0xc1,0x5c, +0x0c,0xff,0x87,0x01,0x80,0x0a,0x00,0x36,0xed,0x07,0x20,0xfc,0x00,0x84,0x1f,0x00, +0x04,0x05,0x47,0x00,0x00,0x88,0xd7,0x5b,0x05,0x05,0xc7,0x00,0xc1,0x07,0xdf,0x5b, +0x0c,0xff,0x87,0x01,0x00,0x07,0x00,0x36,0xed,0x07,0x20,0xfc,0x00,0xb4,0x1f,0x00, +0x0b,0x0d,0xb7,0x00,0x00,0x88,0xd7,0x5b,0x0c,0x0d,0xc7,0x00,0x41,0x0b,0xdf,0x5b, +0x02,0x02,0x47,0x05,0x00,0x80,0x10,0x4c,0xe1,0x07,0x20,0xfc,0x00,0xb0,0x1f,0x00, +0x03,0x03,0x57,0x05,0x00,0x08,0x10,0x4c,0x04,0x04,0x47,0x05,0x00,0x80,0x10,0x4c, +0x06,0x06,0x27,0x00,0x00,0x00,0x10,0x4c,0xe1,0x07,0x20,0xfc,0x00,0x84,0x1f,0x04, +0x05,0x05,0x57,0x05,0x00,0x08,0x10,0x4c,0x07,0x06,0x67,0x05,0x80,0x03,0x62,0x4b, +0x0e,0x11,0x87,0x00,0x00,0x30,0x58,0x5c,0xe1,0x07,0x20,0xfc,0x00,0x84,0x1f,0x00, +0x0a,0x0a,0x77,0x00,0x00,0x30,0x58,0x5c,0x0d,0x13,0x97,0x00,0x00,0x30,0x58,0x5c, +0x08,0x12,0x87,0x00,0x00,0x30,0x58,0x5c,0xe1,0x07,0x60,0xfc,0x00,0x84,0x1f,0x00, +0x09,0x10,0x97,0x00,0x00,0x30,0x58,0x5c,0x10,0x14,0x77,0x00,0x00,0x30,0x58,0x5c, +0x07,0x0d,0xe7,0x00,0x00,0x10,0x68,0x5c,0xe2,0x07,0x60,0xfc,0x00,0x88,0x1f,0x00, +0x0f,0x08,0xa7,0x00,0x00,0x10,0x68,0x5c,0x13,0x10,0x97,0x00,0x00,0x10,0x68,0x5c, +0x07,0x08,0x97,0x00,0x80,0x03,0xa1,0x59,0xf0,0x07,0x20,0x1e,0x00,0x84,0x1f,0x00, +0x08,0x10,0xe7,0x00,0x80,0x07,0xa1,0x59,0x07,0x02,0x37,0xc0,0x00,0x00,0xf9,0xeb, +0x0e,0x0b,0x47,0x05,0x00,0x80,0x10,0x4c,0xf0,0x07,0x40,0x3e,0x00,0xc4,0x0b,0x00, +0x09,0x0d,0xa7,0x00,0x80,0x09,0xa1,0x59,0x08,0x02,0x37,0x00,0x01,0x00,0xf9,0xeb, +0x09,0x02,0x37,0x40,0x01,0x00,0xf9,0xeb,0xf1,0x03,0x00,0x9f,0x00,0x84,0x1f,0x00, +0x07,0x04,0x37,0xc0,0x00,0x00,0xf9,0xeb,0x08,0x04,0x37,0x00,0x01,0x00,0xf9,0xeb, +0x0f,0x0c,0x57,0x05,0x00,0x08,0x10,0x4c,0xf1,0x00,0x20,0x1e,0x00,0xc4,0x03,0x00, +0x09,0x04,0x37,0x40,0x01,0x00,0xf9,0xeb,0x07,0x0e,0x37,0xc0,0x00,0x00,0xf9,0xeb, +0x08,0x0e,0x37,0x00,0x01,0x00,0xf9,0xeb,0xf2,0x00,0xa0,0xff,0x1f,0xf4,0x1f,0x00, +0x09,0x0e,0x37,0x40,0x01,0x00,0xf9,0xeb,0x0f,0x00,0x80,0xbb,0xff,0x0f,0x40,0xe2, +0x0f,0x00,0x07,0x00,0x00,0x00,0xf8,0xf0,0xf0,0x07,0xe0,0xff,0x00,0xf4,0x1f,0x00, +0x07,0x00,0x77,0x05,0x80,0x03,0x62,0x4b,0x00,0x00,0x07,0x00,0x80,0x1b,0xa8,0xf0, +0x0f,0x00,0x08,0x00,0x00,0x00,0x00,0xe3,0xf0,0x07,0x40,0xfe,0x00,0x90,0x1f,0x00, +0x02,0x00,0x47,0x00,0x80,0x00,0x48,0x38,0x00,0x00,0x00,0x18,0x00,0x00,0x90,0xe2, +0x03,0x00,0xc7,0x01,0x00,0x00,0x28,0x38,0xed,0x07,0x40,0xfc,0x00,0xc4,0x1e,0x00, +0x04,0x02,0x07,0x05,0x00,0x80,0x10,0x4c,0x05,0x03,0x17,0x05,0x00,0x08,0x10,0x4c, +0x06,0x04,0x07,0x00,0x00,0x20,0xd4,0xee,0xe1,0x07,0x20,0xfc,0x00,0x90,0x1f,0x00, +0x02,0x00,0x87,0x01,0x80,0x7f,0x00,0x36,0x0a,0xf0,0x87,0x01,0x00,0x00,0x00,0x01, +0x07,0x00,0x87,0x01,0x80,0x7f,0x00,0x36,0xe1,0x07,0x20,0xfc,0x00,0x84,0x1f,0x00, +0x09,0x00,0x87,0x01,0x00,0x01,0x28,0x36,0x03,0x00,0xa7,0x00,0x88,0x7f,0x00,0x5b, +0x08,0x00,0xa7,0x00,0x88,0x7f,0x20,0x5b,0xfd,0x07,0x20,0xfc,0x00,0xb4,0x1f,0x00, +0x02,0x00,0x87,0x01,0x90,0x03,0x20,0x36,0x03,0x09,0x37,0x00,0x20,0x04,0xc0,0x5c, +0x02,0x02,0x47,0x05,0x00,0x80,0x10,0x4c,0xe2,0x07,0x20,0xfe,0x20,0xc8,0x1e,0x00, +0x03,0x03,0x57,0x05,0x00,0x08,0x10,0x4c,0x06,0x02,0x07,0x00,0x00,0x20,0xdc,0xee, +0x09,0x04,0x47,0x00,0x00,0x20,0xd4,0xee,0xf1,0x07,0x21,0xf6,0x00,0xc4,0x1f,0x00, +0x09,0x02,0x47,0x00,0x00,0x20,0xdc,0xee,0x07,0x02,0x07,0x01,0x00,0x20,0xd4,0xee, +0x08,0x02,0xc7,0x00,0x00,0x20,0xd4,0xee,0xf1,0x07,0x40,0x16,0x00,0xc0,0x3f,0x04, +0x06,0x02,0x47,0x01,0x00,0x20,0xd4,0xee,0x04,0x04,0x87,0x00,0x00,0x20,0xd4,0xee, +0x05,0x07,0x77,0x00,0x00,0x10,0x68,0x5c,0xf6,0x00,0xc0,0xfc,0x00,0x98,0x1f,0x00, +0x04,0x02,0x87,0x00,0x00,0x20,0xdc,0xee,0x05,0x08,0x87,0x00,0x80,0x02,0xa0,0x59, +0x05,0x06,0x67,0x00,0x80,0x02,0xa0,0x59,0xed,0x07,0xa0,0xff,0x01,0x84,0x1f,0x00, +0x07,0x05,0xf7,0x0f,0x80,0x83,0xb4,0x5b,0x0f,0x00,0x00,0x03,0x00,0x00,0x40,0xe2, +0x04,0x00,0xf7,0x0f,0x80,0x07,0x98,0x5c,0xe1,0x07,0x00,0xfe,0x00,0xf4,0x1f,0x00, +0x05,0x00,0xf7,0x0f,0x80,0x07,0x98,0x5c,0x06,0x00,0xf7,0x0f,0x80,0x07,0x98,0x5c, +0x0f,0x00,0x07,0x00,0x00,0x00,0xf8,0xf0,0x1d,0x07,0x20,0xfc,0x01,0x84,0x1f,0x00, +0x09,0x05,0x57,0x00,0x00,0x00,0x80,0x50,0x04,0x08,0x97,0x00,0x00,0x10,0x68,0x5c, +0x05,0x07,0x97,0x00,0x00,0x10,0x68,0x5c,0xf0,0x07,0xa0,0xff,0x00,0x84,0x1f,0x00, +0x06,0x06,0x97,0x00,0x00,0x10,0x68,0x5c,0x0f,0x00,0x07,0x00,0x00,0x00,0xf8,0xf0, +0x00,0x00,0x27,0x00,0x00,0x00,0x10,0x4c,0xf1,0x00,0x80,0x3e,0x00,0xc0,0x1f,0x00, +0x04,0x02,0xc7,0x00,0x00,0x20,0xdc,0xee,0x05,0x02,0x07,0x01,0x00,0x20,0xdc,0xee, +0x07,0x00,0x77,0x05,0x80,0x03,0x62,0x4b,0xed,0x02,0xa0,0xff,0x07,0xfc,0x1f,0x00, +0x06,0x02,0x47,0x01,0x00,0x20,0xdc,0xee,0x0f,0x00,0x00,0xe3,0xff,0x0f,0x40,0xe2, +0x0f,0x00,0x07,0x00,0x00,0x00,0x00,0xe3,0xff,0x07,0x00,0xfc,0x00,0x80,0x1f,0x00, +0x0f,0x00,0x87,0xff,0xff,0x0f,0x40,0xe2,0x00,0x0f,0x07,0x00,0x00,0x00,0xb0,0x50, +0x00,0x0f,0x07,0x00,0x00,0x00,0xb0,0x50,0xe0,0x07,0x00,0xfc,0x00,0x80,0x1f,0x00, +0x00,0x0f,0x07,0x00,0x00,0x00,0xb0,0x50,0x00,0x0f,0x07,0x00,0x00,0x00,0xb0,0x50, +0x00,0x0f,0x07,0x00,0x00,0x00,0xb0,0x50,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x03,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xa0,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0b,0x00,0x00,0x00,0x03,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0xe0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xbc,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x13,0x00,0x00,0x00,0x02,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0xa0,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x02,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x36,0x00,0x00,0x00,0x00,0x00,0x00,0x70, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x7c,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x03,0x00,0x00,0x00,0x07,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x74,0x00,0x00,0x00,0x00,0x00,0x00,0x70, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x7c,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7d,0x00,0x00,0x00,0x01,0x00,0x00,0x00, +0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x94,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x60,0x01,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x07,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1b,0x00,0x00,0x00,0x01,0x00,0x00,0x00, +0x06,0x00,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0xc0,0x07,0x00,0x00,0x00,0x00,0x00,0x00, +0x03,0x00,0x00,0x00,0x03,0x00,0x00,0x1a,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x06,0x00,0x00,0x00,0x05,0x00,0x00,0x00, +0xc0,0x0d,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xa8,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0xa8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x01,0x00,0x00,0x00,0x05,0x00,0x00,0x00,0x94,0x02,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x20,0x09,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x09,0x00,0x00,0x00,0x00,0x00,0x00, +0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x06,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00 +}; + +#ifdef __cplusplus +} +#endif + diff --git a/PhysX_3.4/Samples/SampleFramework/renderer/src/cuda/RenderClothNormals_x86.cuh b/PhysX_3.4/Samples/SampleFramework/renderer/src/cuda/RenderClothNormals_x86.cuh new file mode 100644 index 00000000..17b2276e --- /dev/null +++ b/PhysX_3.4/Samples/SampleFramework/renderer/src/cuda/RenderClothNormals_x86.cuh @@ -0,0 +1,683 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved. + +#ifdef __cplusplus +extern "C" { +#endif + +unsigned char computeSmoothNormals[] = { +0x50,0xed,0x55,0xba,0x01,0x00,0x10,0x00,0x38,0x28,0x00,0x00,0x00,0x00,0x00,0x00, +0x02,0x00,0x01,0x01,0x58,0x00,0x00,0x00,0x28,0x0c,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x00,0x01,0x00,0x0b,0x00,0x00,0x00, +0x40,0x00,0x00,0x00,0x15,0x00,0x00,0x00,0x44,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x52,0x65,0x6e,0x64,0x65,0x72,0x43,0x6c,0x6f,0x74,0x68,0x4e,0x6f,0x72,0x6d,0x61, +0x6c,0x73,0x2e,0x63,0x75,0x00,0x00,0x00,0x7f,0x45,0x4c,0x46,0x01,0x01,0x01,0x33, +0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x00,0xbe,0x00,0x01,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0xc8,0x0b,0x00,0x00,0x60,0x0a,0x00,0x00,0x0b,0x01,0x0b,0x00, +0x34,0x00,0x20,0x00,0x03,0x00,0x28,0x00,0x09,0x00,0x01,0x00,0x00,0x2e,0x73,0x68, +0x73,0x74,0x72,0x74,0x61,0x62,0x00,0x2e,0x73,0x74,0x72,0x74,0x61,0x62,0x00,0x2e, +0x73,0x79,0x6d,0x74,0x61,0x62,0x00,0x2e,0x74,0x65,0x78,0x74,0x2e,0x63,0x6f,0x6d, +0x70,0x75,0x74,0x65,0x53,0x6d,0x6f,0x6f,0x74,0x68,0x4e,0x6f,0x72,0x6d,0x61,0x6c, +0x73,0x00,0x2e,0x6e,0x76,0x2e,0x69,0x6e,0x66,0x6f,0x2e,0x63,0x6f,0x6d,0x70,0x75, +0x74,0x65,0x53,0x6d,0x6f,0x6f,0x74,0x68,0x4e,0x6f,0x72,0x6d,0x61,0x6c,0x73,0x00, +0x2e,0x6e,0x76,0x2e,0x73,0x68,0x61,0x72,0x65,0x64,0x2e,0x63,0x6f,0x6d,0x70,0x75, +0x74,0x65,0x53,0x6d,0x6f,0x6f,0x74,0x68,0x4e,0x6f,0x72,0x6d,0x61,0x6c,0x73,0x00, +0x2e,0x6e,0x76,0x2e,0x63,0x6f,0x6e,0x73,0x74,0x61,0x6e,0x74,0x31,0x2e,0x63,0x6f, +0x6d,0x70,0x75,0x74,0x65,0x53,0x6d,0x6f,0x6f,0x74,0x68,0x4e,0x6f,0x72,0x6d,0x61, +0x6c,0x73,0x00,0x2e,0x6e,0x76,0x2e,0x6c,0x6f,0x63,0x61,0x6c,0x2e,0x63,0x6f,0x6d, +0x70,0x75,0x74,0x65,0x53,0x6d,0x6f,0x6f,0x74,0x68,0x4e,0x6f,0x72,0x6d,0x61,0x6c, +0x73,0x00,0x00,0x2e,0x73,0x68,0x73,0x74,0x72,0x74,0x61,0x62,0x00,0x2e,0x73,0x74, +0x72,0x74,0x61,0x62,0x00,0x2e,0x73,0x79,0x6d,0x74,0x61,0x62,0x00,0x63,0x6f,0x6d, +0x70,0x75,0x74,0x65,0x53,0x6d,0x6f,0x6f,0x74,0x68,0x4e,0x6f,0x72,0x6d,0x61,0x6c, +0x73,0x00,0x2e,0x74,0x65,0x78,0x74,0x2e,0x63,0x6f,0x6d,0x70,0x75,0x74,0x65,0x53, +0x6d,0x6f,0x6f,0x74,0x68,0x4e,0x6f,0x72,0x6d,0x61,0x6c,0x73,0x00,0x2e,0x6e,0x76, +0x2e,0x69,0x6e,0x66,0x6f,0x2e,0x63,0x6f,0x6d,0x70,0x75,0x74,0x65,0x53,0x6d,0x6f, +0x6f,0x74,0x68,0x4e,0x6f,0x72,0x6d,0x61,0x6c,0x73,0x00,0x2e,0x6e,0x76,0x2e,0x73, +0x68,0x61,0x72,0x65,0x64,0x2e,0x63,0x6f,0x6d,0x70,0x75,0x74,0x65,0x53,0x6d,0x6f, +0x6f,0x74,0x68,0x4e,0x6f,0x72,0x6d,0x61,0x6c,0x73,0x00,0x2e,0x6e,0x76,0x2e,0x63, +0x6f,0x6e,0x73,0x74,0x61,0x6e,0x74,0x31,0x2e,0x63,0x6f,0x6d,0x70,0x75,0x74,0x65, +0x53,0x6d,0x6f,0x6f,0x74,0x68,0x4e,0x6f,0x72,0x6d,0x61,0x6c,0x73,0x00,0x63,0x6f, +0x6e,0x73,0x74,0x00,0x2e,0x6e,0x76,0x2e,0x6c,0x6f,0x63,0x61,0x6c,0x2e,0x63,0x6f, +0x6d,0x70,0x75,0x74,0x65,0x53,0x6d,0x6f,0x6f,0x74,0x68,0x4e,0x6f,0x72,0x6d,0x61, +0x6c,0x73,0x00,0x24,0x63,0x6f,0x6d,0x70,0x75,0x74,0x65,0x53,0x6d,0x6f,0x6f,0x74, +0x68,0x4e,0x6f,0x72,0x6d,0x61,0x6c,0x73,0x24,0x6c,0x6f,0x63,0x61,0x6c,0x00,0x5f, +0x5f,0x63,0x75,0x64,0x61,0x70,0x61,0x72,0x6d,0x5f,0x63,0x6f,0x6d,0x70,0x75,0x74, +0x65,0x53,0x6d,0x6f,0x6f,0x74,0x68,0x4e,0x6f,0x72,0x6d,0x61,0x6c,0x73,0x5f,0x70, +0x61,0x72,0x74,0x69,0x63,0x6c,0x65,0x73,0x00,0x5f,0x5f,0x63,0x75,0x64,0x61,0x70, +0x61,0x72,0x6d,0x5f,0x63,0x6f,0x6d,0x70,0x75,0x74,0x65,0x53,0x6d,0x6f,0x6f,0x74, +0x68,0x4e,0x6f,0x72,0x6d,0x61,0x6c,0x73,0x5f,0x69,0x6e,0x64,0x69,0x63,0x65,0x73, +0x00,0x5f,0x5f,0x63,0x75,0x64,0x61,0x70,0x61,0x72,0x6d,0x5f,0x63,0x6f,0x6d,0x70, +0x75,0x74,0x65,0x53,0x6d,0x6f,0x6f,0x74,0x68,0x4e,0x6f,0x72,0x6d,0x61,0x6c,0x73, +0x5f,0x76,0x65,0x72,0x74,0x69,0x63,0x65,0x73,0x00,0x5f,0x5f,0x63,0x75,0x64,0x61, +0x70,0x61,0x72,0x6d,0x5f,0x63,0x6f,0x6d,0x70,0x75,0x74,0x65,0x53,0x6d,0x6f,0x6f, +0x74,0x68,0x4e,0x6f,0x72,0x6d,0x61,0x6c,0x73,0x5f,0x6e,0x75,0x6d,0x54,0x72,0x69, +0x73,0x00,0x5f,0x5f,0x63,0x75,0x64,0x61,0x70,0x61,0x72,0x6d,0x5f,0x63,0x6f,0x6d, +0x70,0x75,0x74,0x65,0x53,0x6d,0x6f,0x6f,0x74,0x68,0x4e,0x6f,0x72,0x6d,0x61,0x6c, +0x73,0x5f,0x6e,0x75,0x6d,0x50,0x61,0x72,0x74,0x69,0x63,0x6c,0x65,0x73,0x00,0x24, +0x5f,0x5f,0x5f,0x5f,0x63,0x75,0x64,0x61,0x5f,0x5f,0x5f,0x63,0x75,0x64,0x61,0x5f, +0x5f,0x5f,0x54,0x32,0x31,0x36,0x5f,0x34,0x30,0x32,0x30,0x5f,0x5f,0x37,0x30,0x00, +0x24,0x5f,0x5f,0x5f,0x5f,0x63,0x75,0x64,0x61,0x5f,0x5f,0x5f,0x63,0x75,0x64,0x61, +0x5f,0x5f,0x5f,0x54,0x32,0x32,0x31,0x5f,0x35,0x32,0x33,0x32,0x5f,0x5f,0x37,0x31, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x30,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x03,0x00,0x06,0x00,0x69,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x03,0x00,0x07,0x00,0x89,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x03,0x00,0x05,0x00,0xb2,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x03,0x00,0x08,0x00,0x1b,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xa8,0x06,0x00,0x00, +0x12,0x10,0x06,0x00,0x03,0x18,0x14,0x00,0x04,0x17,0x0c,0x00,0x00,0x00,0x00,0x00, +0x04,0x00,0x10,0x00,0x00,0xf0,0x13,0x00,0x04,0x17,0x0c,0x00,0x00,0x00,0x00,0x00, +0x03,0x00,0x0c,0x00,0x00,0xf0,0x13,0x00,0x04,0x17,0x0c,0x00,0x00,0x00,0x00,0x00, +0x02,0x00,0x08,0x00,0x00,0xf0,0x13,0x00,0x04,0x17,0x0c,0x00,0x00,0x00,0x00,0x00, +0x01,0x00,0x04,0x00,0x00,0xf0,0x13,0x00,0x04,0x17,0x0c,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0xf0,0x13,0x00,0x03,0x1b,0x01,0x00,0x04,0x1e,0x04,0x00, +0x10,0x01,0x00,0x00,0x18,0x00,0x00,0x00,0x06,0x00,0x00,0x00,0x10,0x00,0x00,0x00, +0x11,0x00,0x00,0xa0,0x80,0x07,0x00,0x04,0x01,0xd0,0x04,0x30,0xd0,0x07,0x21,0x64, +0xfd,0x01,0x00,0xa0,0xc8,0x47,0x01,0x0c,0x03,0x50,0x01,0xa0,0x00,0x00,0x00,0x00, +0x03,0x50,0x01,0x10,0x00,0x11,0x00,0x00,0x05,0xd0,0x04,0x30,0x80,0x07,0x30,0xc4, +0x09,0xd0,0x03,0x30,0x80,0x07,0x30,0xc4,0x00,0xec,0x00,0x11,0x08,0x82,0x02,0x20, +0x05,0x22,0x18,0x41,0x03,0x00,0x00,0x00,0x01,0x08,0x80,0x60,0x80,0x07,0x40,0x60, +0x09,0xcc,0x00,0x20,0x80,0x87,0x20,0x04,0x15,0x80,0x0c,0x20,0x03,0x00,0x00,0x00, +0x0d,0x80,0x00,0x10,0x03,0x00,0x00,0x00,0x19,0x80,0x10,0x20,0x03,0x00,0x00,0x00, +0x1d,0x80,0x14,0x20,0x03,0x00,0x00,0x00,0x0d,0x0a,0x0e,0xd0,0x80,0x07,0xc0,0xa0, +0x01,0x00,0x00,0x20,0x80,0x47,0x00,0x04,0x0d,0x0c,0x0e,0xd0,0x80,0x07,0xc0,0xa0, +0xfd,0x01,0x02,0x30,0xd8,0x47,0x00,0x64,0x0d,0x0e,0x0e,0xd0,0x80,0x07,0xc0,0xa0, +0x03,0xb0,0x00,0x10,0x80,0x12,0x00,0x00,0x01,0x00,0x00,0xf0,0x02,0x00,0x00,0xe0, +0x03,0xfe,0x1f,0x86,0x00,0x00,0x00,0x00,0xfd,0xcf,0x04,0x30,0xd8,0xc7,0x20,0x64, +0x03,0x80,0x09,0xa0,0x00,0x00,0x00,0x00,0x03,0x80,0x09,0x10,0x80,0x12,0x00,0x00, +0x05,0xce,0x02,0x30,0x80,0x07,0x30,0xc4,0x09,0xce,0x01,0x30,0x80,0x07,0x30,0xc4, +0x00,0xea,0x00,0x11,0x04,0x82,0x02,0x20,0x15,0x22,0x06,0x41,0x03,0x00,0x00,0x00, +0x01,0x08,0x81,0x60,0x80,0x07,0x40,0x60,0x19,0xca,0x00,0x20,0x80,0x47,0x20,0x04, +0x25,0x00,0x0e,0xd0,0x80,0x07,0x40,0x80,0x05,0x80,0x02,0x20,0x03,0x00,0x00,0x00, +0x21,0x02,0x0e,0xd0,0x80,0x07,0x40,0x80,0x05,0x80,0x04,0x20,0x03,0x00,0x00,0x00, +0x1d,0x02,0x0e,0xd0,0x80,0x07,0x40,0x80,0x05,0x08,0x00,0x10,0x80,0xc7,0x00,0x44, +0x0d,0x24,0x84,0x60,0x80,0x47,0x40,0x00,0x2d,0x06,0x0e,0xd0,0x80,0x07,0xc0,0x80, +0x09,0x20,0x84,0x60,0x80,0x47,0x40,0x00,0x29,0x04,0x0e,0xd0,0x80,0x07,0xc0,0x80, +0x05,0x1c,0x10,0x60,0x03,0x00,0x00,0x00,0x39,0x02,0x0e,0xd0,0x80,0x07,0xc0,0x80, +0x31,0x86,0x04,0x20,0x03,0x00,0x00,0x00,0x31,0x18,0x0e,0xd0,0x80,0x07,0xc0,0x80, +0x35,0x84,0x04,0x20,0x03,0x00,0x00,0x00,0x35,0x1a,0x0e,0xd0,0x80,0x07,0xc0,0x80, +0x28,0x14,0x4b,0xb0,0x2c,0x96,0x0e,0xb0,0x0d,0x86,0x08,0x20,0x03,0x00,0x00,0x00, +0x0d,0x06,0x0e,0xd0,0x80,0x07,0xc0,0x80,0x09,0x84,0x08,0x20,0x03,0x00,0x00,0x00, +0x09,0x04,0x0e,0xd0,0x80,0x07,0xc0,0x80,0x39,0x82,0x04,0x20,0x03,0x00,0x00,0x00, +0x39,0x1c,0x0e,0xd0,0x80,0x07,0xc0,0x80,0x05,0x82,0x08,0x20,0x03,0x00,0x00,0x00, +0x05,0x02,0x0e,0xd0,0x80,0x07,0xc0,0x80,0x34,0x1a,0x4c,0xb0,0x30,0x98,0x0e,0xb0, +0x38,0x04,0x43,0xb0,0x3c,0x86,0x01,0xb0,0x09,0x0c,0x00,0x10,0x80,0xc7,0x00,0x44, +0x09,0x24,0x18,0x60,0x03,0x00,0x00,0x00,0x0c,0x1a,0x0f,0xc0,0x08,0x1c,0x00,0x10, +0x0d,0x20,0x00,0x10,0x80,0xc7,0x03,0x00,0x1d,0x84,0x0c,0x20,0x03,0x00,0x00,0x00, +0x0d,0x1c,0x0c,0xe0,0x80,0xc7,0x00,0x08,0x03,0x80,0x04,0xa0,0x00,0x00,0x00,0x00, +0x21,0x84,0x0c,0x20,0x03,0x00,0x00,0x00,0x21,0x10,0x0e,0xd0,0x80,0x07,0xc0,0x80, +0x25,0x10,0x00,0xb0,0x80,0xc7,0x00,0x00,0x25,0x0e,0x08,0xd7,0x88,0x47,0xc2,0xe0, +0xfd,0x13,0x08,0x30,0xd8,0x47,0x01,0x64,0x03,0x20,0x04,0x10,0x80,0x12,0x00,0x00, +0x1d,0x1c,0x0b,0xc0,0x82,0x07,0x00,0x00,0x1d,0x14,0x0f,0xe0,0x80,0xc7,0x01,0x08, +0x03,0x20,0x05,0xa0,0x00,0x00,0x00,0x00,0x21,0x84,0x10,0x20,0x03,0x00,0x00,0x00, +0x25,0x84,0x10,0x20,0x03,0x00,0x00,0x00,0x25,0x12,0x0e,0xd0,0x80,0x07,0xc0,0x80, +0x39,0x12,0x00,0xb0,0x80,0xc7,0x01,0x00,0x39,0x10,0x09,0xd7,0x88,0x87,0xc3,0xe0, +0xfd,0x1d,0x09,0x30,0xd8,0x47,0x01,0x64,0x03,0xc0,0x04,0x10,0x80,0x12,0x00,0x00, +0x21,0x14,0x0c,0xc0,0x82,0x07,0x00,0x00,0x21,0x1a,0x0b,0xe0,0x80,0x07,0x02,0x08, +0x03,0xc0,0x05,0xa0,0x00,0x00,0x00,0x00,0x25,0x84,0x14,0x20,0x03,0x00,0x00,0x00, +0x29,0x84,0x14,0x20,0x03,0x00,0x00,0x00,0x29,0x14,0x0e,0xd0,0x80,0x07,0xc0,0x80, +0x2d,0x14,0x00,0xb0,0x80,0x07,0x02,0x00,0x2d,0x12,0x0a,0xd7,0x88,0xc7,0xc2,0xe0, +0xfd,0x17,0x0a,0x30,0xd8,0x47,0x01,0x64,0x03,0x60,0x05,0x10,0x80,0x12,0x00,0x00, +0x09,0x0c,0x00,0x10,0x82,0xc7,0x00,0x44,0x09,0x06,0x18,0x60,0x03,0x00,0x00,0x00, +0x03,0x60,0x06,0xa0,0x00,0x00,0x00,0x00,0x25,0x84,0x0c,0x20,0x03,0x00,0x00,0x00, +0x29,0x84,0x0c,0x20,0x03,0x00,0x00,0x00,0x29,0x14,0x0e,0xd0,0x80,0x07,0xc0,0x80, +0x2d,0x14,0x00,0xb0,0x80,0xc7,0x00,0x00,0x2d,0x12,0x0a,0xd7,0x88,0xc7,0xc2,0xe0, +0xfd,0x17,0x0a,0x30,0xd8,0x47,0x01,0x64,0x03,0x00,0x06,0x10,0x80,0x12,0x00,0x00, +0x01,0x00,0x00,0xf0,0x02,0x00,0x00,0xe0,0x03,0xf0,0x06,0xa0,0x00,0x00,0x00,0x00, +0x25,0x84,0x10,0x20,0x03,0x00,0x00,0x00,0x29,0x84,0x10,0x20,0x03,0x00,0x00,0x00, +0x29,0x14,0x0e,0xd0,0x80,0x07,0xc0,0x80,0x2d,0x14,0x00,0xb0,0x80,0xc7,0x01,0x00, +0x2d,0x12,0x0a,0xd7,0x88,0xc7,0xc2,0xe0,0xfd,0x17,0x0a,0x30,0xd8,0x47,0x01,0x64, +0x03,0x90,0x06,0x10,0x80,0x12,0x00,0x00,0x01,0x00,0x00,0xf0,0x02,0x00,0x00,0xe0, +0x03,0x80,0x07,0xa0,0x00,0x00,0x00,0x00,0x25,0x84,0x14,0x20,0x03,0x00,0x00,0x00, +0x29,0x84,0x14,0x20,0x03,0x00,0x00,0x00,0x29,0x14,0x0e,0xd0,0x80,0x07,0xc0,0x80, +0x2d,0x14,0x00,0xb0,0x80,0x07,0x02,0x00,0x2d,0x12,0x0a,0xd7,0x88,0xc7,0xc2,0xe0, +0xfd,0x17,0x0a,0x30,0xd8,0x47,0x01,0x64,0x03,0x20,0x07,0x10,0x80,0x12,0x00,0x00, +0x09,0x0c,0x00,0x10,0x82,0xc7,0x00,0x44,0x05,0x04,0x80,0x60,0x80,0x87,0x40,0x00, +0x03,0x20,0x08,0xa0,0x00,0x00,0x00,0x00,0x09,0x82,0x0c,0x20,0x03,0x00,0x00,0x00, +0x25,0x82,0x0c,0x20,0x03,0x00,0x00,0x00,0x25,0x12,0x0e,0xd0,0x80,0x07,0xc0,0x80, +0x29,0x12,0x00,0xb0,0x80,0xc7,0x00,0x00,0x29,0x04,0x09,0xd7,0x88,0x87,0xc2,0xe0, +0xfd,0x15,0x09,0x30,0xd8,0x47,0x01,0x64,0x03,0xc0,0x07,0x10,0x80,0x12,0x00,0x00, +0x01,0x00,0x00,0xf0,0x02,0x00,0x00,0xe0,0x03,0xb0,0x08,0xa0,0x00,0x00,0x00,0x00, +0x09,0x82,0x10,0x20,0x03,0x00,0x00,0x00,0x0d,0x82,0x10,0x20,0x03,0x00,0x00,0x00, +0x0d,0x06,0x0e,0xd0,0x80,0x07,0xc0,0x80,0x25,0x06,0x00,0xb0,0x80,0xc7,0x01,0x00, +0x25,0x04,0x03,0xd7,0x88,0x47,0xc2,0xe0,0xfd,0x13,0x03,0x30,0xd8,0x47,0x01,0x64, +0x03,0x50,0x08,0x10,0x80,0x12,0x00,0x00,0x01,0x00,0x00,0xf0,0x02,0x00,0x00,0xe0, +0x03,0x40,0x09,0xa0,0x00,0x00,0x00,0x00,0x09,0x82,0x14,0x20,0x03,0x00,0x00,0x00, +0x0d,0x82,0x14,0x20,0x03,0x00,0x00,0x00,0x0d,0x06,0x0e,0xd0,0x80,0x07,0xc0,0x80, +0x1d,0x06,0x00,0xb0,0x80,0x07,0x02,0x00,0x1d,0x04,0x03,0xd7,0x88,0xc7,0xc1,0xe0, +0xfd,0x0f,0x03,0x30,0xd8,0x47,0x01,0x64,0x03,0xe0,0x08,0x10,0x80,0x12,0x00,0x00, +0x01,0x00,0x00,0xf0,0x02,0x00,0x00,0xe0,0x01,0x0a,0x00,0x20,0x80,0x07,0x00,0x04, +0xfd,0x01,0x06,0x30,0xd8,0x47,0x00,0x64,0x03,0x00,0x02,0x10,0x80,0x12,0x00,0x00, +0x01,0x00,0x00,0xf0,0x02,0x00,0x00,0xe0,0x03,0xfe,0x1f,0x86,0x00,0x00,0x00,0x00, +0x03,0x00,0x00,0x30,0x00,0x01,0x00,0x00,0x01,0x0c,0x00,0x10,0x80,0xc7,0x00,0x44, +0x01,0x08,0x80,0x60,0x80,0x07,0x40,0x60,0x0d,0x08,0x04,0x30,0x80,0x07,0x10,0xc4, +0x11,0xd0,0x04,0x30,0x80,0x07,0x30,0xc4,0x05,0x22,0x10,0x41,0x03,0x00,0x00,0x00, +0x09,0x22,0x18,0x41,0x03,0x00,0x00,0x00,0x0c,0xe8,0x03,0x21,0x10,0xe8,0x04,0x21, +0x15,0x06,0x0e,0xd0,0x80,0x07,0xc0,0x80,0x15,0x00,0x0e,0xd0,0x80,0x07,0xc0,0xa0, +0x15,0x86,0x04,0x20,0x03,0x00,0x00,0x00,0x15,0x0a,0x0e,0xd0,0x80,0x07,0xc0,0x80, +0x19,0x80,0x04,0x20,0x03,0x00,0x00,0x00,0x15,0x0c,0x0e,0xd0,0x80,0x07,0xc0,0xa0, +0x15,0x86,0x08,0x20,0x03,0x00,0x00,0x00,0x15,0x0a,0x0e,0xd0,0x80,0x07,0xc0,0x80, +0x19,0x80,0x08,0x20,0x03,0x00,0x00,0x00,0x15,0x0c,0x0e,0xd0,0x80,0x07,0xc0,0xa0, +0x15,0x80,0x10,0x20,0x03,0x00,0x00,0x00,0x15,0x0a,0x0e,0xd0,0x80,0x07,0xc0,0x80, +0x03,0x70,0x0c,0xa0,0x00,0x00,0x00,0x00,0x19,0x80,0x0c,0x20,0x03,0x00,0x00,0x00, +0x19,0x0c,0x0e,0xd0,0x80,0x07,0xc0,0x80,0x1d,0x80,0x14,0x20,0x03,0x00,0x00,0x00, +0x1d,0x0e,0x0e,0xd0,0x80,0x07,0xc0,0x80,0x21,0x0a,0x05,0xc0,0x80,0x07,0x00,0x00, +0x21,0x0c,0x06,0xe0,0x80,0x07,0x02,0x00,0x21,0x0e,0x07,0xe0,0x80,0x07,0x02,0x00, +0xfd,0x11,0x7c,0xb0,0xc8,0x07,0x01,0x60,0x03,0x10,0x0c,0x10,0x00,0x01,0x00,0x00, +0x21,0x10,0x00,0x90,0x80,0x07,0x00,0x40,0x20,0x10,0x00,0x90,0x20,0x10,0x00,0x90, +0x19,0x10,0x06,0xc0,0x80,0x07,0x00,0x00,0x19,0x00,0x00,0xd0,0x80,0x07,0xc0,0x60, +0x14,0x10,0x05,0xc0,0x18,0x10,0x07,0xc0,0x15,0x08,0x00,0xd0,0x80,0x07,0xc0,0x60, +0x19,0x10,0x00,0xd0,0x80,0x07,0xc0,0x60,0x05,0xf8,0x00,0x00,0x80,0x07,0x00,0xc0, +0x03,0x70,0x0c,0x10,0x80,0x07,0x00,0x00,0x15,0x80,0x00,0x10,0x03,0x00,0x00,0x00, +0x15,0x18,0x00,0xd0,0x80,0x07,0xc0,0x60,0x15,0x20,0x00,0xd0,0x80,0x07,0xc0,0x60, +0x19,0x80,0x0c,0x10,0x03,0x00,0x00,0x00,0x15,0x28,0x00,0xd0,0x80,0x07,0xc0,0x60, +0x05,0x0c,0x00,0x00,0x80,0x07,0x00,0xc0,0x15,0x00,0x00,0xd4,0x82,0x07,0xc0,0x40, +0x1d,0x08,0x00,0xd4,0x80,0x07,0xc0,0x40,0x19,0x10,0x00,0xd4,0x80,0x07,0xc0,0x40, +0x21,0x80,0x0c,0x20,0x03,0x00,0x00,0x00,0x15,0x10,0x0e,0xd0,0x80,0x07,0xc0,0xa0, +0x15,0x80,0x10,0x20,0x03,0x00,0x00,0x00,0x0d,0x02,0x00,0x20,0x80,0xc7,0x00,0x04, +0x1d,0x0a,0x0e,0xd0,0x80,0x07,0xc0,0xa0,0x15,0x80,0x14,0x20,0x03,0x00,0x00,0x00, +0xfd,0x07,0x04,0x30,0xc8,0x47,0x00,0x64,0x19,0x0a,0x0e,0xd0,0x80,0x07,0xc0,0xa0, +0x01,0x00,0x00,0x20,0x80,0x87,0x00,0x04,0x03,0x20,0x0a,0x10,0x80,0x02,0x00,0x00, +0x01,0x00,0x00,0xf0,0x01,0x00,0x00,0xe0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x01,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x34,0x00,0x00,0x00,0xb6,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0b,0x00,0x00,0x00,0x03,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xea,0x00,0x00,0x00,0xff,0x01,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x13,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0xec,0x02,0x00,0x00,0x60,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x04,0x00,0x00,0x00, +0x04,0x00,0x00,0x00,0x10,0x00,0x00,0x00,0x36,0x00,0x00,0x00,0x00,0x00,0x00,0x70, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x4c,0x03,0x00,0x00,0x60,0x00,0x00,0x00, +0x03,0x00,0x00,0x00,0x06,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x74,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0xac,0x03,0x00,0x00,0x0c,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x06,0x00,0x00,0x00, +0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1b,0x00,0x00,0x00,0x01,0x00,0x00,0x00, +0x06,0x00,0x10,0x00,0x00,0x00,0x00,0x00,0xb8,0x03,0x00,0x00,0xa8,0x06,0x00,0x00, +0x03,0x00,0x00,0x00,0x05,0x00,0x00,0x10,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x54,0x00,0x00,0x00,0x08,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x60,0x0a,0x00,0x00,0x24,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x06,0x00,0x00,0x00, +0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x97,0x00,0x00,0x00,0x08,0x00,0x00,0x00, +0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x60,0x0a,0x00,0x00,0x18,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x06,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x06,0x00,0x00,0x00,0xc8,0x0b,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x60,0x00,0x00,0x00,0x60,0x00,0x00,0x00,0x05,0x00,0x00,0x00,0x04,0x00,0x00,0x00, +0x01,0x00,0x00,0x00,0xac,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0xb4,0x06,0x00,0x00,0xb4,0x06,0x00,0x00,0x05,0x00,0x00,0x00,0x04,0x00,0x00,0x00, +0x01,0x00,0x00,0x00,0x60,0x0a,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x24,0x00,0x00,0x00,0x06,0x00,0x00,0x00,0x04,0x00,0x00,0x00, +0x02,0x00,0x01,0x01,0x58,0x00,0x00,0x00,0x70,0x07,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0x00,0x01,0x00,0x14,0x00,0x00,0x00, +0x40,0x00,0x00,0x00,0x15,0x00,0x00,0x00,0x44,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x52,0x65,0x6e,0x64,0x65,0x72,0x43,0x6c,0x6f,0x74,0x68,0x4e,0x6f,0x72,0x6d,0x61, +0x6c,0x73,0x2e,0x63,0x75,0x00,0x00,0x00,0x7f,0x45,0x4c,0x46,0x01,0x01,0x01,0x33, +0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x00,0xbe,0x00,0x01,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x0c,0x07,0x00,0x00,0xcc,0x05,0x00,0x00,0x14,0x01,0x14,0x00, +0x34,0x00,0x20,0x00,0x03,0x00,0x28,0x00,0x08,0x00,0x01,0x00,0x00,0x2e,0x73,0x68, +0x73,0x74,0x72,0x74,0x61,0x62,0x00,0x2e,0x73,0x74,0x72,0x74,0x61,0x62,0x00,0x2e, +0x73,0x79,0x6d,0x74,0x61,0x62,0x00,0x2e,0x74,0x65,0x78,0x74,0x2e,0x63,0x6f,0x6d, +0x70,0x75,0x74,0x65,0x53,0x6d,0x6f,0x6f,0x74,0x68,0x4e,0x6f,0x72,0x6d,0x61,0x6c, +0x73,0x00,0x2e,0x6e,0x76,0x2e,0x69,0x6e,0x66,0x6f,0x2e,0x63,0x6f,0x6d,0x70,0x75, +0x74,0x65,0x53,0x6d,0x6f,0x6f,0x74,0x68,0x4e,0x6f,0x72,0x6d,0x61,0x6c,0x73,0x00, +0x2e,0x6e,0x76,0x2e,0x73,0x68,0x61,0x72,0x65,0x64,0x2e,0x63,0x6f,0x6d,0x70,0x75, +0x74,0x65,0x53,0x6d,0x6f,0x6f,0x74,0x68,0x4e,0x6f,0x72,0x6d,0x61,0x6c,0x73,0x00, +0x2e,0x6e,0x76,0x2e,0x69,0x6e,0x66,0x6f,0x00,0x2e,0x6e,0x76,0x2e,0x63,0x6f,0x6e, +0x73,0x74,0x61,0x6e,0x74,0x30,0x2e,0x63,0x6f,0x6d,0x70,0x75,0x74,0x65,0x53,0x6d, +0x6f,0x6f,0x74,0x68,0x4e,0x6f,0x72,0x6d,0x61,0x6c,0x73,0x00,0x00,0x2e,0x73,0x68, +0x73,0x74,0x72,0x74,0x61,0x62,0x00,0x2e,0x73,0x74,0x72,0x74,0x61,0x62,0x00,0x2e, +0x73,0x79,0x6d,0x74,0x61,0x62,0x00,0x63,0x6f,0x6d,0x70,0x75,0x74,0x65,0x53,0x6d, +0x6f,0x6f,0x74,0x68,0x4e,0x6f,0x72,0x6d,0x61,0x6c,0x73,0x00,0x2e,0x74,0x65,0x78, +0x74,0x2e,0x63,0x6f,0x6d,0x70,0x75,0x74,0x65,0x53,0x6d,0x6f,0x6f,0x74,0x68,0x4e, +0x6f,0x72,0x6d,0x61,0x6c,0x73,0x00,0x2e,0x6e,0x76,0x2e,0x69,0x6e,0x66,0x6f,0x2e, +0x63,0x6f,0x6d,0x70,0x75,0x74,0x65,0x53,0x6d,0x6f,0x6f,0x74,0x68,0x4e,0x6f,0x72, +0x6d,0x61,0x6c,0x73,0x00,0x2e,0x6e,0x76,0x2e,0x73,0x68,0x61,0x72,0x65,0x64,0x2e, +0x63,0x6f,0x6d,0x70,0x75,0x74,0x65,0x53,0x6d,0x6f,0x6f,0x74,0x68,0x4e,0x6f,0x72, +0x6d,0x61,0x6c,0x73,0x00,0x2e,0x6e,0x76,0x2e,0x69,0x6e,0x66,0x6f,0x00,0x2e,0x6e, +0x76,0x2e,0x63,0x6f,0x6e,0x73,0x74,0x61,0x6e,0x74,0x30,0x2e,0x63,0x6f,0x6d,0x70, +0x75,0x74,0x65,0x53,0x6d,0x6f,0x6f,0x74,0x68,0x4e,0x6f,0x72,0x6d,0x61,0x6c,0x73, +0x00,0x5f,0x70,0x61,0x72,0x61,0x6d,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x03,0x00,0x07,0x00,0x92,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x03,0x00,0x06,0x00,0x1b,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x48,0x03,0x00,0x00,0x12,0x10,0x07,0x00,0x04,0x0a,0x08,0x00,0x02,0x00,0x00,0x00, +0x20,0x00,0x14,0x00,0x03,0x19,0x14,0x00,0x04,0x17,0x0c,0x00,0x00,0x00,0x00,0x00, +0x04,0x00,0x10,0x00,0x00,0xf0,0x11,0x00,0x04,0x17,0x0c,0x00,0x00,0x00,0x00,0x00, +0x03,0x00,0x0c,0x00,0x00,0xf0,0x11,0x00,0x04,0x17,0x0c,0x00,0x00,0x00,0x00,0x00, +0x02,0x00,0x08,0x00,0x00,0xf0,0x11,0x00,0x04,0x17,0x0c,0x00,0x00,0x00,0x00,0x00, +0x01,0x00,0x04,0x00,0x00,0xf0,0x11,0x00,0x04,0x17,0x0c,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0xf0,0x11,0x00,0x04,0x1e,0x04,0x00,0x8c,0x01,0x00,0x00, +0x04,0x12,0x08,0x00,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x11,0x08,0x00, +0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xe4,0x5d,0x00,0x00, +0x04,0x44,0x00,0x28,0x04,0x1c,0x00,0x84,0x00,0x00,0x00,0x2c,0x07,0x00,0x00,0xa0, +0x01,0x00,0x00,0x60,0x03,0xdc,0x01,0xc0,0x00,0x40,0x0e,0x1b,0xe7,0x01,0x00,0x40, +0x01,0x00,0x00,0x40,0xe4,0x1d,0x01,0xa0,0x00,0x40,0x00,0x28,0xe4,0x9d,0x00,0x00, +0x00,0x00,0x00,0x28,0x03,0xdc,0x1f,0x10,0x00,0x00,0x7e,0x20,0xa3,0xdc,0x20,0x60, +0x00,0xc0,0x08,0x20,0x03,0x9c,0x20,0x20,0x00,0x40,0x00,0x48,0x85,0xdc,0x3f,0x30, +0x00,0x00,0x00,0x90,0x03,0xdc,0x21,0xc0,0x00,0x40,0x8e,0x18,0x85,0xdc,0x3f,0x40, +0x00,0x00,0x00,0x90,0x85,0xdc,0x3f,0x50,0x00,0x00,0x00,0x90,0xe7,0x01,0x00,0x20, +0xff,0xff,0x03,0x40,0x13,0xdc,0x1f,0xfc,0x00,0x00,0x7e,0x20,0x07,0x00,0x00,0x80, +0x06,0x00,0x00,0x60,0x04,0xdc,0xff,0xff,0x00,0x00,0xee,0x50,0x03,0xdc,0x01,0xb0, +0x00,0x40,0x0e,0x1b,0xe7,0x01,0x00,0x00,0x06,0x00,0x00,0x40,0xe4,0x5d,0x02,0xa0, +0x00,0x40,0x00,0x28,0xe4,0x9d,0x00,0x00,0x00,0x00,0x00,0x28,0x03,0xdc,0x9f,0xfc, +0x00,0x00,0x7e,0x20,0xe4,0x1d,0x00,0x00,0x00,0x00,0x00,0x40,0xa3,0xdc,0x20,0x0c, +0x00,0xc0,0x00,0x50,0x03,0x9c,0x20,0x20,0x00,0x40,0x00,0x48,0x23,0xdc,0x30,0x90, +0x00,0x40,0x00,0x40,0x03,0xdc,0x21,0xb0,0x00,0x40,0x8e,0x18,0x45,0xdc,0x33,0x10, +0x00,0x00,0x00,0x80,0x45,0x1c,0x32,0x08,0x00,0x00,0x00,0x80,0x45,0x9c,0x32,0x00, +0x00,0x00,0x00,0x80,0x83,0x9c,0xf1,0x80,0x00,0x40,0x00,0x40,0x83,0x5c,0x81,0x80, +0x00,0x40,0x00,0x40,0x83,0x1c,0xa4,0x80,0x00,0x40,0x00,0x40,0x85,0x5c,0x63,0x00, +0x00,0x00,0x00,0x80,0x85,0xdc,0x61,0x10,0x00,0x00,0x00,0x80,0x85,0x9c,0x53,0x00, +0x00,0x00,0x00,0x80,0x85,0xdc,0x52,0x20,0x00,0x00,0x00,0x80,0x85,0xdc,0x00,0x11, +0x00,0x00,0x00,0x80,0x85,0x1c,0x01,0x21,0x00,0x00,0x00,0x80,0x85,0x1c,0x03,0x01, +0x00,0x00,0x00,0x80,0x85,0x9c,0x61,0x20,0x00,0x00,0x00,0x80,0x85,0x5c,0x51,0x10, +0x00,0x00,0x00,0x80,0xa3,0x9c,0xa2,0x60,0x00,0xc0,0x12,0x20,0xa3,0x1c,0x82,0x60, +0x00,0xc0,0x12,0x20,0xa3,0xdc,0xf3,0x60,0x00,0xc0,0x12,0x20,0x20,0xdd,0x71,0x0c, +0x00,0x00,0x00,0x50,0x20,0xdd,0xb2,0x10,0x00,0x00,0x00,0x50,0x20,0x9d,0xe3,0x30, +0x00,0x00,0x00,0x50,0x20,0x1d,0x61,0x10,0x00,0x00,0x00,0x50,0x20,0x1d,0xd3,0x30, +0x00,0x00,0x00,0x50,0x20,0x5d,0x51,0x0c,0x00,0x00,0x00,0x50,0x40,0xdc,0x70,0x2c, +0x00,0x00,0x00,0x58,0x40,0x9c,0x41,0x38,0x00,0x00,0x00,0x58,0x40,0x5c,0xc3,0x14, +0x00,0x00,0x00,0x58,0x40,0xde,0x40,0x14,0x00,0x00,0x06,0x30,0x40,0x1e,0xc1,0x2c, +0x00,0x00,0x0c,0x30,0x40,0x5e,0x71,0x38,0x00,0x00,0x1a,0x30,0x05,0xde,0xa0,0x30, +0x00,0x00,0x00,0x28,0x05,0x1e,0xa1,0x40,0x00,0x00,0x00,0x28,0x05,0x5e,0xa1,0x50, +0x00,0x00,0x00,0x28,0x05,0xde,0x80,0x30,0x00,0x00,0x00,0x28,0x05,0x1e,0x81,0x40, +0x00,0x00,0x00,0x28,0x05,0x5e,0x81,0x50,0x00,0x00,0x00,0x28,0x05,0xde,0xf0,0x30, +0x00,0x00,0x00,0x28,0x05,0x1e,0xf1,0x40,0x00,0x00,0x00,0x28,0x05,0x5e,0xf1,0x50, +0x00,0x00,0x00,0x28,0xe7,0x01,0x00,0x80,0xfa,0xff,0x03,0x40,0x13,0xdc,0x01,0xc0, +0x00,0x40,0x8e,0x18,0x04,0xdc,0xff,0x07,0x00,0xc0,0x00,0x30,0x04,0xdc,0xff,0xff, +0x00,0x00,0xee,0x50,0xe7,0x21,0x00,0x00,0x00,0x00,0x00,0x80,0xe4,0x9d,0x02,0xa0, +0x00,0x40,0x00,0x28,0x03,0xdc,0xaf,0xfc,0x00,0x00,0x7e,0x20,0x83,0x1c,0x02,0x80, +0x00,0x40,0x00,0x40,0xa3,0xdc,0x01,0x60,0x00,0xc0,0x14,0x20,0x85,0x5c,0x81,0x00, +0x00,0x00,0x00,0x80,0x85,0x5c,0x71,0x00,0x00,0x00,0x00,0x90,0x85,0x9c,0x81,0x10, +0x00,0x00,0x00,0x80,0x85,0xdc,0x70,0x40,0x00,0x00,0x00,0x80,0x85,0x9c,0x70,0x30, +0x00,0x00,0x00,0x80,0x85,0x1c,0x71,0x50,0x00,0x00,0x00,0x80,0x85,0x9c,0x71,0x10, +0x00,0x00,0x00,0x90,0x85,0x5c,0x81,0x20,0x00,0x00,0x00,0x80,0x40,0x5c,0x32,0x0c, +0x00,0x00,0x00,0x58,0x40,0x5c,0x22,0x08,0x00,0x00,0x12,0x30,0x40,0x5c,0x42,0x10, +0x00,0x00,0x12,0x30,0x00,0xdc,0x91,0xfc,0x00,0x00,0x0e,0x2a,0x85,0x5c,0x71,0x20, +0x00,0x00,0x00,0x90,0xe7,0x81,0x00,0x80,0x00,0x00,0x00,0x40,0xe4,0xa1,0x00,0xfc, +0x00,0x00,0x00,0x28,0xe4,0xe1,0x00,0xfc,0x00,0x00,0x00,0x28,0xe4,0x21,0x01,0xfc, +0x00,0x00,0x00,0x28,0xe7,0xa1,0x00,0x80,0x00,0x00,0x00,0x40,0x00,0x40,0x91,0x14, +0x00,0x00,0x00,0xc8,0x40,0x80,0x20,0x14,0x00,0x00,0x00,0x58,0x40,0xc0,0x30,0x14, +0x00,0x00,0x00,0x58,0x40,0x00,0x41,0x14,0x00,0x00,0x00,0x58,0x03,0x1c,0x00,0x20, +0x00,0x40,0x00,0x48,0x85,0x9c,0x70,0x30,0x00,0x00,0x00,0x90,0x85,0xdc,0x70,0x40, +0x00,0x00,0x00,0x90,0x03,0xdc,0x01,0xc0,0x00,0x40,0x8e,0x18,0x85,0x1c,0x71,0x50, +0x00,0x00,0x00,0x90,0xe7,0x01,0x00,0x40,0xfc,0xff,0x03,0x40,0xe7,0x1d,0x00,0x00, +0x00,0x00,0x00,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00, +0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x34,0x00,0x00,0x00, +0xa0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x0b,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0xd4,0x00,0x00,0x00,0xbc,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x13,0x00,0x00,0x00, +0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x90,0x01,0x00,0x00, +0x40,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x04,0x00,0x00,0x00, +0x10,0x00,0x00,0x00,0x36,0x00,0x00,0x00,0x00,0x00,0x00,0x70,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0xd0,0x01,0x00,0x00,0x68,0x00,0x00,0x00,0x03,0x00,0x00,0x00, +0x07,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x74,0x00,0x00,0x00, +0x00,0x00,0x00,0x70,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x38,0x02,0x00,0x00, +0x18,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x7d,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x02,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x50,0x02,0x00,0x00,0x34,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x07,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1b,0x00,0x00,0x00, +0x01,0x00,0x00,0x00,0x06,0x00,0x10,0x00,0x00,0x00,0x00,0x00,0x84,0x02,0x00,0x00, +0x48,0x03,0x00,0x00,0x03,0x00,0x00,0x00,0x03,0x00,0x00,0x11,0x04,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x06,0x00,0x00,0x00,0x0c,0x07,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x60,0x00,0x00,0x00,0x60,0x00,0x00,0x00,0x05,0x00,0x00,0x00, +0x04,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x50,0x02,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x7c,0x03,0x00,0x00,0x7c,0x03,0x00,0x00,0x05,0x00,0x00,0x00, +0x04,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x06,0x00,0x00,0x00, +0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x00,0x01,0x01,0x58,0x00,0x00,0x00, +0x20,0x09,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x07,0x00,0x01,0x00,0x1e,0x00,0x00,0x00,0x40,0x00,0x00,0x00,0x15,0x00,0x00,0x00, +0x44,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x52,0x65,0x6e,0x64,0x65,0x72,0x43,0x6c, +0x6f,0x74,0x68,0x4e,0x6f,0x72,0x6d,0x61,0x6c,0x73,0x2e,0x63,0x75,0x00,0x00,0x00, +0x7f,0x45,0x4c,0x46,0x01,0x01,0x01,0x33,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x02,0x00,0xbe,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc0,0x08,0x00,0x00, +0x80,0x07,0x00,0x00,0x1e,0x01,0x1e,0x00,0x34,0x00,0x20,0x00,0x03,0x00,0x28,0x00, +0x08,0x00,0x01,0x00,0x00,0x2e,0x73,0x68,0x73,0x74,0x72,0x74,0x61,0x62,0x00,0x2e, +0x73,0x74,0x72,0x74,0x61,0x62,0x00,0x2e,0x73,0x79,0x6d,0x74,0x61,0x62,0x00,0x2e, +0x74,0x65,0x78,0x74,0x2e,0x63,0x6f,0x6d,0x70,0x75,0x74,0x65,0x53,0x6d,0x6f,0x6f, +0x74,0x68,0x4e,0x6f,0x72,0x6d,0x61,0x6c,0x73,0x00,0x2e,0x6e,0x76,0x2e,0x69,0x6e, +0x66,0x6f,0x2e,0x63,0x6f,0x6d,0x70,0x75,0x74,0x65,0x53,0x6d,0x6f,0x6f,0x74,0x68, +0x4e,0x6f,0x72,0x6d,0x61,0x6c,0x73,0x00,0x2e,0x6e,0x76,0x2e,0x73,0x68,0x61,0x72, +0x65,0x64,0x2e,0x63,0x6f,0x6d,0x70,0x75,0x74,0x65,0x53,0x6d,0x6f,0x6f,0x74,0x68, +0x4e,0x6f,0x72,0x6d,0x61,0x6c,0x73,0x00,0x2e,0x6e,0x76,0x2e,0x69,0x6e,0x66,0x6f, +0x00,0x2e,0x6e,0x76,0x2e,0x63,0x6f,0x6e,0x73,0x74,0x61,0x6e,0x74,0x30,0x2e,0x63, +0x6f,0x6d,0x70,0x75,0x74,0x65,0x53,0x6d,0x6f,0x6f,0x74,0x68,0x4e,0x6f,0x72,0x6d, +0x61,0x6c,0x73,0x00,0x00,0x2e,0x73,0x68,0x73,0x74,0x72,0x74,0x61,0x62,0x00,0x2e, +0x73,0x74,0x72,0x74,0x61,0x62,0x00,0x2e,0x73,0x79,0x6d,0x74,0x61,0x62,0x00,0x63, +0x6f,0x6d,0x70,0x75,0x74,0x65,0x53,0x6d,0x6f,0x6f,0x74,0x68,0x4e,0x6f,0x72,0x6d, +0x61,0x6c,0x73,0x00,0x2e,0x74,0x65,0x78,0x74,0x2e,0x63,0x6f,0x6d,0x70,0x75,0x74, +0x65,0x53,0x6d,0x6f,0x6f,0x74,0x68,0x4e,0x6f,0x72,0x6d,0x61,0x6c,0x73,0x00,0x2e, +0x6e,0x76,0x2e,0x69,0x6e,0x66,0x6f,0x2e,0x63,0x6f,0x6d,0x70,0x75,0x74,0x65,0x53, +0x6d,0x6f,0x6f,0x74,0x68,0x4e,0x6f,0x72,0x6d,0x61,0x6c,0x73,0x00,0x2e,0x6e,0x76, +0x2e,0x73,0x68,0x61,0x72,0x65,0x64,0x2e,0x63,0x6f,0x6d,0x70,0x75,0x74,0x65,0x53, +0x6d,0x6f,0x6f,0x74,0x68,0x4e,0x6f,0x72,0x6d,0x61,0x6c,0x73,0x00,0x2e,0x6e,0x76, +0x2e,0x69,0x6e,0x66,0x6f,0x00,0x2e,0x6e,0x76,0x2e,0x63,0x6f,0x6e,0x73,0x74,0x61, +0x6e,0x74,0x30,0x2e,0x63,0x6f,0x6d,0x70,0x75,0x74,0x65,0x53,0x6d,0x6f,0x6f,0x74, +0x68,0x4e,0x6f,0x72,0x6d,0x61,0x6c,0x73,0x00,0x5f,0x70,0x61,0x72,0x61,0x6d,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x30,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x00,0x07,0x00, +0x92,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x00,0x06,0x00, +0x1b,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc0,0x03,0x00,0x00,0x12,0x10,0x07,0x00, +0x04,0x0a,0x08,0x00,0x02,0x00,0x00,0x00,0x40,0x01,0x14,0x00,0x03,0x19,0x14,0x00, +0x04,0x17,0x0c,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x10,0x00,0x00,0xf0,0x11,0x00, +0x04,0x17,0x0c,0x00,0x00,0x00,0x00,0x00,0x03,0x00,0x0c,0x00,0x00,0xf0,0x11,0x00, +0x04,0x17,0x0c,0x00,0x00,0x00,0x00,0x00,0x02,0x00,0x08,0x00,0x00,0xf0,0x11,0x00, +0x04,0x17,0x0c,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x04,0x00,0x00,0xf0,0x11,0x00, +0x04,0x17,0x0c,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0x11,0x00, +0x04,0x1e,0x04,0x00,0x10,0x02,0x00,0x00,0x04,0x12,0x08,0x00,0x03,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x04,0x11,0x08,0x00,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0xf7,0x42,0x80,0xc2,0x22,0x42,0xf0,0x22,0xe4,0x5d,0x00,0x10,0x01,0x40,0x00,0x28, +0x04,0x1c,0x00,0x84,0x00,0x00,0x00,0x2c,0x07,0x00,0x00,0xc0,0x01,0x00,0x00,0x60, +0x03,0xdc,0x01,0x40,0x05,0x40,0x0e,0x1b,0xe7,0x01,0x00,0x40,0x01,0x00,0x00,0x40, +0xe4,0x9d,0x00,0x00,0x00,0x00,0x00,0x28,0xe4,0x1d,0x01,0x20,0x05,0x40,0x00,0x28, +0x47,0x80,0x42,0xe0,0xe2,0x42,0xe0,0x22,0xa3,0xdc,0x20,0x60,0x00,0xc0,0x08,0x20, +0x03,0x9c,0x20,0xa0,0x00,0x40,0x00,0x48,0x85,0xdc,0x3f,0x30,0x00,0x00,0x00,0x90, +0x03,0xdc,0x21,0x40,0x05,0x40,0x8e,0x18,0x85,0xdc,0x3f,0x40,0x00,0x00,0x00,0x90, +0x85,0xdc,0x3f,0x50,0x00,0x00,0x00,0x90,0xe7,0x01,0x00,0x00,0xff,0xff,0x03,0x40, +0x07,0x10,0x43,0xc0,0x22,0x42,0xf0,0x22,0xf4,0x1d,0x00,0x00,0x00,0x00,0x00,0x40, +0x04,0x1c,0x00,0x00,0x00,0xc0,0x0e,0x50,0x03,0xdc,0x01,0x30,0x05,0x40,0x0e,0x1b, +0x07,0x00,0x00,0xe0,0x06,0x00,0x00,0x60,0xe7,0x01,0x00,0xa0,0x06,0x00,0x00,0x40, +0xe4,0x9d,0x00,0x00,0x00,0x00,0x00,0x28,0xe4,0xdd,0x00,0x20,0x05,0x40,0x00,0x28, +0x47,0x80,0x82,0x42,0x70,0x43,0x30,0x22,0xa3,0x1c,0x21,0x0c,0x00,0xc0,0x00,0x50, +0x03,0x9c,0x20,0xa0,0x00,0x40,0x00,0x48,0x23,0x9c,0x41,0x10,0x05,0x40,0x00,0x40, +0x45,0xdc,0x63,0x00,0x00,0x00,0x00,0x80,0x03,0xdc,0x21,0x30,0x05,0x40,0x8e,0x18, +0x45,0x1c,0x61,0x08,0x00,0x00,0x00,0x80,0x83,0x5c,0xf4,0x00,0x05,0x40,0x00,0x40, +0x37,0x43,0x30,0x42,0x40,0x42,0x70,0x23,0x45,0x5c,0x61,0x10,0x00,0x00,0x00,0x80, +0x85,0xdc,0x12,0x21,0x00,0x00,0x00,0x80,0x83,0x9c,0x44,0x00,0x05,0x40,0x00,0x40, +0x83,0x1c,0x54,0x00,0x05,0x40,0x00,0x40,0x85,0x5c,0x13,0x11,0x00,0x00,0x00,0x80, +0x85,0x1c,0x23,0x21,0x00,0x00,0x00,0x80,0xa3,0x1c,0x41,0x60,0x00,0xc0,0x06,0x20, +0x47,0x70,0x43,0x30,0x32,0x32,0xf2,0x22,0x85,0x9c,0x03,0x11,0x00,0x00,0x00,0x80, +0x20,0xdd,0xc4,0x2c,0x00,0x00,0x00,0x50,0x85,0x9c,0x02,0x21,0x00,0x00,0x00,0x80, +0x20,0x1d,0xe3,0x34,0x00,0x00,0x00,0x50,0x85,0x5c,0x22,0x11,0x00,0x00,0x00,0x80, +0x85,0xdc,0x11,0x01,0x00,0x00,0x00,0x80,0x85,0x1c,0x22,0x01,0x00,0x00,0x00,0x80, +0x47,0x00,0x02,0x52,0x42,0x80,0x82,0x22,0x20,0x5d,0x93,0x34,0x00,0x00,0x00,0x50, +0x85,0x9c,0x01,0x01,0x00,0x00,0x00,0x80,0xa3,0x5c,0xf2,0x60,0x00,0xc0,0x06,0x20, +0x20,0xdd,0xa2,0x2c,0x00,0x00,0x00,0x50,0x40,0x9c,0xc2,0x4c,0x00,0x00,0x00,0x58, +0x20,0xdd,0x83,0x1c,0x00,0x00,0x00,0x50,0x40,0x1e,0xb2,0x34,0x00,0x00,0x14,0x30, +0x47,0x00,0x82,0x42,0x30,0x42,0x02,0x22,0x20,0x9d,0x62,0x1c,0x00,0x00,0x00,0x50, +0x05,0x1e,0x92,0x30,0x00,0x00,0x00,0x28,0x40,0x9c,0xb1,0x3c,0x00,0x00,0x00,0x58, +0x40,0x9e,0xa1,0x4c,0x00,0x00,0x0c,0x30,0x40,0x9c,0xa2,0x34,0x00,0x00,0x00,0x58, +0xa3,0x5c,0x51,0x60,0x00,0xc0,0x06,0x20,0x05,0x9e,0x91,0x40,0x00,0x00,0x00,0x28, +0xd7,0xe2,0xe2,0xe2,0xe2,0xe2,0xe2,0x22,0x40,0xde,0xc1,0x3c,0x00,0x00,0x14,0x30, +0x05,0xde,0x91,0x50,0x00,0x00,0x00,0x28,0x05,0x1e,0x42,0x30,0x00,0x00,0x00,0x28, +0x05,0x9e,0x41,0x40,0x00,0x00,0x00,0x28,0x05,0xde,0x41,0x50,0x00,0x00,0x00,0x28, +0x05,0x1e,0x52,0x30,0x00,0x00,0x00,0x28,0x05,0x9e,0x51,0x40,0x00,0x00,0x00,0x28, +0x47,0xe0,0xf2,0x12,0xe3,0x42,0xf0,0x22,0x05,0xde,0x51,0x50,0x00,0x00,0x00,0x28, +0xe7,0x01,0x00,0xa0,0xf9,0xff,0x03,0x40,0x13,0xdc,0x01,0x40,0x05,0x40,0x8e,0x18, +0x04,0x1c,0x00,0x00,0x00,0xc0,0x0e,0x50,0xe7,0x21,0x00,0x00,0x00,0x00,0x00,0x80, +0xe4,0xdd,0x02,0x20,0x05,0x40,0x00,0x28,0xe4,0x1d,0x00,0x00,0x00,0x00,0x00,0x40, +0x87,0x42,0x70,0xe3,0x72,0xe3,0x72,0x23,0x83,0xdc,0x01,0x00,0x05,0x40,0x00,0x40, +0x85,0x9c,0x70,0x00,0x00,0x00,0x00,0x80,0xa3,0x9c,0x01,0x60,0x00,0xc0,0x16,0x20, +0x85,0x9c,0x60,0x00,0x00,0x00,0x00,0x90,0x85,0x5c,0x71,0x10,0x00,0x00,0x00,0x80, +0x85,0x5c,0x61,0x10,0x00,0x00,0x00,0x90,0x85,0xdc,0x60,0x40,0x00,0x00,0x00,0x80, +0x47,0x70,0x43,0x70,0x43,0x80,0xe2,0x22,0x85,0x9c,0x60,0x30,0x00,0x00,0x00,0x80, +0x40,0x5c,0x32,0x0c,0x00,0x00,0x00,0x58,0x85,0x1c,0x61,0x50,0x00,0x00,0x00,0x80, +0x40,0x1c,0x22,0x08,0x00,0x00,0x12,0x30,0x85,0x5c,0x71,0x20,0x00,0x00,0x00,0x80, +0x40,0x1c,0x42,0x10,0x00,0x00,0x10,0x30,0x00,0xdc,0x81,0xfc,0x00,0x00,0x0e,0x2a, +0x47,0x00,0x40,0x00,0x42,0x00,0x80,0x22,0x85,0x5c,0x61,0x20,0x00,0x00,0x00,0x90, +0xe7,0x81,0x00,0x80,0x00,0x00,0x00,0x40,0xe4,0xa1,0x00,0xfc,0x00,0x00,0x00,0x28, +0xe4,0xe1,0x00,0xfc,0x00,0x00,0x00,0x28,0xe4,0x21,0x01,0xfc,0x00,0x00,0x00,0x28, +0xe7,0xa1,0x00,0xa0,0x00,0x00,0x00,0x40,0x00,0x40,0x81,0x14,0x00,0x00,0x00,0xc8, +0x47,0x00,0x02,0x00,0xe2,0x42,0xe0,0x22,0x40,0x80,0x20,0x14,0x00,0x00,0x00,0x58, +0x40,0xc0,0x30,0x14,0x00,0x00,0x00,0x58,0x40,0x00,0x41,0x14,0x00,0x00,0x00,0x58, +0x03,0x1c,0x00,0xa0,0x00,0x40,0x00,0x48,0x85,0x9c,0x60,0x30,0x00,0x00,0x00,0x90, +0x03,0xdc,0x01,0x40,0x05,0x40,0x8e,0x18,0x85,0xdc,0x60,0x40,0x00,0x00,0x00,0x90, +0x47,0xe0,0xe2,0x02,0x00,0x00,0x00,0x20,0x85,0x1c,0x61,0x50,0x00,0x00,0x00,0x90, +0xe7,0x01,0x00,0xa0,0xfb,0xff,0x03,0x40,0xe7,0x1d,0x00,0x00,0x00,0x00,0x00,0x80, +0xe7,0x1d,0x00,0xe0,0xff,0xff,0x03,0x40,0xe4,0x1d,0x00,0x00,0x00,0x00,0x00,0x40, +0xe4,0x1d,0x00,0x00,0x00,0x00,0x00,0x40,0xe4,0x1d,0x00,0x00,0x00,0x00,0x00,0x40, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x03,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x34,0x00,0x00,0x00,0xa0,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x0b,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0xd4,0x00,0x00,0x00,0xbc,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x13,0x00,0x00,0x00,0x02,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x90,0x01,0x00,0x00,0x40,0x00,0x00,0x00, +0x02,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x10,0x00,0x00,0x00, +0x36,0x00,0x00,0x00,0x00,0x00,0x00,0x70,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0xd0,0x01,0x00,0x00,0x68,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x07,0x00,0x00,0x00, +0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x74,0x00,0x00,0x00,0x00,0x00,0x00,0x70, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x38,0x02,0x00,0x00,0x18,0x00,0x00,0x00, +0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x7d,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x50,0x02,0x00,0x00,0x54,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0x00,0x00,0x00, +0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1b,0x00,0x00,0x00,0x01,0x00,0x00,0x00, +0x06,0x00,0x10,0x00,0x00,0x00,0x00,0x00,0xc0,0x03,0x00,0x00,0xc0,0x03,0x00,0x00, +0x03,0x00,0x00,0x00,0x03,0x00,0x00,0x14,0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x06,0x00,0x00,0x00,0xc0,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x60,0x00,0x00,0x00,0x60,0x00,0x00,0x00,0x05,0x00,0x00,0x00,0x04,0x00,0x00,0x00, +0x01,0x00,0x00,0x00,0x50,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x14,0x05,0x00,0x00,0x14,0x05,0x00,0x00,0x05,0x00,0x00,0x00,0x04,0x00,0x00,0x00, +0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x06,0x00,0x00,0x00,0x04,0x00,0x00,0x00, +0x02,0x00,0x01,0x01,0x58,0x00,0x00,0x00,0x20,0x0a,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0x00,0x01,0x00,0x32,0x00,0x00,0x00, +0x40,0x00,0x00,0x00,0x15,0x00,0x00,0x00,0x44,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x52,0x65,0x6e,0x64,0x65,0x72,0x43,0x6c,0x6f,0x74,0x68,0x4e,0x6f,0x72,0x6d,0x61, +0x6c,0x73,0x2e,0x63,0x75,0x00,0x00,0x00,0x7f,0x45,0x4c,0x46,0x01,0x01,0x01,0x33, +0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x00,0xbe,0x00,0x01,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0xc0,0x09,0x00,0x00,0x80,0x08,0x00,0x00,0x32,0x01,0x32,0x00, +0x34,0x00,0x20,0x00,0x03,0x00,0x28,0x00,0x08,0x00,0x01,0x00,0x00,0x2e,0x73,0x68, +0x73,0x74,0x72,0x74,0x61,0x62,0x00,0x2e,0x73,0x74,0x72,0x74,0x61,0x62,0x00,0x2e, +0x73,0x79,0x6d,0x74,0x61,0x62,0x00,0x2e,0x74,0x65,0x78,0x74,0x2e,0x63,0x6f,0x6d, +0x70,0x75,0x74,0x65,0x53,0x6d,0x6f,0x6f,0x74,0x68,0x4e,0x6f,0x72,0x6d,0x61,0x6c, +0x73,0x00,0x2e,0x6e,0x76,0x2e,0x69,0x6e,0x66,0x6f,0x2e,0x63,0x6f,0x6d,0x70,0x75, +0x74,0x65,0x53,0x6d,0x6f,0x6f,0x74,0x68,0x4e,0x6f,0x72,0x6d,0x61,0x6c,0x73,0x00, +0x2e,0x6e,0x76,0x2e,0x73,0x68,0x61,0x72,0x65,0x64,0x2e,0x63,0x6f,0x6d,0x70,0x75, +0x74,0x65,0x53,0x6d,0x6f,0x6f,0x74,0x68,0x4e,0x6f,0x72,0x6d,0x61,0x6c,0x73,0x00, +0x2e,0x6e,0x76,0x2e,0x69,0x6e,0x66,0x6f,0x00,0x2e,0x6e,0x76,0x2e,0x63,0x6f,0x6e, +0x73,0x74,0x61,0x6e,0x74,0x30,0x2e,0x63,0x6f,0x6d,0x70,0x75,0x74,0x65,0x53,0x6d, +0x6f,0x6f,0x74,0x68,0x4e,0x6f,0x72,0x6d,0x61,0x6c,0x73,0x00,0x00,0x2e,0x73,0x68, +0x73,0x74,0x72,0x74,0x61,0x62,0x00,0x2e,0x73,0x74,0x72,0x74,0x61,0x62,0x00,0x2e, +0x73,0x79,0x6d,0x74,0x61,0x62,0x00,0x63,0x6f,0x6d,0x70,0x75,0x74,0x65,0x53,0x6d, +0x6f,0x6f,0x74,0x68,0x4e,0x6f,0x72,0x6d,0x61,0x6c,0x73,0x00,0x2e,0x74,0x65,0x78, +0x74,0x2e,0x63,0x6f,0x6d,0x70,0x75,0x74,0x65,0x53,0x6d,0x6f,0x6f,0x74,0x68,0x4e, +0x6f,0x72,0x6d,0x61,0x6c,0x73,0x00,0x2e,0x6e,0x76,0x2e,0x69,0x6e,0x66,0x6f,0x2e, +0x63,0x6f,0x6d,0x70,0x75,0x74,0x65,0x53,0x6d,0x6f,0x6f,0x74,0x68,0x4e,0x6f,0x72, +0x6d,0x61,0x6c,0x73,0x00,0x2e,0x6e,0x76,0x2e,0x73,0x68,0x61,0x72,0x65,0x64,0x2e, +0x63,0x6f,0x6d,0x70,0x75,0x74,0x65,0x53,0x6d,0x6f,0x6f,0x74,0x68,0x4e,0x6f,0x72, +0x6d,0x61,0x6c,0x73,0x00,0x2e,0x6e,0x76,0x2e,0x69,0x6e,0x66,0x6f,0x00,0x2e,0x6e, +0x76,0x2e,0x63,0x6f,0x6e,0x73,0x74,0x61,0x6e,0x74,0x30,0x2e,0x63,0x6f,0x6d,0x70, +0x75,0x74,0x65,0x53,0x6d,0x6f,0x6f,0x74,0x68,0x4e,0x6f,0x72,0x6d,0x61,0x6c,0x73, +0x00,0x5f,0x70,0x61,0x72,0x61,0x6d,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x03,0x00,0x07,0x00,0x92,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x03,0x00,0x06,0x00,0x1b,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0xc0,0x04,0x00,0x00,0x12,0x10,0x07,0x00,0x04,0x0a,0x08,0x00,0x02,0x00,0x00,0x00, +0x40,0x01,0x14,0x00,0x03,0x19,0x14,0x00,0x04,0x17,0x0c,0x00,0x00,0x00,0x00,0x00, +0x04,0x00,0x10,0x00,0x00,0xf0,0x11,0x00,0x04,0x17,0x0c,0x00,0x00,0x00,0x00,0x00, +0x03,0x00,0x0c,0x00,0x00,0xf0,0x11,0x00,0x04,0x17,0x0c,0x00,0x00,0x00,0x00,0x00, +0x02,0x00,0x08,0x00,0x00,0xf0,0x11,0x00,0x04,0x17,0x0c,0x00,0x00,0x00,0x00,0x00, +0x01,0x00,0x04,0x00,0x00,0xf0,0x11,0x00,0x04,0x17,0x0c,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0xf0,0x11,0x00,0x04,0x1e,0x04,0x00,0x10,0x02,0x00,0x00, +0x04,0x1c,0x10,0x00,0x48,0x02,0x00,0x00,0x60,0x03,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x04,0x12,0x08,0x00,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x04,0x11,0x08,0x00,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xe6,0x07,0x20,0xe2,0x00,0xf4,0x1f,0x00, +0x01,0x00,0x87,0x00,0x80,0x07,0x98,0x4c,0x00,0x00,0x17,0x02,0x00,0x00,0xc8,0xf0, +0x00,0x00,0x00,0x09,0x00,0x00,0x90,0xe2,0xed,0x0f,0xa0,0xff,0x00,0x98,0x1f,0x00, +0x07,0x00,0x47,0x05,0x80,0x03,0x6c,0x4b,0x0f,0x00,0x00,0x07,0x00,0x00,0x40,0xe2, +0x02,0x00,0x07,0x00,0x80,0x07,0x98,0x5c,0xe6,0x07,0xc0,0xfc,0x00,0x88,0x1f,0x00, +0x03,0x00,0x27,0x05,0x80,0x07,0x98,0x4c,0x03,0x02,0x87,0x01,0x80,0x01,0x00,0x36, +0x03,0x02,0x87,0x01,0x90,0x01,0x20,0x36,0xf0,0x07,0x20,0x1e,0x00,0xc4,0x07,0x00, +0x02,0x02,0x27,0x00,0x00,0x00,0x10,0x4c,0xff,0x03,0xc7,0x00,0x00,0x00,0xdc,0xee, +0xff,0x03,0x07,0x01,0x00,0x00,0xdc,0xee,0xf4,0x02,0xa0,0xfd,0x00,0xf4,0xff,0x00, +0xff,0x03,0x47,0x01,0x00,0x00,0xdc,0xee,0x07,0x02,0x47,0x05,0x80,0x03,0x62,0x4b, +0x0f,0x00,0x80,0xfa,0xff,0x0f,0x40,0xe2,0xfd,0x07,0xe0,0xff,0x00,0x84,0x1f,0x00, +0x0f,0x00,0x07,0x00,0x00,0x00,0xf8,0xf0,0x00,0x00,0x07,0x00,0x80,0x1b,0xa8,0xf0, +0x07,0x00,0x37,0x05,0x80,0x03,0x6c,0x4b,0xec,0x07,0xa0,0xff,0x00,0x98,0x1f,0x00, +0x00,0x00,0x80,0x22,0x00,0x00,0x90,0xe2,0x0f,0x00,0x80,0x21,0x00,0x00,0x40,0xe2, +0x02,0x00,0x07,0x00,0x80,0x07,0x98,0x5c,0xe6,0x07,0xc0,0xfc,0x00,0x88,0x1f,0x00, +0x03,0x02,0x37,0x00,0x80,0x7f,0x00,0x36,0x03,0x02,0x37,0x00,0x90,0x01,0x20,0x36, +0x05,0x03,0x17,0x05,0x80,0x00,0x18,0x4c,0xb1,0x07,0x20,0xf6,0x00,0xc8,0x1e,0x00, +0x0e,0x05,0x07,0x00,0x00,0x00,0xd2,0xee,0x04,0x05,0x27,0x00,0x00,0x00,0xd2,0xee, +0x03,0x05,0x47,0x00,0x00,0x00,0xd2,0xee,0xe2,0x07,0x21,0xfe,0x00,0xc4,0x1f,0x00, +0x08,0x0e,0x07,0x05,0x00,0x02,0x18,0x4c,0x06,0x08,0x07,0x00,0x00,0x00,0xd4,0xee, +0x0d,0x08,0x47,0x00,0x00,0x00,0xd4,0xee,0xf1,0x00,0x40,0xfc,0x00,0xc0,0x1f,0x00, +0x0a,0x08,0x87,0x00,0x00,0x00,0xd4,0xee,0x10,0x04,0x07,0x05,0x00,0x02,0x18,0x4c, +0x0f,0x03,0x07,0x05,0x00,0x02,0x18,0x4c,0xb1,0x07,0x20,0xfe,0x00,0xc4,0x1e,0x00, +0x0b,0x10,0x87,0x00,0x00,0x00,0xd4,0xee,0x07,0x10,0x07,0x00,0x00,0x00,0xd4,0xee, +0x09,0x0f,0x87,0x00,0x00,0x00,0xd4,0xee,0xb1,0x07,0xa0,0x37,0x00,0xc4,0x3e,0x00, +0x0c,0x0f,0x47,0x00,0x00,0x00,0xd4,0xee,0x05,0x0f,0x07,0x00,0x00,0x00,0xd4,0xee, +0x08,0x10,0x47,0x00,0x00,0x00,0xd4,0xee,0xe1,0x07,0xc0,0xfc,0x00,0x84,0x1f,0x00, +0x15,0x00,0x27,0x05,0x80,0x07,0x98,0x4c,0x02,0x02,0x27,0x00,0x00,0x00,0x10,0x4c, +0x07,0x02,0x37,0x05,0x80,0x03,0x62,0x4b,0xe1,0x07,0x21,0xfc,0x02,0x84,0x1f,0x00, +0x0b,0x0b,0xa7,0x00,0x00,0x30,0x58,0x5c,0x0f,0x09,0xa7,0x00,0x00,0x30,0x58,0x5c, +0x0a,0x07,0x67,0x00,0x00,0x30,0x58,0x5c,0xe1,0x07,0x20,0xfc,0x00,0x8c,0x1f,0x00, +0x09,0x0c,0xd7,0x00,0x00,0x30,0x58,0x5c,0x11,0x05,0x67,0x00,0x00,0x30,0x58,0x5c, +0x05,0x0e,0x87,0x01,0x80,0x0a,0x00,0x36,0xe1,0x07,0x20,0xfc,0x00,0x84,0x1f,0x00, +0x0c,0x0f,0xa7,0x00,0x00,0x10,0x68,0x5c,0x08,0x08,0xd7,0x00,0x00,0x30,0x58,0x5c, +0x06,0x09,0xb7,0x00,0x00,0x10,0x68,0x5c,0xe3,0x07,0x20,0xfc,0x00,0x84,0x1f,0x00, +0x0d,0x04,0x87,0x01,0x80,0x0a,0x00,0x36,0x07,0x11,0xb7,0x00,0x00,0x06,0xa1,0x59, +0x10,0x11,0x87,0x00,0x00,0x10,0x68,0x5c,0xe1,0x07,0x40,0xfc,0x00,0xc0,0x1f,0x00, +0x05,0x0e,0x87,0x01,0x90,0x02,0x20,0x36,0x06,0x0f,0x87,0x00,0x00,0x03,0xa1,0x59, +0x0c,0x03,0x87,0x01,0x80,0x0a,0x00,0x36,0xf1,0x00,0x00,0xfe,0x00,0xc4,0x07,0x00, +0x06,0x05,0x37,0xc0,0x00,0x00,0xf8,0xeb,0x04,0x04,0x87,0x01,0x90,0x06,0x20,0x36, +0x07,0x05,0x37,0x00,0x01,0x00,0xf8,0xeb,0xe2,0x07,0x20,0x5e,0x00,0xc4,0x0f,0x00, +0x08,0x09,0xa7,0x00,0x00,0x08,0xa1,0x59,0x08,0x05,0x37,0x40,0x01,0x00,0xf8,0xeb, +0x06,0x04,0x37,0xc0,0x00,0x00,0xf8,0xeb,0xf0,0x07,0x20,0x9e,0x00,0xc4,0x03,0x00, +0x03,0x03,0x87,0x01,0x10,0x06,0x20,0x36,0x07,0x04,0x37,0x00,0x01,0x00,0xf8,0xeb, +0x08,0x04,0x37,0x40,0x01,0x00,0xf8,0xeb,0xf1,0x00,0x20,0x1e,0x00,0xc8,0x03,0x00, +0x06,0x03,0x37,0xc0,0x00,0x00,0xf8,0xeb,0x07,0x03,0x37,0x00,0x01,0x00,0xf8,0xeb, +0x08,0x03,0x37,0x40,0x01,0x00,0xf8,0xeb,0xfd,0xff,0xa0,0xff,0x00,0x84,0x1f,0x00, +0x0f,0x00,0x80,0xdf,0xff,0x0f,0x40,0xe2,0x0f,0x00,0x07,0x00,0x00,0x00,0xf8,0xf0, +0x07,0x00,0x47,0x05,0x80,0x03,0x62,0x4b,0xff,0x07,0xa0,0xff,0x00,0xc0,0x1f,0x00, +0x00,0x00,0x07,0x00,0x80,0x1b,0xa8,0xf0,0x0f,0x00,0x08,0x00,0x00,0x00,0x00,0xe3, +0x05,0x00,0x07,0x05,0x00,0x02,0x18,0x4c,0xf2,0x07,0x20,0xf6,0x00,0x98,0x1f,0x00, +0x00,0x00,0x80,0x11,0x00,0x00,0x90,0xe2,0x02,0x05,0x07,0x00,0x00,0x00,0xd4,0xee, +0x03,0x00,0x27,0x05,0x80,0x07,0x98,0x4c,0xe6,0x07,0x40,0xfc,0x00,0xc4,0x1f,0x04, +0x03,0x00,0x87,0x01,0x80,0x01,0x00,0x36,0x07,0x00,0x87,0x01,0x90,0x01,0x20,0x36, +0x02,0x07,0x07,0x00,0x00,0x00,0xdc,0xee,0xb2,0x07,0x20,0xfe,0x20,0xc4,0x1e,0x00, +0x06,0x05,0x47,0x00,0x00,0x00,0xd4,0xee,0x06,0x07,0x47,0x00,0x00,0x00,0xdc,0xee, +0x03,0x07,0x07,0x01,0x00,0x00,0xd4,0xee,0xf1,0x07,0x20,0xfe,0x00,0xc8,0x1e,0x00, +0x02,0x07,0xc7,0x00,0x00,0x00,0xd4,0xee,0x04,0x07,0x47,0x01,0x00,0x00,0xd4,0xee, +0x05,0x05,0x87,0x00,0x00,0x00,0xd4,0xee,0xf0,0x07,0xc1,0x1e,0x00,0x98,0x1f,0x00, +0x08,0x03,0x37,0x00,0x00,0x10,0x68,0x5c,0x05,0x07,0x87,0x00,0x00,0x00,0xdc,0xee, +0x06,0x02,0x27,0x00,0x00,0x04,0xa0,0x59,0xe6,0x07,0xa0,0xfd,0x00,0xf4,0x3f,0x00, +0x06,0x04,0x47,0x00,0x00,0x03,0xa0,0x59,0x07,0x06,0xf7,0x0f,0x80,0x83,0xb4,0x5b, +0x0f,0x00,0x00,0x03,0x00,0x00,0x40,0xe2,0xe1,0x07,0x20,0xfc,0x00,0x84,0x1f,0x00, +0x02,0x00,0xf7,0x0f,0x80,0x07,0x98,0x5c,0x03,0x00,0xf7,0x0f,0x80,0x07,0x98,0x5c, +0x04,0x00,0xf7,0x0f,0x80,0x07,0x98,0x5c,0xfd,0x07,0xa0,0xe3,0x00,0x84,0x3f,0x00, +0x0f,0x00,0x07,0x00,0x00,0x00,0xf8,0xf0,0x05,0x06,0x57,0x00,0x00,0x00,0x80,0x50, +0x02,0x02,0x57,0x00,0x00,0x10,0x68,0x5c,0xe1,0x07,0x00,0xfe,0x00,0xf4,0x1f,0x00, +0x03,0x03,0x57,0x00,0x00,0x10,0x68,0x5c,0x04,0x04,0x57,0x00,0x00,0x10,0x68,0x5c, +0x0f,0x00,0x07,0x00,0x00,0x00,0xf8,0xf0,0xf0,0x07,0x20,0x1e,0x00,0xc4,0x07,0x00, +0x00,0x00,0x27,0x00,0x00,0x00,0x10,0x4c,0x02,0x07,0xc7,0x00,0x00,0x00,0xdc,0xee, +0x03,0x07,0x07,0x01,0x00,0x00,0xdc,0xee,0xf4,0x02,0xa0,0xfd,0x00,0xf4,0xff,0x00, +0x04,0x07,0x47,0x01,0x00,0x00,0xdc,0xee,0x07,0x00,0x47,0x05,0x80,0x03,0x62,0x4b, +0x0f,0x00,0x80,0xe9,0xff,0x0f,0x40,0xe2,0xff,0x07,0xe0,0xff,0x00,0x80,0x1f,0x00, +0x0f,0x00,0x07,0x00,0x00,0x00,0x00,0xe3,0x0f,0x00,0x87,0xff,0xff,0x0f,0x40,0xe2, +0x00,0x0f,0x07,0x00,0x00,0x00,0xb0,0x50,0xe0,0x07,0x00,0xfc,0x00,0x80,0x1f,0x00, +0x00,0x0f,0x07,0x00,0x00,0x00,0xb0,0x50,0x00,0x0f,0x07,0x00,0x00,0x00,0xb0,0x50, +0x00,0x0f,0x07,0x00,0x00,0x00,0xb0,0x50,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x01,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x34,0x00,0x00,0x00,0xa0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0b,0x00,0x00,0x00,0x03,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xd4,0x00,0x00,0x00,0xbc,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x13,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x90,0x01,0x00,0x00,0x40,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x02,0x00,0x00,0x00, +0x04,0x00,0x00,0x00,0x10,0x00,0x00,0x00,0x36,0x00,0x00,0x00,0x00,0x00,0x00,0x70, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xd0,0x01,0x00,0x00,0x7c,0x00,0x00,0x00, +0x03,0x00,0x00,0x00,0x07,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x74,0x00,0x00,0x00,0x00,0x00,0x00,0x70,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x4c,0x02,0x00,0x00,0x18,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7d,0x00,0x00,0x00,0x01,0x00,0x00,0x00, +0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x64,0x02,0x00,0x00,0x54,0x01,0x00,0x00, +0x00,0x00,0x00,0x00,0x07,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x1b,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x06,0x00,0x10,0x00,0x00,0x00,0x00,0x00, +0xc0,0x03,0x00,0x00,0xc0,0x04,0x00,0x00,0x03,0x00,0x00,0x00,0x03,0x00,0x00,0x16, +0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x06,0x00,0x00,0x00,0xc0,0x09,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x60,0x00,0x00,0x00,0x60,0x00,0x00,0x00, +0x05,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x64,0x02,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x14,0x06,0x00,0x00,0x14,0x06,0x00,0x00, +0x05,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x06,0x00,0x00,0x00,0x04,0x00,0x00,0x00 +}; + +#ifdef __cplusplus +} +#endif + diff --git a/PhysX_3.4/Samples/SampleFramework/renderer/src/cuda/RenderParticles.cu b/PhysX_3.4/Samples/SampleFramework/renderer/src/cuda/RenderParticles.cu new file mode 100644 index 00000000..f78def28 --- /dev/null +++ b/PhysX_3.4/Samples/SampleFramework/renderer/src/cuda/RenderParticles.cu @@ -0,0 +1,163 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved. + +#include "PxPhysics.h" +#include "PxVec4.h" +#include "PxVec3.h" +#include "PxVec2.h" +#include "PxMat33.h" +#include "PxStrideIterator.h" + +namespace physx +{ + +template <typename T> +__device__ T* ptrOffset(T* p, PxU32 byteOffset) +{ + return (T*)((unsigned char*)(p) + byteOffset); +} + +#if __CUDA_ARCH__ < 200 +__device__ PxU32 gOffset; +#else +__device__ __shared__ PxU32 gOffset; +#endif + + +// copies orientations and positions to the destination vertex +// buffer based on the validityBitmap state +extern "C" __global__ void updateInstancedVB( + PxVec3* destPositions, + PxVec3* destRotation0, + PxVec3* destRotation1, + PxVec3* destRotation2, + PxU32 destStride, + const PxVec4* srcPositions, + const PxMat33* srcRotations, + const PxU32* validParticleBitmap, + PxU32 validParticleRange) +{ + if (!threadIdx.x) + gOffset = 0; + + __syncthreads(); + + if (validParticleRange) + { + for (PxU32 w=threadIdx.x; w <= (validParticleRange) >> 5; w+=blockDim.x) + { + const PxU32 srcBaseIndex = w << 5; + + // reserve space in the output vertex buffer based on + // population count of validity bitmap (avoids excess atomic ops) + PxU32 destIndex = atomicAdd(&gOffset, __popc(validParticleBitmap[w])); + + for (PxU32 b=validParticleBitmap[w]; b; b &= b-1) + { + const PxU32 index = srcBaseIndex | __ffs(b)-1; + + const PxU32 offset = destIndex*destStride; + + *ptrOffset(destRotation0, offset) = srcRotations[index].column0; + *ptrOffset(destRotation1, offset) = srcRotations[index].column1; + *ptrOffset(destRotation2, offset) = srcRotations[index].column2; + + PxVec3* p = ptrOffset(destPositions, offset); + p->x = srcPositions[index].x; + p->y = srcPositions[index].y; + p->z = srcPositions[index].z; + + ++destIndex; + } + } + } +} + + +// copies positions and alpha to the destination vertex buffer based on +// validity bitmap and particle life times +extern "C" __global__ void updateBillboardVB( + PxVec3* destPositions, + PxU8* destAlphas, + PxU32 destStride, + PxF32 fadingPeriod, + const PxVec4* srcPositions, + const PxReal* srcLifetimes, + const PxU32* validParticleBitmap, + PxU32 validParticleRange) +{ + if (!threadIdx.x) + gOffset = 0; + + __syncthreads(); + + if (validParticleRange) + { + for (PxU32 w=threadIdx.x; w <= (validParticleRange) >> 5; w+=blockDim.x) + { + const PxU32 srcBaseIndex = w << 5; + + // reserve space in the output vertex buffer based on + // population count of validity bitmap (avoids excess atomic ops) + PxU32 destIndex = atomicAdd(&gOffset, __popc(validParticleBitmap[w])); + + for (PxU32 b=validParticleBitmap[w]; b; b &= b-1) + { + PxU32 index = srcBaseIndex | __ffs(b)-1; + + const PxU32 offset = destIndex*destStride; + + // copy position + PxVec3* p = ptrOffset(destPositions, offset); + p->x = srcPositions[index].x; + p->y = srcPositions[index].y; + p->z = srcPositions[index].z; + + // update alpha + if (srcLifetimes) + { + PxU8 lifetime = 0; + if(srcLifetimes[index] >= fadingPeriod) + lifetime = 255; + else + { + if(srcLifetimes[index] <= 0.0f) + lifetime = 0; + else + lifetime = static_cast<PxU8>(srcLifetimes[index] * 255 / fadingPeriod); + } + + destAlphas[destIndex*4] = lifetime; + } + + ++destIndex; + } + } + } +} + +}
\ No newline at end of file diff --git a/PhysX_3.4/Samples/SampleFramework/renderer/src/cuda/RenderParticles_x64.cuh b/PhysX_3.4/Samples/SampleFramework/renderer/src/cuda/RenderParticles_x64.cuh new file mode 100644 index 00000000..b87fec7c --- /dev/null +++ b/PhysX_3.4/Samples/SampleFramework/renderer/src/cuda/RenderParticles_x64.cuh @@ -0,0 +1,1201 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved. + +#ifdef __cplusplus +extern "C" { +#endif + +unsigned char updateParticleVertexBuffer[] = { +0x50,0xed,0x55,0xba,0x01,0x00,0x10,0x00,0xa0,0x48,0x00,0x00,0x00,0x00,0x00,0x00, +0x02,0x00,0x01,0x01,0x58,0x00,0x00,0x00,0x50,0x13,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x00,0x01,0x00,0x0b,0x00,0x00,0x00, +0x40,0x00,0x00,0x00,0x12,0x00,0x00,0x00,0x45,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x52,0x65,0x6e,0x64,0x65,0x72,0x50,0x61,0x72,0x74,0x69,0x63,0x6c,0x65,0x73,0x2e, +0x63,0x75,0x00,0x00,0x00,0x00,0x00,0x00,0x7f,0x45,0x4c,0x46,0x02,0x01,0x01,0x33, +0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x00,0xbe,0x00,0x01,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xa8,0x12,0x00,0x00,0x00,0x00,0x00,0x00, +0xe8,0x0e,0x00,0x00,0x00,0x00,0x00,0x00,0x0b,0x01,0x0b,0x00,0x40,0x00,0x38,0x00, +0x03,0x00,0x40,0x00,0x0f,0x00,0x01,0x00,0x00,0x2e,0x73,0x68,0x73,0x74,0x72,0x74, +0x61,0x62,0x00,0x2e,0x73,0x74,0x72,0x74,0x61,0x62,0x00,0x2e,0x73,0x79,0x6d,0x74, +0x61,0x62,0x00,0x2e,0x74,0x65,0x78,0x74,0x2e,0x75,0x70,0x64,0x61,0x74,0x65,0x49, +0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x64,0x56,0x42,0x00,0x2e,0x6e,0x76,0x2e,0x69, +0x6e,0x66,0x6f,0x2e,0x75,0x70,0x64,0x61,0x74,0x65,0x49,0x6e,0x73,0x74,0x61,0x6e, +0x63,0x65,0x64,0x56,0x42,0x00,0x2e,0x6e,0x76,0x2e,0x73,0x68,0x61,0x72,0x65,0x64, +0x2e,0x75,0x70,0x64,0x61,0x74,0x65,0x49,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x64, +0x56,0x42,0x00,0x2e,0x6e,0x76,0x2e,0x63,0x6f,0x6e,0x73,0x74,0x61,0x6e,0x74,0x31, +0x2e,0x75,0x70,0x64,0x61,0x74,0x65,0x49,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x64, +0x56,0x42,0x00,0x2e,0x74,0x65,0x78,0x74,0x2e,0x75,0x70,0x64,0x61,0x74,0x65,0x42, +0x69,0x6c,0x6c,0x62,0x6f,0x61,0x72,0x64,0x56,0x42,0x00,0x2e,0x6e,0x76,0x2e,0x69, +0x6e,0x66,0x6f,0x2e,0x75,0x70,0x64,0x61,0x74,0x65,0x42,0x69,0x6c,0x6c,0x62,0x6f, +0x61,0x72,0x64,0x56,0x42,0x00,0x2e,0x6e,0x76,0x2e,0x73,0x68,0x61,0x72,0x65,0x64, +0x2e,0x75,0x70,0x64,0x61,0x74,0x65,0x42,0x69,0x6c,0x6c,0x62,0x6f,0x61,0x72,0x64, +0x56,0x42,0x00,0x2e,0x6e,0x76,0x2e,0x63,0x6f,0x6e,0x73,0x74,0x61,0x6e,0x74,0x31, +0x2e,0x75,0x70,0x64,0x61,0x74,0x65,0x42,0x69,0x6c,0x6c,0x62,0x6f,0x61,0x72,0x64, +0x56,0x42,0x00,0x2e,0x6e,0x76,0x2e,0x67,0x6c,0x6f,0x62,0x61,0x6c,0x00,0x2e,0x6e, +0x76,0x2e,0x63,0x6f,0x6e,0x73,0x74,0x61,0x6e,0x74,0x31,0x34,0x00,0x2e,0x72,0x65, +0x6c,0x2e,0x6e,0x76,0x2e,0x63,0x6f,0x6e,0x73,0x74,0x61,0x6e,0x74,0x31,0x34,0x00, +0x00,0x2e,0x73,0x68,0x73,0x74,0x72,0x74,0x61,0x62,0x00,0x2e,0x73,0x74,0x72,0x74, +0x61,0x62,0x00,0x2e,0x73,0x79,0x6d,0x74,0x61,0x62,0x00,0x75,0x70,0x64,0x61,0x74, +0x65,0x49,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x64,0x56,0x42,0x00,0x2e,0x74,0x65, +0x78,0x74,0x2e,0x75,0x70,0x64,0x61,0x74,0x65,0x49,0x6e,0x73,0x74,0x61,0x6e,0x63, +0x65,0x64,0x56,0x42,0x00,0x2e,0x6e,0x76,0x2e,0x69,0x6e,0x66,0x6f,0x2e,0x75,0x70, +0x64,0x61,0x74,0x65,0x49,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x64,0x56,0x42,0x00, +0x2e,0x6e,0x76,0x2e,0x73,0x68,0x61,0x72,0x65,0x64,0x2e,0x75,0x70,0x64,0x61,0x74, +0x65,0x49,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x64,0x56,0x42,0x00,0x2e,0x6e,0x76, +0x2e,0x63,0x6f,0x6e,0x73,0x74,0x61,0x6e,0x74,0x31,0x2e,0x75,0x70,0x64,0x61,0x74, +0x65,0x49,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x64,0x56,0x42,0x00,0x63,0x6f,0x6e, +0x73,0x74,0x00,0x5f,0x5f,0x63,0x75,0x64,0x61,0x70,0x61,0x72,0x6d,0x5f,0x75,0x70, +0x64,0x61,0x74,0x65,0x49,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x64,0x56,0x42,0x5f, +0x64,0x65,0x73,0x74,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x73,0x00,0x5f,0x5f, +0x63,0x75,0x64,0x61,0x70,0x61,0x72,0x6d,0x5f,0x75,0x70,0x64,0x61,0x74,0x65,0x49, +0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x64,0x56,0x42,0x5f,0x64,0x65,0x73,0x74,0x52, +0x6f,0x74,0x61,0x74,0x69,0x6f,0x6e,0x30,0x00,0x5f,0x5f,0x63,0x75,0x64,0x61,0x70, +0x61,0x72,0x6d,0x5f,0x75,0x70,0x64,0x61,0x74,0x65,0x49,0x6e,0x73,0x74,0x61,0x6e, +0x63,0x65,0x64,0x56,0x42,0x5f,0x64,0x65,0x73,0x74,0x52,0x6f,0x74,0x61,0x74,0x69, +0x6f,0x6e,0x31,0x00,0x5f,0x5f,0x63,0x75,0x64,0x61,0x70,0x61,0x72,0x6d,0x5f,0x75, +0x70,0x64,0x61,0x74,0x65,0x49,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x64,0x56,0x42, +0x5f,0x64,0x65,0x73,0x74,0x52,0x6f,0x74,0x61,0x74,0x69,0x6f,0x6e,0x32,0x00,0x5f, +0x5f,0x63,0x75,0x64,0x61,0x70,0x61,0x72,0x6d,0x5f,0x75,0x70,0x64,0x61,0x74,0x65, +0x49,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x64,0x56,0x42,0x5f,0x64,0x65,0x73,0x74, +0x53,0x74,0x72,0x69,0x64,0x65,0x00,0x5f,0x5f,0x63,0x75,0x64,0x61,0x70,0x61,0x72, +0x6d,0x5f,0x75,0x70,0x64,0x61,0x74,0x65,0x49,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65, +0x64,0x56,0x42,0x5f,0x73,0x72,0x63,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x73, +0x00,0x5f,0x5f,0x63,0x75,0x64,0x61,0x70,0x61,0x72,0x6d,0x5f,0x75,0x70,0x64,0x61, +0x74,0x65,0x49,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x64,0x56,0x42,0x5f,0x73,0x72, +0x63,0x52,0x6f,0x74,0x61,0x74,0x69,0x6f,0x6e,0x73,0x00,0x5f,0x5f,0x63,0x75,0x64, +0x61,0x70,0x61,0x72,0x6d,0x5f,0x75,0x70,0x64,0x61,0x74,0x65,0x49,0x6e,0x73,0x74, +0x61,0x6e,0x63,0x65,0x64,0x56,0x42,0x5f,0x76,0x61,0x6c,0x69,0x64,0x50,0x61,0x72, +0x74,0x69,0x63,0x6c,0x65,0x42,0x69,0x74,0x6d,0x61,0x70,0x00,0x5f,0x5f,0x63,0x75, +0x64,0x61,0x70,0x61,0x72,0x6d,0x5f,0x75,0x70,0x64,0x61,0x74,0x65,0x49,0x6e,0x73, +0x74,0x61,0x6e,0x63,0x65,0x64,0x56,0x42,0x5f,0x76,0x61,0x6c,0x69,0x64,0x50,0x61, +0x72,0x74,0x69,0x63,0x6c,0x65,0x52,0x61,0x6e,0x67,0x65,0x00,0x75,0x70,0x64,0x61, +0x74,0x65,0x42,0x69,0x6c,0x6c,0x62,0x6f,0x61,0x72,0x64,0x56,0x42,0x00,0x2e,0x74, +0x65,0x78,0x74,0x2e,0x75,0x70,0x64,0x61,0x74,0x65,0x42,0x69,0x6c,0x6c,0x62,0x6f, +0x61,0x72,0x64,0x56,0x42,0x00,0x2e,0x6e,0x76,0x2e,0x69,0x6e,0x66,0x6f,0x2e,0x75, +0x70,0x64,0x61,0x74,0x65,0x42,0x69,0x6c,0x6c,0x62,0x6f,0x61,0x72,0x64,0x56,0x42, +0x00,0x2e,0x6e,0x76,0x2e,0x73,0x68,0x61,0x72,0x65,0x64,0x2e,0x75,0x70,0x64,0x61, +0x74,0x65,0x42,0x69,0x6c,0x6c,0x62,0x6f,0x61,0x72,0x64,0x56,0x42,0x00,0x2e,0x6e, +0x76,0x2e,0x63,0x6f,0x6e,0x73,0x74,0x61,0x6e,0x74,0x31,0x2e,0x75,0x70,0x64,0x61, +0x74,0x65,0x42,0x69,0x6c,0x6c,0x62,0x6f,0x61,0x72,0x64,0x56,0x42,0x00,0x5f,0x5f, +0x63,0x75,0x64,0x61,0x70,0x61,0x72,0x6d,0x5f,0x75,0x70,0x64,0x61,0x74,0x65,0x42, +0x69,0x6c,0x6c,0x62,0x6f,0x61,0x72,0x64,0x56,0x42,0x5f,0x64,0x65,0x73,0x74,0x50, +0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x73,0x00,0x5f,0x5f,0x63,0x75,0x64,0x61,0x70, +0x61,0x72,0x6d,0x5f,0x75,0x70,0x64,0x61,0x74,0x65,0x42,0x69,0x6c,0x6c,0x62,0x6f, +0x61,0x72,0x64,0x56,0x42,0x5f,0x64,0x65,0x73,0x74,0x41,0x6c,0x70,0x68,0x61,0x73, +0x00,0x5f,0x5f,0x63,0x75,0x64,0x61,0x70,0x61,0x72,0x6d,0x5f,0x75,0x70,0x64,0x61, +0x74,0x65,0x42,0x69,0x6c,0x6c,0x62,0x6f,0x61,0x72,0x64,0x56,0x42,0x5f,0x64,0x65, +0x73,0x74,0x53,0x74,0x72,0x69,0x64,0x65,0x00,0x5f,0x5f,0x63,0x75,0x64,0x61,0x70, +0x61,0x72,0x6d,0x5f,0x75,0x70,0x64,0x61,0x74,0x65,0x42,0x69,0x6c,0x6c,0x62,0x6f, +0x61,0x72,0x64,0x56,0x42,0x5f,0x66,0x61,0x64,0x69,0x6e,0x67,0x50,0x65,0x72,0x69, +0x6f,0x64,0x00,0x5f,0x5f,0x63,0x75,0x64,0x61,0x70,0x61,0x72,0x6d,0x5f,0x75,0x70, +0x64,0x61,0x74,0x65,0x42,0x69,0x6c,0x6c,0x62,0x6f,0x61,0x72,0x64,0x56,0x42,0x5f, +0x73,0x72,0x63,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x73,0x00,0x5f,0x5f,0x63, +0x75,0x64,0x61,0x70,0x61,0x72,0x6d,0x5f,0x75,0x70,0x64,0x61,0x74,0x65,0x42,0x69, +0x6c,0x6c,0x62,0x6f,0x61,0x72,0x64,0x56,0x42,0x5f,0x73,0x72,0x63,0x4c,0x69,0x66, +0x65,0x74,0x69,0x6d,0x65,0x73,0x00,0x5f,0x5f,0x63,0x75,0x64,0x61,0x70,0x61,0x72, +0x6d,0x5f,0x75,0x70,0x64,0x61,0x74,0x65,0x42,0x69,0x6c,0x6c,0x62,0x6f,0x61,0x72, +0x64,0x56,0x42,0x5f,0x76,0x61,0x6c,0x69,0x64,0x50,0x61,0x72,0x74,0x69,0x63,0x6c, +0x65,0x42,0x69,0x74,0x6d,0x61,0x70,0x00,0x5f,0x5f,0x63,0x75,0x64,0x61,0x70,0x61, +0x72,0x6d,0x5f,0x75,0x70,0x64,0x61,0x74,0x65,0x42,0x69,0x6c,0x6c,0x62,0x6f,0x61, +0x72,0x64,0x56,0x42,0x5f,0x76,0x61,0x6c,0x69,0x64,0x50,0x61,0x72,0x74,0x69,0x63, +0x6c,0x65,0x52,0x61,0x6e,0x67,0x65,0x00,0x2e,0x6e,0x76,0x2e,0x67,0x6c,0x6f,0x62, +0x61,0x6c,0x00,0x5f,0x5a,0x4e,0x35,0x70,0x68,0x79,0x73,0x78,0x37,0x67,0x4f,0x66, +0x66,0x73,0x65,0x74,0x45,0x00,0x2e,0x6e,0x76,0x2e,0x63,0x6f,0x6e,0x73,0x74,0x61, +0x6e,0x74,0x31,0x34,0x00,0x24,0x41,0x44,0x44,0x52,0x45,0x53,0x53,0x24,0x5f,0x5a, +0x4e,0x35,0x70,0x68,0x79,0x73,0x78,0x37,0x67,0x4f,0x66,0x66,0x73,0x65,0x74,0x45, +0x00,0x2e,0x72,0x65,0x6c,0x2e,0x6e,0x76,0x2e,0x63,0x6f,0x6e,0x73,0x74,0x61,0x6e, +0x74,0x31,0x34,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x2d,0x00,0x00,0x00,0x03,0x00,0x0a,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x60,0x00,0x00,0x00,0x03,0x00,0x0c,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x7d,0x00,0x00,0x00,0x03,0x00,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3e,0x02,0x00,0x00,0x03,0x00,0x0b,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x71,0x02,0x00,0x00,0x03,0x00,0x0d,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x8e,0x02,0x00,0x00,0x03,0x00,0x08,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x08,0x04,0x00,0x00,0x03,0x00,0x0e,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x13,0x04,0x00,0x00,0x01,0x00,0x0e,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x26,0x04,0x00,0x00,0x03,0x00,0x09,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1b,0x00,0x00,0x00,0x12,0x10,0x0a,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x78,0x03,0x00,0x00,0x00,0x00,0x00,0x00, +0x2c,0x02,0x00,0x00,0x12,0x10,0x0b,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x10,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x18,0x44,0x00,0x04,0x17,0x0c,0x00, +0x00,0x00,0x00,0x00,0x08,0x00,0x40,0x00,0x00,0xf0,0x13,0x00,0x04,0x17,0x0c,0x00, +0x00,0x00,0x00,0x00,0x07,0x00,0x38,0x00,0x00,0xf0,0x23,0x00,0x04,0x17,0x0c,0x00, +0x00,0x00,0x00,0x00,0x06,0x00,0x30,0x00,0x00,0xf0,0x23,0x00,0x04,0x17,0x0c,0x00, +0x00,0x00,0x00,0x00,0x05,0x00,0x28,0x00,0x00,0xf0,0x23,0x00,0x04,0x17,0x0c,0x00, +0x00,0x00,0x00,0x00,0x04,0x00,0x20,0x00,0x00,0xf0,0x13,0x00,0x04,0x17,0x0c,0x00, +0x00,0x00,0x00,0x00,0x03,0x00,0x18,0x00,0x00,0xf0,0x23,0x00,0x04,0x17,0x0c,0x00, +0x00,0x00,0x00,0x00,0x02,0x00,0x10,0x00,0x00,0xf0,0x23,0x00,0x04,0x17,0x0c,0x00, +0x00,0x00,0x00,0x00,0x01,0x00,0x08,0x00,0x00,0xf0,0x23,0x00,0x04,0x17,0x0c,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0x23,0x00,0x04,0x1e,0x04,0x00, +0x08,0x01,0x00,0x00,0x03,0x18,0x34,0x00,0x04,0x17,0x0c,0x00,0x00,0x00,0x00,0x00, +0x07,0x00,0x30,0x00,0x00,0xf0,0x13,0x00,0x04,0x17,0x0c,0x00,0x00,0x00,0x00,0x00, +0x06,0x00,0x28,0x00,0x00,0xf0,0x23,0x00,0x04,0x17,0x0c,0x00,0x00,0x00,0x00,0x00, +0x05,0x00,0x20,0x00,0x00,0xf0,0x23,0x00,0x04,0x17,0x0c,0x00,0x00,0x00,0x00,0x00, +0x04,0x00,0x18,0x00,0x00,0xf0,0x23,0x00,0x04,0x17,0x0c,0x00,0x00,0x00,0x00,0x00, +0x03,0x00,0x14,0x00,0x00,0xf0,0x13,0x00,0x04,0x17,0x0c,0x00,0x00,0x00,0x00,0x00, +0x02,0x00,0x10,0x00,0x00,0xf0,0x13,0x00,0x04,0x17,0x0c,0x00,0x00,0x00,0x00,0x00, +0x01,0x00,0x08,0x00,0x00,0xf0,0x23,0x00,0x04,0x17,0x0c,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0xf0,0x23,0x00,0x04,0x1e,0x04,0x00,0x10,0x01,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x08,0x00,0x00,0x00, +0x55,0x55,0x55,0x55,0x33,0x33,0x33,0x33,0x0f,0x0f,0x0f,0x0f,0x00,0x00,0x00,0x00, +0x20,0x00,0x00,0x00,0x9e,0x00,0x00,0x00,0x55,0x55,0x55,0x55,0x33,0x33,0x33,0x33, +0x0f,0x0f,0x0f,0x0f,0x00,0x00,0x00,0x00,0x20,0x00,0x00,0x00,0x9e,0x00,0x00,0x00, +0x00,0x00,0x7f,0x43,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0xa0,0xc0,0x07,0x00,0x04, +0x09,0x00,0x00,0x10,0x00,0xc5,0x80,0x27,0x05,0x06,0x00,0x10,0x00,0xc5,0x40,0x24, +0x05,0x04,0x0e,0xd0,0x00,0x05,0xc0,0xa0,0x03,0xfe,0x1f,0x86,0x00,0x00,0x00,0x00, +0xfd,0xe9,0x7c,0x30,0xc8,0x87,0x20,0x64,0x03,0x00,0x00,0x30,0x80,0x02,0x00,0x00, +0x0d,0xe8,0x05,0x30,0x80,0x07,0x30,0xe4,0xfd,0x07,0x00,0x30,0xc8,0x47,0x00,0x64, +0x09,0x00,0x00,0x10,0x80,0xc7,0x03,0x04,0x03,0x00,0x00,0x30,0x80,0x02,0x00,0x00, +0x11,0x42,0x00,0xa0,0x80,0x07,0x20,0x04,0x15,0x00,0x02,0x30,0x80,0x07,0x10,0xc4, +0x19,0x08,0x02,0x30,0x80,0x07,0x10,0xc4,0x01,0xe4,0x00,0x20,0x80,0x47,0x21,0x04, +0x05,0x00,0x0e,0xd0,0x80,0x07,0xc0,0x80,0x1d,0x02,0x01,0x30,0x80,0x07,0x10,0xe4, +0x1d,0x0e,0x80,0xd0,0x80,0x07,0x40,0x04,0x05,0x02,0x40,0x20,0x80,0xc7,0x01,0x04, +0x1d,0x02,0x02,0x30,0x80,0x07,0x10,0xe4,0x05,0x02,0x81,0xd0,0x80,0x07,0x40,0x04, +0x1d,0x0e,0x81,0xd0,0x80,0x07,0x40,0x04,0x05,0x02,0x00,0x20,0x80,0xc7,0x01,0x04, +0x1d,0x02,0x04,0x30,0x80,0x07,0x10,0xe4,0x05,0x02,0x00,0x20,0x80,0xc7,0x01,0x04, +0x05,0x02,0x82,0xd0,0x80,0x07,0x40,0x04,0x1d,0x02,0x40,0x40,0x0b,0x08,0x08,0x00, +0x1d,0x0e,0x01,0x30,0x80,0x07,0x10,0xc4,0x1d,0x02,0x00,0x20,0x80,0xc7,0x01,0x04, +0x05,0x00,0x00,0x10,0x80,0xc7,0x80,0x27,0x1d,0x0e,0x18,0x30,0x80,0x07,0x10,0xe4, +0x05,0x02,0x07,0xd7,0x80,0x07,0xc0,0xe0,0x1d,0x00,0x0e,0xd0,0x80,0x07,0xc0,0x80, +0x03,0xa0,0x06,0xa0,0x00,0x00,0x00,0x00,0xfd,0x0f,0x7c,0x30,0xc8,0x87,0x00,0x64, +0x03,0xa0,0x06,0x10,0x80,0x02,0x00,0x00,0x01,0x18,0x00,0x10,0x80,0xc7,0x00,0x44, +0x21,0x04,0x01,0x40,0x80,0x07,0x00,0x00,0x21,0x06,0x00,0x60,0x80,0x07,0x02,0x00, +0x21,0x10,0x10,0x30,0x80,0x07,0x10,0xc4,0x05,0x04,0x00,0x60,0x80,0x07,0x02,0x00, +0x01,0x04,0x05,0x30,0x80,0x07,0x10,0xc4,0x21,0x8e,0x00,0x30,0x03,0x00,0x00,0x00, +0x21,0x10,0x07,0xd0,0xc0,0x07,0x00,0x04,0x21,0x10,0x00,0xa0,0x80,0x46,0x06,0x44, +0x21,0x10,0x17,0x30,0x80,0x06,0x10,0xec,0x21,0x10,0x00,0x31,0x80,0x46,0x41,0x04, +0x21,0x08,0x00,0x10,0x00,0xc1,0x40,0x24,0x29,0xcc,0x00,0x20,0x80,0x47,0x20,0x04, +0x21,0x90,0x1f,0x30,0x03,0x00,0x00,0x00,0x21,0x10,0x00,0xd0,0x80,0x47,0x00,0x04, +0x25,0x10,0x05,0x30,0x80,0x07,0x10,0xc4,0x2d,0x10,0x02,0x30,0x80,0x07,0x10,0xc4, +0x25,0x12,0x00,0x20,0x80,0xc7,0x02,0x04,0x25,0xe0,0x00,0x20,0x80,0x47,0x22,0x04, +0x2d,0x12,0x0e,0xd0,0x80,0x07,0xc0,0x80,0x2d,0x14,0x0e,0xd0,0x80,0x07,0xc0,0xa0, +0x2d,0x92,0x04,0x20,0x03,0x00,0x00,0x00,0x2d,0x16,0x0e,0xd0,0x80,0x07,0xc0,0x80, +0x31,0x94,0x04,0x20,0x03,0x00,0x00,0x00,0x2d,0x18,0x0e,0xd0,0x80,0x07,0xc0,0xa0, +0x2d,0x92,0x08,0x20,0x03,0x00,0x00,0x00,0x2d,0x16,0x0e,0xd0,0x80,0x07,0xc0,0x80, +0x29,0x94,0x08,0x20,0x03,0x00,0x00,0x00,0x2d,0x14,0x0e,0xd0,0x80,0x07,0xc0,0xa0, +0x29,0x92,0x0c,0x20,0x03,0x00,0x00,0x00,0x2d,0x14,0x0e,0xd0,0x80,0x07,0xc0,0x80, +0x29,0xd0,0x00,0x20,0x80,0x47,0x20,0x04,0x2d,0x14,0x0e,0xd0,0x80,0x07,0xc0,0xa0, +0x2d,0x92,0x10,0x20,0x03,0x00,0x00,0x00,0x2d,0x16,0x0e,0xd0,0x80,0x07,0xc0,0x80, +0x31,0x94,0x04,0x20,0x03,0x00,0x00,0x00,0x2d,0x18,0x0e,0xd0,0x80,0x07,0xc0,0xa0, +0x2d,0x92,0x14,0x20,0x03,0x00,0x00,0x00,0x2d,0x16,0x0e,0xd0,0x80,0x07,0xc0,0x80, +0x29,0x94,0x08,0x20,0x03,0x00,0x00,0x00,0x2d,0x14,0x0e,0xd0,0x80,0x07,0xc0,0xa0, +0x29,0x92,0x18,0x20,0x03,0x00,0x00,0x00,0x2d,0x14,0x0e,0xd0,0x80,0x07,0xc0,0x80, +0x29,0xd4,0x00,0x20,0x80,0x47,0x20,0x04,0x2d,0x14,0x0e,0xd0,0x80,0x07,0xc0,0xa0, +0x2d,0x92,0x1c,0x20,0x03,0x00,0x00,0x00,0x2d,0x16,0x0e,0xd0,0x80,0x07,0xc0,0x80, +0x31,0x94,0x04,0x20,0x03,0x00,0x00,0x00,0x2d,0x18,0x0e,0xd0,0x80,0x07,0xc0,0xa0, +0x25,0x92,0x20,0x20,0x03,0x00,0x00,0x00,0x25,0x12,0x0e,0xd0,0x80,0x07,0xc0,0x80, +0x29,0x94,0x08,0x20,0x03,0x00,0x00,0x00,0x21,0x10,0x04,0x30,0x80,0x07,0x10,0xc4, +0x25,0x14,0x0e,0xd0,0x80,0x07,0xc0,0xa0,0x29,0xdc,0x00,0x20,0x80,0x07,0x22,0x04, +0x25,0x14,0x0e,0xd0,0x80,0x07,0xc0,0x80,0x21,0xc8,0x00,0x20,0x80,0x47,0x20,0x04, +0x25,0x10,0x0e,0xd0,0x80,0x07,0xc0,0xa0,0x25,0x94,0x04,0x20,0x03,0x00,0x00,0x00, +0x25,0x12,0x0e,0xd0,0x80,0x07,0xc0,0x80,0x2d,0x90,0x04,0x20,0x03,0x00,0x00,0x00, +0x25,0x16,0x0e,0xd0,0x80,0x07,0xc0,0xa0,0x25,0x94,0x08,0x20,0x03,0x00,0x00,0x00, +0x25,0x12,0x0e,0xd0,0x80,0x07,0xc0,0x80,0x21,0x90,0x08,0x20,0x03,0x00,0x00,0x00, +0x29,0x8e,0x3f,0x20,0xff,0xff,0xff,0x0f,0x1d,0x0e,0x0a,0xd0,0xc0,0x07,0x00,0x04, +0x25,0x10,0x0e,0xd0,0x80,0x07,0xc0,0xa0,0x05,0xd8,0x00,0x20,0x80,0x47,0x20,0x04, +0x03,0xa0,0x02,0x10,0x80,0x02,0x00,0x00,0x09,0x04,0x00,0x20,0x82,0x07,0x01,0x04, +0xfd,0x07,0x02,0x30,0xc8,0x87,0x01,0x64,0x15,0x0a,0x00,0x20,0x80,0x87,0x01,0x04, +0x03,0xe0,0x00,0x10,0x80,0x02,0x00,0x00,0x01,0x00,0x00,0xf0,0x01,0x00,0x00,0xe0, +0x01,0x00,0x00,0xa0,0xc0,0x07,0x00,0x04,0x09,0x00,0x00,0x10,0x00,0xc5,0x80,0x27, +0x05,0x06,0x00,0x10,0x00,0xc5,0x40,0x24,0x05,0x04,0x0e,0xd0,0x00,0x05,0xc0,0xa0, +0x03,0xfe,0x1f,0x86,0x00,0x00,0x00,0x00,0xfd,0xe1,0x7c,0x30,0xc8,0x87,0x20,0x64, +0x03,0x00,0x00,0x30,0x80,0x02,0x00,0x00,0x11,0xe0,0x05,0x30,0x80,0x07,0x30,0xe4, +0xfd,0x09,0x00,0x30,0xc8,0x47,0x00,0x64,0x09,0x00,0x00,0x10,0x80,0xc7,0x03,0x04, +0x03,0x00,0x00,0x30,0x80,0x02,0x00,0x00,0x15,0x42,0x00,0xa0,0x80,0x07,0x20,0x04, +0x19,0x00,0x02,0x30,0x80,0x07,0x10,0xc4,0x1d,0x0a,0x02,0x30,0x80,0x07,0x10,0xc4, +0x01,0xdc,0x00,0x20,0x80,0x87,0x21,0x04,0x05,0x00,0x0e,0xd0,0x80,0x07,0xc0,0x80, +0x0d,0x02,0x01,0x30,0x80,0x07,0x10,0xe4,0x0d,0x06,0x80,0xd0,0x80,0x07,0x40,0x04, +0x05,0x02,0x40,0x20,0x80,0xc7,0x00,0x04,0x0d,0x02,0x02,0x30,0x80,0x07,0x10,0xe4, +0x05,0x02,0x81,0xd0,0x80,0x07,0x40,0x04,0x0d,0x06,0x81,0xd0,0x80,0x07,0x40,0x04, +0x05,0x02,0x00,0x20,0x80,0xc7,0x00,0x04,0x0d,0x02,0x04,0x30,0x80,0x07,0x10,0xe4, +0x05,0x02,0x00,0x20,0x80,0xc7,0x00,0x04,0x05,0x02,0x82,0xd0,0x80,0x07,0x40,0x04, +0x0d,0x02,0x40,0x40,0x0b,0x08,0x08,0x00,0x0d,0x06,0x01,0x30,0x80,0x07,0x10,0xc4, +0x0d,0x02,0x00,0x20,0x80,0xc7,0x00,0x04,0x05,0x00,0x00,0x10,0x80,0xc7,0x80,0x27, +0x0d,0x06,0x18,0x30,0x80,0x07,0x10,0xe4,0x05,0x02,0x03,0xd7,0x80,0x07,0xc0,0xe0, +0x21,0x00,0x0e,0xd0,0x80,0x07,0xc0,0x80,0x03,0xd0,0x05,0xa0,0x00,0x00,0x00,0x00, +0xfd,0x11,0x7c,0x30,0xc8,0x87,0x00,0x64,0x0d,0x02,0x00,0x10,0x80,0xc7,0x03,0x04, +0x03,0xd0,0x05,0x10,0x80,0x02,0x00,0x00,0x01,0x10,0x00,0x10,0x80,0xc7,0x00,0x44, +0x29,0xd8,0x7c,0x30,0x80,0x87,0x20,0x64,0x25,0x04,0x01,0x40,0x80,0x07,0x00,0x00, +0x2d,0xda,0x7c,0x30,0x80,0x87,0x20,0x64,0x25,0x06,0x00,0x60,0x80,0x47,0x02,0x00, +0x29,0x14,0x0b,0xd0,0x80,0x07,0x00,0x04,0x25,0x12,0x10,0x30,0x80,0x07,0x10,0xc4, +0x29,0x00,0x0a,0xd0,0x80,0xc7,0x02,0x04,0x25,0x04,0x00,0x60,0x80,0x47,0x02,0x00, +0xfd,0x15,0x00,0xa0,0xc8,0x47,0x01,0x0c,0x05,0x04,0x05,0x30,0x80,0x07,0x10,0xc4, +0x01,0x90,0x00,0x30,0x03,0x00,0x00,0x00,0x01,0x00,0x08,0xd0,0xd0,0x07,0x00,0x04, +0x01,0x00,0x00,0xa0,0x80,0x56,0x06,0x44,0x01,0x00,0x17,0x30,0x80,0x16,0x10,0xec, +0x01,0x00,0x00,0x31,0x80,0x56,0x41,0x04,0x01,0x08,0x00,0x10,0x00,0xd1,0x40,0x24, +0x01,0x80,0x1f,0x30,0x03,0x00,0x00,0x00,0x01,0x00,0x01,0xd0,0x80,0x47,0x00,0x04, +0x29,0x00,0x04,0x30,0x80,0x07,0x10,0xc4,0x2d,0xd4,0x00,0x20,0x80,0x87,0x22,0x04, +0x31,0x16,0x0e,0xd0,0x80,0x07,0xc0,0x80,0x29,0xc8,0x00,0x20,0x80,0x47,0x22,0x04, +0x31,0x14,0x0e,0xd0,0x80,0x07,0xc0,0xa0,0x31,0x96,0x04,0x20,0x03,0x00,0x00,0x00, +0x31,0x18,0x0e,0xd0,0x80,0x07,0xc0,0x80,0x35,0x94,0x04,0x20,0x03,0x00,0x00,0x00, +0x31,0x1a,0x0e,0xd0,0x80,0x07,0xc0,0xa0,0x2d,0x96,0x08,0x20,0x03,0x00,0x00,0x00, +0x2d,0x16,0x0e,0xd0,0x80,0x07,0xc0,0x80,0x29,0x94,0x08,0x20,0x03,0x00,0x00,0x00, +0x2d,0x14,0x0e,0xd0,0x80,0x07,0xc0,0xa0,0x03,0x80,0x05,0x10,0x00,0x01,0x00,0x00, +0x01,0x00,0x02,0x30,0x80,0x07,0x10,0xc4,0x01,0xd8,0x00,0x20,0x80,0x07,0x20,0x04, +0x29,0x00,0x0e,0xd0,0x80,0x07,0xc0,0x80,0xfd,0xd3,0x0a,0xb0,0xd8,0xc7,0x20,0x60, +0x03,0x50,0x05,0xa0,0x00,0x00,0x00,0x00,0x03,0xe0,0x04,0x10,0x00,0x11,0x00,0x00, +0x01,0x80,0x3f,0x10,0x0f,0x00,0x00,0x00,0x03,0x50,0x05,0x10,0x80,0x07,0x00,0x00, +0xfd,0x15,0x7c,0xb0,0xd8,0xc7,0x00,0x60,0x01,0xf8,0x00,0x10,0x80,0xd6,0x03,0x04, +0x01,0x12,0x00,0x10,0x00,0xd1,0x00,0x44,0x29,0x14,0x86,0xc0,0x00,0x11,0x40,0x00, +0x01,0x00,0x00,0x90,0x00,0x11,0x00,0x00,0x01,0x14,0x00,0xc0,0x00,0x11,0x00,0x00, +0x01,0x00,0x00,0xa0,0x00,0x51,0x06,0x84,0x29,0x06,0x02,0x30,0x82,0x07,0x10,0xc4, +0x29,0xcc,0x00,0x20,0x80,0x87,0x22,0x04,0x01,0x14,0x0e,0xd0,0x80,0x07,0x00,0xa0, +0x01,0x90,0x3f,0x20,0xff,0xff,0xff,0x0f,0x21,0x10,0x00,0xd0,0xd0,0x07,0x00,0x04, +0x25,0xd0,0x00,0x20,0x80,0x47,0x22,0x04,0x0d,0x86,0x01,0x20,0x03,0x00,0x00,0x00, +0x03,0x00,0x03,0x10,0x80,0x12,0x00,0x00,0x09,0x04,0x00,0x20,0x82,0x47,0x01,0x04, +0xfd,0x09,0x02,0x30,0xc8,0x87,0x01,0x64,0x19,0x0c,0x00,0x20,0x80,0xc7,0x01,0x04, +0x03,0xe0,0x00,0x10,0x80,0x02,0x00,0x00,0x01,0x00,0x00,0xf0,0x01,0x00,0x00,0xe0, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x01,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x28,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x0b,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x68,0x01,0x00,0x00,0x00,0x00,0x00,0x00, +0x64,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x13,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xd0,0x05,0x00,0x00,0x00,0x00,0x00,0x00, +0x20,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x09,0x00,0x00,0x00, +0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x33,0x00,0x00,0x00,0x00,0x00,0x00,0x70,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0x06,0x00,0x00,0x00,0x00,0x00,0x00, +0x9c,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x0a,0x00,0x00,0x00, +0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0xa3,0x00,0x00,0x00,0x00,0x00,0x00,0x70,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x8c,0x07,0x00,0x00,0x00,0x00,0x00,0x00, +0x8c,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x0b,0x00,0x00,0x00, +0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x15,0x01,0x00,0x00,0x09,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x08,0x00,0x00,0x00,0x00,0x00,0x00, +0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x09,0x00,0x00,0x00, +0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x6b,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x28,0x08,0x00,0x00,0x00,0x00,0x00,0x00, +0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0a,0x00,0x00,0x00, +0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0xdb,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x40,0x08,0x00,0x00,0x00,0x00,0x00,0x00, +0x1c,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0b,0x00,0x00,0x00, +0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x06,0x01,0x00,0x00,0x01,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x5c,0x08,0x00,0x00,0x00,0x00,0x00,0x00, +0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x1b,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x06,0x00,0x10,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x60,0x08,0x00,0x00,0x00,0x00,0x00,0x00, +0x78,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x0a,0x00,0x00,0x0d, +0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x8b,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x06,0x00,0x10,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xd8,0x0b,0x00,0x00,0x00,0x00,0x00,0x00, +0x10,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x0b,0x00,0x00,0x0e, +0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x4e,0x00,0x00,0x00,0x08,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xe8,0x0e,0x00,0x00,0x00,0x00,0x00,0x00, +0x54,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0a,0x00,0x00,0x00, +0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0xbe,0x00,0x00,0x00,0x08,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xe8,0x0e,0x00,0x00,0x00,0x00,0x00,0x00, +0x44,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0b,0x00,0x00,0x00, +0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0xfb,0x00,0x00,0x00,0x08,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xe8,0x0e,0x00,0x00,0x00,0x00,0x00,0x00, +0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x06,0x00,0x00,0x00,0x05,0x00,0x00,0x00,0xa8,0x12,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0xa8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xa8,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x05,0x00,0x00,0x00, +0x28,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc0,0x06,0x00,0x00,0x00,0x00,0x00,0x00, +0xc0,0x06,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x01,0x00,0x00,0x00,0x06,0x00,0x00,0x00,0xe8,0x0e,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x54,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x00,0x01,0x01,0x58,0x00,0x00,0x00, +0x80,0x0e,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x07,0x00,0x01,0x00,0x14,0x00,0x00,0x00,0x40,0x00,0x00,0x00,0x12,0x00,0x00,0x00, +0x45,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x52,0x65,0x6e,0x64,0x65,0x72,0x50,0x61, +0x72,0x74,0x69,0x63,0x6c,0x65,0x73,0x2e,0x63,0x75,0x00,0x00,0x00,0x00,0x00,0x00, +0x7f,0x45,0x4c,0x46,0x02,0x01,0x01,0x33,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x02,0x00,0xbe,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0xd8,0x0d,0x00,0x00,0x00,0x00,0x00,0x00,0x98,0x0a,0x00,0x00,0x00,0x00,0x00,0x00, +0x14,0x05,0x14,0x00,0x40,0x00,0x38,0x00,0x03,0x00,0x40,0x00,0x0d,0x00,0x01,0x00, +0x00,0x2e,0x73,0x68,0x73,0x74,0x72,0x74,0x61,0x62,0x00,0x2e,0x73,0x74,0x72,0x74, +0x61,0x62,0x00,0x2e,0x73,0x79,0x6d,0x74,0x61,0x62,0x00,0x2e,0x74,0x65,0x78,0x74, +0x2e,0x75,0x70,0x64,0x61,0x74,0x65,0x49,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x64, +0x56,0x42,0x00,0x2e,0x6e,0x76,0x2e,0x69,0x6e,0x66,0x6f,0x2e,0x75,0x70,0x64,0x61, +0x74,0x65,0x49,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x64,0x56,0x42,0x00,0x2e,0x6e, +0x76,0x2e,0x73,0x68,0x61,0x72,0x65,0x64,0x2e,0x75,0x70,0x64,0x61,0x74,0x65,0x49, +0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x64,0x56,0x42,0x00,0x2e,0x6e,0x76,0x2e,0x69, +0x6e,0x66,0x6f,0x00,0x2e,0x6e,0x76,0x2e,0x63,0x6f,0x6e,0x73,0x74,0x61,0x6e,0x74, +0x30,0x2e,0x75,0x70,0x64,0x61,0x74,0x65,0x49,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65, +0x64,0x56,0x42,0x00,0x2e,0x74,0x65,0x78,0x74,0x2e,0x75,0x70,0x64,0x61,0x74,0x65, +0x42,0x69,0x6c,0x6c,0x62,0x6f,0x61,0x72,0x64,0x56,0x42,0x00,0x2e,0x6e,0x76,0x2e, +0x69,0x6e,0x66,0x6f,0x2e,0x75,0x70,0x64,0x61,0x74,0x65,0x42,0x69,0x6c,0x6c,0x62, +0x6f,0x61,0x72,0x64,0x56,0x42,0x00,0x2e,0x6e,0x76,0x2e,0x73,0x68,0x61,0x72,0x65, +0x64,0x2e,0x75,0x70,0x64,0x61,0x74,0x65,0x42,0x69,0x6c,0x6c,0x62,0x6f,0x61,0x72, +0x64,0x56,0x42,0x00,0x2e,0x6e,0x76,0x2e,0x63,0x6f,0x6e,0x73,0x74,0x61,0x6e,0x74, +0x30,0x2e,0x75,0x70,0x64,0x61,0x74,0x65,0x42,0x69,0x6c,0x6c,0x62,0x6f,0x61,0x72, +0x64,0x56,0x42,0x00,0x00,0x2e,0x73,0x68,0x73,0x74,0x72,0x74,0x61,0x62,0x00,0x2e, +0x73,0x74,0x72,0x74,0x61,0x62,0x00,0x2e,0x73,0x79,0x6d,0x74,0x61,0x62,0x00,0x75, +0x70,0x64,0x61,0x74,0x65,0x49,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x64,0x56,0x42, +0x00,0x2e,0x74,0x65,0x78,0x74,0x2e,0x75,0x70,0x64,0x61,0x74,0x65,0x49,0x6e,0x73, +0x74,0x61,0x6e,0x63,0x65,0x64,0x56,0x42,0x00,0x2e,0x6e,0x76,0x2e,0x69,0x6e,0x66, +0x6f,0x2e,0x75,0x70,0x64,0x61,0x74,0x65,0x49,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65, +0x64,0x56,0x42,0x00,0x2e,0x6e,0x76,0x2e,0x73,0x68,0x61,0x72,0x65,0x64,0x2e,0x75, +0x70,0x64,0x61,0x74,0x65,0x49,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x64,0x56,0x42, +0x00,0x2e,0x6e,0x76,0x2e,0x69,0x6e,0x66,0x6f,0x00,0x5f,0x5a,0x4e,0x35,0x70,0x68, +0x79,0x73,0x78,0x37,0x67,0x4f,0x66,0x66,0x73,0x65,0x74,0x45,0x00,0x2e,0x6e,0x76, +0x2e,0x63,0x6f,0x6e,0x73,0x74,0x61,0x6e,0x74,0x30,0x2e,0x75,0x70,0x64,0x61,0x74, +0x65,0x49,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x64,0x56,0x42,0x00,0x5f,0x70,0x61, +0x72,0x61,0x6d,0x00,0x75,0x70,0x64,0x61,0x74,0x65,0x42,0x69,0x6c,0x6c,0x62,0x6f, +0x61,0x72,0x64,0x56,0x42,0x00,0x2e,0x74,0x65,0x78,0x74,0x2e,0x75,0x70,0x64,0x61, +0x74,0x65,0x42,0x69,0x6c,0x6c,0x62,0x6f,0x61,0x72,0x64,0x56,0x42,0x00,0x2e,0x6e, +0x76,0x2e,0x69,0x6e,0x66,0x6f,0x2e,0x75,0x70,0x64,0x61,0x74,0x65,0x42,0x69,0x6c, +0x6c,0x62,0x6f,0x61,0x72,0x64,0x56,0x42,0x00,0x2e,0x6e,0x76,0x2e,0x73,0x68,0x61, +0x72,0x65,0x64,0x2e,0x75,0x70,0x64,0x61,0x74,0x65,0x42,0x69,0x6c,0x6c,0x62,0x6f, +0x61,0x72,0x64,0x56,0x42,0x00,0x24,0x75,0x70,0x64,0x61,0x74,0x65,0x42,0x69,0x6c, +0x6c,0x62,0x6f,0x61,0x72,0x64,0x56,0x42,0x24,0x5f,0x5a,0x4e,0x35,0x70,0x68,0x79, +0x73,0x78,0x37,0x67,0x4f,0x66,0x66,0x73,0x65,0x74,0x45,0x00,0x2e,0x6e,0x76,0x2e, +0x63,0x6f,0x6e,0x73,0x74,0x61,0x6e,0x74,0x30,0x2e,0x75,0x70,0x64,0x61,0x74,0x65, +0x42,0x69,0x6c,0x6c,0x62,0x6f,0x61,0x72,0x64,0x56,0x42,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x2d,0x00,0x00,0x00,0x03,0x00,0x09,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x60,0x00,0x00,0x00,0x03,0x00,0x0b,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x99,0x00,0x00,0x00,0x03,0x00,0x07,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0xd2,0x00,0x00,0x00,0x03,0x00,0x0a,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x05,0x01,0x00,0x00,0x03,0x00,0x0c,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x48,0x01,0x00,0x00,0x03,0x00,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1b,0x00,0x00,0x00,0x12,0x10,0x09,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x78,0x02,0x00,0x00,0x00,0x00,0x00,0x00, +0xc0,0x00,0x00,0x00,0x12,0x10,0x0a,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x70,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x0a,0x08,0x00,0x03,0x00,0x00,0x00, +0x20,0x00,0x44,0x00,0x03,0x19,0x44,0x00,0x04,0x17,0x0c,0x00,0x00,0x00,0x00,0x00, +0x08,0x00,0x40,0x00,0x00,0xf0,0x11,0x00,0x04,0x17,0x0c,0x00,0x00,0x00,0x00,0x00, +0x07,0x00,0x38,0x00,0x00,0xf0,0x21,0x00,0x04,0x17,0x0c,0x00,0x00,0x00,0x00,0x00, +0x06,0x00,0x30,0x00,0x00,0xf0,0x21,0x00,0x04,0x17,0x0c,0x00,0x00,0x00,0x00,0x00, +0x05,0x00,0x28,0x00,0x00,0xf0,0x21,0x00,0x04,0x17,0x0c,0x00,0x00,0x00,0x00,0x00, +0x04,0x00,0x20,0x00,0x00,0xf0,0x11,0x00,0x04,0x17,0x0c,0x00,0x00,0x00,0x00,0x00, +0x03,0x00,0x18,0x00,0x00,0xf0,0x21,0x00,0x04,0x17,0x0c,0x00,0x00,0x00,0x00,0x00, +0x02,0x00,0x10,0x00,0x00,0xf0,0x21,0x00,0x04,0x17,0x0c,0x00,0x00,0x00,0x00,0x00, +0x01,0x00,0x08,0x00,0x00,0xf0,0x21,0x00,0x04,0x17,0x0c,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0xf0,0x21,0x00,0x04,0x1e,0x04,0x00,0x8c,0x01,0x00,0x00, +0x04,0x12,0x08,0x00,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x11,0x08,0x00, +0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x12,0x08,0x00,0x07,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x04,0x11,0x08,0x00,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x04,0x0a,0x08,0x00,0x06,0x00,0x00,0x00,0x20,0x00,0x34,0x00,0x03,0x19,0x34,0x00, +0x04,0x17,0x0c,0x00,0x00,0x00,0x00,0x00,0x07,0x00,0x30,0x00,0x00,0xf0,0x11,0x00, +0x04,0x17,0x0c,0x00,0x00,0x00,0x00,0x00,0x06,0x00,0x28,0x00,0x00,0xf0,0x21,0x00, +0x04,0x17,0x0c,0x00,0x00,0x00,0x00,0x00,0x05,0x00,0x20,0x00,0x00,0xf0,0x21,0x00, +0x04,0x17,0x0c,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x18,0x00,0x00,0xf0,0x21,0x00, +0x04,0x17,0x0c,0x00,0x00,0x00,0x00,0x00,0x03,0x00,0x14,0x00,0x00,0xf0,0x11,0x00, +0x04,0x17,0x0c,0x00,0x00,0x00,0x00,0x00,0x02,0x00,0x10,0x00,0x00,0xf0,0x11,0x00, +0x04,0x17,0x0c,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x08,0x00,0x00,0xf0,0x21,0x00, +0x04,0x17,0x0c,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0x21,0x00, +0x04,0x1e,0x04,0x00,0x8c,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0xe4,0x5d,0x00,0x00,0x04,0x44,0x00,0x28,0x04,0xdc,0x02,0x84,0x00,0x00,0x00,0x2c, +0x03,0xdc,0x1f,0xfc,0x00,0x00,0x7e,0x20,0x23,0xdc,0xb1,0xfc,0x00,0x00,0x8e,0x1a, +0x85,0xe0,0xff,0x03,0x00,0x00,0x00,0xc9,0x04,0xdc,0xff,0xff,0x00,0x00,0xee,0x50, +0x23,0xdc,0xf1,0x83,0x01,0x40,0x0e,0x19,0xe7,0x01,0x00,0x00,0x00,0x00,0x00,0x80, +0xe4,0x1d,0x00,0x80,0x01,0x40,0x00,0x28,0x03,0x5c,0x03,0x14,0x00,0xc0,0x00,0x58, +0x03,0xdc,0xb1,0x34,0x00,0x00,0x0e,0x1a,0xe7,0x01,0x00,0x00,0x00,0x00,0x00,0x80, +0xe2,0x9d,0x03,0x10,0x00,0x00,0x00,0x18,0x03,0x9c,0xb0,0x60,0x01,0x80,0x1d,0x20, +0x03,0x1c,0xb3,0x14,0x00,0xc0,0x00,0x60,0x07,0x00,0x00,0x00,0x01,0x00,0x00,0x60, +0x43,0xdc,0xb0,0x70,0x01,0x80,0x9c,0x20,0x85,0x9c,0x22,0x00,0x00,0x00,0x00,0x84, +0x04,0x9c,0xa0,0x28,0x00,0x00,0x00,0x54,0x85,0x1c,0xf0,0x03,0x00,0x00,0x00,0xc4, +0x03,0xc0,0x00,0x08,0x00,0x00,0x00,0x48,0x85,0xc0,0xf0,0x03,0x00,0x00,0x00,0xcc, +0xe7,0x21,0x00,0x80,0xff,0xff,0x03,0x40,0x33,0xdc,0xa1,0xfc,0x00,0x00,0x0e,0x19, +0x07,0x00,0x00,0x60,0x06,0x00,0x00,0x60,0xe7,0x01,0x00,0x20,0x06,0x00,0x00,0x40, +0xe4,0xdd,0x03,0x00,0x01,0x40,0x00,0x28,0xe2,0x1d,0x04,0x90,0x00,0x00,0x00,0x18, +0xe2,0x5d,0x04,0x40,0x00,0x00,0x00,0x18,0x03,0xdc,0xff,0xfc,0x00,0x00,0x7e,0x20, +0x84,0x9f,0x20,0x29,0x00,0x00,0x00,0x1c,0x03,0x9c,0xa0,0x08,0x00,0x00,0x00,0x68, +0x03,0x9c,0x00,0x08,0x00,0x00,0x00,0x78,0x43,0xdc,0x21,0x30,0x00,0x00,0x00,0x68, +0x03,0x9c,0x70,0x40,0x01,0x80,0x21,0x20,0x43,0xdc,0x70,0x50,0x01,0x80,0xa0,0x20, +0xa3,0x1c,0x01,0xa0,0x00,0x80,0x1f,0x20,0x85,0x1c,0x22,0x00,0x00,0x00,0x00,0x84, +0x43,0x5c,0xf1,0xb3,0x00,0x40,0x00,0x48,0x85,0x1c,0x42,0x00,0x00,0x00,0x00,0x94, +0x85,0x9c,0x21,0x10,0x00,0x00,0x00,0x84,0xa3,0x1c,0x02,0xc0,0x00,0x80,0x1f,0x20, +0x43,0x5c,0xf2,0xd3,0x00,0x40,0x00,0x48,0x85,0x9c,0x41,0x10,0x00,0x00,0x00,0x94, +0x85,0x9c,0x24,0x20,0x00,0x00,0x00,0x84,0x85,0x9c,0x44,0x20,0x00,0x00,0x00,0x94, +0x85,0x9c,0x21,0x30,0x00,0x00,0x00,0x84,0x85,0x9c,0x81,0x00,0x00,0x00,0x00,0x94, +0x85,0x1c,0x21,0x40,0x00,0x00,0x00,0x84,0x85,0x1c,0x81,0x10,0x00,0x00,0x00,0x94, +0x85,0x9c,0x24,0x50,0x00,0x00,0x00,0x84,0xa3,0x1c,0x01,0xe0,0x00,0x80,0x1f,0x20, +0x43,0x5c,0xf1,0xf3,0x00,0x40,0x00,0x48,0x85,0x9c,0x84,0x20,0x00,0x00,0x00,0x94, +0x85,0x9c,0x21,0x60,0x00,0x00,0x00,0x84,0x85,0x9c,0x41,0x00,0x00,0x00,0x00,0x94, +0x85,0x1c,0x22,0x70,0x00,0x00,0x00,0x84,0x03,0x9c,0x71,0x20,0x01,0x80,0x23,0x20, +0x43,0xdc,0x71,0x30,0x01,0x80,0xa2,0x20,0x85,0x1c,0x42,0x10,0x00,0x00,0x00,0x94, +0x85,0x5c,0x22,0x80,0x00,0x00,0x00,0x84,0xa3,0x9c,0x00,0x80,0x00,0x80,0x1f,0x20, +0x03,0x1c,0x00,0x04,0x00,0xc0,0x00,0x48,0x43,0xdc,0xf0,0x93,0x00,0x40,0x00,0x48, +0x85,0x5c,0x42,0x20,0x00,0x00,0x00,0x94,0x85,0x1c,0x62,0x00,0x00,0x00,0x00,0x84, +0x85,0x1c,0x22,0x00,0x00,0x00,0x00,0x94,0x85,0x5c,0x61,0x10,0x00,0x00,0x00,0x84, +0x03,0x1c,0xa2,0xfc,0xff,0xff,0x00,0x48,0x03,0x9c,0x82,0x28,0x00,0x00,0x00,0x68, +0x23,0xdc,0xa1,0xfc,0x00,0x00,0x8e,0x1a,0x85,0x5c,0x21,0x10,0x00,0x00,0x00,0x94, +0x85,0x1c,0x61,0x20,0x00,0x00,0x00,0x84,0x85,0x1c,0x21,0x20,0x00,0x00,0x00,0x94, +0xe7,0x01,0x00,0x60,0xfa,0xff,0x03,0x40,0x13,0xdc,0xb2,0x20,0x00,0x40,0x00,0x48, +0x03,0xdc,0xb1,0x34,0x00,0x00,0x8e,0x19,0xe7,0x01,0x00,0xe0,0xf7,0xff,0x03,0x40, +0xe7,0x1d,0x00,0x00,0x00,0x00,0x00,0x80,0xe4,0x5d,0x00,0x00,0x04,0x44,0x00,0x28, +0x04,0x1c,0x00,0x84,0x00,0x00,0x00,0x2c,0x03,0xdc,0x1f,0xfc,0x00,0x00,0x7e,0x20, +0x23,0xdc,0x01,0xfc,0x00,0x00,0x8e,0x1a,0x85,0xe0,0xff,0x03,0x00,0x00,0x00,0xc9, +0x04,0xdc,0xff,0xff,0x00,0x00,0xee,0x50,0x23,0xdc,0xf1,0x43,0x01,0x40,0x0e,0x19, +0xe7,0x01,0x00,0x00,0x00,0x00,0x00,0x80,0xe4,0x9d,0x00,0x40,0x01,0x40,0x00,0x28, +0x03,0x5c,0x22,0x14,0x00,0xc0,0x00,0x58,0x03,0xdc,0x01,0x24,0x00,0x00,0x0e,0x1a, +0xe7,0x01,0x00,0x00,0x00,0x00,0x00,0x80,0xe2,0x9d,0x02,0x10,0x00,0x00,0x00,0x18, +0x03,0x9c,0x00,0x20,0x01,0x80,0x15,0x20,0x03,0x9c,0x01,0x14,0x00,0xc0,0x00,0x60, +0x07,0x00,0x00,0x00,0x01,0x00,0x00,0x60,0x43,0xdc,0x00,0x30,0x01,0x80,0x94,0x20, +0x85,0x1c,0x22,0x00,0x00,0x00,0x00,0x84,0x04,0x9c,0x80,0x20,0x00,0x00,0x00,0x54, +0x85,0xdc,0xf1,0x03,0x00,0x00,0x00,0xc4,0x03,0xc0,0x70,0x08,0x00,0x00,0x00,0x48, +0x85,0xc0,0xf0,0x03,0x00,0x00,0x00,0xcc,0xe7,0x21,0x00,0x80,0xff,0xff,0x03,0x40, +0x33,0xdc,0x81,0xfc,0x00,0x00,0x0e,0x19,0x07,0x00,0x00,0x40,0x06,0x00,0x00,0x60, +0xe7,0x01,0x00,0x00,0x06,0x00,0x00,0x40,0xe4,0x5d,0x03,0x80,0x00,0x40,0x00,0x28, +0xe4,0x1d,0x03,0x10,0x01,0x40,0x00,0x28,0xe2,0xdd,0x02,0x40,0x00,0x00,0x00,0x18, +0x03,0xdc,0xcf,0x34,0x00,0x00,0x7e,0x20,0x84,0x9f,0x20,0x21,0x00,0x00,0x00,0x1c, +0x03,0x9c,0x80,0x08,0x00,0x00,0x00,0x68,0x03,0x9c,0x00,0x08,0x00,0x00,0x00,0x78, +0x43,0x1c,0x24,0x18,0x00,0x00,0x00,0x68,0x03,0x1c,0x01,0xe1,0x00,0x80,0x17,0x20, +0x43,0x5c,0x01,0xf1,0x00,0x80,0x96,0x20,0xa3,0x9c,0x70,0xc0,0x00,0x40,0x1b,0x20, +0x85,0xdc,0x43,0x00,0x00,0x00,0x00,0x84,0x43,0xdc,0xf0,0x93,0x00,0x40,0x00,0x48, +0x03,0xde,0xff,0x03,0x01,0x40,0x01,0x48,0x63,0xdc,0xc1,0xfc,0x00,0x00,0x0e,0x19, +0x85,0xdc,0x23,0x00,0x00,0x00,0x00,0x94,0x85,0x9c,0x43,0x10,0x00,0x00,0x00,0x84, +0x85,0x9c,0x23,0x10,0x00,0x00,0x00,0x94,0x85,0x1c,0x41,0x20,0x00,0x00,0x00,0x84, +0x85,0x1c,0x21,0x20,0x00,0x00,0x00,0x94,0xe7,0x01,0x00,0xc0,0x02,0x00,0x00,0x40, +0xe2,0xdd,0x00,0x10,0x00,0x00,0x00,0x18,0x07,0x00,0x00,0x20,0x02,0x00,0x00,0x60, +0x03,0x9c,0x00,0x01,0x01,0x80,0x07,0x20,0x43,0xdc,0x00,0x11,0x01,0x80,0x86,0x20, +0x85,0x9c,0x20,0x00,0x00,0x00,0x00,0x84,0x00,0xdc,0x21,0xd0,0x00,0x40,0x8e,0x2c, +0xe7,0x01,0x00,0x40,0x00,0x00,0x00,0x40,0xe2,0x1d,0x01,0xfc,0x03,0x00,0x00,0x18, +0xe7,0x1d,0x00,0x20,0x01,0x00,0x00,0x40,0x00,0xdc,0x21,0xfc,0x00,0x00,0x0e,0x2e, +0xe4,0x21,0x01,0xfc,0x00,0x00,0x00,0x28,0xe7,0xa1,0x00,0xc0,0x00,0x00,0x00,0x40, +0xe4,0xc1,0x00,0xd0,0x00,0x40,0x00,0x28,0x40,0x80,0x20,0xc0,0xdf,0xd0,0x00,0x58, +0x00,0xc0,0x30,0x10,0x00,0x00,0x00,0xc8,0x40,0x80,0x20,0x0c,0x00,0x00,0x00,0x58, +0x04,0x80,0x20,0x09,0x00,0x00,0x86,0x14,0x84,0x00,0x91,0x08,0x00,0x00,0x00,0x1c, +0xf4,0x9d,0x00,0xa0,0x00,0x40,0x00,0x28,0x03,0x9c,0x70,0x10,0x00,0xc0,0x05,0x20, +0x43,0xdc,0xf0,0xb3,0x00,0x40,0x00,0x48,0x05,0x1c,0x21,0x00,0x00,0x00,0x00,0x94, +0x03,0x9c,0x80,0xfc,0xff,0xff,0x00,0x48,0x03,0xdc,0x71,0x04,0x00,0xc0,0x00,0x48, +0x03,0x1c,0x22,0x20,0x00,0x00,0x00,0x68,0x23,0xdc,0x81,0xfc,0x00,0x00,0x8e,0x1a, +0xe7,0x01,0x00,0x80,0xfa,0xff,0x03,0x40,0x13,0x1c,0x00,0x20,0x00,0x40,0x00,0x48, +0x03,0xdc,0x01,0x24,0x00,0x00,0x8e,0x19,0xe7,0x01,0x00,0x00,0xf8,0xff,0x03,0x40, +0xe7,0x1d,0x00,0x00,0x00,0x00,0x00,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x03,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x01,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0b,0x00,0x00,0x00,0x03,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x44,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x68,0x01,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x13,0x00,0x00,0x00,0x02,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0xb0,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0xd8,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x02,0x00,0x00,0x00,0x06,0x00,0x00,0x00,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x33,0x00,0x00,0x00,0x00,0x00,0x00,0x70, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x88,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0xa8,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x03,0x00,0x00,0x00,0x09,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x6b,0x00,0x00,0x00,0x00,0x00,0x00,0x70, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x30,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xac,0x00,0x00,0x00,0x00,0x00,0x00,0x70, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x60,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x98,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x03,0x00,0x00,0x00,0x0a,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x74,0x00,0x00,0x00,0x01,0x00,0x00,0x00, +0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0xf8,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x64,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x09,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xe4,0x00,0x00,0x00,0x01,0x00,0x00,0x00, +0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x5c,0x05,0x00,0x00,0x00,0x00,0x00,0x00,0x54,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x0a,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1b,0x00,0x00,0x00,0x01,0x00,0x00,0x00, +0x06,0x00,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0xb0,0x05,0x00,0x00,0x00,0x00,0x00,0x00,0x78,0x02,0x00,0x00,0x00,0x00,0x00,0x00, +0x03,0x00,0x00,0x00,0x07,0x00,0x00,0x13,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x94,0x00,0x00,0x00,0x01,0x00,0x00,0x00, +0x06,0x00,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x28,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x70,0x02,0x00,0x00,0x00,0x00,0x00,0x00, +0x03,0x00,0x00,0x00,0x08,0x00,0x00,0x11,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x4e,0x00,0x00,0x00,0x08,0x00,0x00,0x00, +0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x98,0x0a,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x09,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc7,0x00,0x00,0x00,0x08,0x00,0x00,0x00, +0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x98,0x0a,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x0a,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x06,0x00,0x00,0x00,0x05,0x00,0x00,0x00, +0xd8,0x0d,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xa8,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0xa8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x01,0x00,0x00,0x00,0x05,0x00,0x00,0x00,0xf8,0x04,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0xa0,0x05,0x00,0x00,0x00,0x00,0x00,0x00,0xa0,0x05,0x00,0x00,0x00,0x00,0x00,0x00, +0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x06,0x00,0x00,0x00, +0x98,0x0a,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x02,0x00,0x01,0x01,0x58,0x00,0x00,0x00,0xe8,0x11,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0x00,0x01,0x00,0x1e,0x00,0x00,0x00, +0x40,0x00,0x00,0x00,0x12,0x00,0x00,0x00,0x45,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x52,0x65,0x6e,0x64,0x65,0x72,0x50,0x61,0x72,0x74,0x69,0x63,0x6c,0x65,0x73,0x2e, +0x63,0x75,0x00,0x00,0x00,0x00,0x00,0x00,0x7f,0x45,0x4c,0x46,0x02,0x01,0x01,0x33, +0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x00,0xbe,0x00,0x01,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x40,0x11,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x0e,0x00,0x00,0x00,0x00,0x00,0x00,0x1e,0x05,0x1e,0x00,0x40,0x00,0x38,0x00, +0x03,0x00,0x40,0x00,0x0d,0x00,0x01,0x00,0x00,0x2e,0x73,0x68,0x73,0x74,0x72,0x74, +0x61,0x62,0x00,0x2e,0x73,0x74,0x72,0x74,0x61,0x62,0x00,0x2e,0x73,0x79,0x6d,0x74, +0x61,0x62,0x00,0x2e,0x74,0x65,0x78,0x74,0x2e,0x75,0x70,0x64,0x61,0x74,0x65,0x49, +0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x64,0x56,0x42,0x00,0x2e,0x6e,0x76,0x2e,0x69, +0x6e,0x66,0x6f,0x2e,0x75,0x70,0x64,0x61,0x74,0x65,0x49,0x6e,0x73,0x74,0x61,0x6e, +0x63,0x65,0x64,0x56,0x42,0x00,0x2e,0x6e,0x76,0x2e,0x73,0x68,0x61,0x72,0x65,0x64, +0x2e,0x75,0x70,0x64,0x61,0x74,0x65,0x49,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x64, +0x56,0x42,0x00,0x2e,0x6e,0x76,0x2e,0x69,0x6e,0x66,0x6f,0x00,0x2e,0x6e,0x76,0x2e, +0x63,0x6f,0x6e,0x73,0x74,0x61,0x6e,0x74,0x30,0x2e,0x75,0x70,0x64,0x61,0x74,0x65, +0x49,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x64,0x56,0x42,0x00,0x2e,0x74,0x65,0x78, +0x74,0x2e,0x75,0x70,0x64,0x61,0x74,0x65,0x42,0x69,0x6c,0x6c,0x62,0x6f,0x61,0x72, +0x64,0x56,0x42,0x00,0x2e,0x6e,0x76,0x2e,0x69,0x6e,0x66,0x6f,0x2e,0x75,0x70,0x64, +0x61,0x74,0x65,0x42,0x69,0x6c,0x6c,0x62,0x6f,0x61,0x72,0x64,0x56,0x42,0x00,0x2e, +0x6e,0x76,0x2e,0x73,0x68,0x61,0x72,0x65,0x64,0x2e,0x75,0x70,0x64,0x61,0x74,0x65, +0x42,0x69,0x6c,0x6c,0x62,0x6f,0x61,0x72,0x64,0x56,0x42,0x00,0x2e,0x6e,0x76,0x2e, +0x63,0x6f,0x6e,0x73,0x74,0x61,0x6e,0x74,0x30,0x2e,0x75,0x70,0x64,0x61,0x74,0x65, +0x42,0x69,0x6c,0x6c,0x62,0x6f,0x61,0x72,0x64,0x56,0x42,0x00,0x00,0x2e,0x73,0x68, +0x73,0x74,0x72,0x74,0x61,0x62,0x00,0x2e,0x73,0x74,0x72,0x74,0x61,0x62,0x00,0x2e, +0x73,0x79,0x6d,0x74,0x61,0x62,0x00,0x75,0x70,0x64,0x61,0x74,0x65,0x49,0x6e,0x73, +0x74,0x61,0x6e,0x63,0x65,0x64,0x56,0x42,0x00,0x2e,0x74,0x65,0x78,0x74,0x2e,0x75, +0x70,0x64,0x61,0x74,0x65,0x49,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x64,0x56,0x42, +0x00,0x2e,0x6e,0x76,0x2e,0x69,0x6e,0x66,0x6f,0x2e,0x75,0x70,0x64,0x61,0x74,0x65, +0x49,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x64,0x56,0x42,0x00,0x2e,0x6e,0x76,0x2e, +0x73,0x68,0x61,0x72,0x65,0x64,0x2e,0x75,0x70,0x64,0x61,0x74,0x65,0x49,0x6e,0x73, +0x74,0x61,0x6e,0x63,0x65,0x64,0x56,0x42,0x00,0x2e,0x6e,0x76,0x2e,0x69,0x6e,0x66, +0x6f,0x00,0x5f,0x5a,0x4e,0x35,0x70,0x68,0x79,0x73,0x78,0x37,0x67,0x4f,0x66,0x66, +0x73,0x65,0x74,0x45,0x00,0x2e,0x6e,0x76,0x2e,0x63,0x6f,0x6e,0x73,0x74,0x61,0x6e, +0x74,0x30,0x2e,0x75,0x70,0x64,0x61,0x74,0x65,0x49,0x6e,0x73,0x74,0x61,0x6e,0x63, +0x65,0x64,0x56,0x42,0x00,0x5f,0x70,0x61,0x72,0x61,0x6d,0x00,0x75,0x70,0x64,0x61, +0x74,0x65,0x42,0x69,0x6c,0x6c,0x62,0x6f,0x61,0x72,0x64,0x56,0x42,0x00,0x2e,0x74, +0x65,0x78,0x74,0x2e,0x75,0x70,0x64,0x61,0x74,0x65,0x42,0x69,0x6c,0x6c,0x62,0x6f, +0x61,0x72,0x64,0x56,0x42,0x00,0x2e,0x6e,0x76,0x2e,0x69,0x6e,0x66,0x6f,0x2e,0x75, +0x70,0x64,0x61,0x74,0x65,0x42,0x69,0x6c,0x6c,0x62,0x6f,0x61,0x72,0x64,0x56,0x42, +0x00,0x2e,0x6e,0x76,0x2e,0x73,0x68,0x61,0x72,0x65,0x64,0x2e,0x75,0x70,0x64,0x61, +0x74,0x65,0x42,0x69,0x6c,0x6c,0x62,0x6f,0x61,0x72,0x64,0x56,0x42,0x00,0x24,0x75, +0x70,0x64,0x61,0x74,0x65,0x42,0x69,0x6c,0x6c,0x62,0x6f,0x61,0x72,0x64,0x56,0x42, +0x24,0x5f,0x5a,0x4e,0x35,0x70,0x68,0x79,0x73,0x78,0x37,0x67,0x4f,0x66,0x66,0x73, +0x65,0x74,0x45,0x00,0x2e,0x6e,0x76,0x2e,0x63,0x6f,0x6e,0x73,0x74,0x61,0x6e,0x74, +0x30,0x2e,0x75,0x70,0x64,0x61,0x74,0x65,0x42,0x69,0x6c,0x6c,0x62,0x6f,0x61,0x72, +0x64,0x56,0x42,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x2d,0x00,0x00,0x00,0x03,0x00,0x09,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x60,0x00,0x00,0x00,0x03,0x00,0x0b,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x99,0x00,0x00,0x00,0x03,0x00,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xd2,0x00,0x00,0x00,0x03,0x00,0x0a,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x05,0x01,0x00,0x00,0x03,0x00,0x0c,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x48,0x01,0x00,0x00,0x03,0x00,0x08,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x1b,0x00,0x00,0x00,0x12,0x10,0x09,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0xc0,0x00,0x00,0x00,0x12,0x10,0x0a,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x00,0x00,0x00, +0x04,0x0a,0x08,0x00,0x03,0x00,0x00,0x00,0x40,0x01,0x44,0x00,0x03,0x19,0x44,0x00, +0x04,0x17,0x0c,0x00,0x00,0x00,0x00,0x00,0x08,0x00,0x40,0x00,0x00,0xf0,0x11,0x00, +0x04,0x17,0x0c,0x00,0x00,0x00,0x00,0x00,0x07,0x00,0x38,0x00,0x00,0xf0,0x21,0x00, +0x04,0x17,0x0c,0x00,0x00,0x00,0x00,0x00,0x06,0x00,0x30,0x00,0x00,0xf0,0x21,0x00, +0x04,0x17,0x0c,0x00,0x00,0x00,0x00,0x00,0x05,0x00,0x28,0x00,0x00,0xf0,0x21,0x00, +0x04,0x17,0x0c,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x20,0x00,0x00,0xf0,0x11,0x00, +0x04,0x17,0x0c,0x00,0x00,0x00,0x00,0x00,0x03,0x00,0x18,0x00,0x00,0xf0,0x21,0x00, +0x04,0x17,0x0c,0x00,0x00,0x00,0x00,0x00,0x02,0x00,0x10,0x00,0x00,0xf0,0x21,0x00, +0x04,0x17,0x0c,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x08,0x00,0x00,0xf0,0x21,0x00, +0x04,0x17,0x0c,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0x21,0x00, +0x04,0x1e,0x04,0x00,0x10,0x02,0x00,0x00,0x04,0x12,0x08,0x00,0x08,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x04,0x11,0x08,0x00,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x04,0x12,0x08,0x00,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x11,0x08,0x00, +0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x0a,0x08,0x00,0x06,0x00,0x00,0x00, +0x40,0x01,0x34,0x00,0x03,0x19,0x34,0x00,0x04,0x17,0x0c,0x00,0x00,0x00,0x00,0x00, +0x07,0x00,0x30,0x00,0x00,0xf0,0x11,0x00,0x04,0x17,0x0c,0x00,0x00,0x00,0x00,0x00, +0x06,0x00,0x28,0x00,0x00,0xf0,0x21,0x00,0x04,0x17,0x0c,0x00,0x00,0x00,0x00,0x00, +0x05,0x00,0x20,0x00,0x00,0xf0,0x21,0x00,0x04,0x17,0x0c,0x00,0x00,0x00,0x00,0x00, +0x04,0x00,0x18,0x00,0x00,0xf0,0x21,0x00,0x04,0x17,0x0c,0x00,0x00,0x00,0x00,0x00, +0x03,0x00,0x14,0x00,0x00,0xf0,0x11,0x00,0x04,0x17,0x0c,0x00,0x00,0x00,0x00,0x00, +0x02,0x00,0x10,0x00,0x00,0xf0,0x11,0x00,0x04,0x17,0x0c,0x00,0x00,0x00,0x00,0x00, +0x01,0x00,0x08,0x00,0x00,0xf0,0x21,0x00,0x04,0x17,0x0c,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0xf0,0x21,0x00,0x04,0x1e,0x04,0x00,0x10,0x02,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf7,0x82,0xc2,0xe2,0x12,0xc3,0xe2,0x22, +0xe4,0x5d,0x00,0x10,0x01,0x40,0x00,0x28,0x04,0x1c,0x00,0x84,0x00,0x00,0x00,0x2c, +0x23,0xdc,0x01,0xfc,0x00,0x00,0x8e,0x1a,0x85,0xe0,0xff,0x03,0x00,0x00,0x00,0xc9, +0x04,0x1c,0x00,0x00,0x00,0xc0,0x0e,0x50,0x23,0xdc,0xf1,0x03,0x06,0x40,0x0e,0x19, +0xe7,0x01,0x00,0x00,0x00,0x00,0x00,0x80,0x87,0x82,0xc2,0xe2,0x02,0x40,0xc0,0x22, +0xe4,0x9d,0x00,0x00,0x06,0x40,0x00,0x28,0x03,0x5c,0x22,0x14,0x00,0xc0,0x00,0x58, +0x03,0xdc,0x01,0x24,0x00,0x00,0x0e,0x1a,0xe7,0x01,0x00,0x00,0x00,0x00,0x00,0x80, +0xe2,0xdd,0x02,0x10,0x00,0x00,0x00,0x18,0x03,0x1c,0x01,0xe0,0x05,0x80,0x17,0x20, +0x07,0x00,0x00,0x80,0x01,0x00,0x00,0x60,0x47,0x80,0x42,0x70,0x03,0xb0,0x83,0x22, +0x43,0x5c,0x01,0xf0,0x05,0x80,0x96,0x20,0x04,0xdc,0xf3,0x1c,0x00,0x00,0x0e,0x0c, +0x85,0x1c,0x42,0x00,0x00,0x00,0x00,0x84,0x03,0x9c,0x01,0x14,0x00,0xc0,0x00,0x60, +0x04,0x9c,0x80,0x20,0x00,0x00,0x00,0x54,0x85,0xdc,0xf1,0x03,0x00,0x00,0x00,0xa8, +0x03,0xc0,0x70,0x08,0x00,0x00,0x00,0x48,0xb7,0xe3,0x02,0x40,0x02,0x40,0x00,0x22, +0x85,0xc1,0xf0,0x03,0x00,0x00,0x00,0xb8,0xe7,0x25,0x00,0x60,0xff,0xff,0x03,0x40, +0x33,0xdc,0x81,0xfc,0x00,0x00,0x0e,0x19,0x07,0x00,0x00,0x20,0x07,0x00,0x00,0x60, +0xe7,0x01,0x00,0xe0,0x06,0x00,0x00,0x40,0xe4,0x9d,0x02,0x80,0x05,0x40,0x00,0x28, +0xe2,0x1d,0x03,0x90,0x00,0x00,0x00,0x18,0xe7,0x82,0x82,0x82,0x82,0xc2,0x82,0x22, +0xe2,0x5d,0x03,0x40,0x00,0x00,0x00,0x18,0x84,0xdf,0x20,0x21,0x00,0x00,0x00,0x1c, +0x03,0x9c,0x80,0x0c,0x00,0x00,0x00,0x68,0x03,0x9c,0x00,0x08,0x00,0x00,0x00,0x78, +0x43,0x9c,0x24,0x18,0x00,0x00,0x00,0x68,0x03,0x9c,0x20,0xc1,0x05,0x80,0x19,0x20, +0x43,0xdc,0x20,0xd1,0x05,0x80,0x98,0x20,0x07,0xc2,0x92,0xe2,0x72,0xe3,0x02,0x22, +0x85,0xdc,0x23,0x00,0x00,0x00,0x00,0x84,0xa3,0x1c,0x71,0x20,0x05,0x80,0x15,0x20, +0x43,0x5c,0xf1,0x33,0x05,0x40,0x00,0x48,0x85,0xdc,0x43,0x00,0x00,0x00,0x00,0x94, +0x85,0x9c,0x23,0x10,0x00,0x00,0x00,0x84,0x85,0x9c,0x43,0x10,0x00,0x00,0x00,0x94, +0x85,0x5c,0x24,0x20,0x00,0x00,0x00,0x84,0x67,0x43,0xe0,0x72,0xe3,0x72,0xe3,0x22, +0xa3,0x9c,0x73,0x40,0x05,0x80,0x15,0x20,0x85,0x5c,0x44,0x20,0x00,0x00,0x00,0x94, +0x43,0xdc,0xf3,0x53,0x05,0x40,0x00,0x48,0x85,0x1c,0x24,0x30,0x00,0x00,0x00,0x84, +0x85,0x1c,0xe4,0x00,0x00,0x00,0x00,0x94,0x85,0x1c,0x21,0x40,0x00,0x00,0x00,0x84, +0x85,0x1c,0xe1,0x10,0x00,0x00,0x00,0x94,0x07,0x62,0x43,0xe0,0x72,0xe3,0x72,0x23, +0x85,0x5c,0x24,0x50,0x00,0x00,0x00,0x84,0xa3,0x1c,0x71,0x60,0x05,0x80,0x15,0x20, +0x85,0x5c,0xe4,0x20,0x00,0x00,0x00,0x94,0x43,0x5c,0xf1,0x73,0x05,0x40,0x00,0x48, +0x85,0x1c,0x24,0x60,0x00,0x00,0x00,0x84,0x85,0x1c,0x44,0x00,0x00,0x00,0x00,0x94, +0x85,0xdc,0x23,0x70,0x00,0x00,0x00,0x84,0x47,0xe0,0x02,0xd2,0x82,0xe2,0x02,0x22, +0x03,0x9c,0x23,0xa1,0x05,0x80,0x1b,0x20,0x85,0xdc,0x43,0x10,0x00,0x00,0x00,0x94, +0x85,0x5c,0x24,0x80,0x00,0x00,0x00,0x84,0x43,0xdc,0x23,0xb1,0x05,0x80,0x9a,0x20, +0xa3,0x9c,0x70,0x00,0x05,0x80,0x15,0x20,0x85,0x5c,0x44,0x20,0x00,0x00,0x00,0x94, +0x85,0x1c,0xe4,0x00,0x00,0x00,0x00,0x84,0x47,0x60,0x43,0xe0,0x42,0x80,0xe2,0x22, +0x43,0xdc,0xf0,0x13,0x05,0x40,0x00,0x48,0x03,0x5c,0x84,0xfc,0xff,0xff,0x00,0x48, +0x03,0xdc,0x71,0x04,0x00,0xc0,0x00,0x48,0x85,0x1c,0x24,0x00,0x00,0x00,0x00,0x94, +0x03,0x1c,0x12,0x21,0x00,0x00,0x00,0x68,0x85,0x5c,0xe1,0x10,0x00,0x00,0x00,0x84, +0x23,0xdc,0x81,0xfc,0x00,0x00,0x8e,0x1a,0xe7,0x72,0x43,0xe0,0xf2,0xc2,0xe2,0x22, +0x85,0x5c,0x21,0x10,0x00,0x00,0x00,0x94,0x85,0x1c,0xe1,0x20,0x00,0x00,0x00,0x84, +0x85,0x1c,0x21,0x20,0x00,0x00,0x00,0x94,0xe7,0x01,0x00,0xa0,0xf9,0xff,0x03,0x40, +0x13,0x1c,0x00,0xa0,0x00,0x40,0x00,0x48,0x03,0xdc,0x01,0x24,0x00,0x00,0x8e,0x19, +0xe7,0x01,0x00,0xc0,0xf6,0xff,0x03,0x40,0xe7,0x02,0x00,0x00,0x00,0x00,0x00,0x20, +0xe7,0x1d,0x00,0x00,0x00,0x00,0x00,0x80,0xe7,0x1d,0x00,0xe0,0xff,0xff,0x03,0x40, +0xe4,0x1d,0x00,0x00,0x00,0x00,0x00,0x40,0xe4,0x1d,0x00,0x00,0x00,0x00,0x00,0x40, +0xe4,0x1d,0x00,0x00,0x00,0x00,0x00,0x40,0xe4,0x1d,0x00,0x00,0x00,0x00,0x00,0x40, +0xe4,0x1d,0x00,0x00,0x00,0x00,0x00,0x40,0xf7,0x82,0xc2,0xe2,0x12,0xc3,0xe2,0x22, +0xe4,0x5d,0x00,0x10,0x01,0x40,0x00,0x28,0x04,0x1c,0x00,0x84,0x00,0x00,0x00,0x2c, +0x23,0xdc,0x01,0xfc,0x00,0x00,0x8e,0x1a,0x85,0xe0,0xff,0x03,0x00,0x00,0x00,0xc9, +0x04,0x1c,0x00,0x00,0x00,0xc0,0x0e,0x50,0x23,0xdc,0xf1,0xc3,0x05,0x40,0x0e,0x19, +0xe7,0x01,0x00,0x00,0x00,0x00,0x00,0x80,0x87,0x82,0xc2,0xe2,0x02,0x40,0xc0,0x22, +0xe4,0x9d,0x00,0xc0,0x05,0x40,0x00,0x28,0x03,0x1c,0x21,0x14,0x00,0xc0,0x00,0x58, +0x03,0xdc,0x01,0x10,0x00,0x00,0x0e,0x1a,0xe7,0x01,0x00,0x00,0x00,0x00,0x00,0x80, +0xe2,0x5d,0x01,0x10,0x00,0x00,0x00,0x18,0x03,0x1c,0x02,0xa0,0x05,0x80,0x0b,0x20, +0x07,0x00,0x00,0x80,0x01,0x00,0x00,0x60,0x47,0x80,0x02,0x62,0x03,0xb0,0x83,0x22, +0x43,0x5c,0x02,0xb0,0x05,0x80,0x8a,0x20,0x04,0xdc,0xf3,0x1c,0x00,0x00,0x0e,0x0c, +0x85,0x1c,0x82,0x00,0x00,0x00,0x00,0x84,0x03,0x9c,0x01,0x14,0x00,0xc0,0x00,0x60, +0x04,0x9c,0x80,0x20,0x00,0x00,0x00,0x54,0x85,0xdc,0xf1,0x03,0x00,0x00,0x00,0xa8, +0x03,0xc0,0x70,0x08,0x00,0x00,0x00,0x48,0xb7,0xe3,0x02,0x40,0x02,0x40,0x00,0x22, +0x85,0xc1,0xf0,0x03,0x00,0x00,0x00,0xb8,0xe7,0x25,0x00,0x60,0xff,0xff,0x03,0x40, +0x33,0xdc,0x81,0xfc,0x00,0x00,0x0e,0x19,0x07,0x00,0x00,0x00,0x07,0x00,0x00,0x60, +0xe7,0x01,0x00,0xc0,0x06,0x00,0x00,0x40,0xe4,0xdd,0x02,0x00,0x05,0x40,0x00,0x28, +0xe2,0x5d,0x02,0x40,0x00,0x00,0x00,0x18,0xf7,0x82,0x82,0x82,0x82,0xc2,0x82,0x22, +0xe4,0x9d,0x02,0x90,0x05,0x40,0x00,0x28,0x84,0xdf,0x20,0x21,0x00,0x00,0x00,0x1c, +0x03,0x9c,0x80,0x0c,0x00,0x00,0x00,0x68,0x03,0x9c,0x00,0x08,0x00,0x00,0x00,0x78, +0x43,0x9c,0x23,0x18,0x00,0x00,0x00,0x68,0x03,0x1c,0xe4,0x60,0x05,0x80,0x13,0x20, +0x43,0x5c,0xe4,0x70,0x05,0x80,0x92,0x20,0x07,0xc2,0x92,0x42,0xe0,0x02,0x62,0x23, +0x85,0x1c,0x03,0x01,0x00,0x00,0x00,0x84,0xa3,0x9c,0x70,0x40,0x05,0x40,0x17,0x20, +0x43,0xdc,0xf0,0x13,0x05,0x40,0x00,0x48,0x85,0x1c,0x23,0x00,0x00,0x00,0x00,0x94, +0x03,0xde,0xff,0x83,0x05,0x40,0x01,0x48,0x85,0x5c,0x03,0x11,0x00,0x00,0x00,0x84, +0x63,0xdc,0xa1,0xfc,0x00,0x00,0x0e,0x19,0xe7,0x72,0x43,0x00,0x40,0x80,0xc2,0x22, +0x85,0x5c,0x23,0x10,0x00,0x00,0x00,0x94,0x85,0x1c,0x03,0x21,0x00,0x00,0x00,0x84, +0x85,0x1c,0x23,0x20,0x00,0x00,0x00,0x94,0xe7,0x01,0x00,0x20,0x03,0x00,0x00,0x40, +0xe2,0xdd,0x00,0x10,0x00,0x00,0x00,0x18,0x07,0x00,0x00,0x80,0x02,0x00,0x00,0x60, +0x03,0x9c,0xe0,0x80,0x05,0x80,0x07,0x20,0x87,0x72,0xc3,0x22,0x42,0xe0,0xc2,0x22, +0x43,0xdc,0xe0,0x90,0x05,0x80,0x86,0x20,0x85,0x9c,0x20,0x00,0x00,0x00,0x00,0x84, +0x00,0xdc,0x21,0x50,0x05,0x40,0x8e,0x2c,0xe7,0x01,0x00,0x40,0x00,0x00,0x00,0x40, +0xe2,0x9d,0x00,0xfc,0x03,0x00,0x00,0x18,0xe7,0x1d,0x00,0x60,0x01,0x00,0x00,0x40, +0x00,0xdc,0x21,0xfc,0x00,0x00,0x0e,0x2e,0x47,0x00,0x40,0x80,0x82,0x82,0x82,0x22, +0xe4,0xa1,0x00,0xfc,0x00,0x00,0x00,0x28,0xe7,0xa1,0x00,0xe0,0x00,0x00,0x00,0x40, +0xe4,0xc1,0x00,0x50,0x05,0x40,0x00,0x28,0x40,0x80,0x20,0xc0,0xdf,0xd0,0x00,0x58, +0x00,0xc0,0x30,0x10,0x00,0x00,0x00,0xc8,0x40,0x80,0x20,0x0c,0x00,0x00,0x00,0x58, +0x04,0x80,0x20,0x09,0x00,0x00,0x86,0x14,0x07,0xf0,0xc2,0x82,0x62,0x42,0x80,0x22, +0x84,0x80,0x90,0x08,0x00,0x00,0x00,0x1c,0xf4,0xdd,0x00,0x20,0x05,0x40,0x00,0x28, +0x03,0x1c,0x73,0x10,0x00,0xc0,0x07,0x20,0x43,0x5c,0xf3,0x33,0x05,0x40,0x00,0x48, +0x05,0x9c,0xc0,0x00,0x00,0x00,0x00,0x94,0x03,0xdc,0x80,0xfc,0xff,0xff,0x00,0x48, +0x03,0xdc,0x71,0x04,0x00,0xc0,0x00,0x48,0x87,0xc2,0xe2,0xf2,0xc2,0xe2,0xe2,0x22, +0x03,0x1c,0x32,0x20,0x00,0x00,0x00,0x68,0x23,0xdc,0x81,0xfc,0x00,0x00,0x8e,0x1a, +0xe7,0x01,0x00,0xc0,0xf9,0xff,0x03,0x40,0x13,0x1c,0x00,0xa0,0x00,0x40,0x00,0x48, +0x03,0xdc,0x01,0x10,0x00,0x00,0x8e,0x19,0xe7,0x01,0x00,0xe0,0xf6,0xff,0x03,0x40, +0xe7,0x1d,0x00,0x00,0x00,0x00,0x00,0x80,0xe7,0x1d,0x00,0xe0,0xff,0xff,0x03,0x40, +0xe4,0x1d,0x00,0x00,0x00,0x00,0x00,0x40,0xe4,0x1d,0x00,0x00,0x00,0x00,0x00,0x40, +0xe4,0x1d,0x00,0x00,0x00,0x00,0x00,0x40,0xe4,0x1d,0x00,0x00,0x00,0x00,0x00,0x40, +0xe4,0x1d,0x00,0x00,0x00,0x00,0x00,0x40,0xe4,0x1d,0x00,0x00,0x00,0x00,0x00,0x40, +0xe4,0x1d,0x00,0x00,0x00,0x00,0x00,0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x03,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x01,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0b,0x00,0x00,0x00,0x03,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x44,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x68,0x01,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x13,0x00,0x00,0x00,0x02,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0xb0,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0xd8,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x02,0x00,0x00,0x00,0x06,0x00,0x00,0x00,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x33,0x00,0x00,0x00,0x00,0x00,0x00,0x70, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x88,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0xa8,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x03,0x00,0x00,0x00,0x09,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x6b,0x00,0x00,0x00,0x00,0x00,0x00,0x70, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x30,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xac,0x00,0x00,0x00,0x00,0x00,0x00,0x70, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x60,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x98,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x03,0x00,0x00,0x00,0x0a,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x74,0x00,0x00,0x00,0x01,0x00,0x00,0x00, +0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0xf8,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x84,0x01,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x09,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xe4,0x00,0x00,0x00,0x01,0x00,0x00,0x00, +0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x7c,0x06,0x00,0x00,0x00,0x00,0x00,0x00,0x74,0x01,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x0a,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1b,0x00,0x00,0x00,0x01,0x00,0x00,0x00, +0x06,0x00,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x00,0x00,0x00, +0x03,0x00,0x00,0x00,0x07,0x00,0x00,0x13,0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x94,0x00,0x00,0x00,0x01,0x00,0x00,0x00, +0x06,0x00,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x0b,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x00,0x00,0x00, +0x03,0x00,0x00,0x00,0x08,0x00,0x00,0x12,0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x4e,0x00,0x00,0x00,0x08,0x00,0x00,0x00, +0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x0e,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x09,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc7,0x00,0x00,0x00,0x08,0x00,0x00,0x00, +0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x0e,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x0a,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x06,0x00,0x00,0x00,0x05,0x00,0x00,0x00, +0x40,0x11,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xa8,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0xa8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x01,0x00,0x00,0x00,0x05,0x00,0x00,0x00,0xf8,0x04,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0xf8,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0xf8,0x08,0x00,0x00,0x00,0x00,0x00,0x00, +0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x06,0x00,0x00,0x00, +0x00,0x0e,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x02,0x00,0x01,0x01,0x58,0x00,0x00,0x00,0x88,0x13,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0x00,0x01,0x00,0x32,0x00,0x00,0x00, +0x40,0x00,0x00,0x00,0x12,0x00,0x00,0x00,0x45,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x52,0x65,0x6e,0x64,0x65,0x72,0x50,0x61,0x72,0x74,0x69,0x63,0x6c,0x65,0x73,0x2e, +0x63,0x75,0x00,0x00,0x00,0x00,0x00,0x00,0x7f,0x45,0x4c,0x46,0x02,0x01,0x01,0x33, +0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x00,0xbe,0x00,0x01,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xe0,0x12,0x00,0x00,0x00,0x00,0x00,0x00, +0xa0,0x0f,0x00,0x00,0x00,0x00,0x00,0x00,0x32,0x05,0x32,0x00,0x40,0x00,0x38,0x00, +0x03,0x00,0x40,0x00,0x0d,0x00,0x01,0x00,0x00,0x2e,0x73,0x68,0x73,0x74,0x72,0x74, +0x61,0x62,0x00,0x2e,0x73,0x74,0x72,0x74,0x61,0x62,0x00,0x2e,0x73,0x79,0x6d,0x74, +0x61,0x62,0x00,0x2e,0x74,0x65,0x78,0x74,0x2e,0x75,0x70,0x64,0x61,0x74,0x65,0x49, +0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x64,0x56,0x42,0x00,0x2e,0x6e,0x76,0x2e,0x69, +0x6e,0x66,0x6f,0x2e,0x75,0x70,0x64,0x61,0x74,0x65,0x49,0x6e,0x73,0x74,0x61,0x6e, +0x63,0x65,0x64,0x56,0x42,0x00,0x2e,0x6e,0x76,0x2e,0x73,0x68,0x61,0x72,0x65,0x64, +0x2e,0x75,0x70,0x64,0x61,0x74,0x65,0x49,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x64, +0x56,0x42,0x00,0x2e,0x6e,0x76,0x2e,0x69,0x6e,0x66,0x6f,0x00,0x2e,0x6e,0x76,0x2e, +0x63,0x6f,0x6e,0x73,0x74,0x61,0x6e,0x74,0x30,0x2e,0x75,0x70,0x64,0x61,0x74,0x65, +0x49,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x64,0x56,0x42,0x00,0x2e,0x74,0x65,0x78, +0x74,0x2e,0x75,0x70,0x64,0x61,0x74,0x65,0x42,0x69,0x6c,0x6c,0x62,0x6f,0x61,0x72, +0x64,0x56,0x42,0x00,0x2e,0x6e,0x76,0x2e,0x69,0x6e,0x66,0x6f,0x2e,0x75,0x70,0x64, +0x61,0x74,0x65,0x42,0x69,0x6c,0x6c,0x62,0x6f,0x61,0x72,0x64,0x56,0x42,0x00,0x2e, +0x6e,0x76,0x2e,0x73,0x68,0x61,0x72,0x65,0x64,0x2e,0x75,0x70,0x64,0x61,0x74,0x65, +0x42,0x69,0x6c,0x6c,0x62,0x6f,0x61,0x72,0x64,0x56,0x42,0x00,0x2e,0x6e,0x76,0x2e, +0x63,0x6f,0x6e,0x73,0x74,0x61,0x6e,0x74,0x30,0x2e,0x75,0x70,0x64,0x61,0x74,0x65, +0x42,0x69,0x6c,0x6c,0x62,0x6f,0x61,0x72,0x64,0x56,0x42,0x00,0x00,0x2e,0x73,0x68, +0x73,0x74,0x72,0x74,0x61,0x62,0x00,0x2e,0x73,0x74,0x72,0x74,0x61,0x62,0x00,0x2e, +0x73,0x79,0x6d,0x74,0x61,0x62,0x00,0x75,0x70,0x64,0x61,0x74,0x65,0x49,0x6e,0x73, +0x74,0x61,0x6e,0x63,0x65,0x64,0x56,0x42,0x00,0x2e,0x74,0x65,0x78,0x74,0x2e,0x75, +0x70,0x64,0x61,0x74,0x65,0x49,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x64,0x56,0x42, +0x00,0x2e,0x6e,0x76,0x2e,0x69,0x6e,0x66,0x6f,0x2e,0x75,0x70,0x64,0x61,0x74,0x65, +0x49,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x64,0x56,0x42,0x00,0x2e,0x6e,0x76,0x2e, +0x73,0x68,0x61,0x72,0x65,0x64,0x2e,0x75,0x70,0x64,0x61,0x74,0x65,0x49,0x6e,0x73, +0x74,0x61,0x6e,0x63,0x65,0x64,0x56,0x42,0x00,0x2e,0x6e,0x76,0x2e,0x69,0x6e,0x66, +0x6f,0x00,0x5f,0x5a,0x4e,0x35,0x70,0x68,0x79,0x73,0x78,0x37,0x67,0x4f,0x66,0x66, +0x73,0x65,0x74,0x45,0x00,0x2e,0x6e,0x76,0x2e,0x63,0x6f,0x6e,0x73,0x74,0x61,0x6e, +0x74,0x30,0x2e,0x75,0x70,0x64,0x61,0x74,0x65,0x49,0x6e,0x73,0x74,0x61,0x6e,0x63, +0x65,0x64,0x56,0x42,0x00,0x5f,0x70,0x61,0x72,0x61,0x6d,0x00,0x75,0x70,0x64,0x61, +0x74,0x65,0x42,0x69,0x6c,0x6c,0x62,0x6f,0x61,0x72,0x64,0x56,0x42,0x00,0x2e,0x74, +0x65,0x78,0x74,0x2e,0x75,0x70,0x64,0x61,0x74,0x65,0x42,0x69,0x6c,0x6c,0x62,0x6f, +0x61,0x72,0x64,0x56,0x42,0x00,0x2e,0x6e,0x76,0x2e,0x69,0x6e,0x66,0x6f,0x2e,0x75, +0x70,0x64,0x61,0x74,0x65,0x42,0x69,0x6c,0x6c,0x62,0x6f,0x61,0x72,0x64,0x56,0x42, +0x00,0x2e,0x6e,0x76,0x2e,0x73,0x68,0x61,0x72,0x65,0x64,0x2e,0x75,0x70,0x64,0x61, +0x74,0x65,0x42,0x69,0x6c,0x6c,0x62,0x6f,0x61,0x72,0x64,0x56,0x42,0x00,0x24,0x75, +0x70,0x64,0x61,0x74,0x65,0x42,0x69,0x6c,0x6c,0x62,0x6f,0x61,0x72,0x64,0x56,0x42, +0x24,0x5f,0x5a,0x4e,0x35,0x70,0x68,0x79,0x73,0x78,0x37,0x67,0x4f,0x66,0x66,0x73, +0x65,0x74,0x45,0x00,0x2e,0x6e,0x76,0x2e,0x63,0x6f,0x6e,0x73,0x74,0x61,0x6e,0x74, +0x30,0x2e,0x75,0x70,0x64,0x61,0x74,0x65,0x42,0x69,0x6c,0x6c,0x62,0x6f,0x61,0x72, +0x64,0x56,0x42,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x2d,0x00,0x00,0x00,0x03,0x00,0x09,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x60,0x00,0x00,0x00,0x03,0x00,0x0b,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x99,0x00,0x00,0x00,0x03,0x00,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xd2,0x00,0x00,0x00,0x03,0x00,0x0a,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x05,0x01,0x00,0x00,0x03,0x00,0x0c,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x48,0x01,0x00,0x00,0x03,0x00,0x08,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x1b,0x00,0x00,0x00,0x12,0x10,0x09,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0xc0,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0xc0,0x00,0x00,0x00,0x12,0x10,0x0a,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc0,0x03,0x00,0x00,0x00,0x00,0x00,0x00, +0x04,0x0a,0x08,0x00,0x03,0x00,0x00,0x00,0x40,0x01,0x44,0x00,0x03,0x19,0x44,0x00, +0x04,0x17,0x0c,0x00,0x00,0x00,0x00,0x00,0x08,0x00,0x40,0x00,0x00,0xf0,0x11,0x00, +0x04,0x17,0x0c,0x00,0x00,0x00,0x00,0x00,0x07,0x00,0x38,0x00,0x00,0xf0,0x21,0x00, +0x04,0x17,0x0c,0x00,0x00,0x00,0x00,0x00,0x06,0x00,0x30,0x00,0x00,0xf0,0x21,0x00, +0x04,0x17,0x0c,0x00,0x00,0x00,0x00,0x00,0x05,0x00,0x28,0x00,0x00,0xf0,0x21,0x00, +0x04,0x17,0x0c,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x20,0x00,0x00,0xf0,0x11,0x00, +0x04,0x17,0x0c,0x00,0x00,0x00,0x00,0x00,0x03,0x00,0x18,0x00,0x00,0xf0,0x21,0x00, +0x04,0x17,0x0c,0x00,0x00,0x00,0x00,0x00,0x02,0x00,0x10,0x00,0x00,0xf0,0x21,0x00, +0x04,0x17,0x0c,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x08,0x00,0x00,0xf0,0x21,0x00, +0x04,0x17,0x0c,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0x21,0x00, +0x04,0x1e,0x04,0x00,0x10,0x02,0x00,0x00,0x04,0x1c,0x14,0x00,0x30,0x00,0x00,0x00, +0x50,0x00,0x00,0x00,0xb8,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x04,0x12,0x08,0x00,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x11,0x08,0x00, +0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x12,0x08,0x00,0x07,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x04,0x11,0x08,0x00,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x04,0x0a,0x08,0x00,0x06,0x00,0x00,0x00,0x40,0x01,0x34,0x00,0x03,0x19,0x34,0x00, +0x04,0x17,0x0c,0x00,0x00,0x00,0x00,0x00,0x07,0x00,0x30,0x00,0x00,0xf0,0x11,0x00, +0x04,0x17,0x0c,0x00,0x00,0x00,0x00,0x00,0x06,0x00,0x28,0x00,0x00,0xf0,0x21,0x00, +0x04,0x17,0x0c,0x00,0x00,0x00,0x00,0x00,0x05,0x00,0x20,0x00,0x00,0xf0,0x21,0x00, +0x04,0x17,0x0c,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x18,0x00,0x00,0xf0,0x21,0x00, +0x04,0x17,0x0c,0x00,0x00,0x00,0x00,0x00,0x03,0x00,0x14,0x00,0x00,0xf0,0x11,0x00, +0x04,0x17,0x0c,0x00,0x00,0x00,0x00,0x00,0x02,0x00,0x10,0x00,0x00,0xf0,0x11,0x00, +0x04,0x17,0x0c,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x08,0x00,0x00,0xf0,0x21,0x00, +0x04,0x17,0x0c,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0x21,0x00, +0x04,0x1e,0x04,0x00,0x20,0x02,0x00,0x00,0x04,0x1c,0x14,0x00,0x30,0x00,0x00,0x00, +0x50,0x00,0x00,0x00,0xa8,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xe6,0x07,0xa0,0xe3,0x00,0xb4,0x3f,0x00, +0x01,0x00,0x87,0x00,0x80,0x07,0x98,0x4c,0x00,0x00,0x17,0x02,0x00,0x00,0xc8,0xf0, +0x07,0x00,0xf7,0x0f,0x80,0x03,0x6b,0x5b,0xf4,0x07,0xe0,0xff,0x00,0xb4,0x1f,0x00, +0xff,0xff,0x08,0x00,0x00,0x00,0x5c,0xef,0x00,0x00,0x07,0x00,0x80,0x1b,0xa8,0xf0, +0x07,0xff,0x07,0x06,0x80,0x03,0x65,0x4b,0xfd,0x07,0xc0,0xfc,0x00,0x98,0x1f,0x00, +0x0f,0x00,0x00,0x00,0x00,0x00,0x00,0xe3,0x02,0x00,0x07,0x06,0x80,0x07,0x98,0x4c, +0x05,0x02,0x57,0x00,0x00,0x00,0x28,0x38,0xed,0x07,0xa0,0xff,0x00,0x88,0x1f,0x00, +0x07,0x00,0x57,0x00,0x80,0x03,0x68,0x5b,0x0f,0x00,0x00,0x00,0x00,0x00,0x00,0xe3, +0x02,0x00,0x27,0x00,0x80,0x00,0x48,0x38,0xf0,0x07,0x80,0xfe,0x00,0xb4,0x1f,0x00, +0x03,0x00,0xe7,0x01,0x00,0x00,0x28,0x38,0x00,0x00,0x00,0x2f,0x00,0x00,0x90,0xe2, +0x02,0x02,0xe7,0x05,0x00,0x80,0x10,0x4c,0xe2,0x07,0x20,0xf6,0x00,0x84,0x1f,0x00, +0x03,0x03,0xf7,0x05,0x00,0x08,0x10,0x4c,0x04,0x02,0x07,0x00,0x00,0x20,0xd4,0xee, +0x06,0x00,0x57,0x00,0x00,0x00,0x48,0x38,0x1d,0x07,0x01,0xfe,0x00,0xb4,0x20,0x00, +0x02,0x00,0x47,0x00,0x00,0x00,0x08,0x5c,0x07,0x04,0xf7,0x0f,0x80,0x03,0x65,0x5b, +0x07,0xff,0x27,0x00,0x00,0x00,0x00,0xec,0xfd,0x1f,0xa0,0xe3,0x00,0x88,0x3f,0x00, +0x0f,0x00,0x80,0x28,0x00,0x00,0x40,0xe2,0x02,0x3a,0x47,0x00,0x00,0x20,0xe0,0x5c, +0x02,0x04,0x27,0x00,0x00,0x00,0x47,0x5c,0x1d,0x07,0xc0,0xfc,0x01,0x84,0x1f,0x00, +0x02,0x00,0x27,0x00,0x00,0x00,0x30,0x5c,0x02,0x02,0xf7,0x01,0x00,0x00,0x12,0x38, +0x03,0x02,0xf7,0x01,0x00,0x00,0x12,0x38,0xe5,0x07,0xc0,0xfc,0x00,0x84,0x1f,0x00, +0x09,0xf0,0x47,0x02,0x00,0x00,0x00,0x01,0x0a,0x03,0x67,0x00,0x00,0x02,0x47,0x5c, +0x03,0x0a,0x47,0x02,0x80,0x7f,0x00,0x36,0xe1,0x07,0x20,0xfc,0x00,0x8c,0x1f,0x00, +0x0b,0x0a,0x47,0x02,0x80,0x7f,0x00,0x36,0x08,0x0a,0x97,0x00,0x88,0x7f,0x00,0x5b, +0x09,0x0a,0x97,0x00,0x88,0x7f,0x20,0x5b,0xe1,0x07,0xa0,0xfc,0x00,0x84,0x1f,0x00, +0x03,0x0a,0x47,0x02,0x80,0x01,0x28,0x36,0x02,0x0a,0x47,0x02,0x90,0x05,0x20,0x36, +0x03,0x03,0x87,0x00,0xa0,0x04,0xc0,0x5c,0xed,0x07,0x40,0xfc,0x00,0xc4,0x1e,0x00, +0x02,0x02,0xc7,0x05,0x00,0x80,0x10,0x4c,0x03,0x03,0xd7,0x05,0x00,0x08,0x10,0x4c, +0x08,0x02,0x07,0x00,0x00,0x20,0xd4,0xee,0xfd,0x07,0x20,0xfc,0x00,0x98,0x1f,0x00, +0x0c,0x00,0x87,0x05,0x80,0x07,0x98,0x4c,0x09,0x07,0xc7,0x00,0x80,0x7f,0x00,0x5b, +0x0c,0x07,0xc7,0x00,0xa8,0x7f,0x00,0x5b,0xe6,0x07,0xa0,0xfd,0x00,0x88,0x1f,0x00, +0x0d,0x07,0xc7,0x00,0x98,0x04,0x30,0x5b,0x0e,0x0d,0x27,0x05,0x00,0x80,0x10,0x4c, +0x0f,0xff,0x37,0x05,0x00,0x08,0x10,0x4c,0xf1,0x07,0x41,0xf6,0x00,0xc4,0x1f,0x04, +0x08,0x0e,0x07,0x00,0x00,0x20,0xdc,0xee,0x09,0x02,0x47,0x00,0x00,0x20,0xd4,0xee, +0x09,0x0e,0x47,0x00,0x00,0x20,0xdc,0xee,0xb1,0x07,0x20,0xfc,0x00,0xc4,0x1f,0x04, +0x08,0x02,0x87,0x00,0x00,0x20,0xd4,0xee,0x10,0x0d,0x47,0x05,0x00,0x80,0x10,0x4c, +0x08,0x0e,0x87,0x00,0x00,0x20,0xdc,0xee,0xbb,0x07,0x40,0xfc,0x00,0xc4,0x1f,0x04, +0x09,0x02,0xc7,0x00,0x00,0x20,0xd4,0xee,0x11,0xff,0x57,0x05,0x00,0x08,0x10,0x4c, +0x09,0x10,0x07,0x00,0x00,0x20,0xdc,0xee,0xb2,0x07,0x20,0xfe,0x20,0xc8,0x1e,0x00, +0x08,0x02,0x07,0x01,0x00,0x20,0xd4,0xee,0x08,0x10,0x47,0x00,0x00,0x20,0xdc,0xee, +0x0b,0x02,0x47,0x01,0x00,0x20,0xd4,0xee,0xf1,0x07,0x21,0xf6,0x00,0xb4,0x1f,0x00, +0x0b,0x10,0x87,0x00,0x00,0x20,0xdc,0xee,0x0c,0x02,0x87,0x01,0x00,0x20,0xd4,0xee, +0x08,0x0d,0x67,0x05,0x00,0x80,0x10,0x4c,0xe2,0x07,0x20,0xfe,0x20,0xc8,0x1e,0x00, +0x09,0xff,0x77,0x05,0x00,0x08,0x10,0x4c,0x0c,0x08,0x07,0x00,0x00,0x20,0xdc,0xee, +0x0b,0x02,0xc7,0x01,0x00,0x20,0xd4,0xee,0xf1,0x07,0x21,0xf6,0x00,0x88,0x1f,0x00, +0x0b,0x08,0x47,0x00,0x00,0x20,0xdc,0xee,0x03,0x02,0x07,0x02,0x00,0x20,0xd4,0xee, +0x0c,0x0a,0x47,0x00,0x80,0x00,0x48,0x38,0xe4,0x07,0xa0,0xfd,0x00,0x84,0x1f,0x00, +0x0a,0x0a,0xc7,0x01,0x00,0x00,0x28,0x38,0x0e,0x0c,0xa7,0x05,0x00,0x80,0x10,0x4c, +0x0f,0x0a,0xb7,0x05,0x00,0x08,0x10,0x4c,0xf1,0x07,0x21,0xf6,0x00,0xb4,0x1f,0x00, +0x03,0x08,0x87,0x00,0x00,0x20,0xdc,0xee,0x02,0x0e,0x07,0x00,0x00,0x20,0xd4,0xee, +0x0a,0x0d,0x07,0x05,0x00,0x80,0x10,0x4c,0xe2,0x07,0x20,0xfe,0x20,0xc8,0x1e,0x00, +0x0b,0xff,0x17,0x05,0x00,0x08,0x10,0x4c,0x02,0x0a,0x07,0x00,0x00,0x20,0xdc,0xee, +0x03,0x0e,0x47,0x00,0x00,0x20,0xd4,0xee,0xf1,0x00,0xa1,0xf7,0x00,0x98,0x3f,0x00, +0x03,0x0a,0x47,0x00,0x00,0x20,0xdc,0xee,0x02,0x0e,0x87,0x00,0x00,0x20,0xd4,0xee, +0x03,0x04,0xf7,0xff,0x7f,0x00,0x10,0x39,0xe1,0x07,0xa0,0xfc,0x00,0x84,0x1f,0x00, +0x04,0x03,0x47,0x00,0x00,0x00,0x47,0x5c,0x07,0x07,0x17,0x00,0x00,0x00,0x10,0x38, +0x07,0x04,0xf7,0x0f,0x80,0x03,0x6b,0x5b,0xec,0x00,0xa1,0xff,0x01,0xf4,0x1f,0x00, +0x02,0x0a,0x87,0x00,0x00,0x20,0xdc,0xee,0x0f,0x00,0x80,0xd7,0xff,0x0f,0x40,0xe2, +0x0f,0x00,0x07,0x00,0x00,0x00,0xf8,0xf0,0xe6,0x07,0xa0,0xfd,0x00,0xf4,0x1f,0x00, +0x00,0x00,0x27,0x00,0x00,0x00,0x10,0x4c,0x07,0x00,0x57,0x00,0x80,0x03,0x66,0x5b, +0x0f,0x00,0x80,0xcd,0xff,0x0f,0x40,0xe2,0xff,0x07,0xe0,0xff,0x00,0x80,0x1f,0x00, +0x0f,0x00,0x07,0x00,0x00,0x00,0x00,0xe3,0x0f,0x00,0x87,0xff,0xff,0x0f,0x40,0xe2, +0x00,0x0f,0x07,0x00,0x00,0x00,0xb0,0x50,0xe6,0x07,0xa0,0xe3,0x00,0xb4,0x3f,0x00, +0x01,0x00,0x87,0x00,0x80,0x07,0x98,0x4c,0x00,0x00,0x17,0x02,0x00,0x00,0xc8,0xf0, +0x07,0x00,0xf7,0x0f,0x80,0x03,0x6b,0x5b,0xf4,0x07,0xe0,0xff,0x00,0xb4,0x1f,0x00, +0xff,0xff,0x08,0x00,0x00,0x00,0x5c,0xef,0x00,0x00,0x07,0x00,0x80,0x1b,0xa8,0xf0, +0x07,0xff,0xc7,0x05,0x80,0x03,0x65,0x4b,0xfd,0x07,0xc0,0xfc,0x00,0x98,0x1f,0x00, +0x0f,0x00,0x00,0x00,0x00,0x00,0x00,0xe3,0x02,0x00,0xc7,0x05,0x80,0x07,0x98,0x4c, +0x02,0x02,0x57,0x00,0x00,0x00,0x28,0x38,0xed,0x07,0xa0,0xff,0x00,0x88,0x1f,0x00, +0x07,0x00,0x27,0x00,0x80,0x03,0x68,0x5b,0x0f,0x00,0x00,0x00,0x00,0x00,0x00,0xe3, +0x03,0x00,0x27,0x00,0x80,0x00,0x48,0x38,0xf0,0x07,0x80,0xfe,0x00,0xb4,0x1f,0x00, +0x04,0x00,0xe7,0x01,0x00,0x00,0x28,0x38,0x00,0x00,0x80,0x2d,0x00,0x00,0x90,0xe2, +0x06,0x03,0xa7,0x05,0x00,0x80,0x10,0x4c,0xe2,0x07,0x40,0xf6,0x00,0x74,0x1c,0x04, +0x07,0x04,0xb7,0x05,0x00,0x08,0x10,0x4c,0x03,0x06,0x07,0x00,0x00,0x20,0xd4,0xee, +0x04,0x00,0x37,0x00,0x00,0x00,0x08,0x5c,0xf0,0x07,0xa0,0x05,0x01,0xc0,0x3f,0x00, +0x07,0x03,0xf7,0x0f,0x80,0x03,0x65,0x5b,0x05,0xff,0x47,0x00,0x00,0x00,0x00,0xec, +0x04,0x00,0x57,0x00,0x00,0x00,0x48,0x38,0xfd,0x17,0xa0,0xe3,0x00,0x88,0x3f,0x00, +0x0f,0x00,0x80,0x27,0x00,0x00,0x40,0xe2,0x06,0x3a,0x37,0x00,0x00,0x20,0xe0,0x5c, +0x06,0x03,0x67,0x00,0x00,0x00,0x47,0x5c,0x1d,0x07,0xc0,0xfc,0x01,0x98,0x1f,0x00, +0x06,0x00,0x67,0x00,0x00,0x00,0x30,0x5c,0x06,0x06,0xf7,0x01,0x00,0x00,0x12,0x38, +0x06,0x06,0xf7,0x01,0x00,0x00,0x12,0x38,0xe6,0x07,0x40,0xfc,0x00,0x90,0x1f,0x00, +0x0a,0x06,0x47,0x00,0x00,0x02,0x47,0x5c,0x06,0x0a,0x47,0x00,0x80,0x00,0x48,0x38, +0x07,0x0a,0xc7,0x01,0x00,0x00,0x28,0x38,0xed,0x07,0x40,0xfc,0x00,0xc4,0x1e,0x00, +0x06,0x06,0x67,0x05,0x00,0x80,0x10,0x4c,0x07,0x07,0x77,0x05,0x00,0x08,0x10,0x4c, +0x09,0x06,0x07,0x00,0x00,0x20,0xd4,0xee,0xe6,0x07,0x20,0xfc,0x00,0x98,0x1f,0x00, +0x0b,0x00,0x47,0x05,0x80,0x07,0x98,0x4c,0x08,0x05,0xb7,0x00,0x80,0x7f,0x00,0x5b, +0x0b,0x05,0xb7,0x00,0xa8,0x7f,0x00,0x5b,0xfd,0x07,0xa0,0xfd,0x00,0x88,0x1f,0x00, +0x08,0x05,0xb7,0x00,0x18,0x04,0x30,0x5b,0x0c,0x08,0x07,0x05,0x00,0x80,0x10,0x4c, +0x0d,0xff,0x17,0x05,0x00,0x08,0x10,0x4c,0xf1,0x07,0x21,0xf6,0x00,0x84,0x1f,0x00, +0x09,0x0c,0x07,0x00,0x00,0x20,0xdc,0xee,0x08,0x06,0x47,0x00,0x00,0x20,0xd4,0xee, +0xff,0xff,0x87,0x05,0x00,0x80,0x12,0x4c,0xf1,0x07,0xa1,0x17,0x00,0x84,0x3f,0x00, +0x08,0x0c,0x47,0x00,0x00,0x20,0xdc,0xee,0x06,0x06,0x87,0x00,0x00,0x20,0xd4,0xee, +0x07,0x00,0x97,0x05,0x80,0x07,0x98,0x4c,0xe8,0x07,0x20,0xfc,0x00,0x84,0x1f,0x00, +0x08,0x00,0xf7,0x0f,0x80,0x07,0x98,0x5c,0x07,0x07,0xf7,0x0f,0x80,0x0b,0x65,0x5b, +0x07,0x00,0xf7,0x0f,0x80,0x07,0x98,0x5c,0xfb,0x00,0xa1,0xff,0x01,0xc0,0x1f,0x00, +0x06,0x0c,0x87,0x00,0x00,0x20,0xdc,0xee,0x0f,0x00,0x80,0x11,0x00,0x00,0x40,0xe2, +0x06,0x0a,0x27,0x00,0x00,0x00,0x48,0x38,0xf2,0x07,0x80,0xfc,0x00,0xb4,0x1f,0x00, +0x00,0x00,0x80,0x0c,0x00,0x00,0x90,0xe2,0x07,0x0a,0x27,0x00,0xc0,0x03,0xf8,0x36, +0x06,0x06,0x87,0x05,0x00,0x80,0x10,0x4c,0xe2,0x07,0x40,0xf6,0x00,0xb4,0x1f,0x04, +0x07,0x07,0x97,0x05,0x00,0x08,0x10,0x4c,0x06,0x06,0x07,0x00,0x00,0x20,0xd4,0xee, +0x07,0x06,0x57,0x05,0x80,0x83,0xb9,0x4b,0xfd,0x07,0x00,0xfe,0x00,0xf4,0x1f,0x00, +0x0f,0x00,0x80,0x01,0x00,0x00,0x40,0xe2,0x06,0xf0,0xf7,0x0f,0x00,0x00,0x00,0x01, +0x0f,0x00,0x07,0x00,0x00,0x00,0xf8,0xf0,0xed,0x07,0xa0,0xff,0x00,0xc0,0x1f,0x00, +0x07,0x06,0xf7,0x0f,0x80,0x83,0xbc,0x5b,0x0f,0x00,0x80,0x01,0x00,0x00,0x40,0xe2, +0x06,0x00,0xf7,0x0f,0x80,0x07,0x98,0x5c,0xfd,0x07,0x40,0xfc,0x00,0x44,0x1c,0x00, +0x0f,0x00,0x07,0x00,0x00,0x00,0xf8,0xf0,0x07,0x00,0x57,0x05,0x80,0x07,0x98,0x4c, +0x07,0x07,0x47,0x00,0x00,0x00,0x80,0x50,0xfd,0x07,0x40,0xfc,0x01,0x74,0x1c,0x00, +0x06,0x06,0x07,0x7f,0x43,0x10,0x68,0x38,0x06,0x06,0x77,0x00,0x00,0x10,0x68,0x5c, +0x06,0x0a,0x67,0x00,0x80,0x11,0xb0,0x5c,0x3d,0x08,0xa0,0xff,0x03,0x98,0x1f,0x00, +0x06,0x15,0x67,0x00,0x00,0x00,0xe0,0x5c,0x0f,0x00,0x07,0x00,0x00,0x00,0xf8,0xf0, +0x07,0x05,0x27,0x00,0x00,0x00,0x48,0x38,0xed,0x07,0x40,0xfc,0x00,0xc4,0x03,0x00, +0x0a,0x07,0x27,0x05,0x00,0x80,0x10,0x4c,0x0b,0x08,0x37,0x05,0x00,0x08,0x10,0x4c, +0x06,0x0a,0x07,0x00,0x00,0x20,0xd8,0xee,0xe3,0x07,0xc0,0xfc,0x00,0x84,0x1f,0x00, +0x01,0x00,0x07,0x00,0x00,0x00,0xf0,0xf0,0x06,0x03,0xf7,0xff,0x7f,0x00,0x10,0x39, +0x03,0x06,0x37,0x00,0x00,0x00,0x47,0x5c,0xe5,0x07,0xa0,0xfd,0x00,0xf4,0x1f,0x00, +0x05,0x05,0x17,0x00,0x00,0x00,0x10,0x38,0x07,0x03,0xf7,0x0f,0x80,0x03,0x6b,0x5b, +0x0f,0x00,0x00,0xd9,0xff,0x0f,0x40,0xe2,0xfd,0x07,0xc0,0xfc,0x00,0xb4,0x1f,0x00, +0x0f,0x00,0x07,0x00,0x00,0x00,0xf8,0xf0,0x00,0x00,0x27,0x00,0x00,0x00,0x10,0x4c, +0x07,0x00,0x27,0x00,0x80,0x03,0x66,0x5b,0xfd,0x07,0xe0,0xff,0x00,0xfc,0x1f,0x00, +0x0f,0x00,0x80,0xce,0xff,0x0f,0x40,0xe2,0x0f,0x00,0x07,0x00,0x00,0x00,0x00,0xe3, +0x0f,0x00,0x87,0xff,0xff,0x0f,0x40,0xe2,0xe0,0x07,0x00,0xfc,0x00,0x80,0x1f,0x00, +0x00,0x0f,0x07,0x00,0x00,0x00,0xb0,0x50,0x00,0x0f,0x07,0x00,0x00,0x00,0xb0,0x50, +0x00,0x0f,0x07,0x00,0x00,0x00,0xb0,0x50,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x03,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x01,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0b,0x00,0x00,0x00,0x03,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x44,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x68,0x01,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x13,0x00,0x00,0x00,0x02,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0xb0,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0xd8,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x02,0x00,0x00,0x00,0x06,0x00,0x00,0x00,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x33,0x00,0x00,0x00,0x00,0x00,0x00,0x70, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x88,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0xc0,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x03,0x00,0x00,0x00,0x09,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x6b,0x00,0x00,0x00,0x00,0x00,0x00,0x70, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x48,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xac,0x00,0x00,0x00,0x00,0x00,0x00,0x70, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x78,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0xb0,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x03,0x00,0x00,0x00,0x0a,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x74,0x00,0x00,0x00,0x01,0x00,0x00,0x00, +0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x28,0x05,0x00,0x00,0x00,0x00,0x00,0x00,0x84,0x01,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x09,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xe4,0x00,0x00,0x00,0x01,0x00,0x00,0x00, +0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0xac,0x06,0x00,0x00,0x00,0x00,0x00,0x00,0x74,0x01,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x0a,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1b,0x00,0x00,0x00,0x01,0x00,0x00,0x00, +0x06,0x00,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x20,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0xc0,0x03,0x00,0x00,0x00,0x00,0x00,0x00, +0x03,0x00,0x00,0x00,0x07,0x00,0x00,0x12,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x94,0x00,0x00,0x00,0x01,0x00,0x00,0x00, +0x06,0x00,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0xe0,0x0b,0x00,0x00,0x00,0x00,0x00,0x00,0xc0,0x03,0x00,0x00,0x00,0x00,0x00,0x00, +0x03,0x00,0x00,0x00,0x08,0x00,0x00,0x0e,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x4e,0x00,0x00,0x00,0x08,0x00,0x00,0x00, +0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0xa0,0x0f,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x09,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc7,0x00,0x00,0x00,0x08,0x00,0x00,0x00, +0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0xa0,0x0f,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x0a,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x06,0x00,0x00,0x00,0x05,0x00,0x00,0x00, +0xe0,0x12,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xa8,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0xa8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x01,0x00,0x00,0x00,0x05,0x00,0x00,0x00,0x28,0x05,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x78,0x0a,0x00,0x00,0x00,0x00,0x00,0x00,0x78,0x0a,0x00,0x00,0x00,0x00,0x00,0x00, +0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x06,0x00,0x00,0x00, +0xa0,0x0f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00 +}; + +#ifdef __cplusplus +} +#endif + diff --git a/PhysX_3.4/Samples/SampleFramework/renderer/src/cuda/RenderParticles_x86.cuh b/PhysX_3.4/Samples/SampleFramework/renderer/src/cuda/RenderParticles_x86.cuh new file mode 100644 index 00000000..77db5db9 --- /dev/null +++ b/PhysX_3.4/Samples/SampleFramework/renderer/src/cuda/RenderParticles_x86.cuh @@ -0,0 +1,1021 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved. + +#ifdef __cplusplus +extern "C" { +#endif + +unsigned char updateParticleVertexBuffer[] = { +0x50,0xed,0x55,0xba,0x01,0x00,0x10,0x00,0x60,0x3d,0x00,0x00,0x00,0x00,0x00,0x00, +0x02,0x00,0x01,0x01,0x58,0x00,0x00,0x00,0xf8,0x10,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x00,0x01,0x00,0x0b,0x00,0x00,0x00, +0x40,0x00,0x00,0x00,0x12,0x00,0x00,0x00,0x44,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x52,0x65,0x6e,0x64,0x65,0x72,0x50,0x61,0x72,0x74,0x69,0x63,0x6c,0x65,0x73,0x2e, +0x63,0x75,0x00,0x00,0x00,0x00,0x00,0x00,0x7f,0x45,0x4c,0x46,0x01,0x01,0x01,0x33, +0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x00,0xbe,0x00,0x01,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x98,0x10,0x00,0x00,0x40,0x0e,0x00,0x00,0x0b,0x01,0x0b,0x00, +0x34,0x00,0x20,0x00,0x03,0x00,0x28,0x00,0x0f,0x00,0x01,0x00,0x00,0x2e,0x73,0x68, +0x73,0x74,0x72,0x74,0x61,0x62,0x00,0x2e,0x73,0x74,0x72,0x74,0x61,0x62,0x00,0x2e, +0x73,0x79,0x6d,0x74,0x61,0x62,0x00,0x2e,0x74,0x65,0x78,0x74,0x2e,0x75,0x70,0x64, +0x61,0x74,0x65,0x49,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x64,0x56,0x42,0x00,0x2e, +0x6e,0x76,0x2e,0x69,0x6e,0x66,0x6f,0x2e,0x75,0x70,0x64,0x61,0x74,0x65,0x49,0x6e, +0x73,0x74,0x61,0x6e,0x63,0x65,0x64,0x56,0x42,0x00,0x2e,0x6e,0x76,0x2e,0x73,0x68, +0x61,0x72,0x65,0x64,0x2e,0x75,0x70,0x64,0x61,0x74,0x65,0x49,0x6e,0x73,0x74,0x61, +0x6e,0x63,0x65,0x64,0x56,0x42,0x00,0x2e,0x6e,0x76,0x2e,0x63,0x6f,0x6e,0x73,0x74, +0x61,0x6e,0x74,0x31,0x2e,0x75,0x70,0x64,0x61,0x74,0x65,0x49,0x6e,0x73,0x74,0x61, +0x6e,0x63,0x65,0x64,0x56,0x42,0x00,0x2e,0x74,0x65,0x78,0x74,0x2e,0x75,0x70,0x64, +0x61,0x74,0x65,0x42,0x69,0x6c,0x6c,0x62,0x6f,0x61,0x72,0x64,0x56,0x42,0x00,0x2e, +0x6e,0x76,0x2e,0x69,0x6e,0x66,0x6f,0x2e,0x75,0x70,0x64,0x61,0x74,0x65,0x42,0x69, +0x6c,0x6c,0x62,0x6f,0x61,0x72,0x64,0x56,0x42,0x00,0x2e,0x6e,0x76,0x2e,0x73,0x68, +0x61,0x72,0x65,0x64,0x2e,0x75,0x70,0x64,0x61,0x74,0x65,0x42,0x69,0x6c,0x6c,0x62, +0x6f,0x61,0x72,0x64,0x56,0x42,0x00,0x2e,0x6e,0x76,0x2e,0x63,0x6f,0x6e,0x73,0x74, +0x61,0x6e,0x74,0x31,0x2e,0x75,0x70,0x64,0x61,0x74,0x65,0x42,0x69,0x6c,0x6c,0x62, +0x6f,0x61,0x72,0x64,0x56,0x42,0x00,0x2e,0x6e,0x76,0x2e,0x67,0x6c,0x6f,0x62,0x61, +0x6c,0x00,0x2e,0x6e,0x76,0x2e,0x63,0x6f,0x6e,0x73,0x74,0x61,0x6e,0x74,0x31,0x34, +0x00,0x2e,0x72,0x65,0x6c,0x2e,0x6e,0x76,0x2e,0x63,0x6f,0x6e,0x73,0x74,0x61,0x6e, +0x74,0x31,0x34,0x00,0x00,0x2e,0x73,0x68,0x73,0x74,0x72,0x74,0x61,0x62,0x00,0x2e, +0x73,0x74,0x72,0x74,0x61,0x62,0x00,0x2e,0x73,0x79,0x6d,0x74,0x61,0x62,0x00,0x75, +0x70,0x64,0x61,0x74,0x65,0x49,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x64,0x56,0x42, +0x00,0x2e,0x74,0x65,0x78,0x74,0x2e,0x75,0x70,0x64,0x61,0x74,0x65,0x49,0x6e,0x73, +0x74,0x61,0x6e,0x63,0x65,0x64,0x56,0x42,0x00,0x2e,0x6e,0x76,0x2e,0x69,0x6e,0x66, +0x6f,0x2e,0x75,0x70,0x64,0x61,0x74,0x65,0x49,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65, +0x64,0x56,0x42,0x00,0x2e,0x6e,0x76,0x2e,0x73,0x68,0x61,0x72,0x65,0x64,0x2e,0x75, +0x70,0x64,0x61,0x74,0x65,0x49,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x64,0x56,0x42, +0x00,0x2e,0x6e,0x76,0x2e,0x63,0x6f,0x6e,0x73,0x74,0x61,0x6e,0x74,0x31,0x2e,0x75, +0x70,0x64,0x61,0x74,0x65,0x49,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x64,0x56,0x42, +0x00,0x63,0x6f,0x6e,0x73,0x74,0x00,0x5f,0x5f,0x63,0x75,0x64,0x61,0x70,0x61,0x72, +0x6d,0x5f,0x75,0x70,0x64,0x61,0x74,0x65,0x49,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65, +0x64,0x56,0x42,0x5f,0x64,0x65,0x73,0x74,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e, +0x73,0x00,0x5f,0x5f,0x63,0x75,0x64,0x61,0x70,0x61,0x72,0x6d,0x5f,0x75,0x70,0x64, +0x61,0x74,0x65,0x49,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x64,0x56,0x42,0x5f,0x64, +0x65,0x73,0x74,0x52,0x6f,0x74,0x61,0x74,0x69,0x6f,0x6e,0x30,0x00,0x5f,0x5f,0x63, +0x75,0x64,0x61,0x70,0x61,0x72,0x6d,0x5f,0x75,0x70,0x64,0x61,0x74,0x65,0x49,0x6e, +0x73,0x74,0x61,0x6e,0x63,0x65,0x64,0x56,0x42,0x5f,0x64,0x65,0x73,0x74,0x52,0x6f, +0x74,0x61,0x74,0x69,0x6f,0x6e,0x31,0x00,0x5f,0x5f,0x63,0x75,0x64,0x61,0x70,0x61, +0x72,0x6d,0x5f,0x75,0x70,0x64,0x61,0x74,0x65,0x49,0x6e,0x73,0x74,0x61,0x6e,0x63, +0x65,0x64,0x56,0x42,0x5f,0x64,0x65,0x73,0x74,0x52,0x6f,0x74,0x61,0x74,0x69,0x6f, +0x6e,0x32,0x00,0x5f,0x5f,0x63,0x75,0x64,0x61,0x70,0x61,0x72,0x6d,0x5f,0x75,0x70, +0x64,0x61,0x74,0x65,0x49,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x64,0x56,0x42,0x5f, +0x64,0x65,0x73,0x74,0x53,0x74,0x72,0x69,0x64,0x65,0x00,0x5f,0x5f,0x63,0x75,0x64, +0x61,0x70,0x61,0x72,0x6d,0x5f,0x75,0x70,0x64,0x61,0x74,0x65,0x49,0x6e,0x73,0x74, +0x61,0x6e,0x63,0x65,0x64,0x56,0x42,0x5f,0x73,0x72,0x63,0x50,0x6f,0x73,0x69,0x74, +0x69,0x6f,0x6e,0x73,0x00,0x5f,0x5f,0x63,0x75,0x64,0x61,0x70,0x61,0x72,0x6d,0x5f, +0x75,0x70,0x64,0x61,0x74,0x65,0x49,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x64,0x56, +0x42,0x5f,0x73,0x72,0x63,0x52,0x6f,0x74,0x61,0x74,0x69,0x6f,0x6e,0x73,0x00,0x5f, +0x5f,0x63,0x75,0x64,0x61,0x70,0x61,0x72,0x6d,0x5f,0x75,0x70,0x64,0x61,0x74,0x65, +0x49,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x64,0x56,0x42,0x5f,0x76,0x61,0x6c,0x69, +0x64,0x50,0x61,0x72,0x74,0x69,0x63,0x6c,0x65,0x42,0x69,0x74,0x6d,0x61,0x70,0x00, +0x5f,0x5f,0x63,0x75,0x64,0x61,0x70,0x61,0x72,0x6d,0x5f,0x75,0x70,0x64,0x61,0x74, +0x65,0x49,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x64,0x56,0x42,0x5f,0x76,0x61,0x6c, +0x69,0x64,0x50,0x61,0x72,0x74,0x69,0x63,0x6c,0x65,0x52,0x61,0x6e,0x67,0x65,0x00, +0x75,0x70,0x64,0x61,0x74,0x65,0x42,0x69,0x6c,0x6c,0x62,0x6f,0x61,0x72,0x64,0x56, +0x42,0x00,0x2e,0x74,0x65,0x78,0x74,0x2e,0x75,0x70,0x64,0x61,0x74,0x65,0x42,0x69, +0x6c,0x6c,0x62,0x6f,0x61,0x72,0x64,0x56,0x42,0x00,0x2e,0x6e,0x76,0x2e,0x69,0x6e, +0x66,0x6f,0x2e,0x75,0x70,0x64,0x61,0x74,0x65,0x42,0x69,0x6c,0x6c,0x62,0x6f,0x61, +0x72,0x64,0x56,0x42,0x00,0x2e,0x6e,0x76,0x2e,0x73,0x68,0x61,0x72,0x65,0x64,0x2e, +0x75,0x70,0x64,0x61,0x74,0x65,0x42,0x69,0x6c,0x6c,0x62,0x6f,0x61,0x72,0x64,0x56, +0x42,0x00,0x2e,0x6e,0x76,0x2e,0x63,0x6f,0x6e,0x73,0x74,0x61,0x6e,0x74,0x31,0x2e, +0x75,0x70,0x64,0x61,0x74,0x65,0x42,0x69,0x6c,0x6c,0x62,0x6f,0x61,0x72,0x64,0x56, +0x42,0x00,0x5f,0x5f,0x63,0x75,0x64,0x61,0x70,0x61,0x72,0x6d,0x5f,0x75,0x70,0x64, +0x61,0x74,0x65,0x42,0x69,0x6c,0x6c,0x62,0x6f,0x61,0x72,0x64,0x56,0x42,0x5f,0x64, +0x65,0x73,0x74,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x73,0x00,0x5f,0x5f,0x63, +0x75,0x64,0x61,0x70,0x61,0x72,0x6d,0x5f,0x75,0x70,0x64,0x61,0x74,0x65,0x42,0x69, +0x6c,0x6c,0x62,0x6f,0x61,0x72,0x64,0x56,0x42,0x5f,0x64,0x65,0x73,0x74,0x41,0x6c, +0x70,0x68,0x61,0x73,0x00,0x5f,0x5f,0x63,0x75,0x64,0x61,0x70,0x61,0x72,0x6d,0x5f, +0x75,0x70,0x64,0x61,0x74,0x65,0x42,0x69,0x6c,0x6c,0x62,0x6f,0x61,0x72,0x64,0x56, +0x42,0x5f,0x64,0x65,0x73,0x74,0x53,0x74,0x72,0x69,0x64,0x65,0x00,0x5f,0x5f,0x63, +0x75,0x64,0x61,0x70,0x61,0x72,0x6d,0x5f,0x75,0x70,0x64,0x61,0x74,0x65,0x42,0x69, +0x6c,0x6c,0x62,0x6f,0x61,0x72,0x64,0x56,0x42,0x5f,0x66,0x61,0x64,0x69,0x6e,0x67, +0x50,0x65,0x72,0x69,0x6f,0x64,0x00,0x5f,0x5f,0x63,0x75,0x64,0x61,0x70,0x61,0x72, +0x6d,0x5f,0x75,0x70,0x64,0x61,0x74,0x65,0x42,0x69,0x6c,0x6c,0x62,0x6f,0x61,0x72, +0x64,0x56,0x42,0x5f,0x73,0x72,0x63,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x73, +0x00,0x5f,0x5f,0x63,0x75,0x64,0x61,0x70,0x61,0x72,0x6d,0x5f,0x75,0x70,0x64,0x61, +0x74,0x65,0x42,0x69,0x6c,0x6c,0x62,0x6f,0x61,0x72,0x64,0x56,0x42,0x5f,0x73,0x72, +0x63,0x4c,0x69,0x66,0x65,0x74,0x69,0x6d,0x65,0x73,0x00,0x5f,0x5f,0x63,0x75,0x64, +0x61,0x70,0x61,0x72,0x6d,0x5f,0x75,0x70,0x64,0x61,0x74,0x65,0x42,0x69,0x6c,0x6c, +0x62,0x6f,0x61,0x72,0x64,0x56,0x42,0x5f,0x76,0x61,0x6c,0x69,0x64,0x50,0x61,0x72, +0x74,0x69,0x63,0x6c,0x65,0x42,0x69,0x74,0x6d,0x61,0x70,0x00,0x5f,0x5f,0x63,0x75, +0x64,0x61,0x70,0x61,0x72,0x6d,0x5f,0x75,0x70,0x64,0x61,0x74,0x65,0x42,0x69,0x6c, +0x6c,0x62,0x6f,0x61,0x72,0x64,0x56,0x42,0x5f,0x76,0x61,0x6c,0x69,0x64,0x50,0x61, +0x72,0x74,0x69,0x63,0x6c,0x65,0x52,0x61,0x6e,0x67,0x65,0x00,0x2e,0x6e,0x76,0x2e, +0x67,0x6c,0x6f,0x62,0x61,0x6c,0x00,0x5f,0x5a,0x4e,0x35,0x70,0x68,0x79,0x73,0x78, +0x37,0x67,0x4f,0x66,0x66,0x73,0x65,0x74,0x45,0x00,0x2e,0x6e,0x76,0x2e,0x63,0x6f, +0x6e,0x73,0x74,0x61,0x6e,0x74,0x31,0x34,0x00,0x24,0x41,0x44,0x44,0x52,0x45,0x53, +0x53,0x24,0x5f,0x5a,0x4e,0x35,0x70,0x68,0x79,0x73,0x78,0x37,0x67,0x4f,0x66,0x66, +0x73,0x65,0x74,0x45,0x00,0x2e,0x72,0x65,0x6c,0x2e,0x6e,0x76,0x2e,0x63,0x6f,0x6e, +0x73,0x74,0x61,0x6e,0x74,0x31,0x34,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x2d,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x03,0x00,0x0a,0x00,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x03,0x00,0x0c,0x00,0x7d,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x03,0x00,0x07,0x00,0x3e,0x02,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x03,0x00,0x0b,0x00,0x71,0x02,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x03,0x00,0x0d,0x00,0x8e,0x02,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x03,0x00,0x08,0x00,0x08,0x04,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x03,0x00,0x0e,0x00,0x13,0x04,0x00,0x00,0x00,0x00,0x00,0x00, +0x04,0x00,0x00,0x00,0x01,0x00,0x0e,0x00,0x26,0x04,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x03,0x00,0x09,0x00,0x1b,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x68,0x03,0x00,0x00,0x12,0x10,0x0a,0x00,0x2c,0x02,0x00,0x00,0x00,0x00,0x00,0x00, +0xf0,0x02,0x00,0x00,0x12,0x10,0x0b,0x00,0x03,0x18,0x24,0x00,0x04,0x17,0x0c,0x00, +0x00,0x00,0x00,0x00,0x08,0x00,0x20,0x00,0x00,0xf0,0x13,0x00,0x04,0x17,0x0c,0x00, +0x00,0x00,0x00,0x00,0x07,0x00,0x1c,0x00,0x00,0xf0,0x13,0x00,0x04,0x17,0x0c,0x00, +0x00,0x00,0x00,0x00,0x06,0x00,0x18,0x00,0x00,0xf0,0x13,0x00,0x04,0x17,0x0c,0x00, +0x00,0x00,0x00,0x00,0x05,0x00,0x14,0x00,0x00,0xf0,0x13,0x00,0x04,0x17,0x0c,0x00, +0x00,0x00,0x00,0x00,0x04,0x00,0x10,0x00,0x00,0xf0,0x13,0x00,0x04,0x17,0x0c,0x00, +0x00,0x00,0x00,0x00,0x03,0x00,0x0c,0x00,0x00,0xf0,0x13,0x00,0x04,0x17,0x0c,0x00, +0x00,0x00,0x00,0x00,0x02,0x00,0x08,0x00,0x00,0xf0,0x13,0x00,0x04,0x17,0x0c,0x00, +0x00,0x00,0x00,0x00,0x01,0x00,0x04,0x00,0x00,0xf0,0x13,0x00,0x04,0x17,0x0c,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0x13,0x00,0x04,0x1e,0x04,0x00, +0x08,0x01,0x00,0x00,0x03,0x18,0x20,0x00,0x04,0x17,0x0c,0x00,0x00,0x00,0x00,0x00, +0x07,0x00,0x1c,0x00,0x00,0xf0,0x13,0x00,0x04,0x17,0x0c,0x00,0x00,0x00,0x00,0x00, +0x06,0x00,0x18,0x00,0x00,0xf0,0x13,0x00,0x04,0x17,0x0c,0x00,0x00,0x00,0x00,0x00, +0x05,0x00,0x14,0x00,0x00,0xf0,0x13,0x00,0x04,0x17,0x0c,0x00,0x00,0x00,0x00,0x00, +0x04,0x00,0x10,0x00,0x00,0xf0,0x13,0x00,0x04,0x17,0x0c,0x00,0x00,0x00,0x00,0x00, +0x03,0x00,0x0c,0x00,0x00,0xf0,0x13,0x00,0x04,0x17,0x0c,0x00,0x00,0x00,0x00,0x00, +0x02,0x00,0x08,0x00,0x00,0xf0,0x13,0x00,0x04,0x17,0x0c,0x00,0x00,0x00,0x00,0x00, +0x01,0x00,0x04,0x00,0x00,0xf0,0x13,0x00,0x04,0x17,0x0c,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0xf0,0x13,0x00,0x04,0x1e,0x04,0x00,0x10,0x01,0x00,0x00, +0x00,0x00,0x00,0x00,0x01,0x08,0x00,0x00,0x55,0x55,0x55,0x55,0x33,0x33,0x33,0x33, +0x0f,0x0f,0x0f,0x0f,0x00,0x00,0x00,0x00,0x20,0x00,0x00,0x00,0x9e,0x00,0x00,0x00, +0x55,0x55,0x55,0x55,0x33,0x33,0x33,0x33,0x0f,0x0f,0x0f,0x0f,0x00,0x00,0x00,0x00, +0x20,0x00,0x00,0x00,0x9e,0x00,0x00,0x00,0x00,0x00,0x7f,0x43,0x00,0x00,0x00,0x00, +0x05,0x00,0x00,0xa0,0xc0,0x07,0x00,0x04,0x09,0x00,0x00,0x10,0x00,0xc5,0x80,0x27, +0x01,0x06,0x00,0x10,0x00,0xc5,0x40,0x24,0x01,0x04,0x0e,0xd0,0x00,0x05,0xc0,0xa0, +0x03,0xfe,0x1f,0x86,0x00,0x00,0x00,0x00,0xfd,0xd9,0x7c,0x30,0xc8,0x87,0x20,0x64, +0x03,0x00,0x00,0x30,0x80,0x02,0x00,0x00,0x0d,0xd8,0x05,0x30,0x80,0x07,0x30,0xe4, +0xfd,0x07,0x01,0x30,0xc8,0x47,0x00,0x64,0x01,0x02,0x00,0x10,0x80,0xc7,0x03,0x04, +0x03,0x00,0x00,0x30,0x80,0x02,0x00,0x00,0x05,0x02,0x02,0x30,0x80,0x07,0x10,0xc4, +0x11,0x42,0x00,0xa0,0x80,0x07,0x20,0x04,0x19,0xd6,0x00,0x20,0x80,0x47,0x20,0x04, +0x15,0x08,0x02,0x30,0x80,0x07,0x10,0xc4,0x05,0x0c,0x0e,0xd0,0x80,0x07,0xc0,0x80, +0x09,0x02,0x01,0x30,0x80,0x07,0x10,0xe4,0x09,0x04,0x80,0xd0,0x80,0x07,0x40,0x04, +0x05,0x02,0x40,0x20,0x80,0x87,0x00,0x04,0x09,0x02,0x02,0x30,0x80,0x07,0x10,0xe4, +0x05,0x02,0x81,0xd0,0x80,0x07,0x40,0x04,0x09,0x04,0x81,0xd0,0x80,0x07,0x40,0x04, +0x05,0x02,0x00,0x20,0x80,0x87,0x00,0x04,0x09,0x02,0x04,0x30,0x80,0x07,0x10,0xe4, +0x05,0x02,0x00,0x20,0x80,0x87,0x00,0x04,0x05,0x02,0x82,0xd0,0x80,0x07,0x40,0x04, +0x09,0x02,0x40,0x40,0x0b,0x08,0x08,0x00,0x09,0x04,0x01,0x30,0x80,0x07,0x10,0xc4, +0x05,0x02,0x00,0x20,0x80,0x87,0x00,0x04,0x09,0x00,0x00,0x10,0x80,0xc7,0x80,0x27, +0x05,0x02,0x18,0x30,0x80,0x07,0x10,0xe4,0x05,0x04,0x01,0xd7,0x80,0x07,0xc0,0xe0, +0x1d,0x0c,0x0e,0xd0,0x80,0x07,0xc0,0x80,0x03,0x80,0x06,0xa0,0x00,0x00,0x00,0x00, +0xfd,0x0f,0x7c,0x30,0xc8,0x87,0x00,0x64,0x03,0x80,0x06,0x10,0x80,0x02,0x00,0x00, +0x09,0x10,0x00,0x10,0x80,0xc7,0x00,0x44,0x21,0x04,0x05,0x40,0x80,0x07,0x00,0x00, +0x21,0x06,0x04,0x60,0x80,0x07,0x02,0x00,0x21,0x10,0x10,0x30,0x80,0x07,0x10,0xc4, +0x29,0x04,0x04,0x60,0x80,0x07,0x02,0x00,0x05,0x00,0x05,0x30,0x80,0x07,0x10,0xc4, +0x08,0xea,0x0a,0x21,0x20,0xec,0x0a,0x21,0x24,0xee,0x0a,0x21,0x28,0xe8,0x0a,0x21, +0x2d,0x8e,0x00,0x30,0x03,0x00,0x00,0x00,0x2d,0x16,0x07,0xd0,0xc0,0x07,0x00,0x04, +0x2d,0x16,0x00,0xa0,0x80,0x46,0x06,0x44,0x2d,0x16,0x17,0x30,0x80,0x06,0x10,0xec, +0x2d,0x16,0x00,0x31,0x80,0x46,0x41,0x04,0x2d,0x08,0x00,0x10,0x00,0xc1,0x40,0x24, +0x2d,0x96,0x1f,0x30,0x03,0x00,0x00,0x00,0x2d,0x16,0x01,0xd0,0x80,0x47,0x00,0x04, +0x31,0x16,0x05,0x30,0x80,0x07,0x10,0xc4,0x35,0x16,0x02,0x30,0x80,0x07,0x10,0xc4, +0x30,0x98,0x0d,0x20,0x30,0xf4,0x0c,0x21,0x35,0x18,0x0e,0xd0,0x80,0x07,0xc0,0x80, +0x35,0x04,0x0e,0xd0,0x80,0x07,0xc0,0xa0,0x35,0x98,0x04,0x20,0x03,0x00,0x00,0x00, +0x35,0x1a,0x0e,0xd0,0x80,0x07,0xc0,0x80,0x39,0x84,0x04,0x20,0x03,0x00,0x00,0x00, +0x35,0x1c,0x0e,0xd0,0x80,0x07,0xc0,0xa0,0x35,0x98,0x08,0x20,0x03,0x00,0x00,0x00, +0x35,0x1a,0x0e,0xd0,0x80,0x07,0xc0,0x80,0x39,0x84,0x08,0x20,0x03,0x00,0x00,0x00, +0x35,0x1c,0x0e,0xd0,0x80,0x07,0xc0,0xa0,0x35,0x98,0x0c,0x20,0x03,0x00,0x00,0x00, +0x35,0x1a,0x0e,0xd0,0x80,0x07,0xc0,0x80,0x35,0x10,0x0e,0xd0,0x80,0x07,0xc0,0xa0, +0x35,0x98,0x10,0x20,0x03,0x00,0x00,0x00,0x35,0x1a,0x0e,0xd0,0x80,0x07,0xc0,0x80, +0x39,0x90,0x04,0x20,0x03,0x00,0x00,0x00,0x35,0x1c,0x0e,0xd0,0x80,0x07,0xc0,0xa0, +0x35,0x98,0x14,0x20,0x03,0x00,0x00,0x00,0x35,0x1a,0x0e,0xd0,0x80,0x07,0xc0,0x80, +0x39,0x90,0x08,0x20,0x03,0x00,0x00,0x00,0x35,0x1c,0x0e,0xd0,0x80,0x07,0xc0,0xa0, +0x35,0x98,0x18,0x20,0x03,0x00,0x00,0x00,0x35,0x1a,0x0e,0xd0,0x80,0x07,0xc0,0x80, +0x35,0x12,0x0e,0xd0,0x80,0x07,0xc0,0xa0,0x35,0x98,0x1c,0x20,0x03,0x00,0x00,0x00, +0x35,0x1a,0x0e,0xd0,0x80,0x07,0xc0,0x80,0x39,0x92,0x04,0x20,0x03,0x00,0x00,0x00, +0x35,0x1c,0x0e,0xd0,0x80,0x07,0xc0,0xa0,0x31,0x98,0x20,0x20,0x03,0x00,0x00,0x00, +0x31,0x18,0x0e,0xd0,0x80,0x07,0xc0,0x80,0x35,0x92,0x08,0x20,0x03,0x00,0x00,0x00, +0x31,0x1a,0x0e,0xd0,0x80,0x07,0xc0,0xa0,0x2d,0x16,0x04,0x30,0x80,0x07,0x10,0xc4, +0x31,0xd2,0x00,0x20,0x80,0xc7,0x22,0x04,0x2d,0x18,0x0e,0xd0,0x80,0x07,0xc0,0x80, +0x2d,0x14,0x0e,0xd0,0x80,0x07,0xc0,0xa0,0x2d,0x98,0x04,0x20,0x03,0x00,0x00,0x00, +0x2d,0x16,0x0e,0xd0,0x80,0x07,0xc0,0x80,0x35,0x94,0x04,0x20,0x03,0x00,0x00,0x00, +0x2d,0x1a,0x0e,0xd0,0x80,0x07,0xc0,0xa0,0x2d,0x98,0x08,0x20,0x03,0x00,0x00,0x00, +0x2d,0x16,0x0e,0xd0,0x80,0x07,0xc0,0x80,0x31,0x94,0x08,0x20,0x03,0x00,0x00,0x00, +0x2d,0x18,0x0e,0xd0,0x80,0x07,0xc0,0xa0,0x2d,0x8e,0x3f,0x20,0xff,0xff,0xff,0x0f, +0x1d,0x0e,0x0b,0xd0,0xc0,0x07,0x00,0x04,0x08,0xf0,0x02,0x21,0x20,0xf0,0x08,0x21, +0x24,0xf0,0x09,0x21,0x28,0xf0,0x0a,0x21,0x03,0xc0,0x02,0x10,0x80,0x02,0x00,0x00, +0x01,0x00,0x00,0x20,0x82,0x07,0x01,0x04,0xfd,0x07,0x00,0x30,0xc8,0x87,0x01,0x64, +0x19,0x0a,0x00,0x20,0x80,0x87,0x01,0x04,0x03,0xf0,0x00,0x10,0x80,0x02,0x00,0x00, +0x01,0x00,0x00,0xf0,0x01,0x00,0x00,0xe0,0x01,0x00,0x00,0xa0,0xc0,0x07,0x00,0x04, +0x09,0x00,0x00,0x10,0x00,0xc5,0x80,0x27,0x05,0x06,0x00,0x10,0x00,0xc5,0x40,0x24, +0x05,0x04,0x0e,0xd0,0x00,0x05,0xc0,0xa0,0x03,0xfe,0x1f,0x86,0x00,0x00,0x00,0x00, +0xfd,0xd7,0x7c,0x30,0xc8,0x87,0x20,0x64,0x03,0x00,0x00,0x30,0x80,0x02,0x00,0x00, +0x11,0xd6,0x05,0x30,0x80,0x07,0x30,0xe4,0xfd,0x09,0x00,0x30,0xc8,0x47,0x00,0x64, +0x09,0x00,0x00,0x10,0x80,0xc7,0x03,0x04,0x03,0x00,0x00,0x30,0x80,0x02,0x00,0x00, +0x01,0x00,0x02,0x30,0x80,0x07,0x10,0xc4,0x15,0x42,0x00,0xa0,0x80,0x07,0x20,0x04, +0x1d,0xd4,0x00,0x20,0x80,0x07,0x20,0x04,0x19,0x0a,0x02,0x30,0x80,0x07,0x10,0xc4, +0x01,0x0e,0x0e,0xd0,0x80,0x07,0xc0,0x80,0x05,0x00,0x01,0x30,0x80,0x07,0x10,0xe4, +0x05,0x02,0x80,0xd0,0x80,0x07,0x40,0x04,0x01,0x00,0x40,0x20,0x80,0x47,0x00,0x04, +0x05,0x00,0x02,0x30,0x80,0x07,0x10,0xe4,0x01,0x00,0x81,0xd0,0x80,0x07,0x40,0x04, +0x05,0x02,0x81,0xd0,0x80,0x07,0x40,0x04,0x01,0x00,0x00,0x20,0x80,0x47,0x00,0x04, +0x05,0x00,0x04,0x30,0x80,0x07,0x10,0xe4,0x01,0x00,0x00,0x20,0x80,0x47,0x00,0x04, +0x01,0x00,0x82,0xd0,0x80,0x07,0x40,0x04,0x05,0x00,0x40,0x40,0x0b,0x08,0x08,0x00, +0x05,0x02,0x01,0x30,0x80,0x07,0x10,0xc4,0x01,0x00,0x00,0x20,0x80,0x47,0x00,0x04, +0x05,0x00,0x00,0x10,0x80,0xc7,0x80,0x27,0x01,0x00,0x18,0x30,0x80,0x07,0x10,0xe4, +0x05,0x02,0x00,0xd7,0x80,0x07,0xc0,0xe0,0x21,0x0e,0x0e,0xd0,0x80,0x07,0xc0,0x80, +0x03,0x90,0x05,0xa0,0x00,0x00,0x00,0x00,0x0d,0x02,0x00,0x10,0x80,0xc7,0x03,0x04, +0xfd,0x11,0x7c,0x30,0xc8,0x87,0x00,0x64,0x03,0x90,0x05,0x10,0x80,0x02,0x00,0x00, +0x01,0x0c,0x00,0x10,0x80,0xc7,0x00,0x44,0x25,0x04,0x01,0x40,0x80,0x07,0x00,0x00, +0x25,0x06,0x00,0x60,0x80,0x47,0x02,0x00,0x25,0x12,0x10,0x30,0x80,0x07,0x10,0xc4, +0x01,0x04,0x00,0x60,0x80,0x47,0x02,0x00,0xfd,0xd3,0x7c,0x30,0xc8,0x47,0x21,0x64, +0x05,0x04,0x05,0x30,0x80,0x07,0x10,0xc4,0x25,0xc8,0x00,0x20,0x80,0x07,0x20,0x04, +0x01,0x90,0x00,0x30,0x03,0x00,0x00,0x00,0x01,0x00,0x08,0xd0,0xd0,0x07,0x00,0x04, +0x01,0x00,0x00,0xa0,0x80,0x56,0x06,0x44,0x01,0x00,0x17,0x30,0x80,0x16,0x10,0xec, +0x01,0x00,0x00,0x31,0x80,0x56,0x41,0x04,0x01,0x08,0x00,0x10,0x00,0xd1,0x40,0x24, +0x01,0x80,0x1f,0x30,0x03,0x00,0x00,0x00,0x01,0x00,0x01,0xd0,0x80,0x47,0x00,0x04, +0x29,0x00,0x04,0x30,0x80,0x07,0x10,0xc4,0x29,0xd0,0x00,0x20,0x80,0x87,0x22,0x04, +0x2d,0x14,0x0e,0xd0,0x80,0x07,0xc0,0x80,0x2d,0x12,0x0e,0xd0,0x80,0x07,0xc0,0xa0, +0x2d,0x94,0x04,0x20,0x03,0x00,0x00,0x00,0x2d,0x16,0x0e,0xd0,0x80,0x07,0xc0,0x80, +0x31,0x92,0x04,0x20,0x03,0x00,0x00,0x00,0x2d,0x18,0x0e,0xd0,0x80,0x07,0xc0,0xa0, +0x29,0x94,0x08,0x20,0x03,0x00,0x00,0x00,0x29,0x14,0x0e,0xd0,0x80,0x07,0xc0,0x80, +0x2d,0x92,0x08,0x20,0x03,0x00,0x00,0x00,0x29,0x16,0x0e,0xd0,0x80,0x07,0xc0,0xa0, +0x03,0x40,0x05,0x10,0x00,0x01,0x00,0x00,0x01,0x00,0x02,0x30,0x80,0x07,0x10,0xc4, +0x01,0xd2,0x00,0x20,0x80,0x07,0x20,0x04,0x29,0x00,0x0e,0xd0,0x80,0x07,0xc0,0x80, +0xfd,0xcf,0x0a,0xb0,0xd8,0xc7,0x20,0x60,0x03,0x10,0x05,0xa0,0x00,0x00,0x00,0x00, +0x03,0xa0,0x04,0x10,0x00,0x11,0x00,0x00,0x01,0x80,0x3f,0x10,0x0f,0x00,0x00,0x00, +0x03,0x10,0x05,0x10,0x80,0x07,0x00,0x00,0xfd,0x15,0x7c,0xb0,0xd8,0xc7,0x00,0x60, +0x01,0xf8,0x00,0x10,0x80,0xd6,0x03,0x04,0x01,0x0e,0x00,0x10,0x00,0xd1,0x00,0x44, +0x29,0x14,0x86,0xc0,0x00,0x11,0x40,0x00,0x01,0x00,0x00,0x90,0x00,0x11,0x00,0x00, +0x01,0x14,0x00,0xc0,0x00,0x11,0x00,0x00,0x01,0x00,0x00,0xa0,0x00,0x51,0x06,0x84, +0x29,0x06,0x02,0x30,0x82,0x07,0x10,0xc4,0x29,0xca,0x00,0x20,0x80,0x87,0x22,0x04, +0x01,0x14,0x0e,0xd0,0x80,0x07,0x00,0xa0,0x01,0x90,0x3f,0x20,0xff,0xff,0xff,0x0f, +0x21,0x10,0x00,0xd0,0xd0,0x07,0x00,0x04,0x25,0xcc,0x00,0x20,0x80,0x47,0x22,0x04, +0x0d,0x86,0x01,0x20,0x03,0x00,0x00,0x00,0x03,0xd0,0x02,0x10,0x80,0x12,0x00,0x00, +0x09,0x04,0x00,0x20,0x82,0x47,0x01,0x04,0xfd,0x09,0x02,0x30,0xc8,0x87,0x01,0x64, +0x1d,0x0c,0x00,0x20,0x80,0xc7,0x01,0x04,0x03,0xf0,0x00,0x10,0x80,0x02,0x00,0x00, +0x01,0x00,0x00,0xf0,0x01,0x00,0x00,0xe0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x01,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x34,0x00,0x00,0x00,0x28,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0b,0x00,0x00,0x00,0x03,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x5c,0x01,0x00,0x00,0x64,0x04,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x13,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0xc0,0x05,0x00,0x00,0xc0,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x09,0x00,0x00,0x00, +0x04,0x00,0x00,0x00,0x10,0x00,0x00,0x00,0x33,0x00,0x00,0x00,0x00,0x00,0x00,0x70, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x06,0x00,0x00,0x9c,0x00,0x00,0x00, +0x03,0x00,0x00,0x00,0x0a,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0xa3,0x00,0x00,0x00,0x00,0x00,0x00,0x70,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x1c,0x07,0x00,0x00,0x8c,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x0b,0x00,0x00,0x00, +0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x15,0x01,0x00,0x00,0x09,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xa8,0x07,0x00,0x00,0x08,0x00,0x00,0x00, +0x03,0x00,0x00,0x00,0x09,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x08,0x00,0x00,0x00, +0x6b,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0xb0,0x07,0x00,0x00,0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0a,0x00,0x00,0x00, +0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xdb,0x00,0x00,0x00,0x01,0x00,0x00,0x00, +0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc8,0x07,0x00,0x00,0x1c,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x0b,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x06,0x01,0x00,0x00,0x01,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0xe4,0x07,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1b,0x00,0x00,0x00,0x01,0x00,0x00,0x00, +0x06,0x00,0x10,0x00,0x00,0x00,0x00,0x00,0xe8,0x07,0x00,0x00,0x68,0x03,0x00,0x00, +0x03,0x00,0x00,0x00,0x0a,0x00,0x00,0x0f,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x8b,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x06,0x00,0x10,0x00,0x00,0x00,0x00,0x00, +0x50,0x0b,0x00,0x00,0xf0,0x02,0x00,0x00,0x03,0x00,0x00,0x00,0x0b,0x00,0x00,0x0d, +0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x4e,0x00,0x00,0x00,0x08,0x00,0x00,0x00, +0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x40,0x0e,0x00,0x00,0x34,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x0a,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0xbe,0x00,0x00,0x00,0x08,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x40,0x0e,0x00,0x00,0x30,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0b,0x00,0x00,0x00, +0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfb,0x00,0x00,0x00,0x08,0x00,0x00,0x00, +0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x40,0x0e,0x00,0x00,0x04,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x06,0x00,0x00,0x00,0x98,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x60,0x00,0x00,0x00,0x60,0x00,0x00,0x00,0x05,0x00,0x00,0x00,0x04,0x00,0x00,0x00, +0x01,0x00,0x00,0x00,0xb0,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x90,0x06,0x00,0x00,0x90,0x06,0x00,0x00,0x05,0x00,0x00,0x00,0x04,0x00,0x00,0x00, +0x01,0x00,0x00,0x00,0x40,0x0e,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x34,0x00,0x00,0x00,0x06,0x00,0x00,0x00,0x04,0x00,0x00,0x00, +0x02,0x00,0x01,0x01,0x58,0x00,0x00,0x00,0xd8,0x0b,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0x00,0x01,0x00,0x14,0x00,0x00,0x00, +0x40,0x00,0x00,0x00,0x12,0x00,0x00,0x00,0x44,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x52,0x65,0x6e,0x64,0x65,0x72,0x50,0x61,0x72,0x74,0x69,0x63,0x6c,0x65,0x73,0x2e, +0x63,0x75,0x00,0x00,0x00,0x00,0x00,0x00,0x7f,0x45,0x4c,0x46,0x01,0x01,0x01,0x33, +0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x00,0xbe,0x00,0x01,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x74,0x0b,0x00,0x00,0x6c,0x09,0x00,0x00,0x14,0x01,0x14,0x00, +0x34,0x00,0x20,0x00,0x03,0x00,0x28,0x00,0x0d,0x00,0x01,0x00,0x00,0x2e,0x73,0x68, +0x73,0x74,0x72,0x74,0x61,0x62,0x00,0x2e,0x73,0x74,0x72,0x74,0x61,0x62,0x00,0x2e, +0x73,0x79,0x6d,0x74,0x61,0x62,0x00,0x2e,0x74,0x65,0x78,0x74,0x2e,0x75,0x70,0x64, +0x61,0x74,0x65,0x49,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x64,0x56,0x42,0x00,0x2e, +0x6e,0x76,0x2e,0x69,0x6e,0x66,0x6f,0x2e,0x75,0x70,0x64,0x61,0x74,0x65,0x49,0x6e, +0x73,0x74,0x61,0x6e,0x63,0x65,0x64,0x56,0x42,0x00,0x2e,0x6e,0x76,0x2e,0x73,0x68, +0x61,0x72,0x65,0x64,0x2e,0x75,0x70,0x64,0x61,0x74,0x65,0x49,0x6e,0x73,0x74,0x61, +0x6e,0x63,0x65,0x64,0x56,0x42,0x00,0x2e,0x6e,0x76,0x2e,0x69,0x6e,0x66,0x6f,0x00, +0x2e,0x6e,0x76,0x2e,0x63,0x6f,0x6e,0x73,0x74,0x61,0x6e,0x74,0x30,0x2e,0x75,0x70, +0x64,0x61,0x74,0x65,0x49,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x64,0x56,0x42,0x00, +0x2e,0x74,0x65,0x78,0x74,0x2e,0x75,0x70,0x64,0x61,0x74,0x65,0x42,0x69,0x6c,0x6c, +0x62,0x6f,0x61,0x72,0x64,0x56,0x42,0x00,0x2e,0x6e,0x76,0x2e,0x69,0x6e,0x66,0x6f, +0x2e,0x75,0x70,0x64,0x61,0x74,0x65,0x42,0x69,0x6c,0x6c,0x62,0x6f,0x61,0x72,0x64, +0x56,0x42,0x00,0x2e,0x6e,0x76,0x2e,0x73,0x68,0x61,0x72,0x65,0x64,0x2e,0x75,0x70, +0x64,0x61,0x74,0x65,0x42,0x69,0x6c,0x6c,0x62,0x6f,0x61,0x72,0x64,0x56,0x42,0x00, +0x2e,0x6e,0x76,0x2e,0x63,0x6f,0x6e,0x73,0x74,0x61,0x6e,0x74,0x30,0x2e,0x75,0x70, +0x64,0x61,0x74,0x65,0x42,0x69,0x6c,0x6c,0x62,0x6f,0x61,0x72,0x64,0x56,0x42,0x00, +0x00,0x2e,0x73,0x68,0x73,0x74,0x72,0x74,0x61,0x62,0x00,0x2e,0x73,0x74,0x72,0x74, +0x61,0x62,0x00,0x2e,0x73,0x79,0x6d,0x74,0x61,0x62,0x00,0x75,0x70,0x64,0x61,0x74, +0x65,0x49,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x64,0x56,0x42,0x00,0x2e,0x74,0x65, +0x78,0x74,0x2e,0x75,0x70,0x64,0x61,0x74,0x65,0x49,0x6e,0x73,0x74,0x61,0x6e,0x63, +0x65,0x64,0x56,0x42,0x00,0x2e,0x6e,0x76,0x2e,0x69,0x6e,0x66,0x6f,0x2e,0x75,0x70, +0x64,0x61,0x74,0x65,0x49,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x64,0x56,0x42,0x00, +0x2e,0x6e,0x76,0x2e,0x73,0x68,0x61,0x72,0x65,0x64,0x2e,0x75,0x70,0x64,0x61,0x74, +0x65,0x49,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x64,0x56,0x42,0x00,0x2e,0x6e,0x76, +0x2e,0x69,0x6e,0x66,0x6f,0x00,0x5f,0x5a,0x4e,0x35,0x70,0x68,0x79,0x73,0x78,0x37, +0x67,0x4f,0x66,0x66,0x73,0x65,0x74,0x45,0x00,0x2e,0x6e,0x76,0x2e,0x63,0x6f,0x6e, +0x73,0x74,0x61,0x6e,0x74,0x30,0x2e,0x75,0x70,0x64,0x61,0x74,0x65,0x49,0x6e,0x73, +0x74,0x61,0x6e,0x63,0x65,0x64,0x56,0x42,0x00,0x5f,0x70,0x61,0x72,0x61,0x6d,0x00, +0x75,0x70,0x64,0x61,0x74,0x65,0x42,0x69,0x6c,0x6c,0x62,0x6f,0x61,0x72,0x64,0x56, +0x42,0x00,0x2e,0x74,0x65,0x78,0x74,0x2e,0x75,0x70,0x64,0x61,0x74,0x65,0x42,0x69, +0x6c,0x6c,0x62,0x6f,0x61,0x72,0x64,0x56,0x42,0x00,0x2e,0x6e,0x76,0x2e,0x69,0x6e, +0x66,0x6f,0x2e,0x75,0x70,0x64,0x61,0x74,0x65,0x42,0x69,0x6c,0x6c,0x62,0x6f,0x61, +0x72,0x64,0x56,0x42,0x00,0x2e,0x6e,0x76,0x2e,0x73,0x68,0x61,0x72,0x65,0x64,0x2e, +0x75,0x70,0x64,0x61,0x74,0x65,0x42,0x69,0x6c,0x6c,0x62,0x6f,0x61,0x72,0x64,0x56, +0x42,0x00,0x24,0x75,0x70,0x64,0x61,0x74,0x65,0x42,0x69,0x6c,0x6c,0x62,0x6f,0x61, +0x72,0x64,0x56,0x42,0x24,0x5f,0x5a,0x4e,0x35,0x70,0x68,0x79,0x73,0x78,0x37,0x67, +0x4f,0x66,0x66,0x73,0x65,0x74,0x45,0x00,0x2e,0x6e,0x76,0x2e,0x63,0x6f,0x6e,0x73, +0x74,0x61,0x6e,0x74,0x30,0x2e,0x75,0x70,0x64,0x61,0x74,0x65,0x42,0x69,0x6c,0x6c, +0x62,0x6f,0x61,0x72,0x64,0x56,0x42,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x2d,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x03,0x00,0x09,0x00,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x03,0x00,0x0b,0x00,0x99,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x03,0x00,0x07,0x00,0xd2,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x03,0x00,0x0a,0x00,0x05,0x01,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x03,0x00,0x0c,0x00,0x48,0x01,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x03,0x00,0x08,0x00,0x1b,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x30,0x02,0x00,0x00,0x12,0x10,0x09,0x00,0xc0,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x18,0x02,0x00,0x00,0x12,0x10,0x0a,0x00,0x04,0x0a,0x08,0x00,0x03,0x00,0x00,0x00, +0x20,0x00,0x24,0x00,0x03,0x19,0x24,0x00,0x04,0x17,0x0c,0x00,0x00,0x00,0x00,0x00, +0x08,0x00,0x20,0x00,0x00,0xf0,0x11,0x00,0x04,0x17,0x0c,0x00,0x00,0x00,0x00,0x00, +0x07,0x00,0x1c,0x00,0x00,0xf0,0x11,0x00,0x04,0x17,0x0c,0x00,0x00,0x00,0x00,0x00, +0x06,0x00,0x18,0x00,0x00,0xf0,0x11,0x00,0x04,0x17,0x0c,0x00,0x00,0x00,0x00,0x00, +0x05,0x00,0x14,0x00,0x00,0xf0,0x11,0x00,0x04,0x17,0x0c,0x00,0x00,0x00,0x00,0x00, +0x04,0x00,0x10,0x00,0x00,0xf0,0x11,0x00,0x04,0x17,0x0c,0x00,0x00,0x00,0x00,0x00, +0x03,0x00,0x0c,0x00,0x00,0xf0,0x11,0x00,0x04,0x17,0x0c,0x00,0x00,0x00,0x00,0x00, +0x02,0x00,0x08,0x00,0x00,0xf0,0x11,0x00,0x04,0x17,0x0c,0x00,0x00,0x00,0x00,0x00, +0x01,0x00,0x04,0x00,0x00,0xf0,0x11,0x00,0x04,0x17,0x0c,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0xf0,0x11,0x00,0x04,0x1e,0x04,0x00,0x8c,0x01,0x00,0x00, +0x04,0x12,0x08,0x00,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x11,0x08,0x00, +0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x12,0x08,0x00,0x07,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x04,0x11,0x08,0x00,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x04,0x0a,0x08,0x00,0x06,0x00,0x00,0x00,0x20,0x00,0x20,0x00,0x03,0x19,0x20,0x00, +0x04,0x17,0x0c,0x00,0x00,0x00,0x00,0x00,0x07,0x00,0x1c,0x00,0x00,0xf0,0x11,0x00, +0x04,0x17,0x0c,0x00,0x00,0x00,0x00,0x00,0x06,0x00,0x18,0x00,0x00,0xf0,0x11,0x00, +0x04,0x17,0x0c,0x00,0x00,0x00,0x00,0x00,0x05,0x00,0x14,0x00,0x00,0xf0,0x11,0x00, +0x04,0x17,0x0c,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x10,0x00,0x00,0xf0,0x11,0x00, +0x04,0x17,0x0c,0x00,0x00,0x00,0x00,0x00,0x03,0x00,0x0c,0x00,0x00,0xf0,0x11,0x00, +0x04,0x17,0x0c,0x00,0x00,0x00,0x00,0x00,0x02,0x00,0x08,0x00,0x00,0xf0,0x11,0x00, +0x04,0x17,0x0c,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x04,0x00,0x00,0xf0,0x11,0x00, +0x04,0x17,0x0c,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0x11,0x00, +0x04,0x1e,0x04,0x00,0x8c,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xe4,0x5d,0x00,0x00, +0x04,0x44,0x00,0x28,0x04,0x1c,0x00,0x84,0x00,0x00,0x00,0x2c,0x03,0xdc,0x1f,0xfc, +0x00,0x00,0x7e,0x20,0x23,0xdc,0x01,0xfc,0x00,0x00,0x8e,0x1a,0x85,0xe0,0xff,0x03, +0x00,0x00,0x00,0xc9,0x04,0xdc,0xff,0xff,0x00,0x00,0xee,0x50,0x23,0xdc,0xf1,0x03, +0x01,0x40,0x0e,0x19,0xe7,0x01,0x00,0x00,0x00,0x00,0x00,0x80,0xe4,0x9d,0x00,0x00, +0x01,0x40,0x00,0x28,0x03,0x9c,0x20,0x14,0x00,0xc0,0x00,0x58,0x03,0xdc,0x01,0x08, +0x00,0x00,0x0e,0x1a,0xe7,0x01,0x00,0x00,0x00,0x00,0x00,0x80,0x43,0x1c,0x01,0xf0, +0x00,0x40,0x00,0x40,0x03,0xdc,0x00,0x14,0x00,0xc0,0x00,0x60,0x07,0x00,0x00,0xe0, +0x00,0x00,0x00,0x60,0x85,0x1c,0x41,0x00,0x00,0x00,0x00,0x80,0x04,0x9c,0x41,0x10, +0x00,0x00,0x00,0x54,0x85,0x5c,0xf1,0x03,0x00,0x00,0x00,0xc4,0x03,0xc0,0x51,0x18, +0x00,0x00,0x00,0x48,0x85,0xc0,0xf1,0x03,0x00,0x00,0x00,0xcc,0xe7,0x21,0x00,0x80, +0xff,0xff,0x03,0x40,0x33,0xdc,0x41,0xfc,0x00,0x00,0x0e,0x19,0x07,0x00,0x00,0x80, +0x05,0x00,0x00,0x60,0xe7,0x01,0x00,0x40,0x05,0x00,0x00,0x40,0xe4,0x9d,0x01,0xc0, +0x00,0x40,0x00,0x28,0xe4,0xdd,0x01,0xe0,0x00,0x40,0x00,0x28,0x03,0xdc,0x6f,0x1c, +0x00,0x00,0x7e,0x20,0x84,0x1f,0x22,0x11,0x00,0x00,0x00,0x1c,0xa3,0x1c,0x53,0x90, +0x00,0x80,0x0c,0x20,0xa3,0x5c,0x53,0xa0,0x00,0x80,0x0c,0x20,0x03,0x1c,0x42,0x20, +0x00,0x00,0x00,0x68,0x03,0x1c,0x02,0x20,0x00,0x00,0x00,0x78,0x43,0x1c,0x82,0x0c, +0x00,0x00,0x00,0x68,0xa3,0x5c,0x82,0x90,0x00,0xc0,0x0e,0x20,0x85,0xdc,0x92,0x00, +0x00,0x00,0x00,0x80,0x85,0xdc,0xc2,0x00,0x00,0x00,0x00,0x90,0x85,0x9c,0x92,0x10, +0x00,0x00,0x00,0x80,0x85,0x9c,0xc2,0x10,0x00,0x00,0x00,0x90,0x85,0xdc,0x92,0x20, +0x00,0x00,0x00,0x80,0x85,0xdc,0xc2,0x20,0x00,0x00,0x00,0x90,0x85,0x9c,0x92,0x30, +0x00,0x00,0x00,0x80,0xa3,0x1c,0x53,0xb0,0x00,0x80,0x0c,0x20,0x85,0x9c,0xd2,0x00, +0x00,0x00,0x00,0x90,0x85,0xdc,0x92,0x40,0x00,0x00,0x00,0x80,0x85,0xdc,0xd2,0x10, +0x00,0x00,0x00,0x90,0x85,0x9c,0x92,0x50,0x00,0x00,0x00,0x80,0x85,0x9c,0xd2,0x20, +0x00,0x00,0x00,0x90,0x85,0xdc,0x92,0x60,0x00,0x00,0x00,0x80,0x85,0xdc,0xc2,0x00, +0x00,0x00,0x00,0x90,0x85,0x9c,0x92,0x70,0x00,0x00,0x00,0x80,0x83,0xdc,0x82,0xd0, +0x00,0x40,0x00,0x40,0x85,0x9c,0xc2,0x10,0x00,0x00,0x00,0x90,0x85,0x5c,0x92,0x80, +0x00,0x00,0x00,0x80,0xa3,0x9c,0x52,0x80,0x00,0x80,0x0c,0x20,0x03,0x5c,0x51,0x04, +0x00,0xc0,0x00,0x48,0x85,0x5c,0xc2,0x20,0x00,0x00,0x00,0x90,0x85,0x1c,0xb2,0x00, +0x00,0x00,0x00,0x80,0x03,0x1c,0x43,0xfc,0xff,0xff,0x00,0x48,0x03,0x1c,0xc1,0x10, +0x00,0x00,0x00,0x68,0x23,0xdc,0x41,0xfc,0x00,0x00,0x8e,0x1a,0x85,0x1c,0xa2,0x00, +0x00,0x00,0x00,0x90,0x85,0x5c,0xb2,0x10,0x00,0x00,0x00,0x80,0x85,0x5c,0xa2,0x10, +0x00,0x00,0x00,0x90,0x85,0x1c,0xb2,0x20,0x00,0x00,0x00,0x80,0x85,0x1c,0xa2,0x20, +0x00,0x00,0x00,0x90,0xe7,0x01,0x00,0x20,0xfb,0xff,0x03,0x40,0x13,0x1c,0x00,0x20, +0x00,0x40,0x00,0x48,0x03,0xdc,0x01,0x08,0x00,0x00,0x8e,0x19,0xe7,0x01,0x00,0xe0, +0xf8,0xff,0x03,0x40,0xe7,0x1d,0x00,0x00,0x00,0x00,0x00,0x80,0xe4,0x5d,0x00,0x00, +0x04,0x44,0x00,0x28,0x04,0x1c,0x00,0x84,0x00,0x00,0x00,0x2c,0x03,0xdc,0x1f,0xfc, +0x00,0x00,0x7e,0x20,0x23,0xdc,0x01,0xfc,0x00,0x00,0x8e,0x1a,0x85,0xe0,0xff,0x03, +0x00,0x00,0x00,0xc9,0x04,0xdc,0xff,0xff,0x00,0x00,0xee,0x50,0x23,0xdc,0xf1,0xf3, +0x00,0x40,0x0e,0x19,0xe7,0x01,0x00,0x00,0x00,0x00,0x00,0x80,0xe4,0x9d,0x00,0xf0, +0x00,0x40,0x00,0x28,0x03,0x9c,0x20,0x14,0x00,0xc0,0x00,0x58,0x03,0xdc,0x01,0x08, +0x00,0x00,0x0e,0x1a,0xe7,0x01,0x00,0x00,0x00,0x00,0x00,0x80,0x43,0x1c,0x01,0xe0, +0x00,0x40,0x00,0x40,0x03,0xdc,0x00,0x14,0x00,0xc0,0x00,0x60,0x07,0x00,0x00,0xe0, +0x00,0x00,0x00,0x60,0x85,0x5c,0x41,0x00,0x00,0x00,0x00,0x80,0x04,0x9c,0x51,0x14, +0x00,0x00,0x00,0x54,0x85,0x1c,0xf1,0x03,0x00,0x00,0x00,0xc4,0x03,0xc0,0x41,0x18, +0x00,0x00,0x00,0x48,0x85,0xc0,0xf1,0x03,0x00,0x00,0x00,0xcc,0xe7,0x21,0x00,0x80, +0xff,0xff,0x03,0x40,0x33,0xdc,0x51,0xfc,0x00,0x00,0x0e,0x19,0x07,0x00,0x00,0x20, +0x05,0x00,0x00,0x60,0xe7,0x01,0x00,0xe0,0x04,0x00,0x00,0x40,0xe4,0x9d,0x01,0x80, +0x00,0x40,0x00,0x28,0x03,0xdc,0x6f,0xfc,0x00,0x00,0x7e,0x20,0x84,0xdf,0x21,0x15, +0x00,0x00,0x00,0x1c,0xa3,0x9c,0x42,0xa0,0x00,0x40,0x0c,0x20,0x23,0xdc,0xf1,0xd3, +0x00,0x40,0x0e,0x19,0x03,0xdc,0x51,0x1c,0x00,0x00,0x00,0x68,0x03,0xdc,0x01,0x1c, +0x00,0x00,0x00,0x78,0x43,0x5c,0x72,0x0c,0x00,0x00,0x00,0x68,0x83,0xdc,0x92,0xc0, +0x00,0x40,0x00,0x40,0x85,0xdc,0xb1,0x00,0x00,0x00,0x00,0x80,0x85,0xdc,0xa1,0x00, +0x00,0x00,0x00,0x90,0x85,0x1c,0xb2,0x10,0x00,0x00,0x00,0x80,0x85,0x1c,0xa2,0x10, +0x00,0x00,0x00,0x90,0x85,0xdc,0xb1,0x20,0x00,0x00,0x00,0x80,0x85,0xdc,0xa1,0x20, +0x00,0x00,0x00,0x90,0xe7,0x01,0x00,0x40,0x02,0x00,0x00,0x40,0x43,0xdc,0x91,0xd0, +0x00,0x40,0x00,0x40,0x07,0x00,0x00,0xe0,0x01,0x00,0x00,0x60,0x85,0xdc,0x71,0x00, +0x00,0x00,0x00,0x80,0x00,0xdc,0x71,0xb0,0x00,0x40,0x8e,0x2c,0xe7,0x01,0x00,0x40, +0x00,0x00,0x00,0x40,0xe2,0xdd,0x01,0xfc,0x03,0x00,0x00,0x18,0xe7,0x1d,0x00,0x20, +0x01,0x00,0x00,0x40,0x00,0xdc,0x71,0xfc,0x00,0x00,0x0e,0x2e,0xe4,0xe1,0x01,0xfc, +0x00,0x00,0x00,0x28,0xe7,0xa1,0x00,0xc0,0x00,0x00,0x00,0x40,0xe4,0x01,0x02,0xb0, +0x00,0x40,0x00,0x28,0x40,0xc0,0x71,0xc0,0xdf,0xd0,0x00,0x58,0x00,0x00,0x82,0x10, +0x00,0x00,0x00,0xc8,0x40,0xc0,0x71,0x20,0x00,0x00,0x00,0x58,0x04,0xc0,0x21,0x1d, +0x00,0x00,0x86,0x14,0x84,0xc0,0x91,0x1c,0x00,0x00,0x00,0x1c,0x53,0x1c,0x42,0x90, +0x00,0x40,0x00,0x40,0x05,0xdc,0x81,0x00,0x00,0x00,0x00,0x90,0x03,0xdc,0x51,0xfc, +0xff,0xff,0x00,0x48,0x03,0x1c,0x41,0x04,0x00,0xc0,0x00,0x48,0x03,0x5c,0x71,0x14, +0x00,0x00,0x00,0x68,0x23,0xdc,0x51,0xfc,0x00,0x00,0x8e,0x1a,0xe7,0x01,0x00,0x60, +0xfb,0xff,0x03,0x40,0x13,0x1c,0x00,0x20,0x00,0x40,0x00,0x48,0x03,0xdc,0x01,0x08, +0x00,0x00,0x8e,0x19,0xe7,0x01,0x00,0x40,0xf9,0xff,0x03,0x40,0xe7,0x1d,0x00,0x00, +0x00,0x00,0x00,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00, +0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x34,0x00,0x00,0x00, +0x04,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x0b,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x38,0x01,0x00,0x00,0x68,0x01,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x13,0x00,0x00,0x00, +0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xa0,0x02,0x00,0x00, +0x90,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x06,0x00,0x00,0x00,0x04,0x00,0x00,0x00, +0x10,0x00,0x00,0x00,0x33,0x00,0x00,0x00,0x00,0x00,0x00,0x70,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x30,0x03,0x00,0x00,0xa8,0x00,0x00,0x00,0x03,0x00,0x00,0x00, +0x09,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x6b,0x00,0x00,0x00, +0x00,0x00,0x00,0x70,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xd8,0x03,0x00,0x00, +0x30,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0xac,0x00,0x00,0x00,0x00,0x00,0x00,0x70,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x08,0x04,0x00,0x00,0x98,0x00,0x00,0x00,0x03,0x00,0x00,0x00, +0x0a,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x74,0x00,0x00,0x00, +0x01,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xa0,0x04,0x00,0x00, +0x44,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x09,0x00,0x00,0x00,0x04,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0xe4,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x02,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0xe4,0x04,0x00,0x00,0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x0a,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1b,0x00,0x00,0x00, +0x01,0x00,0x00,0x00,0x06,0x00,0x10,0x00,0x00,0x00,0x00,0x00,0x24,0x05,0x00,0x00, +0x30,0x02,0x00,0x00,0x03,0x00,0x00,0x00,0x07,0x00,0x00,0x0e,0x04,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x94,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x06,0x00,0x10,0x00, +0x00,0x00,0x00,0x00,0x54,0x07,0x00,0x00,0x18,0x02,0x00,0x00,0x03,0x00,0x00,0x00, +0x08,0x00,0x00,0x0c,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x4e,0x00,0x00,0x00, +0x08,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x6c,0x09,0x00,0x00, +0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x09,0x00,0x00,0x00,0x04,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0xc7,0x00,0x00,0x00,0x08,0x00,0x00,0x00,0x03,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x6c,0x09,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x0a,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x06,0x00,0x00,0x00, +0x74,0x0b,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x60,0x00,0x00,0x00, +0x60,0x00,0x00,0x00,0x05,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x01,0x00,0x00,0x00, +0xa0,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xcc,0x04,0x00,0x00, +0xcc,0x04,0x00,0x00,0x05,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x01,0x00,0x00,0x00, +0x6c,0x09,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x04,0x00,0x00,0x00,0x06,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x02,0x00,0x01,0x01,0x58,0x00,0x00,0x00,0xe8,0x0e,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0x00,0x01,0x00,0x1e,0x00,0x00,0x00, +0x40,0x00,0x00,0x00,0x12,0x00,0x00,0x00,0x44,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x52,0x65,0x6e,0x64,0x65,0x72,0x50,0x61,0x72,0x74,0x69,0x63,0x6c,0x65,0x73,0x2e, +0x63,0x75,0x00,0x00,0x00,0x00,0x00,0x00,0x7f,0x45,0x4c,0x46,0x01,0x01,0x01,0x33, +0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x00,0xbe,0x00,0x01,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x88,0x0e,0x00,0x00,0x80,0x0c,0x00,0x00,0x1e,0x01,0x1e,0x00, +0x34,0x00,0x20,0x00,0x03,0x00,0x28,0x00,0x0d,0x00,0x01,0x00,0x00,0x2e,0x73,0x68, +0x73,0x74,0x72,0x74,0x61,0x62,0x00,0x2e,0x73,0x74,0x72,0x74,0x61,0x62,0x00,0x2e, +0x73,0x79,0x6d,0x74,0x61,0x62,0x00,0x2e,0x74,0x65,0x78,0x74,0x2e,0x75,0x70,0x64, +0x61,0x74,0x65,0x49,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x64,0x56,0x42,0x00,0x2e, +0x6e,0x76,0x2e,0x69,0x6e,0x66,0x6f,0x2e,0x75,0x70,0x64,0x61,0x74,0x65,0x49,0x6e, +0x73,0x74,0x61,0x6e,0x63,0x65,0x64,0x56,0x42,0x00,0x2e,0x6e,0x76,0x2e,0x73,0x68, +0x61,0x72,0x65,0x64,0x2e,0x75,0x70,0x64,0x61,0x74,0x65,0x49,0x6e,0x73,0x74,0x61, +0x6e,0x63,0x65,0x64,0x56,0x42,0x00,0x2e,0x6e,0x76,0x2e,0x69,0x6e,0x66,0x6f,0x00, +0x2e,0x6e,0x76,0x2e,0x63,0x6f,0x6e,0x73,0x74,0x61,0x6e,0x74,0x30,0x2e,0x75,0x70, +0x64,0x61,0x74,0x65,0x49,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x64,0x56,0x42,0x00, +0x2e,0x74,0x65,0x78,0x74,0x2e,0x75,0x70,0x64,0x61,0x74,0x65,0x42,0x69,0x6c,0x6c, +0x62,0x6f,0x61,0x72,0x64,0x56,0x42,0x00,0x2e,0x6e,0x76,0x2e,0x69,0x6e,0x66,0x6f, +0x2e,0x75,0x70,0x64,0x61,0x74,0x65,0x42,0x69,0x6c,0x6c,0x62,0x6f,0x61,0x72,0x64, +0x56,0x42,0x00,0x2e,0x6e,0x76,0x2e,0x73,0x68,0x61,0x72,0x65,0x64,0x2e,0x75,0x70, +0x64,0x61,0x74,0x65,0x42,0x69,0x6c,0x6c,0x62,0x6f,0x61,0x72,0x64,0x56,0x42,0x00, +0x2e,0x6e,0x76,0x2e,0x63,0x6f,0x6e,0x73,0x74,0x61,0x6e,0x74,0x30,0x2e,0x75,0x70, +0x64,0x61,0x74,0x65,0x42,0x69,0x6c,0x6c,0x62,0x6f,0x61,0x72,0x64,0x56,0x42,0x00, +0x00,0x2e,0x73,0x68,0x73,0x74,0x72,0x74,0x61,0x62,0x00,0x2e,0x73,0x74,0x72,0x74, +0x61,0x62,0x00,0x2e,0x73,0x79,0x6d,0x74,0x61,0x62,0x00,0x75,0x70,0x64,0x61,0x74, +0x65,0x49,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x64,0x56,0x42,0x00,0x2e,0x74,0x65, +0x78,0x74,0x2e,0x75,0x70,0x64,0x61,0x74,0x65,0x49,0x6e,0x73,0x74,0x61,0x6e,0x63, +0x65,0x64,0x56,0x42,0x00,0x2e,0x6e,0x76,0x2e,0x69,0x6e,0x66,0x6f,0x2e,0x75,0x70, +0x64,0x61,0x74,0x65,0x49,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x64,0x56,0x42,0x00, +0x2e,0x6e,0x76,0x2e,0x73,0x68,0x61,0x72,0x65,0x64,0x2e,0x75,0x70,0x64,0x61,0x74, +0x65,0x49,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x64,0x56,0x42,0x00,0x2e,0x6e,0x76, +0x2e,0x69,0x6e,0x66,0x6f,0x00,0x5f,0x5a,0x4e,0x35,0x70,0x68,0x79,0x73,0x78,0x37, +0x67,0x4f,0x66,0x66,0x73,0x65,0x74,0x45,0x00,0x2e,0x6e,0x76,0x2e,0x63,0x6f,0x6e, +0x73,0x74,0x61,0x6e,0x74,0x30,0x2e,0x75,0x70,0x64,0x61,0x74,0x65,0x49,0x6e,0x73, +0x74,0x61,0x6e,0x63,0x65,0x64,0x56,0x42,0x00,0x5f,0x70,0x61,0x72,0x61,0x6d,0x00, +0x75,0x70,0x64,0x61,0x74,0x65,0x42,0x69,0x6c,0x6c,0x62,0x6f,0x61,0x72,0x64,0x56, +0x42,0x00,0x2e,0x74,0x65,0x78,0x74,0x2e,0x75,0x70,0x64,0x61,0x74,0x65,0x42,0x69, +0x6c,0x6c,0x62,0x6f,0x61,0x72,0x64,0x56,0x42,0x00,0x2e,0x6e,0x76,0x2e,0x69,0x6e, +0x66,0x6f,0x2e,0x75,0x70,0x64,0x61,0x74,0x65,0x42,0x69,0x6c,0x6c,0x62,0x6f,0x61, +0x72,0x64,0x56,0x42,0x00,0x2e,0x6e,0x76,0x2e,0x73,0x68,0x61,0x72,0x65,0x64,0x2e, +0x75,0x70,0x64,0x61,0x74,0x65,0x42,0x69,0x6c,0x6c,0x62,0x6f,0x61,0x72,0x64,0x56, +0x42,0x00,0x24,0x75,0x70,0x64,0x61,0x74,0x65,0x42,0x69,0x6c,0x6c,0x62,0x6f,0x61, +0x72,0x64,0x56,0x42,0x24,0x5f,0x5a,0x4e,0x35,0x70,0x68,0x79,0x73,0x78,0x37,0x67, +0x4f,0x66,0x66,0x73,0x65,0x74,0x45,0x00,0x2e,0x6e,0x76,0x2e,0x63,0x6f,0x6e,0x73, +0x74,0x61,0x6e,0x74,0x30,0x2e,0x75,0x70,0x64,0x61,0x74,0x65,0x42,0x69,0x6c,0x6c, +0x62,0x6f,0x61,0x72,0x64,0x56,0x42,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x2d,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x03,0x00,0x09,0x00,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x03,0x00,0x0b,0x00,0x99,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x03,0x00,0x07,0x00,0xd2,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x03,0x00,0x0a,0x00,0x05,0x01,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x03,0x00,0x0c,0x00,0x48,0x01,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x03,0x00,0x08,0x00,0x1b,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x80,0x02,0x00,0x00,0x12,0x10,0x09,0x00,0xc0,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x80,0x02,0x00,0x00,0x12,0x10,0x0a,0x00,0x04,0x0a,0x08,0x00,0x03,0x00,0x00,0x00, +0x40,0x01,0x24,0x00,0x03,0x19,0x24,0x00,0x04,0x17,0x0c,0x00,0x00,0x00,0x00,0x00, +0x08,0x00,0x20,0x00,0x00,0xf0,0x11,0x00,0x04,0x17,0x0c,0x00,0x00,0x00,0x00,0x00, +0x07,0x00,0x1c,0x00,0x00,0xf0,0x11,0x00,0x04,0x17,0x0c,0x00,0x00,0x00,0x00,0x00, +0x06,0x00,0x18,0x00,0x00,0xf0,0x11,0x00,0x04,0x17,0x0c,0x00,0x00,0x00,0x00,0x00, +0x05,0x00,0x14,0x00,0x00,0xf0,0x11,0x00,0x04,0x17,0x0c,0x00,0x00,0x00,0x00,0x00, +0x04,0x00,0x10,0x00,0x00,0xf0,0x11,0x00,0x04,0x17,0x0c,0x00,0x00,0x00,0x00,0x00, +0x03,0x00,0x0c,0x00,0x00,0xf0,0x11,0x00,0x04,0x17,0x0c,0x00,0x00,0x00,0x00,0x00, +0x02,0x00,0x08,0x00,0x00,0xf0,0x11,0x00,0x04,0x17,0x0c,0x00,0x00,0x00,0x00,0x00, +0x01,0x00,0x04,0x00,0x00,0xf0,0x11,0x00,0x04,0x17,0x0c,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0xf0,0x11,0x00,0x04,0x1e,0x04,0x00,0x10,0x02,0x00,0x00, +0x04,0x12,0x08,0x00,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x11,0x08,0x00, +0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x12,0x08,0x00,0x07,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x04,0x11,0x08,0x00,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x04,0x0a,0x08,0x00,0x06,0x00,0x00,0x00,0x40,0x01,0x20,0x00,0x03,0x19,0x20,0x00, +0x04,0x17,0x0c,0x00,0x00,0x00,0x00,0x00,0x07,0x00,0x1c,0x00,0x00,0xf0,0x11,0x00, +0x04,0x17,0x0c,0x00,0x00,0x00,0x00,0x00,0x06,0x00,0x18,0x00,0x00,0xf0,0x11,0x00, +0x04,0x17,0x0c,0x00,0x00,0x00,0x00,0x00,0x05,0x00,0x14,0x00,0x00,0xf0,0x11,0x00, +0x04,0x17,0x0c,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x10,0x00,0x00,0xf0,0x11,0x00, +0x04,0x17,0x0c,0x00,0x00,0x00,0x00,0x00,0x03,0x00,0x0c,0x00,0x00,0xf0,0x11,0x00, +0x04,0x17,0x0c,0x00,0x00,0x00,0x00,0x00,0x02,0x00,0x08,0x00,0x00,0xf0,0x11,0x00, +0x04,0x17,0x0c,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x04,0x00,0x00,0xf0,0x11,0x00, +0x04,0x17,0x0c,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0x11,0x00, +0x04,0x1e,0x04,0x00,0x10,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf7,0x82,0xc2,0xe2,0x12,0xc3,0xe2,0x22, +0xe4,0x5d,0x00,0x10,0x01,0x40,0x00,0x28,0x04,0x1c,0x00,0x84,0x00,0x00,0x00,0x2c, +0x23,0xdc,0x01,0xfc,0x00,0x00,0x8e,0x1a,0x85,0xe0,0xff,0x03,0x00,0x00,0x00,0xc9, +0x04,0x1c,0x00,0x00,0x00,0xc0,0x0e,0x50,0x23,0xdc,0xf1,0x83,0x05,0x40,0x0e,0x19, +0xe7,0x01,0x00,0x00,0x00,0x00,0x00,0x80,0x87,0x82,0xc2,0xe2,0x42,0x80,0x02,0x22, +0xe4,0x9d,0x00,0x80,0x05,0x40,0x00,0x28,0x03,0xdc,0x20,0x14,0x00,0xc0,0x00,0x58, +0x03,0xdc,0x01,0x0c,0x00,0x00,0x0e,0x1a,0xe7,0x01,0x00,0x00,0x00,0x00,0x00,0x80, +0x43,0x9c,0x00,0x70,0x05,0x40,0x00,0x40,0x04,0xdc,0xf3,0x1c,0x00,0x00,0x0e,0x0c, +0x85,0x1c,0x21,0x00,0x00,0x00,0x00,0x80,0x07,0x52,0x03,0xb0,0x83,0xb2,0xe3,0x22, +0x07,0x00,0x00,0x00,0x01,0x00,0x00,0x60,0x03,0x5c,0x01,0x14,0x00,0xc0,0x00,0x60, +0x04,0x9c,0x41,0x10,0x00,0x00,0x00,0x54,0x85,0x9c,0xf0,0x03,0x00,0x00,0x00,0xa8, +0x03,0xc0,0x21,0x18,0x00,0x00,0x00,0x48,0x85,0xc1,0xf1,0x03,0x00,0x00,0x00,0xb8, +0xe7,0x25,0x00,0x80,0xff,0xff,0x03,0x40,0x07,0x40,0x02,0x40,0xf0,0x82,0x82,0x22, +0x33,0xdc,0x41,0xfc,0x00,0x00,0x0e,0x19,0x07,0x00,0x00,0x20,0x06,0x00,0x00,0x60, +0xe7,0x01,0x00,0xe0,0x05,0x00,0x00,0x40,0xe4,0x1d,0x03,0x40,0x05,0x40,0x00,0x28, +0xe4,0x5d,0x03,0x60,0x05,0x40,0x00,0x28,0x84,0xdf,0x21,0x11,0x00,0x00,0x00,0x1c, +0x03,0x9c,0x41,0x1c,0x00,0x00,0x00,0x68,0x87,0x82,0x82,0x02,0x62,0xe3,0x72,0x23, +0x03,0x9c,0x01,0x18,0x00,0x00,0x00,0x78,0x43,0x5c,0x62,0x14,0x00,0x00,0x00,0x68, +0xa3,0x9c,0x92,0x90,0x00,0xc0,0x1a,0x20,0x85,0xdc,0xa1,0x00,0x00,0x00,0x00,0x80, +0xa3,0x1c,0x22,0x10,0x05,0x80,0x18,0x20,0x85,0xdc,0x81,0x00,0x00,0x00,0x00,0x90, +0x85,0x9c,0xa1,0x10,0x00,0x00,0x00,0x80,0xe7,0x02,0x62,0xe3,0x72,0xe3,0x72,0x23, +0x85,0x9c,0x81,0x10,0x00,0x00,0x00,0x90,0x85,0xdc,0xa1,0x20,0x00,0x00,0x00,0x80, +0xa3,0xdc,0x22,0x20,0x05,0x80,0x18,0x20,0x85,0xdc,0x81,0x20,0x00,0x00,0x00,0x90, +0x85,0x9c,0xa1,0x30,0x00,0x00,0x00,0x80,0x85,0x9c,0xb1,0x00,0x00,0x00,0x00,0x90, +0x85,0xdc,0xa1,0x40,0x00,0x00,0x00,0x80,0x47,0xe0,0x72,0xe3,0x42,0x70,0xe3,0x22, +0x85,0xdc,0xb1,0x10,0x00,0x00,0x00,0x90,0xa3,0x1c,0x22,0x30,0x05,0x80,0x18,0x20, +0x85,0x9c,0xa1,0x50,0x00,0x00,0x00,0x80,0x85,0x9c,0xb1,0x20,0x00,0x00,0x00,0x90, +0x85,0xdc,0xa1,0x60,0x00,0x00,0x00,0x80,0x83,0xdc,0x92,0x50,0x05,0x40,0x00,0x40, +0x85,0xdc,0x81,0x00,0x00,0x00,0x00,0x90,0x77,0xe3,0x02,0x42,0x60,0xe3,0x02,0x22, +0x85,0x9c,0xa1,0x70,0x00,0x00,0x00,0x80,0x85,0x9c,0x81,0x10,0x00,0x00,0x00,0x90, +0x85,0xdc,0xa1,0x80,0x00,0x00,0x00,0x80,0xa3,0x5c,0x22,0x00,0x05,0x80,0x18,0x20, +0x03,0x9c,0x20,0x04,0x00,0xc0,0x00,0x48,0x85,0xdc,0x81,0x20,0x00,0x00,0x00,0x90, +0x85,0x9c,0xb1,0x00,0x00,0x00,0x00,0x80,0x67,0xe3,0x42,0x70,0x43,0xe0,0x72,0x23, +0x03,0x1c,0x42,0xfc,0xff,0xff,0x00,0x48,0x85,0x9c,0x91,0x00,0x00,0x00,0x00,0x90, +0x85,0xdc,0xb1,0x10,0x00,0x00,0x00,0x80,0x03,0x1c,0x81,0x10,0x00,0x00,0x00,0x68, +0x85,0xdc,0x91,0x10,0x00,0x00,0x00,0x90,0x23,0xdc,0x41,0xfc,0x00,0x00,0x8e,0x1a, +0x85,0x9c,0xb1,0x20,0x00,0x00,0x00,0x80,0x47,0xe0,0xf2,0xc2,0xe2,0xe2,0x02,0x20, +0x85,0x9c,0x91,0x20,0x00,0x00,0x00,0x90,0xe7,0x01,0x00,0x60,0xfa,0xff,0x03,0x40, +0x13,0x1c,0x00,0xa0,0x00,0x40,0x00,0x48,0x03,0xdc,0x01,0x0c,0x00,0x00,0x8e,0x19, +0xe7,0x01,0x00,0xe0,0xf7,0xff,0x03,0x40,0xe7,0x1d,0x00,0x00,0x00,0x00,0x00,0x80, +0xe7,0x1d,0x00,0xe0,0xff,0xff,0x03,0x40,0xf7,0x82,0xc2,0xe2,0x12,0xc3,0xe2,0x22, +0xe4,0x5d,0x00,0x10,0x01,0x40,0x00,0x28,0x04,0x1c,0x00,0x84,0x00,0x00,0x00,0x2c, +0x23,0xdc,0x01,0xfc,0x00,0x00,0x8e,0x1a,0x85,0xe0,0xff,0x03,0x00,0x00,0x00,0xc9, +0x04,0x1c,0x00,0x00,0x00,0xc0,0x0e,0x50,0x23,0xdc,0xf1,0x73,0x05,0x40,0x0e,0x19, +0xe7,0x01,0x00,0x00,0x00,0x00,0x00,0x80,0x87,0x82,0xc2,0xe2,0x42,0x80,0x02,0x22, +0xe4,0x9d,0x00,0x70,0x05,0x40,0x00,0x28,0x03,0x9c,0x21,0x14,0x00,0xc0,0x00,0x58, +0x03,0xdc,0x01,0x18,0x00,0x00,0x0e,0x1a,0xe7,0x01,0x00,0x00,0x00,0x00,0x00,0x80, +0x43,0xdc,0x00,0x60,0x05,0x40,0x00,0x40,0x04,0xdc,0xf3,0x1c,0x00,0x00,0x0e,0x0c, +0x85,0x1c,0x31,0x00,0x00,0x00,0x00,0x80,0x47,0x60,0x03,0xb0,0x83,0xb2,0xe3,0x22, +0x03,0x9c,0x00,0x14,0x00,0xc0,0x00,0x60,0x07,0x00,0x00,0xe0,0x00,0x00,0x00,0x60, +0x04,0x5c,0x41,0x10,0x00,0x00,0x00,0x54,0x85,0xdc,0xf0,0x03,0x00,0x00,0x00,0xa8, +0x03,0xc0,0x31,0x14,0x00,0x00,0x00,0x48,0x85,0xc1,0xf1,0x03,0x00,0x00,0x00,0xb8, +0xe7,0x25,0x00,0x80,0xff,0xff,0x03,0x40,0x07,0x40,0x02,0xf0,0x42,0x80,0x82,0x22, +0x33,0xdc,0x41,0xfc,0x00,0x00,0x0e,0x19,0x07,0x00,0x00,0xa0,0x05,0x00,0x00,0x60, +0xe7,0x01,0x00,0x60,0x05,0x00,0x00,0x40,0xe4,0x1d,0x03,0x00,0x05,0x40,0x00,0x28, +0x84,0x5f,0x21,0x11,0x00,0x00,0x00,0x1c,0x23,0xdc,0xf1,0x53,0x05,0x40,0x0e,0x19, +0x03,0x5c,0x41,0x14,0x00,0x00,0x00,0x68,0x87,0x42,0x80,0x82,0x72,0xe3,0x72,0x23, +0x03,0x5c,0x01,0x14,0x00,0x00,0x00,0x78,0x43,0x1c,0x52,0x08,0x00,0x00,0x00,0x68, +0xa3,0x5c,0x32,0x20,0x05,0x40,0x18,0x20,0x83,0x9c,0x82,0x40,0x05,0x40,0x00,0x40, +0x85,0x5c,0xa1,0x00,0x00,0x00,0x00,0x80,0x85,0x5c,0x91,0x00,0x00,0x00,0x00,0x90, +0x85,0xdc,0xa1,0x10,0x00,0x00,0x00,0x80,0xe7,0x72,0x43,0x00,0x80,0x42,0x70,0x23, +0x85,0xdc,0x91,0x10,0x00,0x00,0x00,0x90,0x85,0x5c,0xa1,0x20,0x00,0x00,0x00,0x80, +0x85,0x5c,0x91,0x20,0x00,0x00,0x00,0x90,0xe7,0x01,0x00,0xa0,0x02,0x00,0x00,0x40, +0x43,0x5c,0x81,0x50,0x05,0x40,0x00,0x40,0x85,0x5c,0x51,0x00,0x00,0x00,0x00,0x80, +0x07,0x00,0x00,0x00,0x02,0x00,0x00,0x60,0xc7,0x22,0x42,0xe0,0xc2,0x42,0x00,0x20, +0x00,0xdc,0x51,0x30,0x05,0x40,0x8e,0x2c,0xe7,0x01,0x00,0x40,0x00,0x00,0x00,0x40, +0xe2,0x5d,0x01,0xfc,0x03,0x00,0x00,0x18,0xe7,0x1d,0x00,0x40,0x01,0x00,0x00,0x40, +0x00,0xdc,0x51,0xfc,0x00,0x00,0x0e,0x2e,0xe4,0x61,0x01,0xfc,0x00,0x00,0x00,0x28, +0xe7,0xa1,0x00,0xe0,0x00,0x00,0x00,0x40,0x47,0x80,0x82,0x82,0x82,0x02,0xf0,0x22, +0xe4,0xc1,0x01,0x30,0x05,0x40,0x00,0x28,0x40,0x40,0x51,0xc0,0xdf,0xd0,0x00,0x58, +0x00,0x00,0x72,0x10,0x00,0x00,0x00,0xc8,0x40,0x40,0x51,0x20,0x00,0x00,0x00,0x58, +0x04,0x40,0x21,0x15,0x00,0x00,0x86,0x14,0x84,0x40,0x91,0x14,0x00,0x00,0x00,0x1c, +0x53,0xdc,0x31,0x10,0x05,0x40,0x00,0x40,0x07,0x40,0x80,0x82,0xc2,0xe2,0xf2,0x22, +0x05,0x5c,0x71,0x00,0x00,0x00,0x00,0x90,0x03,0x5c,0x41,0xfc,0xff,0xff,0x00,0x48, +0x03,0xdc,0x30,0x04,0x00,0xc0,0x00,0x48,0x03,0x1c,0x51,0x10,0x00,0x00,0x00,0x68, +0x23,0xdc,0x41,0xfc,0x00,0x00,0x8e,0x1a,0xe7,0x01,0x00,0xc0,0xfa,0xff,0x03,0x40, +0x13,0x1c,0x00,0xa0,0x00,0x40,0x00,0x48,0xc7,0xe2,0xe2,0x02,0x00,0x00,0x00,0x20, +0x03,0xdc,0x01,0x18,0x00,0x00,0x8e,0x19,0xe7,0x01,0x00,0x40,0xf8,0xff,0x03,0x40, +0xe7,0x1d,0x00,0x00,0x00,0x00,0x00,0x80,0xe7,0x1d,0x00,0xe0,0xff,0xff,0x03,0x40, +0xe4,0x1d,0x00,0x00,0x00,0x00,0x00,0x40,0xe4,0x1d,0x00,0x00,0x00,0x00,0x00,0x40, +0xe4,0x1d,0x00,0x00,0x00,0x00,0x00,0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x01,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x34,0x00,0x00,0x00,0x04,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0b,0x00,0x00,0x00,0x03,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x38,0x01,0x00,0x00,0x68,0x01,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x13,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0xa0,0x02,0x00,0x00,0x90,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x06,0x00,0x00,0x00, +0x04,0x00,0x00,0x00,0x10,0x00,0x00,0x00,0x33,0x00,0x00,0x00,0x00,0x00,0x00,0x70, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x03,0x00,0x00,0xa8,0x00,0x00,0x00, +0x03,0x00,0x00,0x00,0x09,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x6b,0x00,0x00,0x00,0x00,0x00,0x00,0x70,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0xd8,0x03,0x00,0x00,0x30,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xac,0x00,0x00,0x00,0x00,0x00,0x00,0x70, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x04,0x00,0x00,0x98,0x00,0x00,0x00, +0x03,0x00,0x00,0x00,0x0a,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x74,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0xa0,0x04,0x00,0x00,0x64,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x09,0x00,0x00,0x00, +0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xe4,0x00,0x00,0x00,0x01,0x00,0x00,0x00, +0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x06,0x00,0x00,0x60,0x01,0x00,0x00, +0x00,0x00,0x00,0x00,0x0a,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x1b,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x06,0x00,0x10,0x00,0x00,0x00,0x00,0x00, +0x80,0x07,0x00,0x00,0x80,0x02,0x00,0x00,0x03,0x00,0x00,0x00,0x07,0x00,0x00,0x0e, +0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x94,0x00,0x00,0x00,0x01,0x00,0x00,0x00, +0x06,0x00,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x0a,0x00,0x00,0x80,0x02,0x00,0x00, +0x03,0x00,0x00,0x00,0x08,0x00,0x00,0x0d,0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x4e,0x00,0x00,0x00,0x08,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x80,0x0c,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x09,0x00,0x00,0x00, +0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc7,0x00,0x00,0x00,0x08,0x00,0x00,0x00, +0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x0c,0x00,0x00,0x04,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x0a,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x06,0x00,0x00,0x00,0x88,0x0e,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x60,0x00,0x00,0x00,0x60,0x00,0x00,0x00,0x05,0x00,0x00,0x00,0x04,0x00,0x00,0x00, +0x01,0x00,0x00,0x00,0xa0,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0xc4,0x07,0x00,0x00,0xc4,0x07,0x00,0x00,0x05,0x00,0x00,0x00,0x04,0x00,0x00,0x00, +0x01,0x00,0x00,0x00,0x80,0x0c,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x06,0x00,0x00,0x00,0x04,0x00,0x00,0x00, +0x02,0x00,0x01,0x01,0x58,0x00,0x00,0x00,0x48,0x10,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0x00,0x01,0x00,0x32,0x00,0x00,0x00, +0x40,0x00,0x00,0x00,0x12,0x00,0x00,0x00,0x44,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x52,0x65,0x6e,0x64,0x65,0x72,0x50,0x61,0x72,0x74,0x69,0x63,0x6c,0x65,0x73,0x2e, +0x63,0x75,0x00,0x00,0x00,0x00,0x00,0x00,0x7f,0x45,0x4c,0x46,0x01,0x01,0x01,0x33, +0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x00,0xbe,0x00,0x01,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0xe8,0x0f,0x00,0x00,0xe0,0x0d,0x00,0x00,0x32,0x01,0x32,0x00, +0x34,0x00,0x20,0x00,0x03,0x00,0x28,0x00,0x0d,0x00,0x01,0x00,0x00,0x2e,0x73,0x68, +0x73,0x74,0x72,0x74,0x61,0x62,0x00,0x2e,0x73,0x74,0x72,0x74,0x61,0x62,0x00,0x2e, +0x73,0x79,0x6d,0x74,0x61,0x62,0x00,0x2e,0x74,0x65,0x78,0x74,0x2e,0x75,0x70,0x64, +0x61,0x74,0x65,0x49,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x64,0x56,0x42,0x00,0x2e, +0x6e,0x76,0x2e,0x69,0x6e,0x66,0x6f,0x2e,0x75,0x70,0x64,0x61,0x74,0x65,0x49,0x6e, +0x73,0x74,0x61,0x6e,0x63,0x65,0x64,0x56,0x42,0x00,0x2e,0x6e,0x76,0x2e,0x73,0x68, +0x61,0x72,0x65,0x64,0x2e,0x75,0x70,0x64,0x61,0x74,0x65,0x49,0x6e,0x73,0x74,0x61, +0x6e,0x63,0x65,0x64,0x56,0x42,0x00,0x2e,0x6e,0x76,0x2e,0x69,0x6e,0x66,0x6f,0x00, +0x2e,0x6e,0x76,0x2e,0x63,0x6f,0x6e,0x73,0x74,0x61,0x6e,0x74,0x30,0x2e,0x75,0x70, +0x64,0x61,0x74,0x65,0x49,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x64,0x56,0x42,0x00, +0x2e,0x74,0x65,0x78,0x74,0x2e,0x75,0x70,0x64,0x61,0x74,0x65,0x42,0x69,0x6c,0x6c, +0x62,0x6f,0x61,0x72,0x64,0x56,0x42,0x00,0x2e,0x6e,0x76,0x2e,0x69,0x6e,0x66,0x6f, +0x2e,0x75,0x70,0x64,0x61,0x74,0x65,0x42,0x69,0x6c,0x6c,0x62,0x6f,0x61,0x72,0x64, +0x56,0x42,0x00,0x2e,0x6e,0x76,0x2e,0x73,0x68,0x61,0x72,0x65,0x64,0x2e,0x75,0x70, +0x64,0x61,0x74,0x65,0x42,0x69,0x6c,0x6c,0x62,0x6f,0x61,0x72,0x64,0x56,0x42,0x00, +0x2e,0x6e,0x76,0x2e,0x63,0x6f,0x6e,0x73,0x74,0x61,0x6e,0x74,0x30,0x2e,0x75,0x70, +0x64,0x61,0x74,0x65,0x42,0x69,0x6c,0x6c,0x62,0x6f,0x61,0x72,0x64,0x56,0x42,0x00, +0x00,0x2e,0x73,0x68,0x73,0x74,0x72,0x74,0x61,0x62,0x00,0x2e,0x73,0x74,0x72,0x74, +0x61,0x62,0x00,0x2e,0x73,0x79,0x6d,0x74,0x61,0x62,0x00,0x75,0x70,0x64,0x61,0x74, +0x65,0x49,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x64,0x56,0x42,0x00,0x2e,0x74,0x65, +0x78,0x74,0x2e,0x75,0x70,0x64,0x61,0x74,0x65,0x49,0x6e,0x73,0x74,0x61,0x6e,0x63, +0x65,0x64,0x56,0x42,0x00,0x2e,0x6e,0x76,0x2e,0x69,0x6e,0x66,0x6f,0x2e,0x75,0x70, +0x64,0x61,0x74,0x65,0x49,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x64,0x56,0x42,0x00, +0x2e,0x6e,0x76,0x2e,0x73,0x68,0x61,0x72,0x65,0x64,0x2e,0x75,0x70,0x64,0x61,0x74, +0x65,0x49,0x6e,0x73,0x74,0x61,0x6e,0x63,0x65,0x64,0x56,0x42,0x00,0x2e,0x6e,0x76, +0x2e,0x69,0x6e,0x66,0x6f,0x00,0x5f,0x5a,0x4e,0x35,0x70,0x68,0x79,0x73,0x78,0x37, +0x67,0x4f,0x66,0x66,0x73,0x65,0x74,0x45,0x00,0x2e,0x6e,0x76,0x2e,0x63,0x6f,0x6e, +0x73,0x74,0x61,0x6e,0x74,0x30,0x2e,0x75,0x70,0x64,0x61,0x74,0x65,0x49,0x6e,0x73, +0x74,0x61,0x6e,0x63,0x65,0x64,0x56,0x42,0x00,0x5f,0x70,0x61,0x72,0x61,0x6d,0x00, +0x75,0x70,0x64,0x61,0x74,0x65,0x42,0x69,0x6c,0x6c,0x62,0x6f,0x61,0x72,0x64,0x56, +0x42,0x00,0x2e,0x74,0x65,0x78,0x74,0x2e,0x75,0x70,0x64,0x61,0x74,0x65,0x42,0x69, +0x6c,0x6c,0x62,0x6f,0x61,0x72,0x64,0x56,0x42,0x00,0x2e,0x6e,0x76,0x2e,0x69,0x6e, +0x66,0x6f,0x2e,0x75,0x70,0x64,0x61,0x74,0x65,0x42,0x69,0x6c,0x6c,0x62,0x6f,0x61, +0x72,0x64,0x56,0x42,0x00,0x2e,0x6e,0x76,0x2e,0x73,0x68,0x61,0x72,0x65,0x64,0x2e, +0x75,0x70,0x64,0x61,0x74,0x65,0x42,0x69,0x6c,0x6c,0x62,0x6f,0x61,0x72,0x64,0x56, +0x42,0x00,0x24,0x75,0x70,0x64,0x61,0x74,0x65,0x42,0x69,0x6c,0x6c,0x62,0x6f,0x61, +0x72,0x64,0x56,0x42,0x24,0x5f,0x5a,0x4e,0x35,0x70,0x68,0x79,0x73,0x78,0x37,0x67, +0x4f,0x66,0x66,0x73,0x65,0x74,0x45,0x00,0x2e,0x6e,0x76,0x2e,0x63,0x6f,0x6e,0x73, +0x74,0x61,0x6e,0x74,0x30,0x2e,0x75,0x70,0x64,0x61,0x74,0x65,0x42,0x69,0x6c,0x6c, +0x62,0x6f,0x61,0x72,0x64,0x56,0x42,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x2d,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x03,0x00,0x09,0x00,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x03,0x00,0x0b,0x00,0x99,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x03,0x00,0x07,0x00,0xd2,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x03,0x00,0x0a,0x00,0x05,0x01,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x03,0x00,0x0c,0x00,0x48,0x01,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x03,0x00,0x08,0x00,0x1b,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x40,0x03,0x00,0x00,0x12,0x10,0x09,0x00,0xc0,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x03,0x00,0x00,0x12,0x10,0x0a,0x00,0x04,0x0a,0x08,0x00,0x03,0x00,0x00,0x00, +0x40,0x01,0x24,0x00,0x03,0x19,0x24,0x00,0x04,0x17,0x0c,0x00,0x00,0x00,0x00,0x00, +0x08,0x00,0x20,0x00,0x00,0xf0,0x11,0x00,0x04,0x17,0x0c,0x00,0x00,0x00,0x00,0x00, +0x07,0x00,0x1c,0x00,0x00,0xf0,0x11,0x00,0x04,0x17,0x0c,0x00,0x00,0x00,0x00,0x00, +0x06,0x00,0x18,0x00,0x00,0xf0,0x11,0x00,0x04,0x17,0x0c,0x00,0x00,0x00,0x00,0x00, +0x05,0x00,0x14,0x00,0x00,0xf0,0x11,0x00,0x04,0x17,0x0c,0x00,0x00,0x00,0x00,0x00, +0x04,0x00,0x10,0x00,0x00,0xf0,0x11,0x00,0x04,0x17,0x0c,0x00,0x00,0x00,0x00,0x00, +0x03,0x00,0x0c,0x00,0x00,0xf0,0x11,0x00,0x04,0x17,0x0c,0x00,0x00,0x00,0x00,0x00, +0x02,0x00,0x08,0x00,0x00,0xf0,0x11,0x00,0x04,0x17,0x0c,0x00,0x00,0x00,0x00,0x00, +0x01,0x00,0x04,0x00,0x00,0xf0,0x11,0x00,0x04,0x17,0x0c,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0xf0,0x11,0x00,0x04,0x1e,0x04,0x00,0x10,0x02,0x00,0x00, +0x04,0x1c,0x14,0x00,0x30,0x00,0x00,0x00,0x50,0x00,0x00,0x00,0x58,0x02,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x12,0x08,0x00,0x08,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x04,0x11,0x08,0x00,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x04,0x12,0x08,0x00,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x11,0x08,0x00, +0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x0a,0x08,0x00,0x06,0x00,0x00,0x00, +0x40,0x01,0x20,0x00,0x03,0x19,0x20,0x00,0x04,0x17,0x0c,0x00,0x00,0x00,0x00,0x00, +0x07,0x00,0x1c,0x00,0x00,0xf0,0x11,0x00,0x04,0x17,0x0c,0x00,0x00,0x00,0x00,0x00, +0x06,0x00,0x18,0x00,0x00,0xf0,0x11,0x00,0x04,0x17,0x0c,0x00,0x00,0x00,0x00,0x00, +0x05,0x00,0x14,0x00,0x00,0xf0,0x11,0x00,0x04,0x17,0x0c,0x00,0x00,0x00,0x00,0x00, +0x04,0x00,0x10,0x00,0x00,0xf0,0x11,0x00,0x04,0x17,0x0c,0x00,0x00,0x00,0x00,0x00, +0x03,0x00,0x0c,0x00,0x00,0xf0,0x11,0x00,0x04,0x17,0x0c,0x00,0x00,0x00,0x00,0x00, +0x02,0x00,0x08,0x00,0x00,0xf0,0x11,0x00,0x04,0x17,0x0c,0x00,0x00,0x00,0x00,0x00, +0x01,0x00,0x04,0x00,0x00,0xf0,0x11,0x00,0x04,0x17,0x0c,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0xf0,0x11,0x00,0x04,0x1e,0x04,0x00,0x20,0x02,0x00,0x00, +0x04,0x1c,0x14,0x00,0x30,0x00,0x00,0x00,0x50,0x00,0x00,0x00,0x20,0x02,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xe6,0x07,0xa0,0xe3,0x00,0xb4,0x3f,0x00, +0x01,0x00,0x87,0x00,0x80,0x07,0x98,0x4c,0x00,0x00,0x17,0x02,0x00,0x00,0xc8,0xf0, +0x07,0x00,0xf7,0x0f,0x80,0x03,0x6b,0x5b,0xf4,0x07,0xe0,0xff,0x00,0xb4,0x1f,0x00, +0xff,0xff,0x08,0x00,0x00,0x00,0x5c,0xef,0x00,0x00,0x07,0x00,0x80,0x1b,0xa8,0xf0, +0x07,0xff,0x87,0x05,0x80,0x03,0x65,0x4b,0xfd,0x07,0xc0,0xfc,0x00,0x98,0x1f,0x00, +0x0f,0x00,0x00,0x00,0x00,0x00,0x00,0xe3,0x02,0x00,0x87,0x05,0x80,0x07,0x98,0x4c, +0x02,0x02,0x57,0x00,0x00,0x00,0x28,0x38,0xed,0x07,0xa0,0xff,0x00,0x88,0x1f,0x00, +0x07,0x00,0x27,0x00,0x80,0x03,0x68,0x5b,0x0f,0x00,0x00,0x00,0x00,0x00,0x00,0xe3, +0x03,0x00,0x77,0x05,0x00,0x01,0x18,0x4c,0xb1,0x07,0x20,0xfe,0x00,0x74,0x1c,0x04, +0x03,0x03,0x07,0x00,0x00,0x00,0xd4,0xee,0x00,0x00,0x00,0x27,0x00,0x00,0x90,0xe2, +0x04,0x00,0x37,0x00,0x00,0x00,0x08,0x5c,0xf0,0x07,0x40,0x06,0x01,0xac,0x3f,0x00, +0x07,0x03,0xf7,0x0f,0x80,0x03,0x65,0x5b,0x05,0xff,0x47,0x00,0x00,0x00,0x00,0xec, +0x04,0x00,0x57,0x00,0x00,0x00,0x48,0x38,0xfd,0x17,0xa0,0xe3,0x00,0x88,0x3f,0x00, +0x0f,0x00,0x80,0x22,0x00,0x00,0x40,0xe2,0x06,0x3a,0x37,0x00,0x00,0x20,0xe0,0x5c, +0x06,0x03,0x67,0x00,0x00,0x00,0x47,0x5c,0x1d,0x07,0xc0,0xfc,0x01,0x84,0x1f,0x00, +0x06,0x00,0x67,0x00,0x00,0x00,0x30,0x5c,0x06,0x06,0xf7,0x01,0x00,0x00,0x12,0x38, +0x06,0x06,0xf7,0x01,0x00,0x00,0x12,0x38,0xe5,0x07,0xc0,0xfc,0x00,0x98,0x1f,0x00, +0x07,0x00,0x67,0x05,0x80,0x07,0x98,0x4c,0x09,0x06,0x47,0x00,0x00,0x02,0x47,0x5c, +0x06,0x09,0x47,0x02,0x80,0x03,0x00,0x36,0xe2,0x07,0x20,0xf6,0x00,0x98,0x1f,0x00, +0x0a,0x09,0x47,0x02,0x10,0x03,0x20,0x36,0x07,0x0a,0x07,0x00,0x00,0x00,0xd4,0xee, +0x0f,0x00,0x47,0x05,0x80,0x07,0x98,0x4c,0xe1,0x07,0xc0,0xfc,0x00,0x88,0x1f,0x00, +0x06,0x05,0x17,0x05,0x80,0x07,0x00,0x51,0x08,0x05,0xf7,0x00,0xa8,0x7f,0x00,0x5b, +0x08,0x05,0x87,0x00,0x18,0x03,0x30,0x5b,0xf1,0x07,0x41,0xf6,0x00,0xc4,0x1f,0x04, +0x07,0x08,0x07,0x00,0x00,0x00,0xdc,0xee,0x06,0x0a,0x47,0x00,0x00,0x00,0xd4,0xee, +0x06,0x08,0x47,0x00,0x00,0x00,0xdc,0xee,0xb1,0x07,0x20,0xfc,0x00,0x84,0x1f,0x00, +0x07,0x0a,0x87,0x00,0x00,0x00,0xd4,0xee,0x0b,0x05,0x27,0x05,0x80,0x07,0x00,0x51, +0x0c,0x05,0xf7,0x00,0xa8,0x7f,0x00,0x5b,0xf1,0x07,0x81,0xf6,0x00,0x88,0x1f,0x00, +0x07,0x08,0x87,0x00,0x00,0x00,0xdc,0xee,0x06,0x0a,0xc7,0x00,0x00,0x00,0xd4,0xee, +0x0b,0x05,0xc7,0x00,0x98,0x05,0x30,0x5b,0xf1,0x07,0x41,0xf6,0x00,0xc4,0x1f,0x04, +0x06,0x0b,0x07,0x00,0x00,0x00,0xdc,0xee,0x07,0x0a,0x07,0x01,0x00,0x00,0xd4,0xee, +0x07,0x0b,0x47,0x00,0x00,0x00,0xdc,0xee,0xb1,0x07,0x20,0xfc,0x00,0x84,0x1f,0x00, +0x06,0x0a,0x47,0x01,0x00,0x00,0xd4,0xee,0x08,0x05,0x37,0x05,0x80,0x07,0x00,0x51, +0x0e,0x05,0xf7,0x00,0xa8,0x7f,0x00,0x5b,0xf1,0x07,0x81,0xf6,0x00,0x88,0x1f,0x00, +0x06,0x0b,0x87,0x00,0x00,0x00,0xdc,0xee,0x07,0x0a,0x87,0x01,0x00,0x00,0xd4,0xee, +0x08,0x05,0xe7,0x00,0x18,0x04,0x30,0x5b,0xf1,0x07,0x41,0xf6,0x00,0xc4,0x1f,0x04, +0x07,0x08,0x07,0x00,0x00,0x00,0xdc,0xee,0x06,0x0a,0xc7,0x01,0x00,0x00,0xd4,0xee, +0x06,0x08,0x47,0x00,0x00,0x00,0xdc,0xee,0xbd,0x00,0x20,0xfc,0x01,0xc4,0x1f,0x04, +0x07,0x0a,0x07,0x02,0x00,0x00,0xd4,0xee,0x0a,0x09,0x57,0x05,0x00,0x02,0x18,0x4c, +0x07,0x08,0x87,0x00,0x00,0x00,0xdc,0xee,0xb1,0x07,0x20,0xfc,0x00,0x98,0x1f,0x00, +0x06,0x0a,0x07,0x00,0x00,0x00,0xd4,0xee,0x0b,0x05,0x07,0x05,0x80,0x07,0x00,0x51, +0x0c,0x05,0xf7,0x00,0xa8,0x7f,0x00,0x5b,0xe2,0x07,0x20,0xfe,0x20,0xc4,0x1e,0x00, +0x09,0x05,0xc7,0x00,0x98,0x05,0x30,0x5b,0x06,0x09,0x07,0x00,0x00,0x00,0xdc,0xee, +0x07,0x0a,0x47,0x00,0x00,0x00,0xd4,0xee,0xe6,0x07,0x20,0xfc,0x00,0xc4,0x1f,0x04, +0x08,0x03,0xf7,0xff,0x7f,0x00,0x10,0x39,0x03,0x08,0x37,0x00,0x00,0x00,0x47,0x5c, +0x07,0x09,0x47,0x00,0x00,0x00,0xdc,0xee,0xb4,0x07,0x20,0xfc,0x00,0xc0,0x1f,0x00, +0x06,0x0a,0x87,0x00,0x00,0x00,0xd4,0xee,0x07,0x03,0xf7,0x0f,0x80,0x03,0x6b,0x5b, +0x05,0x05,0x17,0x00,0x00,0x00,0x10,0x38,0xec,0x00,0xa1,0xff,0x01,0xf4,0x1f,0x00, +0x06,0x09,0x87,0x00,0x00,0x00,0xdc,0xee,0x0f,0x00,0x80,0xdd,0xff,0x0f,0x40,0xe2, +0x0f,0x00,0x07,0x00,0x00,0x00,0xf8,0xf0,0xe6,0x07,0xa0,0xfd,0x00,0xf4,0x1f,0x00, +0x00,0x00,0x27,0x00,0x00,0x00,0x10,0x4c,0x07,0x00,0x27,0x00,0x80,0x03,0x66,0x5b, +0x0f,0x00,0x80,0xd5,0xff,0x0f,0x40,0xe2,0xff,0x07,0xe0,0xff,0x00,0x80,0x1f,0x00, +0x0f,0x00,0x07,0x00,0x00,0x00,0x00,0xe3,0x0f,0x00,0x87,0xff,0xff,0x0f,0x40,0xe2, +0x00,0x0f,0x07,0x00,0x00,0x00,0xb0,0x50,0xe6,0x07,0xa0,0xe3,0x00,0xb4,0x3f,0x00, +0x01,0x00,0x87,0x00,0x80,0x07,0x98,0x4c,0x00,0x00,0x17,0x02,0x00,0x00,0xc8,0xf0, +0x07,0x00,0xf7,0x0f,0x80,0x03,0x6b,0x5b,0xf4,0x07,0xe0,0xff,0x00,0xb4,0x1f,0x00, +0xff,0xff,0x08,0x00,0x00,0x00,0x5c,0xef,0x00,0x00,0x07,0x00,0x80,0x1b,0xa8,0xf0, +0x07,0xff,0x77,0x05,0x80,0x03,0x65,0x4b,0xfd,0x07,0xc0,0xfc,0x00,0x98,0x1f,0x00, +0x0f,0x00,0x00,0x00,0x00,0x00,0x00,0xe3,0x02,0x00,0x77,0x05,0x80,0x07,0x98,0x4c, +0x06,0x02,0x57,0x00,0x00,0x00,0x28,0x38,0xed,0x07,0xa0,0xff,0x00,0x88,0x1f,0x00, +0x07,0x00,0x67,0x00,0x80,0x03,0x68,0x5b,0x0f,0x00,0x00,0x00,0x00,0x00,0x00,0xe3, +0x02,0x00,0x67,0x05,0x00,0x01,0x18,0x4c,0xb1,0x07,0x20,0xfe,0x00,0x74,0x1c,0x04, +0x04,0x02,0x07,0x00,0x00,0x00,0xd4,0xee,0x00,0x00,0x00,0x22,0x00,0x00,0x90,0xe2, +0x02,0x00,0x47,0x00,0x00,0x00,0x08,0x5c,0xf0,0x07,0x40,0x06,0x01,0xac,0x3f,0x00, +0x07,0x04,0xf7,0x0f,0x80,0x03,0x65,0x5b,0x03,0xff,0x27,0x00,0x00,0x00,0x00,0xec, +0x02,0x00,0x57,0x00,0x00,0x00,0x48,0x38,0xfd,0x17,0xa0,0xe3,0x00,0x88,0x3f,0x00, +0x0f,0x00,0x00,0x1e,0x00,0x00,0x40,0xe2,0x05,0x3a,0x47,0x00,0x00,0x20,0xe0,0x5c, +0x05,0x04,0x57,0x00,0x00,0x00,0x47,0x5c,0x1d,0x07,0xc0,0xfc,0x01,0x98,0x1f,0x00, +0x05,0x00,0x57,0x00,0x00,0x00,0x30,0x5c,0x05,0x05,0xf7,0x01,0x00,0x00,0x12,0x38, +0x05,0x05,0xf7,0x01,0x00,0x00,0x12,0x38,0xe6,0x07,0x40,0xfc,0x00,0xc4,0x1e,0x00, +0x08,0x05,0x27,0x00,0x00,0x02,0x47,0x5c,0x0a,0x08,0x47,0x05,0x00,0x02,0x18,0x4c, +0x05,0x0a,0x07,0x00,0x00,0x00,0xd4,0xee,0xe6,0x07,0x20,0xfc,0x00,0x98,0x1f,0x00, +0x0c,0x00,0x27,0x05,0x80,0x07,0x98,0x4c,0x09,0x03,0x07,0x05,0x00,0x06,0x00,0x51, +0x0c,0x03,0xc7,0x00,0xa8,0x7f,0x00,0x5b,0xe2,0x07,0x20,0xfe,0x20,0xc8,0x1e,0x00, +0x09,0x03,0xc7,0x00,0x98,0x04,0x30,0x5b,0x05,0x09,0x07,0x00,0x00,0x00,0xdc,0xee, +0x07,0x0a,0x47,0x00,0x00,0x00,0xd4,0xee,0xf0,0x07,0x20,0xfe,0x20,0xc8,0x1e,0x00, +0x07,0xff,0x57,0x05,0x80,0x03,0x65,0x4b,0x07,0x09,0x47,0x00,0x00,0x00,0xdc,0xee, +0x05,0x0a,0x87,0x00,0x00,0x00,0xd4,0xee,0xfa,0x00,0xa1,0xff,0x01,0xc0,0x1f,0x00, +0x05,0x09,0x87,0x00,0x00,0x00,0xdc,0xee,0x0f,0x00,0x00,0x0e,0x00,0x00,0x40,0xe2, +0x05,0x08,0x57,0x05,0x00,0x01,0x18,0x4c,0xf2,0x07,0x40,0xf6,0x00,0xb4,0x1f,0x04, +0x00,0x00,0x80,0x0a,0x00,0x00,0x90,0xe2,0x05,0x05,0x07,0x00,0x00,0x00,0xd4,0xee, +0x07,0x05,0x37,0x05,0x80,0x83,0xb9,0x4b,0xfd,0x07,0x00,0xfe,0x00,0xf4,0x1f,0x00, +0x0f,0x00,0x80,0x01,0x00,0x00,0x40,0xe2,0x05,0xf0,0xf7,0x0f,0x00,0x00,0x00,0x01, +0x0f,0x00,0x07,0x00,0x00,0x00,0xf8,0xf0,0xed,0x07,0xa0,0xff,0x00,0x84,0x1f,0x00, +0x07,0x05,0xf7,0x0f,0x80,0x83,0xbc,0x5b,0x0f,0x00,0x80,0x01,0x00,0x00,0x40,0xe2, +0x05,0x00,0xf7,0x0f,0x80,0x07,0x98,0x5c,0xfd,0x07,0x40,0xfc,0x00,0x44,0x1c,0x00, +0x0f,0x00,0x07,0x00,0x00,0x00,0xf8,0xf0,0x07,0x00,0x37,0x05,0x80,0x07,0x98,0x4c, +0x07,0x07,0x47,0x00,0x00,0x00,0x80,0x50,0xfd,0x07,0x40,0xfc,0x01,0x74,0x1c,0x00, +0x05,0x05,0x07,0x7f,0x43,0x10,0x68,0x38,0x05,0x05,0x77,0x00,0x00,0x10,0x68,0x5c, +0x05,0x0a,0x57,0x00,0x80,0x11,0xb0,0x5c,0x3d,0x08,0xa0,0xff,0x03,0x88,0x1f,0x00, +0x05,0x15,0x57,0x00,0x00,0x00,0xe0,0x5c,0x0f,0x00,0x07,0x00,0x00,0x00,0xf8,0xf0, +0x07,0x03,0x17,0x05,0x00,0x01,0x18,0x4c,0xf1,0x00,0x60,0xfc,0x00,0x98,0x1f,0x00, +0x05,0x07,0x07,0x00,0x00,0x00,0xd8,0xee,0x01,0x00,0x07,0x00,0x00,0x00,0xf0,0xf0, +0x05,0x04,0xf7,0xff,0x7f,0x00,0x10,0x39,0xe1,0x07,0xa0,0xfc,0x00,0xb4,0x1f,0x00, +0x04,0x05,0x47,0x00,0x00,0x00,0x47,0x5c,0x03,0x03,0x17,0x00,0x00,0x00,0x10,0x38, +0x07,0x04,0xf7,0x0f,0x80,0x03,0x6b,0x5b,0xfd,0x07,0xa0,0xff,0x00,0x98,0x1f,0x00, +0x0f,0x00,0x00,0xe2,0xff,0x0f,0x40,0xe2,0x0f,0x00,0x07,0x00,0x00,0x00,0xf8,0xf0, +0x00,0x00,0x27,0x00,0x00,0x00,0x10,0x4c,0xed,0x07,0xa0,0xff,0x00,0xfc,0x1f,0x00, +0x07,0x00,0x67,0x00,0x80,0x03,0x66,0x5b,0x0f,0x00,0x00,0xda,0xff,0x0f,0x40,0xe2, +0x0f,0x00,0x07,0x00,0x00,0x00,0x00,0xe3,0xff,0x07,0x00,0xfc,0x00,0x80,0x1f,0x00, +0x0f,0x00,0x87,0xff,0xff,0x0f,0x40,0xe2,0x00,0x0f,0x07,0x00,0x00,0x00,0xb0,0x50, +0x00,0x0f,0x07,0x00,0x00,0x00,0xb0,0x50,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x01,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x34,0x00,0x00,0x00,0x04,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0b,0x00,0x00,0x00,0x03,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x38,0x01,0x00,0x00,0x68,0x01,0x00,0x00, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x13,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0xa0,0x02,0x00,0x00,0x90,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x06,0x00,0x00,0x00, +0x04,0x00,0x00,0x00,0x10,0x00,0x00,0x00,0x33,0x00,0x00,0x00,0x00,0x00,0x00,0x70, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x03,0x00,0x00,0xc0,0x00,0x00,0x00, +0x03,0x00,0x00,0x00,0x09,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x6b,0x00,0x00,0x00,0x00,0x00,0x00,0x70,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0xf0,0x03,0x00,0x00,0x30,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xac,0x00,0x00,0x00,0x00,0x00,0x00,0x70, +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x04,0x00,0x00,0xb0,0x00,0x00,0x00, +0x03,0x00,0x00,0x00,0x0a,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x74,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0xd0,0x04,0x00,0x00,0x64,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x09,0x00,0x00,0x00, +0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xe4,0x00,0x00,0x00,0x01,0x00,0x00,0x00, +0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x34,0x06,0x00,0x00,0x60,0x01,0x00,0x00, +0x00,0x00,0x00,0x00,0x0a,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x1b,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x06,0x00,0x10,0x00,0x00,0x00,0x00,0x00, +0xa0,0x07,0x00,0x00,0x40,0x03,0x00,0x00,0x03,0x00,0x00,0x00,0x07,0x00,0x00,0x10, +0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x94,0x00,0x00,0x00,0x01,0x00,0x00,0x00, +0x06,0x00,0x10,0x00,0x00,0x00,0x00,0x00,0xe0,0x0a,0x00,0x00,0x00,0x03,0x00,0x00, +0x03,0x00,0x00,0x00,0x08,0x00,0x00,0x0d,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x4e,0x00,0x00,0x00,0x08,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0xe0,0x0d,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x09,0x00,0x00,0x00, +0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc7,0x00,0x00,0x00,0x08,0x00,0x00,0x00, +0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xe0,0x0d,0x00,0x00,0x04,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x0a,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x06,0x00,0x00,0x00,0xe8,0x0f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x60,0x00,0x00,0x00,0x60,0x00,0x00,0x00,0x05,0x00,0x00,0x00,0x04,0x00,0x00,0x00, +0x01,0x00,0x00,0x00,0xd0,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x04,0x09,0x00,0x00,0x04,0x09,0x00,0x00,0x05,0x00,0x00,0x00,0x04,0x00,0x00,0x00, +0x01,0x00,0x00,0x00,0xe0,0x0d,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x06,0x00,0x00,0x00,0x04,0x00,0x00,0x00 +}; + +#ifdef __cplusplus +} +#endif + diff --git a/PhysX_3.4/Samples/SampleFramework/renderer/src/cuda/build.cmd b/PhysX_3.4/Samples/SampleFramework/renderer/src/cuda/build.cmd new file mode 100755 index 00000000..0cf97a64 --- /dev/null +++ b/PhysX_3.4/Samples/SampleFramework/renderer/src/cuda/build.cmd @@ -0,0 +1,21 @@ +REM Rebuilds the cloth CUDA kernel that calculates smooth normals, the resulting fatbin +REM will be converted to a C header file that is included in the SampleRenderer + +set CUDA_PATH=..\..\..\..\..\..\..\..\..\externals\CUDA\6.0.2-17056404 +set SDK_ROOT=..\..\..\..\.. +set COMPILER_DIR=C:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\Tools + +"%CUDA_PATH%\bin\nvcc.exe" -m32 -g -gencode=arch=compute_11,code=sm_11 -gencode=arch=compute_20,code=sm_20 -gencode=arch=compute_30,code=sm_30 -gencode=arch=compute_50,code=sm_50 -Xopencc -woffall -prec-div=false -prec-sqrt=false -ftz=true -use_fast_math -D_USE_MATH_DEFINES -DNDEBUG --compiler-bindir="%COMPILER_DIR%" --compiler-options=/W3,/nologo,/Zi,/MT,/Ox -I"%CUDA_PATH%\include" -I"%SDK_ROOT%\Include" -I"%SDK_ROOT%\Include\foundation" -I"%SDK_ROOT%\Source\LowLevelCloth\include" -I"%SDK_ROOT%\Source\LowLevelCloth\src" --fatbin -o RenderClothNormals_x86.fatbin RenderClothNormals.cu +"%CUDA_PATH%\bin\bin2c.exe" --name computeSmoothNormals RenderClothNormals_x86.fatbin > RenderClothNormals_x86.cuh + +"%CUDA_PATH%\bin\nvcc.exe" -m64 -g -gencode=arch=compute_11,code=sm_11 -gencode=arch=compute_20,code=sm_20 -gencode=arch=compute_30,code=sm_30 -gencode=arch=compute_50,code=sm_50 -Xopencc -woffall -prec-div=false -prec-sqrt=false -ftz=true -use_fast_math -D_USE_MATH_DEFINES -DNDEBUG --compiler-bindir="%COMPILER_DIR%" --compiler-options=/W3,/nologo,/Zi,/MT,/Ox -I"%CUDA_PATH%\include" -I"%SDK_ROOT%\Include" -I"%SDK_ROOT%\Include\foundation" -I"%SDK_ROOT%\Source\LowLevelCloth\include" -I"%SDK_ROOT%\Source\LowLevelCloth\src" --fatbin -o RenderClothNormals_x64.fatbin RenderClothNormals.cu +"%CUDA_PATH%\bin\bin2c.exe" --name computeSmoothNormals RenderClothNormals_x64.fatbin > RenderClothNormals_x64.cuh + +"%CUDA_PATH%\bin\nvcc.exe" -m32 -g -gencode=arch=compute_11,code=sm_11 -gencode=arch=compute_20,code=sm_20 -gencode=arch=compute_30,code=sm_30 -gencode=arch=compute_50,code=sm_50 -Xopencc -woffall -prec-div=false -prec-sqrt=false -ftz=true -use_fast_math -D_USE_MATH_DEFINES -DNDEBUG --compiler-bindir="%COMPILER_DIR%" --compiler-options=/W3,/nologo,/Zi,/MT,/Ox -I"%CUDA_PATH%\include" -I"%SDK_ROOT%\Include" -I"%SDK_ROOT%\Include\foundation" -I"%SDK_ROOT%\Source\LowLevelCloth\include" -I"%SDK_ROOT%\Source\LowLevelCloth\src" --fatbin -o RenderParticles_x86.fatbin RenderParticles.cu +"%CUDA_PATH%\bin\bin2c.exe" --name updateParticleVertexBuffer RenderParticles_x86.fatbin > RenderParticles_x86.cuh + +"%CUDA_PATH%\bin\nvcc.exe" -m64 -g -gencode=arch=compute_11,code=sm_11 -gencode=arch=compute_20,code=sm_20 -gencode=arch=compute_30,code=sm_30 -gencode=arch=compute_50,code=sm_50 -Xopencc -woffall -prec-div=false -prec-sqrt=false -ftz=true -use_fast_math -D_USE_MATH_DEFINES -DNDEBUG --compiler-bindir="%COMPILER_DIR%" --compiler-options=/W3,/nologo,/Zi,/MT,/Ox -I"%CUDA_PATH%\include" -I"%SDK_ROOT%\Include" -I"%SDK_ROOT%\Include\foundation" -I"%SDK_ROOT%\Source\LowLevelCloth\include" -I"%SDK_ROOT%\Source\LowLevelCloth\src" --fatbin -o RenderParticles_x64.fatbin RenderParticles.cu +"%CUDA_PATH%\bin\bin2c.exe" --name updateParticleVertexBuffer RenderParticles_x64.fatbin > RenderParticles_x64.cuh + +pause + diff --git a/PhysX_3.4/Samples/SampleFramework/renderer/src/d3d11/D3D11Renderer.cpp b/PhysX_3.4/Samples/SampleFramework/renderer/src/d3d11/D3D11Renderer.cpp new file mode 100644 index 00000000..ea820c3d --- /dev/null +++ b/PhysX_3.4/Samples/SampleFramework/renderer/src/d3d11/D3D11Renderer.cpp @@ -0,0 +1,1467 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved. + +#include <RendererConfig.h> + +#if defined(RENDERER_ENABLE_DIRECT3D11) + +#include "D3D11Renderer.h" + +#include <RendererDesc.h> + +#include <RendererProjection.h> + +#include <RendererVertexBufferDesc.h> +#include "D3D11RendererVertexBuffer.h" + +#include <RendererIndexBufferDesc.h> +#include "D3D11RendererIndexBuffer.h" + +#include <RendererInstanceBufferDesc.h> +#include "D3D11RendererInstanceBuffer.h" + +#include <RendererMeshDesc.h> +#include <RendererMeshContext.h> +#include "D3D11RendererMesh.h" + +#include <RendererMaterialDesc.h> +#include <RendererMaterialInstance.h> +#include "D3D11RendererMaterial.h" + +#include <RendererLightDesc.h> +#include <RendererDirectionalLightDesc.h> +#include "D3D11RendererDirectionalLight.h" +#include <RendererSpotLightDesc.h> +#include "D3D11RendererSpotLight.h" + +#include <RendererTextureDesc.h> +#include "D3D11RendererTexture2D.h" +#include "D3D11RendererTexture3D.h" + +#include <RendererTargetDesc.h> +#include "D3D11RendererTarget.h" + +#include "D3D11RendererResourceManager.h" +#include "D3D11RendererVariableManager.h" +#include "D3D11RendererMemoryMacros.h" +#include "D3D11RendererUtils.h" + +#include <PsUtilities.h> +#include <SamplePlatform.h> +#include <deque> + +using namespace SampleRenderer; +using std::tr1::get; + +void SampleRenderer::convertToD3D11(PxVec3& dxcolor, const RendererColor& color) +{ + static const float inv255 = 1.0f / 255.0f; + dxcolor = PxVec3(color.r * inv255, color.g * inv255, color.b * inv255); +} + +void SampleRenderer::convertToD3D11(PxVec4& dxcolor, const RendererColor& color) +{ + static const float inv255 = 1.0f / 255.0f; + dxcolor = PxVec4(color.r * inv255, color.g * inv255, color.b * inv255, color.a * inv255); +} + +void SampleRenderer::convertToD3D11(PxMat44& dxmat, const physx::PxMat44 &mat) +{ + dxmat = mat.getTranspose(); +} + +void SampleRenderer::convertToD3D11(PxMat44& dxmat, const RendererProjection& mat) +{ + convertToD3D11(dxmat, mat.getPxMat44()); +} + +/**************************************** +* D3D11Renderer::D3D11ShaderEnvironment * +****************************************/ + +D3D11Renderer::D3D11ShaderEnvironment::D3D11ShaderEnvironment() +{ + memset(this, 0, sizeof(*this)); + vfs = 1.; +} + +#define SHADER_VAR_NAME(_name) PX_STRINGIZE(PX_CONCAT(g_, _name)) + +void D3D11Renderer::D3D11ShaderEnvironment::bindFrame() const +{ + constantManager->setSharedVariable("cbFrame", SHADER_VAR_NAME(viewMatrix), &viewMatrix); + constantManager->setSharedVariable("cbFrame", SHADER_VAR_NAME(projMatrix), &projMatrix); + constantManager->setSharedVariable("cbFrame", SHADER_VAR_NAME(eyePosition), &eyePosition.x); + constantManager->setSharedVariable("cbFrame", SHADER_VAR_NAME(eyeDirection), &eyeDirection.x); + constantManager->setSharedVariable("cbFrameInv", SHADER_VAR_NAME(invViewProjMatrix), &invViewProjMatrix); +} + +void D3D11Renderer::D3D11ShaderEnvironment::bindLight(PxU32 lightIndex) const +{ + RENDERER_ASSERT(lightIndex < RENDERER_MAX_LIGHTS, "Invalid light index"); + if (lightIndex < RENDERER_MAX_LIGHTS) + { + if (numLights < ((int)lightIndex + 1)) numLights = lightIndex + 1; + const char* lightName = RENDERER_ENABLE_SINGLE_PASS_LIGHTING ? "cbLights" : "cbLight"; + constantManager->setSharedVariable(lightName, SHADER_VAR_NAME(lightColor), &lightColor[lightIndex].x, sizeof(PxVec3), lightIndex*sizeof(PxVec3)); + constantManager->setSharedVariable(lightName, SHADER_VAR_NAME(lightDirection), &lightDirection[lightIndex].x, sizeof(PxVec3), lightIndex*sizeof(PxVec3)); + constantManager->setSharedVariable(lightName, SHADER_VAR_NAME(lightPosition), &lightPosition[lightIndex].x, sizeof(PxVec3), lightIndex*sizeof(PxVec3)); + constantManager->setSharedVariable(lightName, SHADER_VAR_NAME(lightIntensity), &lightIntensity[lightIndex], sizeof(float), lightIndex*sizeof(float)); + constantManager->setSharedVariable(lightName, SHADER_VAR_NAME(lightInnerRadius), &lightInnerRadius[lightIndex], sizeof(float), lightIndex*sizeof(float)); + constantManager->setSharedVariable(lightName, SHADER_VAR_NAME(lightOuterRadius), &lightOuterRadius[lightIndex], sizeof(float), lightIndex*sizeof(float)); + constantManager->setSharedVariable(lightName, SHADER_VAR_NAME(lightInnerCone), &lightInnerCone[lightIndex], sizeof(float), lightIndex*sizeof(float)); + constantManager->setSharedVariable(lightName, SHADER_VAR_NAME(lightOuterCone), &lightOuterCone[lightIndex], sizeof(float), lightIndex*sizeof(float)); +#if RENDERER_ENABLE_SINGLE_PASS_LIGHTING + constantManager->setSharedVariable(lightName, SHADER_VAR_NAME(lightType), &lightType[lightIndex], sizeof(int), lightIndex*sizeof(int)); + constantManager->setSharedVariable(lightName, SHADER_VAR_NAME(numLights), &numLights, sizeof(int)); +#endif + +#if RENDERER_ENABLE_SHADOWS + if (lightShadowMap) + { + // The actual shadow map texture will be bound as a variable of the material + constantManager->setSharedVariable("cbLightShadow", SHADER_VAR_NAME(lightShadowMatrix), &lightShadowMatrix); + } +#endif + } +} + +void D3D11Renderer::D3D11ShaderEnvironment::bindModel() const +{ + constantManager->setSharedVariable("cbMesh", SHADER_VAR_NAME(modelMatrix), &modelMatrix); + constantManager->setSharedVariable("cbMesh", SHADER_VAR_NAME(modelViewMatrix), &modelViewMatrix); + constantManager->setSharedVariable("cbMesh", SHADER_VAR_NAME(modelViewProjMatrix), &modelViewProjMatrix); +} + +void D3D11Renderer::D3D11ShaderEnvironment::bindBones() const +{ + if (numBones > 0) + { + constantManager->setSharedVariable("cbBones", SHADER_VAR_NAME(boneMatrices), &boneMatrices[0], numBones * sizeof(PxMat44)); + } +} + +void D3D11Renderer::D3D11ShaderEnvironment::bindFogState() const +{ + constantManager->setSharedVariable("cbFog", SHADER_VAR_NAME(fogColorAndDistance), &fogColorAndDistance.x); +} + +void D3D11Renderer::D3D11ShaderEnvironment::bindAmbientState() const +{ + constantManager->setSharedVariable("cbAmbient", SHADER_VAR_NAME(ambientColor), &ambientColor.x); +} + +void D3D11Renderer::D3D11ShaderEnvironment::bindVFaceScale() const +{ +#if defined(RENDERER_ENABLE_VFACE_SCALE) + constantManager->setSharedVariable("cbScale", SHADER_VAR_NAME(vfaceScale), &vfs); +#endif +} + +void D3D11Renderer::D3D11ShaderEnvironment::reset() +{ + numLights = 0; +} + +#undef SHADER_VAR_NAME + +/*************** +* D3D11Renderer * +***************/ + +static std::deque<ID3D11BlendState*> gBlendState; +static std::deque<ID3D11DepthStencilState*> gDepthStencilState; +static std::deque<ID3D11RasterizerState*> gRasterizerState; +static std::deque<D3D11_VIEWPORT> gViewport; +static std::deque<PxVec4> gBlendFactor; +static std::deque<UINT> gBlendMask; +static std::deque<UINT> gDepthStencilMask; + +D3D11Renderer::D3D11Renderer(const RendererDesc& desc, const char* assetDir) : + Renderer(DRIVER_DIRECT3D11, desc.errorCallback, assetDir), + m_displayWidth(0), + m_displayHeight(0), + m_displayBuffer(0), + m_vsync(desc.vsync), + m_multipassDepthBias(desc.multipassDepthBias ? -1 : 0), + m_d3d(NULL), + m_d3dSwapChain(NULL), + m_d3dDevice(NULL), + m_d3dDeviceContext(NULL), + m_d3dDeviceFeatureLevel(D3D_FEATURE_LEVEL_11_0), + m_d3dDepthStencilBuffer(NULL), + m_d3dDepthStencilView(NULL), + m_d3dRenderTargetBuffer(NULL), + m_d3dRenderTargetView(NULL), + m_currentTextMesh(0), + m_linesMesh(NULL), + m_linesVertices(NULL), + m_d3dx(NULL), + m_constantManager(NULL), + m_resourceManager(NULL) +{ + for (PxU32 i = 0; i < NUM_BLEND_STATES; ++i) + m_d3dBlendStates[i] = NULL; + for (PxU32 i = 0; i < NUM_DEPTH_STENCIL_STATES; ++i) + m_d3dDepthStencilStates[i] = NULL; + + m_useShadersForTextRendering = true; + m_pixelCenterOffset = 0.f; + m_viewMatrix = physx::PxMat44(PxIdentity); + + SampleFramework::SamplePlatform* m_platform = SampleFramework::SamplePlatform::platform(); + m_d3d = static_cast<IDXGIFactory*>(m_platform->initializeD3D11()); + RENDERER_ASSERT(m_d3d, "Could not create Direct3D11 Interface."); + if (m_d3d) + { + // Setup swap chain configuration + memset(&m_swapChainDesc, 0, sizeof(m_swapChainDesc)); + m_swapChainDesc.BufferCount = 1; + m_swapChainDesc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT; + m_swapChainDesc.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM; + m_swapChainDesc.BufferDesc.Height = m_displayHeight; + m_swapChainDesc.BufferDesc.RefreshRate.Numerator = 60; + m_swapChainDesc.BufferDesc.RefreshRate.Denominator = 1; + m_swapChainDesc.BufferDesc.Scaling = DXGI_MODE_SCALING_UNSPECIFIED; + m_swapChainDesc.BufferDesc.ScanlineOrdering = DXGI_MODE_SCANLINE_ORDER_UNSPECIFIED; + m_swapChainDesc.BufferDesc.Width = m_displayWidth; + m_swapChainDesc.Flags = DXGI_SWAP_CHAIN_FLAG_ALLOW_MODE_SWITCH ; + m_swapChainDesc.SampleDesc.Count = 1; + m_swapChainDesc.SampleDesc.Quality = 0; + m_swapChainDesc.SwapEffect = DXGI_SWAP_EFFECT_DISCARD; + m_swapChainDesc.Windowed = 1; + + HRESULT hr = m_platform->initializeD3D11Display( + &m_swapChainDesc, + m_deviceName, + m_displayWidth, + m_displayHeight, + &m_d3dDevice, + &m_d3dDeviceContext, + &m_d3dSwapChain); + RENDERER_ASSERT(SUCCEEDED(hr), "Failed to create Direct3D11 Device."); + if (SUCCEEDED(hr)) + { + m_d3dDeviceFeatureLevel = m_d3dDevice->GetFeatureLevel(); + setEnableTessellation(true); + checkResize(false); + } + } + + D3D11RendererVariableManager::StringSet cbNames; + cbNames.insert("cbAllData"); + cbNames.insert("cbMesh"); + cbNames.insert("cbFrame"); + cbNames.insert("cbFrameInv"); + cbNames.insert("cbBones"); + cbNames.insert("cbFog"); + cbNames.insert("cbAmbient"); + cbNames.insert("cbLight"); + cbNames.insert("cbLights"); + cbNames.insert("cbLightShadow"); + cbNames.insert("cbScale"); + cbNames.insert("cbTessellation"); + + m_d3dx = new D3DX11(); + m_constantManager = new D3D11RendererVariableManager(*this, cbNames /*, D3D11RendererVariableManager::BIND_MAP*/); + m_resourceManager = new D3D11RendererResourceManager( ); + m_environment.constantManager = m_constantManager; +} + +D3D11Renderer::~D3D11Renderer(void) +{ + releaseAllMaterials(); + + if (m_d3dDeviceContext) + { + m_d3dDeviceContext->ClearState(); + m_d3dDeviceContext->Flush(); + } + + dxSafeRelease(m_displayBuffer); + + dxSafeRelease(m_d3d); + dxSafeRelease(m_d3dSwapChain); + dxSafeRelease(m_d3dDevice); + dxSafeRelease(m_d3dDeviceContext); + + dxSafeRelease(m_d3dDepthStencilBuffer); + dxSafeRelease(m_d3dDepthStencilView); + dxSafeRelease(m_d3dRenderTargetBuffer); + dxSafeRelease(m_d3dRenderTargetView); + + for (PxU32 i = 0; i < NUM_BLEND_STATES; ++i) + dxSafeRelease(m_d3dBlendStates[i]); + for (PxU32 i = 0; i < NUM_DEPTH_STENCIL_STATES; ++i) + dxSafeRelease(m_d3dDepthStencilStates[i]); + + dxSafeReleaseAll(gRasterizerState); + dxSafeReleaseAll(gBlendState); + dxSafeReleaseAll(gDepthStencilState); + + deleteAll(m_textMeshes); + deleteAll(m_textVertices); + deleteAll(m_textIndices); + + delete m_linesMesh; + delete m_linesVertices; + + delete m_constantManager; + delete m_resourceManager; + delete m_d3dx; +} + +bool D3D11Renderer::checkResize(bool resetDevice) +{ + bool isDeviceReset = false; +#if defined(RENDERER_WINDOWS) + if (SampleFramework::SamplePlatform::platform()->getWindowHandle() && m_d3dDevice) + { + PxU32 width = 0; + PxU32 height = 0; + SampleFramework::SamplePlatform::platform()->getWindowSize(width, height); + if (width && height && (width != m_displayWidth || height != m_displayHeight) || resetDevice) + { + m_displayWidth = width; + m_displayHeight = height; + m_d3dDeviceContext->ClearState(); + m_d3dDeviceContext->OMSetRenderTargets(0, NULL, NULL); + + dxSafeRelease(m_d3dRenderTargetView); + dxSafeRelease(m_d3dRenderTargetBuffer); + dxSafeRelease(m_d3dDepthStencilView); + dxSafeRelease(m_d3dDepthStencilBuffer); + + HRESULT hr = S_OK; + DXGI_SWAP_CHAIN_DESC desc; + m_d3dSwapChain->GetDesc(&desc); + if(desc.BufferDesc.Width != width || desc.BufferDesc.Height != height) + hr = m_d3dSwapChain->ResizeBuffers(0, 0, 0, DXGI_FORMAT_UNKNOWN, 0); + RENDERER_ASSERT(SUCCEEDED(hr), "Failed to resize swap chain buffers."); + + D3D11_TEXTURE2D_DESC depthDesc; + depthDesc.Format = DXGI_FORMAT_D24_UNORM_S8_UINT; + if (SUCCEEDED(hr)) + { + depthDesc.Width = m_displayWidth; + depthDesc.Height = m_displayHeight; + depthDesc.MipLevels = 1; + depthDesc.ArraySize = 1; + depthDesc.SampleDesc.Count = m_swapChainDesc.SampleDesc.Count; + depthDesc.SampleDesc.Quality = m_swapChainDesc.SampleDesc.Quality; + depthDesc.Usage = D3D11_USAGE_DEFAULT; + depthDesc.BindFlags = D3D11_BIND_DEPTH_STENCIL; + depthDesc.CPUAccessFlags = 0; + depthDesc.MiscFlags = 0; + + hr = m_d3dDevice->CreateTexture2D(&depthDesc, NULL, &m_d3dDepthStencilBuffer); + RENDERER_ASSERT(SUCCEEDED(hr), "Failed to create depth stencil buffer."); + } + + if (SUCCEEDED(hr)) + { + hr = m_d3dSwapChain->GetBuffer(0, __uuidof(ID3D11Texture2D), (void**)&m_d3dRenderTargetBuffer); + RENDERER_ASSERT(SUCCEEDED(hr), "Failed to acquire swap chain buffer."); + } + + if (SUCCEEDED(hr) && m_d3dRenderTargetBuffer) + { + D3D11_RENDER_TARGET_VIEW_DESC rtvDesc; + rtvDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM; + rtvDesc.ViewDimension = D3D11_RTV_DIMENSION_TEXTURE2DMS; + //rtvDesc.Texture2D.MipSlice = 0; + hr = m_d3dDevice->CreateRenderTargetView(m_d3dRenderTargetBuffer, &rtvDesc, &m_d3dRenderTargetView); + RENDERER_ASSERT(SUCCEEDED(hr), "Failed to create render target view."); + } + + if (SUCCEEDED(hr)) + { + D3D11_DEPTH_STENCIL_VIEW_DESC dsvDesc; + dsvDesc.ViewDimension = D3D11_DSV_DIMENSION_TEXTURE2DMS; + dsvDesc.Format = depthDesc.Format; + dsvDesc.Flags = 0; + //dsvDesc.Texture2D.MipSlice = 0; + hr = m_d3dDevice->CreateDepthStencilView(m_d3dDepthStencilBuffer, &dsvDesc, &m_d3dDepthStencilView); + RENDERER_ASSERT(SUCCEEDED(hr), "Failed to create depth stencil view."); + } + + m_d3dDeviceContext->OMSetRenderTargets(1, &m_d3dRenderTargetView, m_d3dDepthStencilView); + + if (resetDevice) + { + onDeviceReset(); + isDeviceReset = true; + } + + PxU32 NUM_VIEWPORTS = 1; + D3D11_VIEWPORT viewport[1]; + ZeroMemory(viewport, sizeof(D3D11_VIEWPORT)*NUM_VIEWPORTS); + m_d3dDeviceContext->RSGetViewports(&NUM_VIEWPORTS, viewport); + viewport[0].Width = (FLOAT)m_displayWidth; + viewport[0].Height = (FLOAT)m_displayHeight; + viewport[0].MinDepth = 0.0f; + viewport[0].MaxDepth = 1.0f; + m_d3dDeviceContext->RSSetViewports(1, viewport); + } + } + +#endif + return isDeviceReset; +} + +void D3D11Renderer::onDeviceLost(void) +{ + notifyResourcesLostDevice(); +} + +void D3D11Renderer::onDeviceReset(void) +{ + notifyResourcesResetDevice(); +} + +// clears the offscreen buffers. +void D3D11Renderer::clearBuffers(void) +{ + if (m_d3dDeviceContext && m_d3dRenderTargetView) + { + PxVec4 clearColor; + convertToD3D11(clearColor, getClearColor()); + m_d3dDeviceContext->ClearRenderTargetView(m_d3dRenderTargetView, &clearColor.x); + } + if (m_d3dDeviceContext && m_d3dDepthStencilView) + { + m_d3dDeviceContext->ClearDepthStencilView(m_d3dDepthStencilView, D3D11_CLEAR_DEPTH | D3D11_CLEAR_STENCIL, 1.0, 0); + } +} + +// presents the current color buffer to the screen. +// returns true on device reset and if buffers need to be rewritten. +bool D3D11Renderer::swapBuffers(void) +{ + PX_PROFILE_ZONE("SwapBuffers", 0); + bool isDeviceReset = false; + if (m_d3dDevice) + { + HRESULT result = SampleFramework::SamplePlatform::platform()->D3D11Present(m_vsync); + if ( DXGI_STATUS_OCCLUDED == result ) + { + // This is fine, though we should set a flag to use a "test" D3D11Present + // for the next frame until the window is no longer occluded + } + else if (SUCCEEDED(result) || DXGI_ERROR_DEVICE_RESET == result) + { + isDeviceReset = checkResize(DXGI_ERROR_DEVICE_RESET == result); + } + } + return isDeviceReset; +} + +void D3D11Renderer::getWindowSize(PxU32& width, PxU32& height) const +{ + RENDERER_ASSERT(m_displayHeight * m_displayWidth > 0, "variables not initialized properly"); + width = m_displayWidth; + height = m_displayHeight; +} + +RendererVertexBuffer* D3D11Renderer::createVertexBuffer(const RendererVertexBufferDesc& desc) +{ + D3D11RendererVertexBuffer* vb = 0; + if (m_d3dDevice) + { + RENDERER_ASSERT(desc.isValid(), "Invalid Vertex Buffer Descriptor."); + if (desc.isValid()) + { + vb = new D3D11RendererVertexBuffer(*m_d3dDevice, *m_d3dDeviceContext, desc); + } + } + if (vb) + { + addResource(*vb); + } + return vb; +} + +RendererIndexBuffer* D3D11Renderer::createIndexBuffer(const RendererIndexBufferDesc& desc) +{ + D3D11RendererIndexBuffer* ib = 0; + if (m_d3dDevice) + { + RENDERER_ASSERT(desc.isValid(), "Invalid Index Buffer Descriptor."); + if (desc.isValid()) + { + ib = new D3D11RendererIndexBuffer(*m_d3dDevice, *m_d3dDeviceContext, desc); + } + } + if (ib) + { + addResource(*ib); + } + return ib; +} + +RendererInstanceBuffer* D3D11Renderer::createInstanceBuffer(const RendererInstanceBufferDesc& desc) +{ + D3D11RendererInstanceBuffer* ib = 0; + if (m_d3dDevice) + { + RENDERER_ASSERT(desc.isValid(), "Invalid Instance Buffer Descriptor."); + if (desc.isValid()) + { + ib = new D3D11RendererInstanceBuffer(*m_d3dDevice, *m_d3dDeviceContext, desc); + } + } + if (ib) + { + addResource(*ib); + } + return ib; +} + +RendererTexture2D* D3D11Renderer::createTexture2D(const RendererTexture2DDesc& desc) +{ + D3D11RendererTexture2D* texture = 0; + if (m_d3dDevice) + { + RENDERER_ASSERT(desc.isValid(), "Invalid Texture 2D Descriptor."); + if (desc.isValid()) + { + texture = new D3D11RendererTexture2D(*m_d3dDevice, *m_d3dDeviceContext, desc); + } + } + if (texture) + { + addResource(*texture); + } + return texture; +} + +RendererTexture3D* D3D11Renderer::createTexture3D(const RendererTexture3DDesc& desc) +{ + D3D11RendererTexture3D* texture = 0; + if (m_d3dDevice) + { + RENDERER_ASSERT(desc.isValid(), "Invalid Texture 3D Descriptor."); + if (desc.isValid()) + { + texture = new D3D11RendererTexture3D(*m_d3dDevice, *m_d3dDeviceContext, desc); + } + } + if (texture) + { + addResource(*texture); + } + return texture; +} + +RendererTarget* D3D11Renderer::createTarget(const RendererTargetDesc& desc) +{ + RendererTarget* target = 0; +#if defined(RENDERER_ENABLE_DIRECT3D11_TARGET) + D3D11RendererTarget* d3dTarget = 0; + RENDERER_ASSERT(desc.isValid(), "Invalid Target Descriptor."); + if (desc.isValid()) + { + d3dTarget = new D3D11RendererTarget(*m_d3dDevice, *m_d3dDeviceContext, desc); + } + if (d3dTarget) + { + addResource(*d3dTarget); + } + target = d3dTarget; +#endif + return target; +} + +RendererMaterial* D3D11Renderer::createMaterial(const RendererMaterialDesc& desc) +{ + RendererMaterial* mat = hasMaterialAlready(desc); + RENDERER_ASSERT(desc.isValid(), "Invalid Material Descriptor."); + if (!mat && desc.isValid()) + { + mat = new D3D11RendererMaterial(*this, desc); + + registerMaterial(desc, mat); + } + return mat; +} + +RendererMesh* D3D11Renderer::createMesh(const RendererMeshDesc& desc) +{ + D3D11RendererMesh* mesh = 0; + RENDERER_ASSERT(desc.isValid(), "Invalid Mesh Descriptor."); + if (desc.isValid()) + { + mesh = new D3D11RendererMesh(*this, desc); + } + return mesh; +} + +RendererLight* D3D11Renderer::createLight(const RendererLightDesc& desc) +{ + RendererLight* light = 0; + if (m_d3dDevice) + { + RENDERER_ASSERT(desc.isValid(), "Invalid Light Descriptor."); + if (desc.isValid()) + { + switch (desc.type) + { + case RendererLight::TYPE_DIRECTIONAL: + light = new D3D11RendererDirectionalLight(*this, *(RendererDirectionalLightDesc*)&desc); + break; + case RendererLight::TYPE_SPOT: + light = new D3D11RendererSpotLight(*this, *(RendererSpotLightDesc*)&desc); + break; + default: + RENDERER_ASSERT(0, "Not implemented!"); + } + } + } + return light; +} + +void D3D11Renderer::setVsync(bool on) +{ + m_vsync = on; +} + +bool D3D11Renderer::beginRender(void) +{ + setBlendState(); + + setRasterizerState(); + + setTessellationState(); + + m_environment.reset(); + m_currentTextMesh = 0; + return true; +} + +void D3D11Renderer::endRender(void) +{ + +} + +void D3D11Renderer::bindViewProj(const physx::PxMat44& eye, const RendererProjection& proj) +{ + m_viewMatrix = eye.inverseRT(); + + convertToD3D11(m_environment.viewMatrix, m_viewMatrix); + convertToD3D11(m_environment.invViewProjMatrix, eye); + convertToD3D11(m_environment.projMatrix, proj); + + m_environment.eyePosition = eye.getPosition(); + m_environment.eyeDirection = -eye.getBasis(2); + + m_environment.bindFrame(); +} + +void D3D11Renderer::bindFogState(const RendererColor& fogColor, float fogDistance) +{ + const float inv255 = 1.0f / 255.0f; + + m_environment.fogColorAndDistance.x = fogColor.r * inv255; + m_environment.fogColorAndDistance.y = fogColor.g * inv255; + m_environment.fogColorAndDistance.z = fogColor.b * inv255; + m_environment.fogColorAndDistance.w = fogDistance; + m_environment.bindFogState(); +} + +void D3D11Renderer::bindAmbientState(const RendererColor& ambientColor) +{ + convertToD3D11(m_environment.ambientColor, ambientColor); + m_environment.bindAmbientState(); +} + +void D3D11Renderer::bindDeferredState(void) +{ + RENDERER_ASSERT(0, "Not implemented!"); +} + +void D3D11Renderer::bindMeshContext(const RendererMeshContext& context) +{ + physx::PxMat44 model; + physx::PxMat44 modelView; + if(context.transform) model = *context.transform; + else model = PxMat44(PxIdentity); + modelView = m_viewMatrix * model; + + convertToD3D11(m_environment.modelMatrix, model); + convertToD3D11(m_environment.modelViewMatrix, modelView); + m_environment.bindModel(); + + + // it appears that D3D winding is backwards, so reverse them... + D3D11_CULL_MODE cullMode = D3D11_CULL_BACK; + switch (context.cullMode) + { + case RendererMeshContext::CLOCKWISE: + cullMode = context.negativeScale ? D3D11_CULL_BACK : D3D11_CULL_FRONT; + break; + case RendererMeshContext::COUNTER_CLOCKWISE: + cullMode = context.negativeScale ? D3D11_CULL_FRONT : D3D11_CULL_BACK; + break; + case RendererMeshContext::NONE: + cullMode = D3D11_CULL_NONE; + break; + default: + RENDERER_ASSERT(0, "Invalid Cull Mode"); + } + if (!blendingCull() && NULL != context.material && context.material->getBlending()) + cullMode = D3D11_CULL_NONE; + + D3D11_FILL_MODE fillMode = D3D11_FILL_SOLID; + switch (context.fillMode) + { + case RendererMeshContext::SOLID: + fillMode = D3D11_FILL_SOLID; + break; + case RendererMeshContext::LINE: + fillMode = D3D11_FILL_WIREFRAME; + break; + case RendererMeshContext::POINT: + fillMode = D3D11_FILL_SOLID; + break; + default: + RENDERER_ASSERT(0, "Invalid Fill Mode"); + } + if (wireframeEnabled()) + { + fillMode = D3D11_FILL_WIREFRAME; + } + + setRasterizerState(fillMode, cullMode, get<2>(m_boundRasterizerStateKey)); + + RENDERER_ASSERT(context.numBones <= RENDERER_MAX_BONES, "Too many bones."); + if (context.boneMatrices && context.numBones > 0 && context.numBones <= RENDERER_MAX_BONES) + { + for (PxU32 i = 0; i < context.numBones; ++i) + { + convertToD3D11(m_environment.boneMatrices[i], context.boneMatrices[i]); + } + m_environment.numBones = context.numBones; + m_environment.bindBones(); + } +} + +void D3D11Renderer::setRasterizerState(D3D11_FILL_MODE fillMode, D3D11_CULL_MODE cullMode, PxI32 depthBias) +{ + + D3DTraits<ID3D11RasterizerState>::key_type rasterizerStateKey(fillMode, cullMode, depthBias); + + ID3D11RasterizerState* pRasterizerState = + getResourceManager()->hasResource<ID3D11RasterizerState>(rasterizerStateKey); + if (NULL == pRasterizerState) + { + RENDERER_ASSERT(m_d3dDevice, "Invalid D3D11 device."); + D3D11_RASTERIZER_DESC rasterizerDesc = + { + fillMode, // D3D11_FILL_MODE FillMode; + cullMode, // D3D11_CULL_MODE CullMode; + TRUE, // BOOL FrontCounterClockwise; + 0, // INT DepthBias; + .05f * depthBias, // FLOAT DepthBiasClamp; + .05f * depthBias, // FLOAT SlopeScaledDepthBias; + FALSE, // BOOL DepthClipEnable; + FALSE, // BOOL ScissorEnable; + (fillMode == D3D11_FILL_WIREFRAME) ? FALSE : TRUE, // BOOL MultisampleEnable; + FALSE, // BOOL AntialiasedLineEnable; + }; + if(getFeatureLevel() <= D3D_FEATURE_LEVEL_9_3) + { + rasterizerDesc.DepthClipEnable = TRUE; + } + HRESULT result = m_d3dDevice->CreateRasterizerState(&rasterizerDesc, &pRasterizerState); + RENDERER_ASSERT(SUCCEEDED(result) && pRasterizerState, "Error creating D3D11 rasterizer state."); + if (SUCCEEDED(result)) + { + getResourceManager()->registerResource<ID3D11RasterizerState>(rasterizerStateKey, pRasterizerState); + } + } + RENDERER_ASSERT(pRasterizerState, "Invalid D3D11RasterizerState"); + if (pRasterizerState && m_d3dDeviceContext) + { + m_d3dDeviceContext->RSSetState(pRasterizerState); + if (get<1>(m_boundRasterizerStateKey) != get<1>(rasterizerStateKey)) + { + m_environment.vfs = (get<1>(rasterizerStateKey) == D3D11_CULL_BACK) ? 1.f : -1.f; + m_environment.bindVFaceScale(); + } + m_boundRasterizerStateKey = rasterizerStateKey; + } +} + + +void SampleRenderer::D3D11Renderer::setDepthStencilState(DepthStencilState state) +{ + if (!m_d3dDeviceContext || state >= NUM_DEPTH_STENCIL_STATES) + { + return; + } + + // The standard depth-stencil state + D3D11_DEPTH_STENCIL_DESC depthStencilDesc = + { + TRUE, // BOOL DepthEnable; + D3D11_DEPTH_WRITE_MASK_ALL, // D3D11_DEPTH_WRITE_MASK DepthWriteMask; + D3D11_COMPARISON_LESS, // D3D11_COMPARISON_FUNC DepthFunc; + TRUE, // BOOL StencilEnable; + 0xFF, // UINT8 StencilReadMask; + 0xFF, // UINT8 StencilWriteMask; + { + // D3D11_DEPTH_STENCILOP_DESC FrontFace; + D3D11_STENCIL_OP_KEEP, // D3D11_STENCIL_OP StencilFailOp; + D3D11_STENCIL_OP_INCR, // D3D11_STENCIL_OP StencilDepthFailOp; + D3D11_STENCIL_OP_KEEP, // D3D11_STENCIL_OP StencilPassOp; + D3D11_COMPARISON_ALWAYS, // D3D11_COMPARISON_FUNC StencilFunc; + }, + { + // D3D11_DEPTH_STENCILOP_DESC BackFace; + D3D11_STENCIL_OP_KEEP, // D3D11_STENCIL_OP StencilFailOp; + D3D11_STENCIL_OP_INCR, // D3D11_STENCIL_OP StencilDepthFailOp; + D3D11_STENCIL_OP_KEEP, // D3D11_STENCIL_OP StencilPassOp; + D3D11_COMPARISON_ALWAYS, // D3D11_COMPARISON_FUNC StencilFunc; + }, + }; + + if (!m_d3dDepthStencilStates[DEPTHSTENCIL_DEFAULT]) + { + m_d3dDevice->CreateDepthStencilState(&depthStencilDesc, &m_d3dDepthStencilStates[DEPTHSTENCIL_DEFAULT]); + RENDERER_ASSERT(m_d3dDepthStencilStates[DEPTHSTENCIL_DEFAULT], "Error creating D3D depth stencil state"); + } + if (!m_d3dDepthStencilStates[DEPTHSTENCIL_TRANSPARENT]) + { + depthStencilDesc.DepthWriteMask = D3D11_DEPTH_WRITE_MASK_ZERO; + depthStencilDesc.DepthFunc = D3D11_COMPARISON_LESS_EQUAL; + depthStencilDesc.StencilWriteMask = 0x00; + m_d3dDevice->CreateDepthStencilState(&depthStencilDesc, &m_d3dDepthStencilStates[DEPTHSTENCIL_TRANSPARENT]); + RENDERER_ASSERT(m_d3dDepthStencilStates[DEPTHSTENCIL_TRANSPARENT], "Error creating D3D depth stencil state"); + } + if (!m_d3dDepthStencilStates[DEPTHSTENCIL_DISABLED]) + { + depthStencilDesc.DepthEnable = FALSE; + depthStencilDesc.DepthWriteMask = D3D11_DEPTH_WRITE_MASK_ZERO; + depthStencilDesc.DepthFunc = D3D11_COMPARISON_NEVER; + depthStencilDesc.StencilEnable = FALSE; + depthStencilDesc.StencilReadMask = 0x00; + depthStencilDesc.StencilWriteMask = 0x00; + m_d3dDevice->CreateDepthStencilState(&depthStencilDesc, &m_d3dDepthStencilStates[DEPTHSTENCIL_DISABLED]); + RENDERER_ASSERT(m_d3dDepthStencilStates[DEPTHSTENCIL_DISABLED], "Error creating D3D depth stencil state"); + } + + m_d3dDeviceContext->OMSetDepthStencilState(m_d3dDepthStencilStates[state], 1); +} + +void SampleRenderer::D3D11Renderer::setBlendState(BlendState state) +{ + if (!m_d3dDeviceContext || state >= NUM_BLEND_STATES) + { + return; + } + + // BLEND_DEFAULT is purposefully NULL + if (!m_d3dBlendStates[BLEND_MULTIPASS] && m_d3dDevice) + { + D3D11_BLEND_DESC blendDesc; + memset(&blendDesc, 0, sizeof(blendDesc)); + if(getFeatureLevel() <= D3D_FEATURE_LEVEL_9_3) + { + blendDesc.AlphaToCoverageEnable = FALSE; + blendDesc.IndependentBlendEnable = FALSE; + } + else + { + blendDesc.AlphaToCoverageEnable = TRUE; + blendDesc.IndependentBlendEnable = TRUE; + } + blendDesc.RenderTarget[0].BlendEnable = TRUE; + blendDesc.RenderTarget[0].SrcBlend = D3D11_BLEND_ONE; + blendDesc.RenderTarget[0].DestBlend = D3D11_BLEND_ONE; + blendDesc.RenderTarget[0].BlendOp = D3D11_BLEND_OP_ADD; + blendDesc.RenderTarget[0].SrcBlendAlpha = D3D11_BLEND_ONE; + blendDesc.RenderTarget[0].DestBlendAlpha = D3D11_BLEND_ONE; + blendDesc.RenderTarget[0].BlendOpAlpha = D3D11_BLEND_OP_ADD; + blendDesc.RenderTarget[0].RenderTargetWriteMask = D3D11_COLOR_WRITE_ENABLE_ALL; + + m_d3dDevice->CreateBlendState(&blendDesc, &m_d3dBlendStates[BLEND_MULTIPASS]); + RENDERER_ASSERT(m_d3dBlendStates[BLEND_MULTIPASS], "Error creating D3D blend state"); + } + if (!m_d3dBlendStates[BLEND_TRANSPARENT_ALPHA_COVERAGE] && m_d3dDevice) + { + D3D11_BLEND_DESC blendDesc; + memset(&blendDesc, 0, sizeof(blendDesc)); + if(getFeatureLevel() <= D3D_FEATURE_LEVEL_9_3) + { + blendDesc.AlphaToCoverageEnable = FALSE; + blendDesc.IndependentBlendEnable = FALSE; + } + else + { + blendDesc.AlphaToCoverageEnable = TRUE; + blendDesc.IndependentBlendEnable = TRUE; + } + blendDesc.RenderTarget[0].BlendEnable = TRUE; + blendDesc.RenderTarget[0].SrcBlend = D3D11_BLEND_SRC_ALPHA; + blendDesc.RenderTarget[0].DestBlend = D3D11_BLEND_ONE; + blendDesc.RenderTarget[0].BlendOp = D3D11_BLEND_OP_ADD; + blendDesc.RenderTarget[0].SrcBlendAlpha = D3D11_BLEND_ONE; + blendDesc.RenderTarget[0].DestBlendAlpha = D3D11_BLEND_ONE; + blendDesc.RenderTarget[0].BlendOpAlpha = D3D11_BLEND_OP_ADD; + blendDesc.RenderTarget[0].RenderTargetWriteMask = D3D11_COLOR_WRITE_ENABLE_ALL; + + m_d3dDevice->CreateBlendState(&blendDesc, &m_d3dBlendStates[BLEND_TRANSPARENT_ALPHA_COVERAGE]); + RENDERER_ASSERT(m_d3dBlendStates[BLEND_TRANSPARENT_ALPHA_COVERAGE], "Error creating D3D blend state"); + } + if (!m_d3dBlendStates[BLEND_TRANSPARENT] && m_d3dDevice) + { + D3D11_BLEND_DESC blendDesc; + memset(&blendDesc, 0, sizeof(blendDesc)); + blendDesc.AlphaToCoverageEnable = FALSE; + if(getFeatureLevel() <= D3D_FEATURE_LEVEL_9_3) + { + blendDesc.IndependentBlendEnable = FALSE; + } + else + { + blendDesc.IndependentBlendEnable = TRUE; + } + blendDesc.RenderTarget[0].BlendEnable = TRUE; + blendDesc.RenderTarget[0].SrcBlend = D3D11_BLEND_SRC_ALPHA; + blendDesc.RenderTarget[0].DestBlend = D3D11_BLEND_INV_SRC_ALPHA; + blendDesc.RenderTarget[0].BlendOp = D3D11_BLEND_OP_ADD; + blendDesc.RenderTarget[0].SrcBlendAlpha = D3D11_BLEND_ONE; + blendDesc.RenderTarget[0].DestBlendAlpha = D3D11_BLEND_ONE; + blendDesc.RenderTarget[0].BlendOpAlpha = D3D11_BLEND_OP_ADD; + blendDesc.RenderTarget[0].RenderTargetWriteMask = D3D11_COLOR_WRITE_ENABLE_ALL; + + m_d3dDevice->CreateBlendState(&blendDesc, &m_d3dBlendStates[BLEND_TRANSPARENT]); + RENDERER_ASSERT(m_d3dBlendStates[BLEND_TRANSPARENT], "Error creating D3D blend state"); + } + + const FLOAT BlendFactor[4] = {0, 0, 0, 0}; + m_d3dDeviceContext->OMSetBlendState(m_d3dBlendStates[state], BlendFactor, 0xffffffff); +} + +void SampleRenderer::D3D11Renderer::setTessellationState() +{ + getVariableManager()->setSharedVariable("cbTessellation", "g_tessFactor", &getTessellationParams().tessFactor); + getVariableManager()->setSharedVariable("cbTessellation", "g_tessMinMaxDistance", &getTessellationParams().tessMinMaxDistance); + getVariableManager()->setSharedVariable("cbTessellation", "g_tessHeightScaleAndBias", &getTessellationParams().tessHeightScaleAndBias); + getVariableManager()->setSharedVariable("cbTessellation", "g_tessUVScale", &getTessellationParams().tessUVScale); +} + +bool D3D11Renderer::tessellationEnabled() const +{ + return getEnableTessellation(); +} + +bool D3D11Renderer::isTessellationSupported(void) const +{ + return m_d3dDeviceFeatureLevel >= D3D_FEATURE_LEVEL_11_0; +} + +bool D3D11Renderer::multisamplingEnabled() const +{ + return m_swapChainDesc.SampleDesc.Count > 1 && m_swapChainDesc.SampleDesc.Quality > 0; +} + +void D3D11Renderer::beginMultiPass(void) +{ + setBlendState(BLEND_MULTIPASS); + setDepthStencilState(DEPTHSTENCIL_TRANSPARENT); + setRasterizerState(get<0>(m_boundRasterizerStateKey), get<1>(m_boundRasterizerStateKey), m_multipassDepthBias); +} + +void D3D11Renderer::endMultiPass(void) +{ + setBlendState(BLEND_DEFAULT); + setDepthStencilState(DEPTHSTENCIL_DEFAULT); + setRasterizerState(get<0>(m_boundRasterizerStateKey), get<1>(m_boundRasterizerStateKey), 0); +} + +void D3D11Renderer::beginTransparentMultiPass(void) +{ + setEnableBlendingOverride(true); + setBlendState(BLEND_TRANSPARENT_ALPHA_COVERAGE); + setDepthStencilState(DEPTHSTENCIL_TRANSPARENT); +} + +void D3D11Renderer::endTransparentMultiPass(void) +{ + setEnableBlendingOverride(false); + setBlendState(BLEND_DEFAULT); + setDepthStencilState(DEPTHSTENCIL_DEFAULT); +} + +void D3D11Renderer::renderDeferredLight(const RendererLight& light) +{ + RENDERER_ASSERT(0, "Not implemented!"); +} + +PxU32 D3D11Renderer::convertColor(const RendererColor& color) const +{ + return color.a << 24 | color.r << 16 | color.g << 8 | color.b; +} + +bool D3D11Renderer::isOk(void) const +{ + bool ok = (m_d3d && m_d3dDevice); +#if defined(RENDERER_WINDOWS) + if (!SampleFramework::SamplePlatform::platform()->isD3D11ok() || !m_d3dx->m_library) + { + ok = false; + } +#endif + return ok; +} + +void D3D11Renderer::addResource(D3D11RendererResource& resource) +{ + RENDERER_ASSERT(resource.m_d3dRenderer == 0, "Resource already in added to the Renderer!"); + if (resource.m_d3dRenderer == 0) + { + resource.m_d3dRenderer = this; + m_resources.push_back(&resource); + } +} + +void D3D11Renderer::removeResource(D3D11RendererResource& resource) +{ + RENDERER_ASSERT(resource.m_d3dRenderer == this, "Resource not part of this Renderer!"); + if (resource.m_d3dRenderer == this) + { + resource.m_d3dRenderer = 0; + const PxU32 numResources = (PxU32)m_resources.size(); + PxU32 foundResource = numResources; + for (PxU32 i = 0; i < numResources; ++i) + { + if (m_resources[i] == &resource) + { + foundResource = i; + break; + } + } + if (foundResource < numResources) + { + m_resources[foundResource] = m_resources.back(); + m_resources.pop_back(); + } + } +} + +void D3D11Renderer::notifyResourcesLostDevice(void) +{ + const PxU32 numResources = (PxU32)m_resources.size(); + for (PxU32 i = 0; i < numResources; ++i) + { + m_resources[i]->onDeviceLost(); + } +} + +void D3D11Renderer::notifyResourcesResetDevice(void) +{ + const PxU32 numResources = (PxU32)m_resources.size(); + for (PxU32 i = 0; i < numResources; ++i) { + m_resources[i]->onDeviceReset(); + } +} + +void D3D11Renderer::bind(RendererMaterialInstance* materialInstance) +{ + m_boundMaterial = materialInstance; +#if RENDERER_ENABLE_SHADOWS + if (m_boundMaterial && m_environment.lightShadowMap) + { + const RendererMaterial::Variable* pShadowMap = m_boundMaterial->findVariable("g_lightShadowMap", RendererMaterial::VARIABLE_SAMPLER2D); + if (pShadowMap) + { + m_boundMaterial->writeData(*pShadowMap, &m_environment.lightShadowMap); + } + } +#endif +} + +/////////////////////////////////////////////////////////////////////////////// + +static void pushRasterizer(ID3D11DeviceContext& context) +{ + gRasterizerState.push_back(NULL); + gViewport.push_back(D3D11_VIEWPORT()); + PxU32 NUM_VIEWPORTS = 1; + context.RSGetState(&gRasterizerState.back()); + context.RSGetViewports(&NUM_VIEWPORTS, &gViewport.back()); +} + +static void pushBlend(ID3D11DeviceContext& context) +{ + gBlendState.push_back(NULL); + gBlendFactor.push_back(PxVec4()); + gBlendMask.push_back(0); + context.OMGetBlendState(&gBlendState.back(), &gBlendFactor.back()[0], &gBlendMask.back()); +} + +static void pushDepthStencil(ID3D11DeviceContext& context) +{ + gDepthStencilState.push_back(NULL); + gDepthStencilMask.push_back(0); + context.OMGetDepthStencilState(&gDepthStencilState.back(), &gDepthStencilMask.back()); +} + +static void popRasterizer(ID3D11DeviceContext& context) +{ + if (!gRasterizerState.empty()) + { + context.RSSetState(gRasterizerState.back()); + dxSafeRelease(gRasterizerState.back()); + gRasterizerState.pop_back(); + } + if (!gViewport.empty()) + { + context.RSSetViewports(1, &gViewport.back()); + gViewport.pop_back(); + } +} + +static void popBlend(ID3D11DeviceContext& context) +{ + if (!gBlendState.empty()) + { + context.OMSetBlendState(gBlendState.back(), &gBlendFactor.back()[0], gBlendMask.back()); + dxSafeRelease(gBlendState.back()); + gBlendState.pop_back(); + gBlendFactor.pop_back(); + gBlendMask.pop_back(); + } +} + +static void popDepthStencil(ID3D11DeviceContext& context) +{ + if (!gDepthStencilState.empty()) + { + context.OMSetDepthStencilState(gDepthStencilState.back(), gDepthStencilMask.back()); + dxSafeRelease(gDepthStencilState.back()); + gDepthStencilState.pop_back(); + gDepthStencilMask.pop_back(); + } +} + +void D3D11Renderer::pushState(StateType stateType) +{ + if (m_d3dDeviceContext) + { + switch (stateType) + { + case STATE_BLEND: + pushBlend(*m_d3dDeviceContext); + break; + case STATE_RASTERIZER: + pushRasterizer(*m_d3dDeviceContext); + break; + case STATE_DEPTHSTENCIL: + pushDepthStencil(*m_d3dDeviceContext); + break; + default: + break; + } + } +} + +void D3D11Renderer::popState(StateType stateType) +{ + if (m_d3dDeviceContext) + { + switch (stateType) + { + case STATE_BLEND: + popBlend(*m_d3dDeviceContext); + break; + case STATE_RASTERIZER: + popRasterizer(*m_d3dDeviceContext); + break; + case STATE_DEPTHSTENCIL: + popDepthStencil(*m_d3dDeviceContext); + break; + default: + break; + } + } +} + +bool D3D11Renderer::initTexter() +{ + if (!Renderer::initTexter() || !m_d3dDevice) + { + return false; + } + + return true; +} + +void D3D11Renderer::closeTexter() +{ + Renderer::closeTexter(); +} + +void D3D11Renderer::setupTextRenderStates() +{ + if (m_d3dDeviceContext) + { + pushState(STATE_BLEND); + pushState(STATE_DEPTHSTENCIL); + pushState(STATE_RASTERIZER); + + setBlendState(BLEND_TRANSPARENT); + setDepthStencilState(DEPTHSTENCIL_DISABLED); + setRasterizerState(D3D11_FILL_SOLID, D3D11_CULL_NONE); + } +} + +void D3D11Renderer::resetTextRenderStates() +{ + if (m_d3dDeviceContext) + { + popState(STATE_RASTERIZER); + popState(STATE_DEPTHSTENCIL); + popState(STATE_BLEND); + } +} + +void D3D11Renderer::renderTextBuffer(const void* vertices, PxU32 nbVerts, const PxU16* indices, PxU32 nbIndices, RendererMaterial* material) +{ + PX_UNUSED(material); + // PT: font texture must have been selected prior to calling this function + if (m_d3dDeviceContext && m_d3dDevice && m_boundMaterial) + { + const PxU32 minMeshSize = m_currentTextMesh + 1; + if ((m_currentTextMesh + 1) > m_textVertices.size() || m_textVertices[m_currentTextMesh]->getMaxVertices() < nbVerts) + { + resizeIfSmallerThan(m_textVertices, minMeshSize, NULL); + resizeIfSmallerThan(m_textMeshes, minMeshSize, NULL); + + deleteSafe(m_textVertices[m_currentTextMesh]); + deleteSafe(m_textMeshes[m_currentTextMesh]); + + RendererVertexBufferDesc desc; + desc.maxVertices = nbVerts * 3; + desc.semanticFormats[RendererVertexBuffer::SEMANTIC_POSITION] = RendererVertexBuffer::FORMAT_FLOAT4; + desc.semanticFormats[RendererVertexBuffer::SEMANTIC_COLOR] = RendererVertexBuffer::FORMAT_COLOR_BGRA; + desc.semanticFormats[RendererVertexBuffer::SEMANTIC_TEXCOORD0] = RendererVertexBuffer::FORMAT_FLOAT2; + m_textVertices[m_currentTextMesh] = new D3D11RendererVertexBuffer(*m_d3dDevice, *m_d3dDeviceContext, desc, false); + } + if ((m_currentTextMesh + 1) > m_textIndices.size() || m_textIndices[m_currentTextMesh]->getMaxIndices() < nbIndices) + { + resizeIfSmallerThan(m_textIndices, minMeshSize, NULL); + resizeIfSmallerThan(m_textMeshes, minMeshSize, NULL); + + deleteSafe(m_textIndices[m_currentTextMesh]); + deleteSafe(m_textMeshes[m_currentTextMesh]); + + RendererIndexBufferDesc desc; + desc.maxIndices = nbIndices * 3; + desc.hint = RendererIndexBuffer::HINT_DYNAMIC; + desc.format = RendererIndexBuffer::FORMAT_UINT16; + m_textIndices[m_currentTextMesh] = new D3D11RendererIndexBuffer(*m_d3dDevice, *m_d3dDeviceContext, desc); + } + if ((m_currentTextMesh + 1) > m_textMeshes.size() || NULL == m_textMeshes[m_currentTextMesh] && m_textIndices[m_currentTextMesh] && m_textVertices[m_currentTextMesh]) + { + resizeIfSmallerThan(m_textMeshes, minMeshSize, NULL); + + RendererMeshDesc meshdesc; + meshdesc.primitives = RendererMesh::PRIMITIVE_TRIANGLES; + RendererVertexBuffer* vertexBuffer = m_textVertices[m_currentTextMesh]; + meshdesc.vertexBuffers = &vertexBuffer; + meshdesc.numVertexBuffers = 1; + meshdesc.firstVertex = 0; + meshdesc.numVertices = nbVerts; + meshdesc.indexBuffer = m_textIndices[m_currentTextMesh]; + meshdesc.firstIndex = 0; + meshdesc.numIndices = nbIndices; + m_textMeshes[m_currentTextMesh] = new D3D11RendererMesh(*this, meshdesc); + } + + if (m_textMeshes[m_currentTextMesh]) + { + // Assign the vertex transform and bind to the pipeline + const RendererMaterial::Variable* pViewVariable = m_boundMaterial->findVariable("g_viewMatrix2D", RendererMaterial::VARIABLE_FLOAT4x4); + RENDERER_ASSERT(pViewVariable, "Unable to locate view matrix variable in text vertex shader."); + if (pViewVariable) + { + PxMat44 viewMatrix (PxVec4(2.f / m_displayWidth , 0, 0, -1), + PxVec4(0, -2.f / m_displayHeight, 0, 1), + PxVec4(0 , 0, 1, 0), + PxVec4(0 , 0, 0, 1)); + m_boundMaterial->writeData(*pViewVariable, &viewMatrix); + static_cast<D3D11RendererMaterial&>(m_boundMaterial->getMaterial()).bindMeshState(false); + } + memcpy(m_textVertices[m_currentTextMesh]->internalLock(D3D11_MAP_WRITE_DISCARD), vertices, nbVerts * sizeof(TextVertex)); + m_textVertices[m_currentTextMesh]->unlock(); + memcpy(m_textIndices[m_currentTextMesh]->internalLock(D3D11_MAP_WRITE_DISCARD), indices, nbIndices * sizeof(PxU16)); + m_textIndices[m_currentTextMesh]->unlock(); + + m_textMeshes[m_currentTextMesh]->setNumVerticesAndIndices(nbVerts, nbIndices); + m_textMeshes[m_currentTextMesh]->bind(); + m_textMeshes[m_currentTextMesh]->render(&m_boundMaterial->getMaterial()); + ++m_currentTextMesh; + } + } +} + +bool D3D11Renderer::isSpriteRenderingSupported(void) const +{ + if(getFeatureLevel() <= D3D_FEATURE_LEVEL_9_3) + { + return false; + } + else + { + return true; + } +} + +void D3D11Renderer::renderLines2D(const void* vertices, PxU32 nbVerts) +{ + if (m_d3dDeviceContext && m_d3dDevice && m_boundMaterial) + { + if (!m_linesVertices || m_linesVertices->getMaxVertices() < nbVerts) + { + deleteSafe(m_linesVertices); + deleteSafe(m_linesMesh); + + RendererVertexBufferDesc desc; + desc.maxVertices = nbVerts * 3; + desc.semanticFormats[RendererVertexBuffer::SEMANTIC_POSITION] = RendererVertexBuffer::FORMAT_FLOAT4; + desc.semanticFormats[RendererVertexBuffer::SEMANTIC_COLOR] = RendererVertexBuffer::FORMAT_COLOR_BGRA; + desc.semanticFormats[RendererVertexBuffer::SEMANTIC_TEXCOORD0] = RendererVertexBuffer::FORMAT_FLOAT2; + m_linesVertices = new D3D11RendererVertexBuffer(*m_d3dDevice, *m_d3dDeviceContext, desc, false); + } + if (!m_linesMesh && m_linesVertices) + { + RendererMeshDesc meshdesc; + meshdesc.primitives = RendererMesh::PRIMITIVE_LINE_STRIP; + RendererVertexBuffer* vertexBuffer = m_linesVertices; + meshdesc.vertexBuffers = &vertexBuffer; + meshdesc.numVertexBuffers = 1; + meshdesc.firstVertex = 0; + meshdesc.numVertices = nbVerts; + m_linesMesh = new D3D11RendererMesh(*this, meshdesc); + } + + if (m_linesMesh) + { + const RendererMaterial::Variable* pViewVariable = m_boundMaterial->findVariable("g_viewMatrix2D", RendererMaterial::VARIABLE_FLOAT4x4); + if (pViewVariable) + { + PxMat44 viewMatrix (PxVec4(2.f / m_displayWidth , 0, 0, -1), + PxVec4(0, -2.f / m_displayHeight, 0, 1), + PxVec4(0 , 0, 1, 0), + PxVec4(0 , 0, 0, 1)); + m_boundMaterial->writeData(*pViewVariable, &viewMatrix); + static_cast<D3D11RendererMaterial&>(m_boundMaterial->getMaterial()).bindMeshState(false); + } + memcpy(m_linesVertices->internalLock(D3D11_MAP_WRITE_DISCARD), vertices, nbVerts * sizeof(TextVertex)); + m_linesVertices->unlock(); + + m_linesMesh->setNumVerticesAndIndices(nbVerts, 0); + m_linesMesh->bind(); + m_linesMesh->render(&m_boundMaterial->getMaterial()); + } + } +} + +void D3D11Renderer::setupScreenquadRenderStates() +{ + if (m_d3dDeviceContext) + { + pushState(STATE_DEPTHSTENCIL); + pushState(STATE_RASTERIZER); + pushState(STATE_BLEND); + + setDepthStencilState(DEPTHSTENCIL_DISABLED); + setRasterizerState(D3D11_FILL_SOLID, D3D11_CULL_NONE); + setBlendState(BLEND_TRANSPARENT); + } +} + +void D3D11Renderer::resetScreenquadRenderStates() +{ + if (m_d3dDeviceContext) + { + popState(STATE_DEPTHSTENCIL); + popState(STATE_RASTERIZER); + popState(STATE_BLEND); + } +} + +bool D3D11Renderer::captureScreen( PxU32 &width, PxU32& height, PxU32& sizeInBytes, const void*& screenshotData ) +{ + bool bSuccess = false; + + HRESULT hr; + ID3D11Resource *backbufferRes; + m_d3dRenderTargetView->GetResource(&backbufferRes); + + D3D11_TEXTURE2D_DESC texDesc; + texDesc.ArraySize = 1; + texDesc.BindFlags = 0; + texDesc.CPUAccessFlags = 0; + texDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM; + texDesc.Width = m_displayWidth; + texDesc.Height = m_displayHeight; + texDesc.MipLevels = 1; + texDesc.MiscFlags = 0; + texDesc.SampleDesc.Count = 1; + texDesc.SampleDesc.Quality = 0; + texDesc.Usage = D3D11_USAGE_DEFAULT; + + ID3D11Texture2D *texture = NULL; + hr = m_d3dDevice->CreateTexture2D(&texDesc, 0, &texture); + + if (SUCCEEDED(hr)) + { + dxSafeRelease(m_displayBuffer); + m_d3dDeviceContext->CopyResource(texture, backbufferRes); +#if !PX_XBOXONE + hr = m_d3dx->saveTextureToMemory(m_d3dDeviceContext, texture, D3DX11_IFF_BMP, &m_displayBuffer, 0); +#endif + } + + dxSafeRelease(texture); + dxSafeRelease(backbufferRes); + + if(SUCCEEDED(hr)) + { + getWindowSize(width, height); + sizeInBytes = (physx::PxU32)m_displayBuffer->GetBufferSize(); + screenshotData = m_displayBuffer->GetBufferPointer(); + bSuccess = true; + } + return bSuccess; +} + + +#endif // #if defined(RENDERER_ENABLE_DIRECT3D11) diff --git a/PhysX_3.4/Samples/SampleFramework/renderer/src/d3d11/D3D11Renderer.h b/PhysX_3.4/Samples/SampleFramework/renderer/src/d3d11/D3D11Renderer.h new file mode 100644 index 00000000..f716cfa6 --- /dev/null +++ b/PhysX_3.4/Samples/SampleFramework/renderer/src/d3d11/D3D11Renderer.h @@ -0,0 +1,344 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved. + +#ifndef D3D11_RENDERER_H +#define D3D11_RENDERER_H + +#include <RendererConfig.h> + +#if defined(RENDERER_ENABLE_DIRECT3D11) + +#include <Renderer.h> +#include <vector> +#include <tuple> + +#if defined(RENDERER_DEBUG) +//#define D3D_DEBUG_INFO 1 +#endif + +#define RENDERER_ENABLE_VFACE_SCALE 1 +#define RENDERER_ENABLE_SHADOWS 0 + +#if RENDERER_ENABLE_SINGLE_PASS_LIGHTING +#define RENDERER_MAX_LIGHTS 4 +#else +#define RENDERER_MAX_LIGHTS 1 +#endif + +#define INITGUID +#pragma warning(push) +// Disable macro redefinition warnings +#pragma warning(disable: 4005) +#include <d3d11.h> +#pragma warning(pop) +#undef INITGUID + +namespace SampleRenderer +{ +class RendererDesc; +class RendererColor; + +void convertToD3D11(PxVec3& dxcolor, const RendererColor& color); +void convertToD3D11(PxVec4& dxcolor, const RendererColor& color); +void convertToD3D11(PxMat44& dxmat, const RendererProjection& mat); +void convertToD3D11(PxMat44& dxmat, const physx::PxMat44 &mat); + +class D3D11RendererVariableManager; +class D3D11RendererResourceManager; +class D3D11RendererResource; +class D3D11RendererMaterial; +class D3D11RendererMesh; +class D3D11RendererVertexBuffer; +class D3D11RendererIndexBuffer; +class D3D11RendererTexture2D; + +class D3DX11; + +class D3D11Renderer : public Renderer +{ + friend class D3D11RendererResource; + friend class D3D11RendererMesh; +public: + class D3D11ShaderEnvironment + { + friend class D3D11Renderer; + friend class D3D11RendererSpotLight; + friend class D3D11RendererDirectionalLight; + + public: + D3D11ShaderEnvironment(); + + void bindFrame() const; + void bindLight(PxU32 lightIndex = 0) const; + void bindModel() const; + void bindBones() const; + void bindFogState() const; + void bindAmbientState() const; + void bindVFaceScale() const; + + void reset(); + + protected: + PxMat44 modelMatrix; + PxMat44 modelViewMatrix; + PxMat44 modelViewProjMatrix; + + PxMat44 viewMatrix; + PxMat44 projMatrix; + PxMat44 invViewProjMatrix; + PxMat44 lightShadowMatrix; + + PxMat44 boneMatrices[RENDERER_MAX_BONES]; + PxU32 numBones; + + PxVec4 fogColorAndDistance; + + PxVec3 eyePosition; + PxVec3 eyeDirection; + + PxVec3 ambientColor; + + PxVec3 lightColor[RENDERER_MAX_LIGHTS]; + PxVec3 lightDirection[RENDERER_MAX_LIGHTS]; + PxVec3 lightPosition[RENDERER_MAX_LIGHTS]; + float lightIntensity[RENDERER_MAX_LIGHTS]; + float lightInnerRadius[RENDERER_MAX_LIGHTS]; + float lightOuterRadius[RENDERER_MAX_LIGHTS]; + float lightInnerCone[RENDERER_MAX_LIGHTS]; + float lightOuterCone[RENDERER_MAX_LIGHTS]; + int lightType[RENDERER_MAX_LIGHTS]; + mutable int numLights; + + D3D11RendererTexture2D* lightShadowMap; + + float vfs; + + D3D11RendererVariableManager* constantManager; + }; + +public: + D3D11Renderer(const RendererDesc& desc, const char* assetDir); + virtual ~D3D11Renderer(void); + + ID3D11Device* getD3DDevice(void) { return m_d3dDevice; } + ID3D11DeviceContext* getD3DDeviceContext(void) { return m_d3dDeviceContext; } + D3DX11* getD3DX11(void) { return m_d3dx; } + D3D11ShaderEnvironment& getShaderEnvironment(void) { return m_environment; } + const D3D11ShaderEnvironment& getShaderEnvironment(void) const { return m_environment; } + D3D11RendererResourceManager* getResourceManager(void) { return m_resourceManager; } + D3D11RendererVariableManager* getVariableManager(void) { return m_constantManager; } + + bool multisamplingEnabled(void) const; + bool tessellationEnabled(void) const; + bool isTessellationSupported(void) const; + +private: + bool checkResize(bool resetDevice); + +public: + void onDeviceLost(void); + void onDeviceReset(void); + +public: + // clears the offscreen buffers. + virtual void clearBuffers(void); + + // presents the current color buffer to the screen. + // returns true on device reset and if buffers need to be rewritten. + virtual bool swapBuffers(void); + + // get the device pointer (void * abstraction) + virtual void* getDevice() + { + return static_cast<void*>(getD3DDevice()); + } + + // get the window size + void getWindowSize(PxU32& width, PxU32& height) const; + + // gets a handle to the current frame's data, in bitmap format + // note: subsequent calls will invalidate any previously returned data + // return true on successful screenshot capture + bool captureScreen(PxU32 &width, PxU32& height, PxU32& sizeInBytes, const void*& screenshotData); + + D3D_FEATURE_LEVEL getFeatureLevel() const { return (D3D_FEATURE_LEVEL)m_d3dDeviceFeatureLevel; } + + virtual RendererVertexBuffer* createVertexBuffer(const RendererVertexBufferDesc& desc); + virtual RendererIndexBuffer* createIndexBuffer(const RendererIndexBufferDesc& desc); + virtual RendererInstanceBuffer* createInstanceBuffer(const RendererInstanceBufferDesc& desc); + virtual RendererTexture2D* createTexture2D(const RendererTexture2DDesc& desc); + virtual RendererTexture3D* createTexture3D(const RendererTexture3DDesc& desc); + virtual RendererTarget* createTarget(const RendererTargetDesc& desc); + virtual RendererMaterial* createMaterial(const RendererMaterialDesc& desc); + virtual RendererMesh* createMesh(const RendererMeshDesc& desc); + virtual RendererLight* createLight(const RendererLightDesc& desc); + + virtual void setVsync(bool on); + + virtual bool initTexter(); + virtual void closeTexter(); + + void bind(RendererMaterialInstance* materialInstance); + + virtual bool isSpriteRenderingSupported(void) const; + +private: + virtual bool beginRender(void); + virtual void endRender(void); + virtual void bindViewProj(const physx::PxMat44& eye, const RendererProjection& proj); + virtual void bindFogState(const RendererColor& fogColor, float fogDistance); + virtual void bindAmbientState(const RendererColor& ambientColor); + virtual void bindDeferredState(void); + virtual void bindMeshContext(const RendererMeshContext& context); + virtual void beginMultiPass(void); + virtual void endMultiPass(void); + virtual void beginTransparentMultiPass(void); + virtual void endTransparentMultiPass(void); + virtual void renderDeferredLight(const RendererLight& light); + virtual PxU32 convertColor(const RendererColor& color) const; + + virtual bool isOk(void) const; + + virtual void setupTextRenderStates(); + virtual void resetTextRenderStates(); + virtual void renderTextBuffer(const void* vertices, PxU32 nbVerts, const PxU16* indices, PxU32 nbIndices, RendererMaterial* material); + virtual void renderLines2D(const void* vertices, PxU32 nbVerts); + virtual void setupScreenquadRenderStates(); + virtual void resetScreenquadRenderStates(); + +public: + enum BlendState + { + BLEND_DEFAULT = 0, + BLEND_MULTIPASS, + BLEND_TRANSPARENT, + BLEND_TRANSPARENT_ALPHA_COVERAGE, + NUM_BLEND_STATES + }; + void setBlendState(BlendState state = BLEND_DEFAULT); + + void setRasterizerState(D3D11_FILL_MODE = D3D11_FILL_SOLID, D3D11_CULL_MODE = D3D11_CULL_BACK, PxI32 depthBias = 0); + + enum DepthStencilState + { + DEPTHSTENCIL_DEFAULT = 0, + DEPTHSTENCIL_DISABLED, + DEPTHSTENCIL_TRANSPARENT, + NUM_DEPTH_STENCIL_STATES + }; + void setDepthStencilState(DepthStencilState state); + + enum StateType + { + STATE_BLEND, + STATE_DEPTHSTENCIL, + STATE_RASTERIZER, + NUM_STATE_TYPES + }; + void pushState(StateType stateType); + void popState(StateType stateType); + + void setTessellationState(); + +private: + void addResource(D3D11RendererResource& resource); + void removeResource(D3D11RendererResource& resource); + void notifyResourcesLostDevice(void); + void notifyResourcesResetDevice(void); + +private: + PxU32 m_displayWidth; + PxU32 m_displayHeight; + ID3DBlob* m_displayBuffer; + bool m_vsync; + PxI32 m_multipassDepthBias; + + IDXGIFactory* m_d3d; + IDXGISwapChain* m_d3dSwapChain; + + ID3D11BlendState* m_d3dBlendStates[NUM_BLEND_STATES]; + ID3D11Device* m_d3dDevice; + ID3D11DeviceContext* m_d3dDeviceContext; + PxU32 m_d3dDeviceFeatureLevel; + ID3D11Texture2D* m_d3dDepthStencilBuffer; + ID3D11DepthStencilView* m_d3dDepthStencilView; + ID3D11DepthStencilState* m_d3dDepthStencilStates[NUM_DEPTH_STENCIL_STATES]; + ID3D11Texture2D* m_d3dRenderTargetBuffer; + ID3D11RenderTargetView* m_d3dRenderTargetView; + + std::tr1::tuple<D3D11_FILL_MODE, D3D11_CULL_MODE, int> m_boundRasterizerStateKey; + + RendererMaterialInstance* m_boundMaterial; + + std::vector<D3D11RendererMesh*> m_textMeshes; + std::vector<D3D11RendererVertexBuffer*> m_textVertices; + std::vector<D3D11RendererIndexBuffer*> m_textIndices; + PxU32 m_currentTextMesh; + D3D11RendererMesh* m_linesMesh; + D3D11RendererVertexBuffer* m_linesVertices; + + DXGI_SWAP_CHAIN_DESC m_swapChainDesc; + physx::PxMat44 m_viewMatrix; + + // non-managed resources... + std::vector<D3D11RendererResource*> m_resources; + + D3DX11* m_d3dx; + D3D11ShaderEnvironment m_environment; + D3D11RendererVariableManager* m_constantManager; + D3D11RendererResourceManager* m_resourceManager; +}; + +class D3D11RendererResource +{ + friend class D3D11Renderer; +public: + D3D11RendererResource(void) + { + m_d3dRenderer = 0; + } + + virtual ~D3D11RendererResource(void) + { + if (m_d3dRenderer) + { + m_d3dRenderer->removeResource(*this); + } + } + +public: + virtual void onDeviceLost(void) = 0; + virtual void onDeviceReset(void) = 0; + +private: + D3D11Renderer* m_d3dRenderer; +}; + +} // namespace SampleRenderer + +#endif // #if defined(RENDERER_ENABLE_DIRECT3D11) +#endif diff --git a/PhysX_3.4/Samples/SampleFramework/renderer/src/d3d11/D3D11RendererDirectionalLight.cpp b/PhysX_3.4/Samples/SampleFramework/renderer/src/d3d11/D3D11RendererDirectionalLight.cpp new file mode 100644 index 00000000..16e25b1b --- /dev/null +++ b/PhysX_3.4/Samples/SampleFramework/renderer/src/d3d11/D3D11RendererDirectionalLight.cpp @@ -0,0 +1,61 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved. + +#include <RendererConfig.h> + +#if defined(RENDERER_ENABLE_DIRECT3D11) + +#include "D3D11RendererDirectionalLight.h" + +using namespace SampleRenderer; + +D3D11RendererDirectionalLight::D3D11RendererDirectionalLight(D3D11Renderer& renderer, const RendererDirectionalLightDesc& desc) : + RendererDirectionalLight(desc), + m_renderer(renderer) +{ + +} + +D3D11RendererDirectionalLight::~D3D11RendererDirectionalLight(void) +{ + +} + +void D3D11RendererDirectionalLight::bind(PxU32 lightIndex) const +{ + D3D11Renderer::D3D11ShaderEnvironment& shaderEnv = m_renderer.getShaderEnvironment(); + if (lightIndex < RENDERER_MAX_LIGHTS) + { + convertToD3D11(shaderEnv.lightColor[lightIndex], m_color); + shaderEnv.lightDirection[lightIndex] = m_direction; + shaderEnv.lightIntensity[lightIndex] = m_intensity; + shaderEnv.lightType[lightIndex] = RendererMaterial::PASS_DIRECTIONAL_LIGHT; + shaderEnv.bindLight(lightIndex); + } +} + +#endif // #if defined(RENDERER_ENABLE_DIRECT3D11) diff --git a/PhysX_3.4/Samples/SampleFramework/renderer/src/d3d11/D3D11RendererDirectionalLight.h b/PhysX_3.4/Samples/SampleFramework/renderer/src/d3d11/D3D11RendererDirectionalLight.h new file mode 100644 index 00000000..7c98e693 --- /dev/null +++ b/PhysX_3.4/Samples/SampleFramework/renderer/src/d3d11/D3D11RendererDirectionalLight.h @@ -0,0 +1,58 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved. + +#ifndef D3D11_RENDERER_DIRECTIONAL_LIGHT_H +#define D3D11_RENDERER_DIRECTIONAL_LIGHT_H + +#include <RendererConfig.h> + +#if defined(RENDERER_ENABLE_DIRECT3D11) + +#include <RendererDirectionalLight.h> + +#include "D3D11Renderer.h" + +namespace SampleRenderer +{ + +class D3D11RendererDirectionalLight : public RendererDirectionalLight +{ +public: + D3D11RendererDirectionalLight(D3D11Renderer& renderer, const RendererDirectionalLightDesc& desc); + virtual ~D3D11RendererDirectionalLight(void); + + virtual void bind(void) const { bind(0); } + virtual void bind(PxU32) const; + +private: + D3D11Renderer& m_renderer; +}; + +} // namespace SampleRenderer + +#endif // #if defined(RENDERER_ENABLE_DIRECT3D11) +#endif diff --git a/PhysX_3.4/Samples/SampleFramework/renderer/src/d3d11/D3D11RendererIndexBuffer.cpp b/PhysX_3.4/Samples/SampleFramework/renderer/src/d3d11/D3D11RendererIndexBuffer.cpp new file mode 100644 index 00000000..5265c28e --- /dev/null +++ b/PhysX_3.4/Samples/SampleFramework/renderer/src/d3d11/D3D11RendererIndexBuffer.cpp @@ -0,0 +1,193 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved. + +#include <RendererConfig.h> + +#if defined(RENDERER_ENABLE_DIRECT3D11) + +#include "D3D11RendererIndexBuffer.h" +#include <RendererIndexBufferDesc.h> + +#if PX_WINDOWS +#include <task/PxTask.h> +#endif + +using namespace SampleRenderer; + +static DXGI_FORMAT getD3D11Format(RendererIndexBuffer::Format format) +{ + DXGI_FORMAT dxgiFormat = DXGI_FORMAT_UNKNOWN; + switch (format) + { + case RendererIndexBuffer::FORMAT_UINT16: + dxgiFormat = DXGI_FORMAT_R16_UINT; + break; + case RendererIndexBuffer::FORMAT_UINT32: + dxgiFormat = DXGI_FORMAT_R32_UINT; + break; + } + RENDERER_ASSERT(dxgiFormat != DXGI_FORMAT_UNKNOWN, "Unable to convert to DXGI_FORMAT."); + return dxgiFormat; +} + +D3D11RendererIndexBuffer::D3D11RendererIndexBuffer(ID3D11Device& d3dDevice, ID3D11DeviceContext& d3dDeviceContext, const RendererIndexBufferDesc& desc, bool bUseMapForLocking) : + RendererIndexBuffer(desc), + m_d3dDevice(d3dDevice), + m_d3dDeviceContext(d3dDeviceContext), + m_d3dIndexBuffer(NULL), + m_bUseMapForLocking(bUseMapForLocking && (!desc.registerInCUDA)), + m_buffer(NULL) +{ + memset(&m_d3dBufferDesc, 0, sizeof(D3D11_BUFFER_DESC)); + m_d3dBufferDesc.BindFlags = D3D11_BIND_INDEX_BUFFER; + m_d3dBufferDesc.ByteWidth = (UINT)(getFormatByteSize(desc.format) * desc.maxIndices); + m_d3dBufferFormat = getD3D11Format(desc.format); + + if (m_bUseMapForLocking) + { + m_d3dBufferDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE; + m_d3dBufferDesc.Usage = D3D11_USAGE_DYNAMIC; + } + else + { + m_d3dBufferDesc.CPUAccessFlags = 0; + m_d3dBufferDesc.Usage = D3D11_USAGE_DEFAULT; + m_buffer = new PxU8[m_d3dBufferDesc.ByteWidth]; + memset(m_buffer, 0, sizeof(PxU8)*m_d3dBufferDesc.ByteWidth); + } + + onDeviceReset(); + + if (m_d3dIndexBuffer) + { + m_maxIndices = desc.maxIndices; + } + +} + +D3D11RendererIndexBuffer::~D3D11RendererIndexBuffer(void) +{ + if (m_d3dIndexBuffer) + { +#if PX_WINDOWS && PX_SUPPORT_GPU_PHYSX + if (m_interopContext && m_registeredInCUDA) + { + m_registeredInCUDA = !m_interopContext->unregisterResourceInCuda(m_InteropHandle); + } +#endif + m_d3dIndexBuffer->Release(); + m_d3dIndexBuffer = NULL; + } + + delete [] m_buffer; +} + + +void D3D11RendererIndexBuffer::onDeviceLost(void) +{ + m_registeredInCUDA = false; + + if (m_d3dIndexBuffer) + { +#if PX_WINDOWS && PX_SUPPORT_GPU_PHYSX + if (m_interopContext && m_registeredInCUDA) + { + m_registeredInCUDA = !m_interopContext->unregisterResourceInCuda(m_InteropHandle); + } +#endif + m_d3dIndexBuffer->Release(); + m_d3dIndexBuffer = 0; + } +} + +void D3D11RendererIndexBuffer::onDeviceReset(void) +{ + if (!m_d3dIndexBuffer) + { + m_d3dDevice.CreateBuffer(&m_d3dBufferDesc, NULL, &m_d3dIndexBuffer); + RENDERER_ASSERT(m_d3dIndexBuffer, "Failed to create DIRECT3D11 Index Buffer."); +#if PX_WINDOWS && PX_SUPPORT_GPU_PHYSX + if (m_interopContext && m_d3dIndexBuffer && m_mustBeRegisteredInCUDA) + { + m_registeredInCUDA = m_interopContext->registerResourceInCudaD3D(m_InteropHandle, m_d3dIndexBuffer); + } +#endif + } +} + +void* D3D11RendererIndexBuffer::lock(void) +{ + // For now NO_OVERWRITE is the only mapping that functions properly + return internalLock(getHint() == HINT_STATIC ? /* D3D11_MAP_WRITE_DISCARD */ D3D11_MAP_WRITE_NO_OVERWRITE : D3D11_MAP_WRITE_NO_OVERWRITE); +} + +void* D3D11RendererIndexBuffer::internalLock(D3D11_MAP MapType) +{ + void* buffer = 0; + if (m_d3dIndexBuffer) + { + if (m_bUseMapForLocking) + { + D3D11_MAPPED_SUBRESOURCE mappedRead; + m_d3dDeviceContext.Map(m_d3dIndexBuffer, 0, MapType, NULL, &mappedRead); + RENDERER_ASSERT(mappedRead.pData, "Failed to lock DIRECT3D11 Index Buffer."); + buffer = mappedRead.pData; + } + else + { + buffer = m_buffer; + } + } + return buffer; +} + +void D3D11RendererIndexBuffer::unlock(void) +{ + if (m_d3dIndexBuffer) + { + if (m_bUseMapForLocking) + { + m_d3dDeviceContext.Unmap(m_d3dIndexBuffer, 0); + } + else + { + m_d3dDeviceContext.UpdateSubresource(m_d3dIndexBuffer, 0, NULL, m_buffer, m_d3dBufferDesc.ByteWidth, 0); + } + } +} + +void D3D11RendererIndexBuffer::bind(void) const +{ + m_d3dDeviceContext.IASetIndexBuffer(m_d3dIndexBuffer, m_d3dBufferFormat, 0); +} + +void D3D11RendererIndexBuffer::unbind(void) const +{ + m_d3dDeviceContext.IASetIndexBuffer(NULL, DXGI_FORMAT(), 0); +} + +#endif // #if defined(RENDERER_ENABLE_DIRECT3D11) diff --git a/PhysX_3.4/Samples/SampleFramework/renderer/src/d3d11/D3D11RendererIndexBuffer.h b/PhysX_3.4/Samples/SampleFramework/renderer/src/d3d11/D3D11RendererIndexBuffer.h new file mode 100644 index 00000000..52d8aaf4 --- /dev/null +++ b/PhysX_3.4/Samples/SampleFramework/renderer/src/d3d11/D3D11RendererIndexBuffer.h @@ -0,0 +1,75 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved. + +#ifndef D3D11_RENDERER_INDEXBUFFER_H +#define D3D11_RENDERER_INDEXBUFFER_H + +#include <RendererConfig.h> + +#if defined(RENDERER_ENABLE_DIRECT3D11) + +#include <RendererIndexBuffer.h> +#include "D3D11Renderer.h" + +namespace SampleRenderer +{ + +class D3D11RendererIndexBuffer : public RendererIndexBuffer, public D3D11RendererResource +{ + friend class D3D11Renderer; +public: + D3D11RendererIndexBuffer(ID3D11Device& d3dDevice, ID3D11DeviceContext& d3dDeviceContext, const RendererIndexBufferDesc& desc, bool bUseMapForLocking = TRUE); + virtual ~D3D11RendererIndexBuffer(void); + +public: + virtual void* lock(void); + virtual void unlock(void); + +private: + virtual void bind(void) const; + virtual void unbind(void) const; + + virtual void onDeviceLost(void); + virtual void onDeviceReset(void); + + void* internalLock(D3D11_MAP MapType); + +private: + ID3D11Device& m_d3dDevice; + ID3D11DeviceContext& m_d3dDeviceContext; + ID3D11Buffer* m_d3dIndexBuffer; + D3D11_BUFFER_DESC m_d3dBufferDesc; + DXGI_FORMAT m_d3dBufferFormat; + + bool m_bUseMapForLocking; + PxU8* m_buffer; +}; + +} // namespace SampleRenderer + +#endif // #if defined(RENDERER_ENABLE_DIRECT3D11) +#endif diff --git a/PhysX_3.4/Samples/SampleFramework/renderer/src/d3d11/D3D11RendererInstanceBuffer.cpp b/PhysX_3.4/Samples/SampleFramework/renderer/src/d3d11/D3D11RendererInstanceBuffer.cpp new file mode 100644 index 00000000..8ee0191e --- /dev/null +++ b/PhysX_3.4/Samples/SampleFramework/renderer/src/d3d11/D3D11RendererInstanceBuffer.cpp @@ -0,0 +1,278 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved. + +#include <RendererConfig.h> +#if defined(RENDERER_ENABLE_DIRECT3D11) + +#include "D3D11RendererInstanceBuffer.h" +#include <RendererInstanceBufferDesc.h> + +#if PX_WINDOWS +#include <task/PxTask.h> +#endif + +using namespace SampleRenderer; + +static D3D11_INPUT_ELEMENT_DESC buildVertexElement(LPCSTR name, UINT index, DXGI_FORMAT format, UINT inputSlot, UINT alignedByOffset, D3D11_INPUT_CLASSIFICATION inputSlotClass, UINT instanceDataStepRate) +{ + D3D11_INPUT_ELEMENT_DESC element; + element.SemanticName = name; + element.SemanticIndex = index; + element.Format = format; + element.InputSlot = inputSlot; + element.AlignedByteOffset = alignedByOffset; + element.InputSlotClass = inputSlotClass; + element.InstanceDataStepRate = instanceDataStepRate; + return element; +} + +static DXGI_FORMAT getD3DFormat(RendererInstanceBuffer::Format format) +{ + DXGI_FORMAT d3dFormat = DXGI_FORMAT_UNKNOWN; + switch (format) + { + case RendererInstanceBuffer::FORMAT_FLOAT1: + d3dFormat = DXGI_FORMAT_R32_FLOAT; + break; + case RendererInstanceBuffer::FORMAT_FLOAT2: + d3dFormat = DXGI_FORMAT_R32G32_FLOAT; + break; + case RendererInstanceBuffer::FORMAT_FLOAT3: + d3dFormat = DXGI_FORMAT_R32G32B32_FLOAT; + break; + case RendererInstanceBuffer::FORMAT_FLOAT4: + d3dFormat = DXGI_FORMAT_R32G32B32A32_FLOAT; + break; + } + RENDERER_ASSERT(d3dFormat != DXGI_FORMAT_UNKNOWN, "Invalid DIRECT3D11 vertex type."); + return d3dFormat; +} + +static void getD3DUsage(RendererInstanceBuffer::Semantic semantic, LPCSTR& usageName, PxU8& usageIndex) +{ + if (semantic >= RendererInstanceBuffer::SEMANTIC_POSITION && semantic < RendererInstanceBuffer::NUM_SEMANTICS) + { + usageName = "TEXCOORD"; + switch (semantic) + { + case RendererInstanceBuffer::SEMANTIC_POSITION: + usageIndex = RENDERER_INSTANCE_POSITION_CHANNEL; + break; + case RendererInstanceBuffer::SEMANTIC_NORMALX: + usageIndex = RENDERER_INSTANCE_NORMALX_CHANNEL; + break; + case RendererInstanceBuffer::SEMANTIC_NORMALY: + usageIndex = RENDERER_INSTANCE_NORMALY_CHANNEL; + break; + case RendererInstanceBuffer::SEMANTIC_NORMALZ: + usageIndex = RENDERER_INSTANCE_NORMALZ_CHANNEL; + break; + case RendererInstanceBuffer::SEMANTIC_VELOCITY_LIFE: + usageIndex = RENDERER_INSTANCE_VEL_LIFE_CHANNEL; + break; + case RendererInstanceBuffer::SEMANTIC_DENSITY: + usageIndex = RENDERER_INSTANCE_DENSITY_CHANNEL; + break; + case RendererInstanceBuffer::SEMANTIC_UV_OFFSET: + usageIndex = RENDERER_INSTANCE_UV_CHANNEL; + break; + case RendererInstanceBuffer::SEMANTIC_LOCAL_OFFSET: + usageIndex = RENDERER_INSTANCE_LOCAL_CHANNEL; + break; + } + } + else + { + RENDERER_ASSERT(false, "Invalid Direct3D11 instance usage."); + } +} + +D3D11RendererInstanceBuffer::D3D11RendererInstanceBuffer(ID3D11Device& d3dDevice, ID3D11DeviceContext& d3dDeviceContext, const RendererInstanceBufferDesc& desc, bool bUseMapForLocking) : + RendererInstanceBuffer(desc) + , m_d3dDevice(d3dDevice) + , m_d3dDeviceContext(d3dDeviceContext) + , m_d3dInstanceBuffer(NULL) + , m_bUseMapForLocking(bUseMapForLocking) + , m_buffer(NULL) +{ + memset(&m_d3dBufferDesc, 0, sizeof(D3D11_BUFFER_DESC)); + m_d3dBufferDesc.BindFlags = D3D11_BIND_VERTEX_BUFFER; + m_d3dBufferDesc.ByteWidth = (UINT)(desc.maxInstances * m_stride); + + if (m_bUseMapForLocking) + { + m_d3dBufferDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE; + m_d3dBufferDesc.Usage = D3D11_USAGE_DYNAMIC; + } + else + { + m_d3dBufferDesc.CPUAccessFlags = 0; + m_d3dBufferDesc.Usage = D3D11_USAGE_DEFAULT; + m_buffer = new PxU8[m_d3dBufferDesc.ByteWidth]; + memset(m_buffer, 0, sizeof(PxU8)*m_d3dBufferDesc.ByteWidth); + } + + onDeviceReset(); + + if (m_d3dInstanceBuffer) + { + m_maxInstances = desc.maxInstances; + } +} + +D3D11RendererInstanceBuffer::~D3D11RendererInstanceBuffer(void) +{ + if (m_d3dInstanceBuffer) + { +#if PX_WINDOWS && PX_SUPPORT_GPU_PHYSX + if (m_interopContext && m_registeredInCUDA) + { + m_registeredInCUDA = !m_interopContext->unregisterResourceInCuda(m_InteropHandle); + } +#endif + m_d3dInstanceBuffer->Release(); + m_d3dInstanceBuffer = NULL; + } + + delete [] m_buffer; +} + +void D3D11RendererInstanceBuffer::addVertexElements(PxU32 streamIndex, std::vector<D3D11_INPUT_ELEMENT_DESC> &vertexElements) const +{ + for (PxU32 i = 0; i < NUM_SEMANTICS; i++) + { + Semantic semantic = (Semantic)i; + const SemanticDesc& sm = m_semanticDescs[semantic]; + if (sm.format < NUM_FORMATS) + { + PxU8 d3dUsageIndex = 0; + LPCSTR d3dUsageName = ""; + getD3DUsage(semantic, d3dUsageName, d3dUsageIndex); + vertexElements.push_back(buildVertexElement(d3dUsageName, + d3dUsageIndex, + getD3DFormat(sm.format), + streamIndex, + (UINT)sm.offset, + D3D11_INPUT_PER_INSTANCE_DATA, + 1)); + } + } +} + +void* D3D11RendererInstanceBuffer::lock(void) +{ + return internalLock(getHint() == HINT_STATIC ? D3D11_MAP_WRITE_DISCARD : D3D11_MAP_WRITE_NO_OVERWRITE); +} + +void* D3D11RendererInstanceBuffer::internalLock(D3D11_MAP MapType) +{ + void* lockedBuffer = 0; + if (m_d3dInstanceBuffer) + { + if (m_bUseMapForLocking) + { + D3D11_MAPPED_SUBRESOURCE mappedRead; + m_d3dDeviceContext.Map(m_d3dInstanceBuffer, 0, MapType, NULL, &mappedRead); + RENDERER_ASSERT(mappedRead.pData, "Failed to lock DIRECT3D11 Vertex Buffer."); + lockedBuffer = mappedRead.pData; + } + else + { + lockedBuffer = m_buffer; + } + } + return lockedBuffer; +} + +void D3D11RendererInstanceBuffer::unlock(void) +{ + if (m_d3dInstanceBuffer) + { + if (m_bUseMapForLocking) + { + m_d3dDeviceContext.Unmap(m_d3dInstanceBuffer, 0); + } + else + { + m_d3dDeviceContext.UpdateSubresource(m_d3dInstanceBuffer, 0, NULL, m_buffer, m_d3dBufferDesc.ByteWidth, 0); + } + } +} + +void D3D11RendererInstanceBuffer::bind(PxU32 streamID, PxU32 firstInstance) const +{ + if (m_d3dInstanceBuffer) + { + ID3D11Buffer* pBuffers[1] = { m_d3dInstanceBuffer }; + UINT strides[1] = { m_stride }; + UINT offsets[1] = { firstInstance* m_stride }; + m_d3dDeviceContext.IASetVertexBuffers(streamID, 1, pBuffers, strides, offsets); + } +} + +void D3D11RendererInstanceBuffer::unbind(PxU32 streamID) const +{ + ID3D11Buffer* pBuffers[1] = { NULL }; + UINT strides[1] = { 0 }; + UINT offsets[1] = { 0 }; + m_d3dDeviceContext.IASetVertexBuffers(streamID, 1, pBuffers, strides, offsets); +} + +void D3D11RendererInstanceBuffer::onDeviceLost(void) +{ +#if PX_WINDOWS && PX_SUPPORT_GPU_PHYSX + if (m_interopContext && m_registeredInCUDA) + { + PX_ASSERT(m_d3dInstanceBuffer); + m_interopContext->unregisterResourceInCuda(m_InteropHandle); + } + + m_registeredInCUDA = false; +#endif + if (m_d3dInstanceBuffer) + { + m_d3dInstanceBuffer->Release(); + m_d3dInstanceBuffer = 0; + } +} + +void D3D11RendererInstanceBuffer::onDeviceReset(void) +{ + if (!m_d3dInstanceBuffer) + { + m_d3dDevice.CreateBuffer(&m_d3dBufferDesc, NULL, &m_d3dInstanceBuffer); + RENDERER_ASSERT(m_d3dInstanceBuffer, "Failed to create DIRECT3D11 Vertex Buffer."); +#if PX_WINDOWS && PX_SUPPORT_GPU_PHYSX + if (m_interopContext && m_d3dInstanceBuffer && m_mustBeRegisteredInCUDA) + { + m_registeredInCUDA = m_interopContext->registerResourceInCudaD3D(m_InteropHandle, m_d3dInstanceBuffer); + } +#endif + } +} + +#endif // #if defined(RENDERER_ENABLE_DIRECT3D11) diff --git a/PhysX_3.4/Samples/SampleFramework/renderer/src/d3d11/D3D11RendererInstanceBuffer.h b/PhysX_3.4/Samples/SampleFramework/renderer/src/d3d11/D3D11RendererInstanceBuffer.h new file mode 100644 index 00000000..7180bfb5 --- /dev/null +++ b/PhysX_3.4/Samples/SampleFramework/renderer/src/d3d11/D3D11RendererInstanceBuffer.h @@ -0,0 +1,74 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved. +#ifndef D3D11_RENDERER_INSTANCEBUFFER_H +#define D3D11_RENDERER_INSTANCEBUFFER_H + +#include <RendererConfig.h> + +#if defined(RENDERER_ENABLE_DIRECT3D11) + +#include <RendererInstanceBuffer.h> +#include "D3D11Renderer.h" + +namespace SampleRenderer +{ + +class D3D11RendererInstanceBuffer : public RendererInstanceBuffer, public D3D11RendererResource +{ +public: + D3D11RendererInstanceBuffer(ID3D11Device& d3dDevice, ID3D11DeviceContext& d3dDeviceContext, const RendererInstanceBufferDesc& desc, bool bUseMapForLocking = FALSE); + virtual ~D3D11RendererInstanceBuffer(void); + + void addVertexElements(PxU32 streamIndex, std::vector<D3D11_INPUT_ELEMENT_DESC> &vertexElements) const; + +protected: + virtual void* lock(void); + virtual void unlock(void); + + virtual void bind(PxU32 streamID, PxU32 firstInstance) const; + virtual void unbind(PxU32 streamID) const; + +private: + virtual void onDeviceLost(void); + virtual void onDeviceReset(void); + + void *internalLock(D3D11_MAP MapType); + +private: + ID3D11Device& m_d3dDevice; + ID3D11DeviceContext& m_d3dDeviceContext; + ID3D11Buffer* m_d3dInstanceBuffer; + D3D11_BUFFER_DESC m_d3dBufferDesc; + + bool m_bUseMapForLocking; + PxU8* m_buffer; +}; + +} // namespace SampleRenderer + +#endif // #if defined(RENDERER_ENABLE_DIRECT3D11) +#endif diff --git a/PhysX_3.4/Samples/SampleFramework/renderer/src/d3d11/D3D11RendererMaterial.cpp b/PhysX_3.4/Samples/SampleFramework/renderer/src/d3d11/D3D11RendererMaterial.cpp new file mode 100644 index 00000000..70ccab14 --- /dev/null +++ b/PhysX_3.4/Samples/SampleFramework/renderer/src/d3d11/D3D11RendererMaterial.cpp @@ -0,0 +1,729 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved. + +#include <RendererConfig.h> + +#if defined(RENDERER_ENABLE_DIRECT3D11) + +#include "D3D11RendererMaterial.h" + +#include <RendererMaterialDesc.h> + +#include "D3D11RendererVariableManager.h" +#include "D3D11RendererTexture2D.h" +#include "D3D11RendererMemoryMacros.h" +#include "D3D11RendererResourceManager.h" +#include "D3D11RendererUtils.h" +#include "D3D11RendererTraits.h" +#include "RendererMemoryMacros.h" + +#include <stdio.h> +#include <sstream> + +#include <PsUtilities.h> + +#if !defined PX_USE_DX11_PRECOMPILED_SHADERS +#define RENDERER_ENABLE_LAYOUT_PRECACHE 1 +#endif +static D3D_FEATURE_LEVEL gFeatureLevel = D3D_FEATURE_LEVEL_9_1; + +#if RENDERER_ENABLE_LAYOUT_PRECACHE + +static bool gBonePrecached = false; +static bool gStaticPrecached = false; + +/* Cache some sensible default input layouts */ +static D3D11_INPUT_ELEMENT_DESC inputDescStaticDiffuse[4] = +{{"POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0}, + {"NORMAL", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0}, + {"TANGENT", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0}, + {"TEXCOORD", 0, DXGI_FORMAT_R32G32_FLOAT, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0}}; + +static D3D11_INPUT_ELEMENT_DESC inputDescStaticDiffuseInstanced[10] = +{{"POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0}, + {"NORMAL", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0}, + {"TANGENT", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0}, + {"TEXCOORD", 0, DXGI_FORMAT_R32G32_FLOAT, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0}, + {"TEXCOORD", 8, DXGI_FORMAT_R32G32B32_FLOAT, 1, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 1}, + {"TEXCOORD", 9, DXGI_FORMAT_R32G32B32_FLOAT, 1, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_INSTANCE_DATA, 1}, + {"TEXCOORD", 10, DXGI_FORMAT_R32G32B32_FLOAT, 1, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_INSTANCE_DATA, 1}, + {"TEXCOORD", 11, DXGI_FORMAT_R32G32B32_FLOAT, 1, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_INSTANCE_DATA, 1}, + {"TEXCOORD", 12, DXGI_FORMAT_R32G32B32A32_FLOAT, 1, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_INSTANCE_DATA, 1}, + {"TEXCOORD", 13, DXGI_FORMAT_R32G32_FLOAT, 1, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_INSTANCE_DATA, 1}}; + +static D3D11_INPUT_ELEMENT_DESC inputDescBoneDiffuse0[3] = +{{"POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0}, + {"NORMAL", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0}, + {"TANGENT", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0}}; + +static D3D11_INPUT_ELEMENT_DESC inputDescBoneDiffuse1[5] = +{{"POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0}, + {"NORMAL", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0}, + {"TANGENT", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0}, + {"TEXCOORD", 0, DXGI_FORMAT_R32G32_FLOAT, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0}, + {"TEXCOORD", 6, DXGI_FORMAT_R16G16B16A16_UINT, 1, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0}}; + +static D3D11_INPUT_ELEMENT_DESC inputDescBoneDiffuse2[6] = +{{"COLOR", 0, DXGI_FORMAT_R8G8B8A8_UNORM, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0}, + {"TANGENT", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0}, + {"TEXCOORD", 0, DXGI_FORMAT_R32G32_FLOAT, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0}, + {"POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 1, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0}, + {"NORMAL", 0, DXGI_FORMAT_R32G32B32_FLOAT, 1, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0}, + {"TEXCOORD", 6, DXGI_FORMAT_R16G16B16A16_UINT, 2, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0}}; + +static D3D11_INPUT_ELEMENT_DESC inputDescBoneDiffuse3[4] = +{{"POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0}, + {"NORMAL", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0}, + {"TEXCOORD", 0, DXGI_FORMAT_R32G32_FLOAT, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0}, + {"TEXCOORD", 6, DXGI_FORMAT_R16G16B16A16_UINT, 1, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0}}; + +static D3D11_INPUT_ELEMENT_DESC inputDescBoneSimple[5] = +{{"COLOR", 0, DXGI_FORMAT_R8G8B8A8_UNORM, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0}, + {"TANGENT", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0}, + {"POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 1, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0}, + {"NORMAL", 0, DXGI_FORMAT_R32G32B32_FLOAT, 1, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0}, + {"TEXCOORD", 6, DXGI_FORMAT_R16G16B16A16_UINT, 2, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0}}; + +#endif + +using namespace SampleRenderer; + +static D3D11_BLEND getD3DBlend(RendererMaterial::BlendFunc func) +{ + D3D11_BLEND d3dBlend = D3D11_BLEND_ONE; + switch (func) + { + case RendererMaterial::BLEND_ZERO: + d3dBlend = D3D11_BLEND_ZERO; + break; + case RendererMaterial::BLEND_ONE: + d3dBlend = D3D11_BLEND_ONE; + break; + case RendererMaterial::BLEND_SRC_COLOR: + d3dBlend = D3D11_BLEND_SRC_COLOR; + break; + case RendererMaterial::BLEND_ONE_MINUS_SRC_COLOR: + d3dBlend = D3D11_BLEND_INV_SRC_COLOR; + break; + case RendererMaterial::BLEND_SRC_ALPHA: + d3dBlend = D3D11_BLEND_SRC_ALPHA; + break; + case RendererMaterial::BLEND_ONE_MINUS_SRC_ALPHA: + d3dBlend = D3D11_BLEND_INV_SRC_ALPHA; + break; + case RendererMaterial::BLEND_DST_ALPHA: + d3dBlend = D3D11_BLEND_DEST_ALPHA; + break; + case RendererMaterial::BLEND_ONE_MINUS_DST_ALPHA: + d3dBlend = D3D11_BLEND_INV_DEST_ALPHA; + break; + case RendererMaterial::BLEND_DST_COLOR: + d3dBlend = D3D11_BLEND_DEST_COLOR; + break; + case RendererMaterial::BLEND_ONE_MINUS_DST_COLOR: + d3dBlend = D3D11_BLEND_INV_DEST_COLOR; + break; + case RendererMaterial::BLEND_SRC_ALPHA_SATURATE: + d3dBlend = D3D11_BLEND_SRC_ALPHA_SAT; + break; + } + return d3dBlend; +} + +static D3D_SHADER_MACRO getD3DDefine(const D3D11_INPUT_ELEMENT_DESC& inputDesc) +{ +#define D3D_DEFINE_NAME(a) d3dDefine.Name = PX_STRINGIZE(PX_CONCAT(USE_,a)) +#define D3D_DEFINE_NAME_2(a,b) D3D_DEFINE_NAME(PX_CONCAT(a,b)) +#define D3D_CASE_INDEX_DEFINE_NAME_WITH_INDEX(a,b) case b: D3D_DEFINE_NAME_2(a,b); break; +#define D3D_DEFINE_NAME_WITH_INDEX(a,b) { \ + switch(b) { \ + D3D_CASE_INDEX_DEFINE_NAME_WITH_INDEX(a,0) \ + D3D_CASE_INDEX_DEFINE_NAME_WITH_INDEX(a,1) \ + D3D_CASE_INDEX_DEFINE_NAME_WITH_INDEX(a,2) \ + D3D_CASE_INDEX_DEFINE_NAME_WITH_INDEX(a,3) \ + D3D_CASE_INDEX_DEFINE_NAME_WITH_INDEX(a,4) \ + D3D_CASE_INDEX_DEFINE_NAME_WITH_INDEX(a,5) \ + D3D_CASE_INDEX_DEFINE_NAME_WITH_INDEX(a,6) \ + D3D_CASE_INDEX_DEFINE_NAME_WITH_INDEX(a,7) \ + D3D_CASE_INDEX_DEFINE_NAME_WITH_INDEX(a,8) \ + D3D_CASE_INDEX_DEFINE_NAME_WITH_INDEX(a,9) \ + D3D_CASE_INDEX_DEFINE_NAME_WITH_INDEX(a,10) \ + D3D_CASE_INDEX_DEFINE_NAME_WITH_INDEX(a,11) \ + D3D_CASE_INDEX_DEFINE_NAME_WITH_INDEX(a,12) \ + D3D_CASE_INDEX_DEFINE_NAME_WITH_INDEX(a,13) \ + D3D_CASE_INDEX_DEFINE_NAME_WITH_INDEX(a,14) \ + D3D_CASE_INDEX_DEFINE_NAME_WITH_INDEX(a,15) \ + D3D_CASE_INDEX_DEFINE_NAME_WITH_INDEX(a,16) \ + default: D3D_DEFINE_NAME(a); break; \ + }; \ +} \ + + D3D_SHADER_MACRO d3dDefine = {"DEFAULT", "1"}; + if (_stricmp(inputDesc.SemanticName, "TEXCOORD") == 0) D3D_DEFINE_NAME_WITH_INDEX(TEXCOORD, inputDesc.SemanticIndex) + else if (_stricmp(inputDesc.SemanticName, "TANGENT") == 0) D3D_DEFINE_NAME(TANGENT); + else if (_stricmp(inputDesc.SemanticName, "POSITION") == 0) D3D_DEFINE_NAME(POSITION); + else if (_stricmp(inputDesc.SemanticName, "NORMAL") == 0) D3D_DEFINE_NAME(NORMAL); + else if (_stricmp(inputDesc.SemanticName, "COLOR") == 0) D3D_DEFINE_NAME(COLOR); + else if (_stricmp(inputDesc.SemanticName, "BONE") == 0) D3D_DEFINE_NAME(BONE); + return d3dDefine; + +#undef D3D_DEFINE_NAME +#undef D3D_DEFINE_NAME_2 +#undef D3D_CASE_INDEX_DEFINE_NAME_WITH_INDEX +#undef D3D_DEFINE_NAME_WITH_INDEX +} + +static void getD3DDefines(const char* passName, std::vector<D3D10_SHADER_MACRO>& outputDefines) +{ + if(gFeatureLevel <= D3D_FEATURE_LEVEL_9_3) + { + const D3D_SHADER_MACRO psDefines[] = + { + "RENDERER_FRAGMENT", "1", + "RENDERER_D3D11", "1", +#if RENDERER_ENABLE_SINGLE_PASS_LIGHTING + "PASS_ALL_LIGHTS", "1", + RendererMaterial::getPassName((RendererMaterial::Pass)1), RENDERER_TEXT2(1), + RendererMaterial::getPassName((RendererMaterial::Pass)2), RENDERER_TEXT2(2), + RendererMaterial::getPassName((RendererMaterial::Pass)3), RENDERER_TEXT2(3), + RendererMaterial::getPassName((RendererMaterial::Pass)4), RENDERER_TEXT2(4), + "MAX_LIGHTS", RENDERER_TEXT2(RENDERER_MAX_LIGHTS), +#else + passName, "1", +#endif + "NO_SUPPORT_DDX_DDY", "1", + "ENABLE_VFACE", "0", + "ENABLE_VFACE_SCALE", "0", + "PX_WINDOWS", "1", + "ENABLE_SHADOWS", RENDERER_TEXT2(RENDERER_ENABLE_SHADOWS), + NULL, NULL + }; + + outputDefines.resize(PX_ARRAY_SIZE(psDefines)); + //memcpy(&outputDefines[0], psDefines, sizeof(psDefines)); + for (PxU32 i = 0; i < outputDefines.size(); ++i) + { + outputDefines[i] = psDefines[i]; + } + } + else + { + const D3D_SHADER_MACRO psDefines[] = + { + "RENDERER_FRAGMENT", "1", + "RENDERER_D3D11", "1", +#if RENDERER_ENABLE_SINGLE_PASS_LIGHTING + "PASS_ALL_LIGHTS", "1", + RendererMaterial::getPassName((RendererMaterial::Pass)1), RENDERER_TEXT2(1), + RendererMaterial::getPassName((RendererMaterial::Pass)2), RENDERER_TEXT2(2), + RendererMaterial::getPassName((RendererMaterial::Pass)3), RENDERER_TEXT2(3), + RendererMaterial::getPassName((RendererMaterial::Pass)4), RENDERER_TEXT2(4), + "MAX_LIGHTS", RENDERER_TEXT2(RENDERER_MAX_LIGHTS), +#else + passName, "1", +#endif + "ENABLE_VFACE", RENDERER_TEXT2(RENDERER_ENABLE_VFACE_SCALE), + "ENABLE_VFACE_SCALE", RENDERER_TEXT2(RENDERER_ENABLE_VFACE_SCALE), + "PX_WINDOWS", "1", + "ENABLE_SHADOWS", RENDERER_TEXT2(RENDERER_ENABLE_SHADOWS), + NULL, NULL + }; + + outputDefines.resize(PX_ARRAY_SIZE(psDefines)); + //memcpy(&outputDefines[0], psDefines, sizeof(psDefines)); + for (PxU32 i = 0; i < outputDefines.size(); ++i) + { + outputDefines[i] = psDefines[i]; + } + } +} + +static const char* boolToString(bool bTrue) +{ + return bTrue ? "1" : "0"; +} + +/* +static const bool hasDisplacementSemantic(const D3D11_INPUT_ELEMENT_DESC* inputDesc, PxU32 numInputDescs) +{ + // If no input semantics were specified, enable it by default + if (NULL == inputDesc || numInputDescs == 0) + return true; + + for (PxU32 i = 0; i < numInputDescs; ++i) + { + if (strcmp(inputDesc[i].SemanticName, "TEXCOORD") == 0 && + (inputDesc[i].SemanticIndex == RENDERER_DISPLACEMENT_CHANNEL || + inputDesc[i].SemanticIndex == RENDERER_DISPLACEMENT_FLAGS_CHANNEL)) + return true; + } + return false; +} +*/ + +static void getD3DDefines(const D3D11_INPUT_ELEMENT_DESC* inputDesc, PxU32 numInputDescs, bool bTessellationEnabled, bool bInstanced, std::vector<D3D10_SHADER_MACRO>& outputDefines) +{ + PxU32 i = 0; + static const D3D_SHADER_MACRO allVsDefine = { "USE_ALL", "1" }; + static const D3D_SHADER_MACRO nullVsDefine = { NULL, NULL }; + + if(gFeatureLevel <= D3D_FEATURE_LEVEL_9_3) + { + const D3D_SHADER_MACRO baseVsDefines[] = + { + "RENDERER_VERTEX", "1", + "RENDERER_D3D11", "1", + "PX_WINDOWS", "1", + "RENDERER_INSTANCED", "0", + "RENDERER_DISPLACED", "0", + "ENABLE_VFACE", "0", + "ENABLE_VFACE_SCALE", "0", + "ENABLE_TESSELLATION", "0", + "ADAPTIVE_TESSELLATION", "0", + "SEMANTIC_TANGENT", "TANGENT", // This will prevent mapping tangent to texcoord5 and instead to the proper TANGENT semantic + }; + const int numBaseVsDefines = PX_ARRAY_SIZE(baseVsDefines); + + // Each input element description adds a define + if (inputDesc && numInputDescs > 0) outputDefines.resize(numBaseVsDefines + numInputDescs + 1); + // If there are no input element descriptions, we simply add a "USE_ALL" define + else outputDefines.resize(numBaseVsDefines + 2); + + for (; i < numBaseVsDefines; ++i) + { + outputDefines[i] = baseVsDefines[i]; + } + } + else + { + const D3D_SHADER_MACRO baseVsDefines[] = + { + "RENDERER_VERTEX", "1", + "RENDERER_D3D11", "1", + "PX_WINDOWS", "1", + "RENDERER_INSTANCED", boolToString(bInstanced), + "RENDERER_DISPLACED", boolToString(bTessellationEnabled),// && hasDisplacementSemantic(inputDesc, numInputDescs)), + "ENABLE_VFACE", RENDERER_TEXT2(RENDERER_ENABLE_VFACE_SCALE), + "ENABLE_VFACE_SCALE", RENDERER_TEXT2(RENDERER_ENABLE_VFACE_SCALE), + "ENABLE_TESSELLATION", boolToString(bTessellationEnabled), + "ADAPTIVE_TESSELLATION", boolToString(bTessellationEnabled), + "SEMANTIC_TANGENT", "TANGENT", // This will prevent mapping tangent to texcoord5 and instead to the proper TANGENT semantic + }; + const int numBaseVsDefines = PX_ARRAY_SIZE(baseVsDefines); + + // Each input element description adds a define + if (inputDesc && numInputDescs > 0) outputDefines.resize(numBaseVsDefines + numInputDescs + 1); + // If there are no input element descriptions, we simply add a "USE_ALL" define + else outputDefines.resize(numBaseVsDefines + 2); + + for (; i < numBaseVsDefines; ++i) + { + outputDefines[i] = baseVsDefines[i]; + } + } + + // If input element descriptions were provided, add the appropriate shader defines + if (inputDesc && numInputDescs > 0) + { + for (PxU32 j = 0; j < numInputDescs; ++j) + { + if (inputDesc[j].SemanticName) + outputDefines[i++] = getD3DDefine(inputDesc[j]); + } + } + // Otherwise add the default USE_ALL define + else + { + outputDefines[i++] = allVsDefine; + } + + outputDefines[i] = nullVsDefine; +} + +D3D11RendererMaterial::D3D11RendererMaterial(D3D11Renderer& renderer, const RendererMaterialDesc& desc) : + RendererMaterial(desc, renderer.getEnableMaterialCaching()), + m_renderer(renderer), + m_blendState(NULL), + m_vertexShader(NULL), + m_instancedVertexShader(NULL), + m_geometryShader(NULL), + m_hullShader(NULL), + m_domainShader(NULL) +{ + gFeatureLevel = m_renderer.getFeatureLevel(); + memset(m_fragmentPrograms, 0, sizeof(m_fragmentPrograms)); + + if (m_renderer.getD3DDevice()) + { + if (getBlending()) loadBlending(desc); + loadShaders(desc); + } +} + +D3D11RendererMaterial::~D3D11RendererMaterial(void) +{ + dxSafeRelease(m_blendState); + m_renderer.getVariableManager()->unloadVariables(this); + +} + +void D3D11RendererMaterial::setModelMatrix(const float* matrix) +{ + m_renderer.getVariableManager()->setSharedVariable("cbMesh", "g_modelMatrix", matrix); + bindMeshState(false); +} + +void D3D11RendererMaterial::bind(RendererMaterial::Pass pass, RendererMaterialInstance* materialInstance, bool instanced) const +{ + RENDERER_ASSERT(pass < NUM_PASSES, "Invalid Material Pass."); + if (m_renderer.getD3DDeviceContext() && pass < NUM_PASSES) + { + m_renderer.bind(materialInstance); + RendererMaterial::bind(pass, materialInstance, instanced); + setVariables(pass); + setBlending(pass); + setShaders(instanced, pass); + } +} + +void D3D11RendererMaterial::bindMeshState(bool instanced) const +{ + m_renderer.getVariableManager()->bind(this, D3DTypes::SHADER_VERTEX); + if (m_geometryShader) m_renderer.getVariableManager()->bind(this, D3DTypes::SHADER_GEOMETRY); + if (m_hullShader) m_renderer.getVariableManager()->bind(this, D3DTypes::SHADER_HULL); + if (m_domainShader) m_renderer.getVariableManager()->bind(this, D3DTypes::SHADER_DOMAIN); +} + +// This may not be the best place for this, but it works just fine +static ID3D11BlendState* gBlendState = NULL; +static FLOAT gBlendFactor[4] = {0., 0., 0., 0.}; +static UINT gBlendMask = 0; + +void D3D11RendererMaterial::unbind(void) const +{ + ID3D11DeviceContext* d3dDeviceContext = m_renderer.getD3DDeviceContext(); + if (d3dDeviceContext) + { + // Only reset the blend state if it was changed + if (getBlending() && m_blendState) + { + m_renderer.popState(D3D11Renderer::STATE_DEPTHSTENCIL); + d3dDeviceContext->OMSetBlendState(gBlendState, gBlendFactor, gBlendMask); + dxSafeRelease(gBlendState); + } + d3dDeviceContext->VSSetShader(NULL, NULL, 0); + d3dDeviceContext->PSSetShader(NULL, NULL, 0); + d3dDeviceContext->GSSetShader(NULL, NULL, 0); + d3dDeviceContext->HSSetShader(NULL, NULL, 0); + d3dDeviceContext->DSSetShader(NULL, NULL, 0); + } +} + +void D3D11RendererMaterial::bindVariable(Pass pass, const Variable& variable, const void* data) const +{ + D3D11Variable& var = *(D3D11Variable*)&variable; + var.bind(pass, data); +} + +void D3D11RendererMaterial::setBlending(RendererMaterial::Pass pass) const +{ + if (getBlending() && m_blendState) + { + m_renderer.pushState(D3D11Renderer::STATE_DEPTHSTENCIL); + m_renderer.setDepthStencilState(D3D11Renderer::DEPTHSTENCIL_TRANSPARENT); + + m_renderer.getD3DDeviceContext()->OMGetBlendState(&gBlendState, gBlendFactor, &gBlendMask); + m_renderer.getD3DDeviceContext()->OMSetBlendState(m_blendState, NULL, 0xffffffff); + } +} + +void D3D11RendererMaterial::setShaders(bool instanced, RendererMaterial::Pass pass) const +{ + m_renderer.getD3DDeviceContext()->VSSetShader(getVS(instanced), NULL, 0); + m_renderer.getD3DDeviceContext()->PSSetShader(getPS(pass), NULL, 0); + m_renderer.getD3DDeviceContext()->GSSetShader(getGS(), NULL, 0); + m_renderer.getD3DDeviceContext()->HSSetShader(getHS(), NULL, 0); + m_renderer.getD3DDeviceContext()->DSSetShader(getDS(), NULL, 0); +} + +void D3D11RendererMaterial::setVariables(RendererMaterial::Pass pass) const +{ + m_renderer.getVariableManager()->bind(this, D3DTypes::SHADER_PIXEL, pass); +} + +bool D3D11RendererMaterial::tessellationEnabled() const +{ + return m_renderer.tessellationEnabled() && tessellationSupported(); +} + +bool SampleRenderer::D3D11RendererMaterial::tessellationInitialized() const +{ + return (NULL != m_hullShader) && (NULL != m_domainShader); +} + +bool D3D11RendererMaterial::tessellationSupported() const +{ + return m_renderer.isTessellationSupported() && + !m_shaderNames[D3DTypes::SHADER_DOMAIN].empty() && + !m_shaderNames[D3DTypes::SHADER_HULL].empty(); +} + +bool D3D11RendererMaterial::geometryEnabled() const +{ + return m_renderer.getFeatureLevel() >= D3D_FEATURE_LEVEL_10_0 && + !m_shaderNames[D3DTypes::SHADER_GEOMETRY].empty(); +} + +bool D3D11RendererMaterial::geometryInitialized() const +{ + return NULL != m_geometryShader; +} + +void D3D11RendererMaterial::loadBlending(const RendererMaterialDesc& desc) +{ + D3D11_BLEND_DESC blendDesc; + memset(&blendDesc, 0, sizeof(blendDesc)); + blendDesc.AlphaToCoverageEnable = m_renderer.multisamplingEnabled(); + blendDesc.IndependentBlendEnable = FALSE; + blendDesc.RenderTarget[0].BlendEnable = getBlending(); + blendDesc.RenderTarget[0].SrcBlend = getD3DBlend(getSrcBlendFunc()); + blendDesc.RenderTarget[0].DestBlend = getD3DBlend(getDstBlendFunc()); + blendDesc.RenderTarget[0].BlendOp = D3D11_BLEND_OP_ADD; + blendDesc.RenderTarget[0].SrcBlendAlpha = D3D11_BLEND_ONE; + blendDesc.RenderTarget[0].DestBlendAlpha = D3D11_BLEND_ZERO; + blendDesc.RenderTarget[0].BlendOpAlpha = D3D11_BLEND_OP_ADD; + blendDesc.RenderTarget[0].RenderTargetWriteMask = D3D11_COLOR_WRITE_ENABLE_ALL; + m_renderer.getD3DDevice()->CreateBlendState(&blendDesc, &m_blendState); + RENDERER_ASSERT(m_blendState, "Failed to create blend state."); +} + +void D3D11RendererMaterial::loadShaders(const RendererMaterialDesc& desc) +{ + HRESULT result = S_OK; + +#ifdef PX_USE_DX11_PRECOMPILED_SHADERS + if(gFeatureLevel < D3D_FEATURE_LEVEL_11_0) + { + m_shaderPaths[D3DTypes::SHADER_VERTEX] = std::string(m_renderer.getAssetDir()) + "compiledshaders/dx11feature9/" + desc.vertexShaderPath + ".cso"; + m_shaderNames[D3DTypes::SHADER_VERTEX] = std::string(desc.vertexShaderPath) + ".cso"; + m_shaderPaths[D3DTypes::SHADER_PIXEL] = std::string(m_renderer.getAssetDir()) + "compiledshaders/dx11feature9/" + desc.fragmentShaderPath; + m_shaderNames[D3DTypes::SHADER_PIXEL] = std::string(desc.fragmentShaderPath); + } + else + { + m_shaderPaths[D3DTypes::SHADER_VERTEX] = std::string(m_renderer.getAssetDir()) + "compiledshaders/dx11feature11/" + desc.vertexShaderPath + ".cso"; + m_shaderNames[D3DTypes::SHADER_VERTEX] = std::string(desc.vertexShaderPath) + ".cso"; + m_shaderPaths[D3DTypes::SHADER_PIXEL] = std::string(m_renderer.getAssetDir()) + "compiledshaders/dx11feature11/" + desc.fragmentShaderPath; + m_shaderNames[D3DTypes::SHADER_PIXEL] = std::string(desc.fragmentShaderPath); + + if (desc.geometryShaderPath) + { + m_shaderPaths[D3DTypes::SHADER_GEOMETRY] = std::string(m_renderer.getAssetDir()) + "compiledshaders/dx11feature11/" + desc.geometryShaderPath; + m_shaderNames[D3DTypes::SHADER_GEOMETRY] = desc.geometryShaderPath; + } + if (desc.hullShaderPath) + { + m_shaderPaths[D3DTypes::SHADER_HULL] = std::string(m_renderer.getAssetDir()) + "compiledshaders/dx11feature11/" + desc.hullShaderPath; + m_shaderNames[D3DTypes::SHADER_HULL] = desc.hullShaderPath; + } + if (desc.domainShaderPath) + { + m_shaderPaths[D3DTypes::SHADER_DOMAIN] = std::string(m_renderer.getAssetDir()) + "compiledshaders/dx11feature11/" + desc.domainShaderPath; + m_shaderNames[D3DTypes::SHADER_DOMAIN] = desc.domainShaderPath; + } + + } +#else + m_shaderPaths[D3DTypes::SHADER_VERTEX] = std::string(m_renderer.getAssetDir()) + "shaders/" + desc.vertexShaderPath; + m_shaderNames[D3DTypes::SHADER_VERTEX] = desc.vertexShaderPath; + m_shaderPaths[D3DTypes::SHADER_PIXEL] = std::string(m_renderer.getAssetDir()) + "shaders/" + desc.fragmentShaderPath; + m_shaderNames[D3DTypes::SHADER_PIXEL] = desc.fragmentShaderPath; + if (desc.geometryShaderPath) + { + m_shaderPaths[D3DTypes::SHADER_GEOMETRY] = std::string(m_renderer.getAssetDir()) + "shaders/" + desc.geometryShaderPath; + m_shaderNames[D3DTypes::SHADER_GEOMETRY] = desc.geometryShaderPath; + } + if (desc.hullShaderPath) + { + m_shaderPaths[D3DTypes::SHADER_HULL] = std::string(m_renderer.getAssetDir()) + "shaders/" + desc.hullShaderPath; + m_shaderNames[D3DTypes::SHADER_HULL] = desc.hullShaderPath; + } + if (desc.domainShaderPath) + { + m_shaderPaths[D3DTypes::SHADER_DOMAIN] = std::string(m_renderer.getAssetDir()) + "shaders/" + desc.domainShaderPath; + m_shaderNames[D3DTypes::SHADER_DOMAIN] = desc.domainShaderPath; + } +#endif + + ID3DBlob* pShaderBlob = NULL; + + D3D11ShaderLoader loader(m_renderer); + std::vector<D3D_SHADER_MACRO> vsDefines; + std::vector<D3D_SHADER_MACRO> psDefines; + + // Load vertex shader + getD3DDefines(NULL, 0, tessellationSupported(), false, vsDefines); + D3DTraits<ID3D11VertexShader>::key_type vsKey(0xffffff, m_shaderNames[D3DTypes::SHADER_VERTEX]); + result = loader.load<ID3D11VertexShader>(vsKey, getPath(D3DTypes::SHADER_VERTEX), &vsDefines[0], &m_vertexShader, &pShaderBlob); + if (SUCCEEDED(result)) m_renderer.getVariableManager()->loadVariables(this, pShaderBlob, D3DTypes::SHADER_VERTEX); + + // Load pixel shadders for each pass + for (PxU32 i = 0; i < NUM_PASSES; i++) + { + if (SUCCEEDED(result)) + { + getD3DDefines(getPassName(Pass(i)), psDefines); + std::string shaderName = m_shaderNames[D3DTypes::SHADER_PIXEL]; + const char* pixelShaderPath = getPath(D3DTypes::SHADER_PIXEL); +#ifdef PX_USE_DX11_PRECOMPILED_SHADERS + shaderName += std::string(".") + (getPassName(Pass(i))) + ".cso"; + char shaderPathCompiled[MAX_PATH]; + strcpy(shaderPathCompiled,pixelShaderPath); + strcat(shaderPathCompiled,"."); + strcat(shaderPathCompiled,getPassName(Pass(i))); + strcat(shaderPathCompiled,".cso"); + pixelShaderPath = shaderPathCompiled; +#endif + D3DTraits<ID3D11PixelShader>::key_type psKey(i, shaderName); + result = loader.load<ID3D11PixelShader>(psKey, pixelShaderPath, &psDefines[0], &m_fragmentPrograms[i], &pShaderBlob, true); + if (SUCCEEDED(result)) m_renderer.getVariableManager()->loadVariables(this, pShaderBlob, D3DTypes::SHADER_PIXEL, (Pass)i); + } + } + + // Load geometry shader + if (SUCCEEDED(result) && geometryEnabled()) + { + D3DTraits<ID3D11GeometryShader>::key_type gsKey(m_shaderNames[D3DTypes::SHADER_GEOMETRY]); + result = loader.load<ID3D11GeometryShader>(gsKey, getPath(D3DTypes::SHADER_GEOMETRY), &vsDefines[0], &m_geometryShader, &pShaderBlob); + if (SUCCEEDED(result)) m_renderer.getVariableManager()->loadVariables(this, pShaderBlob, D3DTypes::SHADER_GEOMETRY); + } + + // Load hull shader + if (SUCCEEDED(result) && tessellationSupported()) + { + D3DTraits<ID3D11HullShader>::key_type hsKey(0xffffff, m_shaderNames[D3DTypes::SHADER_HULL]); + result = loader.load<ID3D11HullShader>(hsKey, getPath(D3DTypes::SHADER_HULL), &vsDefines[0], &m_hullShader, &pShaderBlob); + if (SUCCEEDED(result)) m_renderer.getVariableManager()->loadVariables(this, pShaderBlob, D3DTypes::SHADER_HULL); + } + + // Load domain shader + if (SUCCEEDED(result) && tessellationSupported()) + { + D3DTraits<ID3D11DomainShader>::key_type dsKey(0xffffff, m_shaderNames[D3DTypes::SHADER_DOMAIN]); + result = loader.load<ID3D11DomainShader>(dsKey, getPath(D3DTypes::SHADER_DOMAIN), &vsDefines[0], &m_domainShader, &pShaderBlob); + if (SUCCEEDED(result)) m_renderer.getVariableManager()->loadVariables(this, pShaderBlob, D3DTypes::SHADER_DOMAIN); + } + +#if RENDERER_ENABLE_LAYOUT_PRECACHE +#define CACHE_VS(desc, instanced) cacheVS(desc, ARRAYSIZE(desc), D3DX11::getInputHash(desc, ARRAYSIZE(desc)), instanced) + + if (!gStaticPrecached && !strcmp(desc.vertexShaderPath, "vertex/staticmesh.cg")) + { + gStaticPrecached = true; + CACHE_VS(inputDescStaticDiffuse, false); + CACHE_VS(inputDescStaticDiffuseInstanced, true); + } + if (!gBonePrecached && !strcmp(desc.vertexShaderPath, "vertex/skeletalmesh_1bone.cg")) + { + gBonePrecached = true; + CACHE_VS(inputDescBoneDiffuse0, false); + CACHE_VS(inputDescBoneDiffuse1, false); + CACHE_VS(inputDescBoneDiffuse2, false); + CACHE_VS(inputDescBoneDiffuse3, false); + CACHE_VS(inputDescBoneSimple, false); + } +#undef CACHE_VS +#endif // RENDERER_ENABLE_LAYOUT_PRECACHE +} + +std::string D3D11RendererMaterial::getShaderNameFromInputLayout(const D3D11_INPUT_ELEMENT_DESC* inputDesc,PxU32 numInputDescs, const std::string& shaderName) const +{ + std::string outString = shaderName; + +#ifdef PX_USE_DX11_PRECOMPILED_SHADERS + // rename + if(inputDesc && numInputDescs > 0) + { + PX_ASSERT(outString.size() > 4); + outString.resize(outString.length()-4); + for (PxU32 i = 0; i < numInputDescs; i++) + { + if (inputDesc[i].SemanticName) + { + outString += "_"; + outString += &getD3DDefine(inputDesc[i]).Name[4]; + } + } + outString += ".cso"; + } +#endif + + return outString; +} + +ID3DBlob* D3D11RendererMaterial::getVSBlob(const D3D11_INPUT_ELEMENT_DESC* inputDesc, PxU32 numInputDescs, PxU64 inputDescHash, bool bInstanced) const +{ + D3D11ShaderCacher cacher(m_renderer.getResourceManager()); + D3DTraits<ID3D11VertexShader>::value_type vsValue; + if (!cacher.check<ID3D11VertexShader>(std::make_pair(inputDescHash,getShaderNameFromInputLayout(inputDesc,numInputDescs,m_shaderNames[D3DTypes::SHADER_VERTEX])), vsValue.first, vsValue.second)) + { + cacheVS(inputDesc, numInputDescs, inputDescHash, bInstanced, &vsValue.first, &vsValue.second); + } + + // In the event we had to create a new shader for the given input layout, + // we'll need to assign it as the current shader + ID3D11VertexShader*& currentShader = bInstanced ? m_instancedVertexShader : m_vertexShader; + if (currentShader != vsValue.first) + { + currentShader = vsValue.first; + m_renderer.getD3DDeviceContext()->VSSetShader(currentShader, NULL, 0); + } + + return vsValue.second; +} + +ID3DBlob* D3D11RendererMaterial::getVSBlob(const std::vector<D3D11_INPUT_ELEMENT_DESC>& inputDesc, PxU64 inputDescHash, bool bInstanced) const +{ + return getVSBlob(&inputDesc[0], (UINT)inputDesc.size(), inputDescHash, bInstanced); +} + +void D3D11RendererMaterial::cacheVS(const D3D11_INPUT_ELEMENT_DESC* inputDesc, PxU32 numInputDescs, PxU64 inputDescHash, bool bInstanced, ID3D11VertexShader** ppShader, ID3DBlob** ppBlob) const +{ + std::vector<D3D10_SHADER_MACRO> defines; + getD3DDefines(inputDesc, numInputDescs, tessellationSupported(), bInstanced, defines); + + D3DTraits<ID3D11VertexShader>::key_type vsKey(inputDescHash, getShaderNameFromInputLayout(inputDesc,numInputDescs, m_shaderNames[D3DTypes::SHADER_VERTEX])); + + D3D11ShaderLoader loader(m_renderer); + if (FAILED(loader.load<ID3D11VertexShader>(vsKey, getShaderNameFromInputLayout(inputDesc,numInputDescs,getPath(D3DTypes::SHADER_VERTEX)).c_str(), &defines[0], ppShader, ppBlob, false))) + { + RENDERER_ASSERT(0, "Error loading D3D11 layout signature."); + } +} + +#endif + diff --git a/PhysX_3.4/Samples/SampleFramework/renderer/src/d3d11/D3D11RendererMaterial.h b/PhysX_3.4/Samples/SampleFramework/renderer/src/d3d11/D3D11RendererMaterial.h new file mode 100644 index 00000000..c32b3c3f --- /dev/null +++ b/PhysX_3.4/Samples/SampleFramework/renderer/src/d3d11/D3D11RendererMaterial.h @@ -0,0 +1,125 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved. +#ifndef D3D11_RENDERER_MATERIAL_H +#define D3D11_RENDERER_MATERIAL_H + +#include <RendererConfig.h> + +#if defined(RENDERER_ENABLE_DIRECT3D11) + +#include <RendererMaterial.h> + +#include "D3D11Renderer.h" +#include "D3D11RendererTraits.h" +#include "D3Dcompiler.h" + +namespace SampleRenderer +{ + +class D3D11Renderer; + +class D3D11RendererMaterial : public RendererMaterial +{ + friend class D3D11Renderer; + friend class D3D11RendererMesh; + friend class D3D11RendererVariableManager; + + typedef RendererMaterial::Variable Variable; + +public: + D3D11RendererMaterial(D3D11Renderer& renderer, const RendererMaterialDesc& desc); + virtual ~D3D11RendererMaterial(void); + virtual void setModelMatrix(const float* matrix); + + bool tessellationEnabled() const; + bool tessellationInitialized() const; + bool tessellationSupported() const; + + bool geometryEnabled() const; + bool geometryInitialized() const; + +private: + virtual const Renderer& getRenderer() const { return m_renderer; } + virtual void bind(RendererMaterial::Pass pass, RendererMaterialInstance* materialInstance, bool instanced) const; + virtual void bindMeshState(bool instanced) const; + virtual void unbind(void) const; + virtual void bindVariable(Pass pass, const Variable& variable, const void* data) const; + +private: + typedef RendererMaterial::Variable D3D11BaseVariable; + class D3D11Variable : public D3D11BaseVariable + { + public: + D3D11Variable(const char* name, RendererMaterial::VariableType type, PxU32 offset) + : Variable(name, type, offset) { } + virtual void bind(RendererMaterial::Pass pass, const void* data) = 0; + }; + +private: + D3D11RendererMaterial& operator=(const D3D11RendererMaterial&) { return *this;} + + ID3D11VertexShader* getVS(bool bInstanced) const { return bInstanced ? m_instancedVertexShader : m_vertexShader; } + ID3D11PixelShader* getPS(RendererMaterial::Pass pass) const { return m_fragmentPrograms[pass]; } + ID3D11GeometryShader* getGS() const { return geometryEnabled() ? m_geometryShader : NULL; } + ID3D11HullShader* getHS() const { return tessellationEnabled() ? m_hullShader : NULL; } + ID3D11DomainShader* getDS() const { return tessellationEnabled() ? m_domainShader : NULL; } + + ID3DBlob* getVSBlob(const std::vector<D3D11_INPUT_ELEMENT_DESC>& inputDesc, PxU64 inputDescHash, bool bInstanced) const; + ID3DBlob* getVSBlob(const D3D11_INPUT_ELEMENT_DESC* inputDesc, PxU32 numInputDescs, PxU64 inputDescHash, bool bInstanced) const; + + const char* getPath(const D3DType type) const { return m_shaderPaths[type].c_str(); } + + void cacheVS(const D3D11_INPUT_ELEMENT_DESC* inputDesc, PxU32 numInputDescs, PxU64 inputDescHash, bool bInstanced, ID3D11VertexShader** ppShader = NULL, ID3DBlob** ppBlob = NULL) const; + std::string getShaderNameFromInputLayout(const D3D11_INPUT_ELEMENT_DESC* inputDesc, PxU32 numInputDescs,const std::string& shaderName) const; + + void setVariables(RendererMaterial::Pass pass) const; + void setBlending(RendererMaterial::Pass pass) const; + void setShaders(bool bInstanced, RendererMaterial::Pass pass) const; + + void loadBlending(const RendererMaterialDesc& desc); + void loadShaders(const RendererMaterialDesc& desc); + +private: + D3D11Renderer& m_renderer; + + ID3D11BlendState* m_blendState; + + mutable ID3D11VertexShader* m_vertexShader; + mutable ID3D11VertexShader* m_instancedVertexShader; + ID3D11GeometryShader* m_geometryShader; + ID3D11HullShader* m_hullShader; + ID3D11DomainShader* m_domainShader; + ID3D11PixelShader* m_fragmentPrograms[NUM_PASSES]; + + std::string m_shaderNames[D3DTypes::NUM_SHADER_TYPES]; + std::string m_shaderPaths[D3DTypes::NUM_SHADER_TYPES]; +}; + +} // namespace SampleRenderer + +#endif // #if defined(RENDERER_ENABLE_DIRECT3D11) +#endif diff --git a/PhysX_3.4/Samples/SampleFramework/renderer/src/d3d11/D3D11RendererMemoryMacros.h b/PhysX_3.4/Samples/SampleFramework/renderer/src/d3d11/D3D11RendererMemoryMacros.h new file mode 100644 index 00000000..29640f6b --- /dev/null +++ b/PhysX_3.4/Samples/SampleFramework/renderer/src/d3d11/D3D11RendererMemoryMacros.h @@ -0,0 +1,61 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved. + +#ifndef D3D11_RENDERER_MEMORY_MACROS_H +#define D3D11_RENDERER_MEMORY_MACROS_H + +namespace SampleRenderer +{ + +template<class T> +PX_INLINE void dxSafeRelease( T*& t ) { if(t) { t->Release(); t = NULL; } } + +template<class T> +PX_INLINE void deleteSafe( T*& t ) { if(t) { delete t; t = NULL; } } + +template<class T> +PX_INLINE bool deleteAndReturnTrue( T& t ) { deleteSafe(t); return true; } + +template<class T> +PX_INLINE bool dxReleaseAndReturnTrue( T& t ) { dxSafeRelease(t); return true; } + +template<class T> +PX_INLINE void deleteAll( T& t ) { std::remove_if(t.begin(), t.end(), deleteAndReturnTrue<typename T::value_type>); }; + +template<class T> +PX_INLINE void dxSafeReleaseAll( T& t ) { std::remove_if(t.begin(), t.end(), dxReleaseAndReturnTrue<typename T::value_type>); }; + +template<class T> +PX_INLINE void resizeIfSmallerThan( T& t, typename T::size_type s, typename T::value_type v = typename T::value_type() ) +{ + if (s > t.size()) + t.resize(s, v); +} + +} + +#endif diff --git a/PhysX_3.4/Samples/SampleFramework/renderer/src/d3d11/D3D11RendererMesh.cpp b/PhysX_3.4/Samples/SampleFramework/renderer/src/d3d11/D3D11RendererMesh.cpp new file mode 100644 index 00000000..493b9850 --- /dev/null +++ b/PhysX_3.4/Samples/SampleFramework/renderer/src/d3d11/D3D11RendererMesh.cpp @@ -0,0 +1,291 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved. + +#include <RendererConfig.h> + +#if defined(RENDERER_ENABLE_DIRECT3D11) + +#include "D3D11RendererMesh.h" +#include "D3D11RendererVertexBuffer.h" +#include "D3D11RendererInstanceBuffer.h" +#include "D3D11RendererMemoryMacros.h" +#include "D3D11RendererMaterial.h" +#include "D3D11RendererUtils.h" +#include "D3D11RendererResourceManager.h" +#include "D3D11RendererVariableManager.h" + +#include <RendererMeshDesc.h> + +#include <SamplePlatform.h> + +#pragma warning(disable:4702 4189) + +using namespace SampleRenderer; + +D3D11RendererMesh::D3D11RendererMesh(D3D11Renderer& renderer, const RendererMeshDesc& desc) : + RendererMesh(desc), + m_renderer(renderer), + m_inputHash(0), + m_instancedInputHash(0), + m_bPopStates(false), +#ifdef PX_USE_DX11_PRECOMPILED_SHADERS + m_spriteShaderPath(std::string(m_renderer.getAssetDir())+"compiledshaders/dx11feature11/geometry/pointsprite.cg.cso") +#else + m_spriteShaderPath(std::string(m_renderer.getAssetDir())+"shaders/vertex/pointsprite.cg") +#endif +{ + ID3D11Device* d3dDevice = m_renderer.getD3DDevice(); + RENDERER_ASSERT(d3dDevice, "Renderer's D3D Device not found!"); + if (d3dDevice) + { + PxU32 numVertexBuffers = getNumVertexBuffers(); + const RendererVertexBuffer* const* vertexBuffers = getVertexBuffers(); + + for (PxU32 i = 0; i < numVertexBuffers; i++) + { + const RendererVertexBuffer* vb = vertexBuffers[i]; + if (vb) + { + const D3D11RendererVertexBuffer& d3dVb = *static_cast<const D3D11RendererVertexBuffer*>(vb); + d3dVb.addVertexElements(i, m_inputDescriptions); + } + } + m_inputHash = D3DX11::getInputHash(m_inputDescriptions); + + m_instancedInputDescriptions = m_inputDescriptions; + if (m_instanceBuffer) + { + static_cast<const D3D11RendererInstanceBuffer*>(m_instanceBuffer)->addVertexElements(numVertexBuffers, m_instancedInputDescriptions); + m_instancedInputHash = D3DX11::getInputHash(m_instancedInputDescriptions); + } + else + { + m_instancedInputHash = m_inputHash; + } + } +} + +D3D11RendererMesh::~D3D11RendererMesh(void) +{ + +} + +static D3D_PRIMITIVE_TOPOLOGY getD3DPrimitive(const RendererMesh::Primitive& primitive, bool bTessellationEnabled) +{ + D3D_PRIMITIVE_TOPOLOGY d3dPrimitive = D3D_PRIMITIVE_TOPOLOGY_UNDEFINED; + switch (primitive) + { + case RendererMesh::PRIMITIVE_POINTS: + d3dPrimitive = D3D_PRIMITIVE_TOPOLOGY_POINTLIST; + break; + case RendererMesh::PRIMITIVE_LINES: + d3dPrimitive = D3D_PRIMITIVE_TOPOLOGY_LINELIST; + break; + case RendererMesh::PRIMITIVE_LINE_STRIP: + d3dPrimitive = D3D_PRIMITIVE_TOPOLOGY_LINESTRIP; + break; + case RendererMesh::PRIMITIVE_TRIANGLES: + d3dPrimitive = bTessellationEnabled ? D3D11_PRIMITIVE_TOPOLOGY_3_CONTROL_POINT_PATCHLIST : D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST; + break; + case RendererMesh::PRIMITIVE_TRIANGLE_STRIP: + d3dPrimitive = bTessellationEnabled ? D3D11_PRIMITIVE_TOPOLOGY_3_CONTROL_POINT_PATCHLIST : D3D_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP; + break; + case RendererMesh::PRIMITIVE_POINT_SPRITES: + d3dPrimitive = D3D_PRIMITIVE_TOPOLOGY_POINTLIST; + break; + } + RENDERER_ASSERT(d3dPrimitive != D3D_PRIMITIVE_TOPOLOGY_UNDEFINED, "Unable to find DIRECT3D11 Primitive."); + return d3dPrimitive; +} + +class D3D11RendererMesh::ScopedMeshRender { +public: + + ScopedMeshRender(const D3D11RendererMesh& mesh_, RendererMaterial* material, bool instanced) : mesh(mesh_) + { + mesh.setTopology(mesh.getPrimitives(), static_cast<D3D11RendererMaterial*>(material)->tessellationEnabled()); + mesh.setLayout(material, instanced); + if (mesh.getPrimitives() == RendererMesh::PRIMITIVE_POINT_SPRITES) + mesh.setSprites(true); + } + + ~ScopedMeshRender() + { + if (mesh.getPrimitives() == RendererMesh::PRIMITIVE_POINT_SPRITES) + mesh.setSprites(false); + } + + ScopedMeshRender& operator=(const ScopedMeshRender&) { return *this; } + + const D3D11RendererMesh& mesh; +}; + +void D3D11RendererMesh::renderIndices(PxU32 numVertices, PxU32 firstIndex, PxU32 numIndices, RendererIndexBuffer::Format indexFormat, RendererMaterial* material) const +{ + ID3D11DeviceContext* d3dDeviceContext = m_renderer.getD3DDeviceContext(); + RENDERER_ASSERT(material, "Invalid RendererMaterial"); + if (d3dDeviceContext && material) + { + ScopedMeshRender renderScope(*this, material, false); + d3dDeviceContext->DrawIndexed(numIndices, firstIndex, 0); + } +} + +void D3D11RendererMesh::renderVertices(PxU32 numVertices, RendererMaterial* material) const +{ + ID3D11DeviceContext* d3dDeviceContext = m_renderer.getD3DDeviceContext(); + RENDERER_ASSERT(material, "Invalid RendererMaterial"); + if (d3dDeviceContext && material) + { + ScopedMeshRender renderScope(*this, material, false); + d3dDeviceContext->Draw(numVertices, 0); + } +} + +void D3D11RendererMesh::renderIndicesInstanced(PxU32 numVertices, PxU32 firstIndex, PxU32 numIndices, RendererIndexBuffer::Format indexFormat, RendererMaterial* material) const +{ + ID3D11DeviceContext* d3dDeviceContext = m_renderer.getD3DDeviceContext(); + RENDERER_ASSERT(material, "Invalid RendererMaterial"); + if (d3dDeviceContext && material) + { + ScopedMeshRender renderScope(*this, material, true); + d3dDeviceContext->DrawIndexedInstanced(numIndices, m_numInstances, firstIndex, 0, m_firstInstance); + } +} + +void D3D11RendererMesh::renderVerticesInstanced(PxU32 numVertices, RendererMaterial* material) const +{ + ID3D11DeviceContext* d3dDeviceContext = m_renderer.getD3DDeviceContext(); + RENDERER_ASSERT(material, "Invalid RendererMaterial"); + if (d3dDeviceContext && material) + { + ScopedMeshRender renderScope(*this, material, true); + d3dDeviceContext->DrawInstanced(numVertices, m_numInstances, 0, m_firstInstance); + } +} + +void D3D11RendererMesh::bind(void) const +{ + RendererMesh::bind(); +} + +void D3D11RendererMesh::render(RendererMaterial* material) const +{ + RendererMesh::render(material); +} + +void D3D11RendererMesh::setTopology(const Primitive& primitive, bool bTessellationEnabled) const +{ + ID3D11DeviceContext* d3dContext = m_renderer.getD3DDeviceContext(); + RENDERER_ASSERT(d3dContext, "Invalid D3D11 context"); + d3dContext->IASetPrimitiveTopology(getD3DPrimitive(primitive, bTessellationEnabled)); +} + +ID3D11InputLayout* D3D11RendererMesh::getInputLayoutForMaterial(const D3D11RendererMaterial* pMaterial, bool bInstanced) const +{ + ID3D11InputLayout* pLayout = NULL; + + RENDERER_ASSERT(pMaterial, "Invalid D3D11 Material"); + const LayoutVector& inputDescriptions = bInstanced ? m_instancedInputDescriptions : m_inputDescriptions; + const PxU64& inputHash = bInstanced ? m_instancedInputHash : m_inputHash; + ID3DBlob* pVSBlob = pMaterial->getVSBlob(inputDescriptions, inputHash, bInstanced); + RENDERER_ASSERT(pVSBlob, "Invalid D3D11 Shader Blob"); + + D3DTraits<ID3D11InputLayout>::key_type ilKey(inputHash, pVSBlob); + pLayout = m_renderer.getResourceManager()->hasResource<ID3D11InputLayout>(ilKey); + if (!pLayout) + { + ID3D11Device* d3dDevice = m_renderer.getD3DDevice(); + RENDERER_ASSERT(d3dDevice, "Invalid D3D11 device"); + HRESULT result = d3dDevice->CreateInputLayout(&inputDescriptions[0], + (UINT)inputDescriptions.size(), + pVSBlob->GetBufferPointer(), + pVSBlob->GetBufferSize(), + &pLayout); + RENDERER_ASSERT(SUCCEEDED(result) && pLayout, "Failed to create DIRECT3D11 Input Layout."); + if (SUCCEEDED(result) && pLayout) + { + m_renderer.getResourceManager()->registerResource<ID3D11InputLayout>(ilKey, pLayout); + } + } + + RENDERER_ASSERT(pLayout, "Failed to find DIRECT3D11 Input Layout."); + return pLayout; +} + +void D3D11RendererMesh::setLayout(const RendererMaterial* pMaterial, bool bInstanced) const +{ + ID3D11DeviceContext* d3dContext = m_renderer.getD3DDeviceContext(); + RENDERER_ASSERT(d3dContext, "Invalid D3D11 context"); + ID3D11InputLayout* pLayout = getInputLayoutForMaterial(static_cast<const D3D11RendererMaterial*>(pMaterial), bInstanced); + d3dContext->IASetInputLayout(pLayout); +} + +void D3D11RendererMesh::setSprites(bool bEnabled) const +{ + if (bEnabled && m_renderer.getFeatureLevel() > D3D_FEATURE_LEVEL_9_3) + { + static const D3D_SHADER_MACRO geometryDefines[] = + { + "RENDERER_GEOMETRY", "1", + "RENDERER_D3D11", "1", + "PX_WINDOWS", "1", + "USE_ALL", "1", + "SEMANTIC_TANGENT", "TANGENT", + NULL, NULL + }; + + ID3D11GeometryShader* pShader = NULL; + ID3DBlob* pBlob = NULL; + bool bLoadedFromCache = false; + + D3D11ShaderLoader gsLoader(m_renderer); + if (SUCCEEDED(gsLoader.load("pointsprite", m_spriteShaderPath.c_str(), geometryDefines, &pShader, &pBlob, true, &bLoadedFromCache))) + { + // If the shader was just compiled we need to load the proper variables for it + if (!bLoadedFromCache) + { + m_renderer.getVariableManager()->loadSharedVariables(this, pBlob, D3DTypes::SHADER_GEOMETRY); + } + m_renderer.getVariableManager()->bind(this, D3DTypes::SHADER_GEOMETRY); + m_renderer.getD3DDeviceContext()->GSSetShader(pShader, NULL, 0); + } + } + else + { + m_renderer.getD3DDeviceContext()->GSSetShader(NULL, NULL, 0); + } +} + +void D3D11RendererMesh::setNumVerticesAndIndices(PxU32 nbVerts, PxU32 nbIndices) +{ + m_numVertices = nbVerts; + m_numIndices = nbIndices; +} + + +#endif // #if defined(RENDERER_ENABLE_DIRECT3D11) diff --git a/PhysX_3.4/Samples/SampleFramework/renderer/src/d3d11/D3D11RendererMesh.h b/PhysX_3.4/Samples/SampleFramework/renderer/src/d3d11/D3D11RendererMesh.h new file mode 100644 index 00000000..577d7dbd --- /dev/null +++ b/PhysX_3.4/Samples/SampleFramework/renderer/src/d3d11/D3D11RendererMesh.h @@ -0,0 +1,93 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved. +#ifndef D3D11_RENDERER_MESH_H +#define D3D11_RENDERER_MESH_H + +#include <RendererConfig.h> + +#if defined(RENDERER_ENABLE_DIRECT3D11) + +#include <RendererMesh.h> +#include "D3D11Renderer.h" + +namespace SampleRenderer +{ +class D3D11RendererMaterial; + +class D3D11RendererMesh : public RendererMesh +{ + friend class D3D11Renderer; + +public: + D3D11RendererMesh(D3D11Renderer& renderer, const RendererMeshDesc& desc); + virtual ~D3D11RendererMesh(void); + +protected: + virtual void renderIndices(PxU32 numVertices, PxU32 firstIndex, PxU32 numIndices, RendererIndexBuffer::Format indexFormat, RendererMaterial* material) const; + virtual void renderVertices(PxU32 numVertices, RendererMaterial* material) const; + + virtual void renderIndicesInstanced(PxU32 numVertices, PxU32 firstIndex, PxU32 numIndices, RendererIndexBuffer::Format indexFormat, RendererMaterial* material) const; + virtual void renderVerticesInstanced(PxU32 numVertices, RendererMaterial* material) const; + + D3D11RendererMesh& operator=(const D3D11RendererMesh&) { return *this; } + + Renderer& renderer() { return m_renderer; } + +private: + void bind(void) const; + void render(RendererMaterial* material) const; + + void setTopology(const Primitive& primitive, bool bTessellationEnabled) const; + void setLayout(const RendererMaterial*, bool bInstanced) const; + void setSprites(bool bEnabled) const; + void setNumVerticesAndIndices(PxU32 numIndices, PxU32 numVertices); + + ID3D11InputLayout* getInputLayoutForMaterial(const D3D11RendererMaterial*, bool bInstanced) const; + +private: + class ScopedMeshRender; + friend class ScopedMeshRender; + + typedef std::vector<D3D11_INPUT_ELEMENT_DESC> LayoutVector; + + D3D11Renderer& m_renderer; + + LayoutVector m_inputDescriptions; + LayoutVector m_instancedInputDescriptions; + PxU64 m_inputHash; + PxU64 m_instancedInputHash; + + // This is merely for cleanup, and has no effect on externally visible state + mutable bool m_bPopStates; + + std::string m_spriteShaderPath; +}; + +} // namespace SampleRenderer + +#endif // #if defined(RENDERER_ENABLE_DIRECT3D11) +#endif diff --git a/PhysX_3.4/Samples/SampleFramework/renderer/src/d3d11/D3D11RendererResourceManager.h b/PhysX_3.4/Samples/SampleFramework/renderer/src/d3d11/D3D11RendererResourceManager.h new file mode 100644 index 00000000..cb0d28c2 --- /dev/null +++ b/PhysX_3.4/Samples/SampleFramework/renderer/src/d3d11/D3D11RendererResourceManager.h @@ -0,0 +1,333 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved. +#ifndef D3D11_RENDERER_RESOURCE_MANAGER_H +#define D3D11_RENDERER_RESROUCE_MAANGER_H + +#include <RendererConfig.h> + +#if defined(RENDERER_ENABLE_DIRECT3D11) + +#include <algorithm> + +#include "D3D11RendererTraits.h" +#include "D3D11RendererMemoryMacros.h" + +namespace SampleRenderer +{ + +#define USE_ANY_AS_CONTAINER 1 +class Any +{ +public: + class Visitor; +private: + class Proxy; + +public: + Any() : mpProxy(NULL) { } + ~Any() { delete mpProxy; } + +public: + Any(const Any &other): mpProxy(other.mpProxy ? other.mpProxy->clone() : 0) { } + Any &swap(Any &rhs) { std::swap(mpProxy, rhs.mpProxy); return *this; } + Any &operator=(const Any &rhs) { Any rhsTemp(rhs); return swap(rhsTemp); } + + template<typename value_type> + Any(const value_type &value) : mpProxy(new ProxyImpl<value_type>(value)) { } + + template<typename value_type> + Any &operator=(const value_type &rhs) { Any rhsTemp(rhs); return swap(rhsTemp); } + + void assign(Proxy *otherProxy) { mpProxy = otherProxy; } + +public: + const std::type_info &type_info() const { return mpProxy ? mpProxy->type_info() : typeid(void); } + operator const void *() const { return mpProxy; } + + template<typename value_type> + bool copy_to(value_type &value) const { + const value_type *copyable = to_ptr<value_type>(); + if(copyable) value = *copyable; + return copyable; + } + template<typename value_type> + const value_type *to_ptr() const + { + return type_info() == typeid(value_type) ? &static_cast<ProxyImpl<value_type> *>(mpProxy)->mValue : 0; + } + template<typename value_type> + value_type *to_ptr() + { + return type_info() == typeid(value_type) ? &static_cast<ProxyImpl<value_type> *>(mpProxy)->mValue : 0; + } + +#if !USE_ANY_AS_CONTAINER + bool operator==(const Any& other) const { + return (mpProxy && other.mpProxy) ? (*mpProxy == *other.mpProxy) + :((!mpProxy && !other.mpProxy) ? true : false); } +#endif + + void release() { if(mpProxy) mpProxy->release(); } + //void accept(Visitor& visitor) { if (mpProxy) mpProxy->accept(visitor); } + +public: + class Visitor + { + public: + virtual void visit(Proxy& proxy) = 0; + }; + +private: + + + template<typename T> + struct Releaser { + public: + static void release(T& t) { } + }; + + template <typename T> + struct Releaser<T*> + { + public: + static void release(T*& t) { dxSafeRelease(t); } + }; + + template<typename T1,typename T2> + struct Releaser< std::pair<T1*,T2*> > + { + public: + static void release(std::pair<T1*,T2*>& t) { dxSafeRelease(t.first); dxSafeRelease(t.second); } + }; + + template<typename T1,typename T2> + struct Releaser< std::map<T1,T2> > : public Visitor + { + public: + static void release(std::map<T1,T2>& t) + { + for (typename std::map<T1,T2>::iterator it = t.begin(); it != t.end(); ++it) + { + Releaser<T2>::release(it->second); + } + } + }; + + class Proxy + { + public: + virtual const std::type_info& type_info() const = 0; + virtual Proxy *clone() const = 0; + virtual void release() = 0; +#if !USE_ANY_AS_CONTAINER + virtual bool operator<(const Proxy&) const = 0; + virtual bool operator==(const Proxy&) const = 0; +#endif + }; + template<typename value_type> + class ProxyImpl : public Proxy + { + public: + ProxyImpl(const value_type &value) : mValue(value) { } + virtual const std::type_info &type_info() const { return typeid(value_type); } + virtual Proxy *clone() const { return new ProxyImpl(mValue); } + virtual void release() { Releaser<value_type>::release(mValue); } + +#if !USE_ANY_AS_CONTAINER + virtual bool operator<(const Proxy& rhs) const { return mValue < static_cast< const ProxyImpl<value_type>& >(rhs).mValue; } + virtual bool operator==(const Proxy& rhs) const { return mValue == static_cast< const ProxyImpl<value_type>& >(rhs).mValue; } +#endif + value_type mValue; + private: + ProxyImpl &operator=(const ProxyImpl&); + }; + +public: + +#if !USE_ANY_AS_CONTAINER + struct Comp + { + bool operator()(const Any& lhs, const Any& rhs) const { return *(lhs.mpProxy) < *(rhs.mpProxy); } + }; +#endif + + // Let's us use the stack instead of calling new every time we use Any + template<typename value_type> + class Temp + { + public: + Temp(const value_type& value) : mProxy(value) { mAny.assign(&mProxy); } + ~Temp() { mAny.assign(NULL); } + + Any& operator()(void) { return mAny; } + const Any& operator()(void) const { return mAny; } + + protected: + ProxyImpl<value_type> mProxy; + Any mAny; + }; + + +private: + Proxy *mpProxy; +}; + +template<typename value_type> +value_type& any_cast(Any &operand) { + return *operand.to_ptr<value_type>(); +} + +template<typename value_type> +const value_type& any_cast(const Any &operand) { + return *operand.to_ptr<value_type>(); +} + +class D3D11RendererResourceManager +{ +public: +#if USE_ANY_AS_CONTAINER + typedef Any CacheType; +#else + typedef std::map<Any, Any, Any::Comp> CacheType; +#endif + D3D11RendererResourceManager() + { +#if USE_ANY_AS_CONTAINER + mResources[D3DTraits<ID3D11VertexShader>::getType()] = + std::map< typename D3DTraits<ID3D11VertexShader>::key_type, typename D3DTraits<ID3D11VertexShader>::value_type >(); + mResources[D3DTraits<ID3D11PixelShader>::getType()] = + std::map< typename D3DTraits<ID3D11PixelShader>::key_type, typename D3DTraits<ID3D11PixelShader>::value_type >(); + mResources[D3DTraits<ID3D11GeometryShader>::getType()] = + std::map< typename D3DTraits<ID3D11GeometryShader>::key_type, typename D3DTraits<ID3D11GeometryShader>::value_type >(); + mResources[D3DTraits<ID3D11HullShader>::getType()] = + std::map< typename D3DTraits<ID3D11HullShader>::key_type, typename D3DTraits<ID3D11HullShader>::value_type >(); + mResources[D3DTraits<ID3D11DomainShader>::getType()] = + std::map< typename D3DTraits<ID3D11DomainShader>::key_type, typename D3DTraits<ID3D11DomainShader>::value_type >(); + mResources[D3DTraits<ID3D11InputLayout>::getType()] = + std::map< typename D3DTraits<ID3D11InputLayout>::key_type, typename D3DTraits<ID3D11InputLayout>::value_type >(); + mResources[D3DTraits<ID3D11RasterizerState>::getType()] = + std::map< typename D3DTraits<ID3D11RasterizerState>::key_type, typename D3DTraits<ID3D11RasterizerState>::value_type >(); + mResources[D3DTraits<ID3D11DepthStencilState>::getType()] = + std::map< typename D3DTraits<ID3D11DepthStencilState>::key_type, typename D3DTraits<ID3D11DepthStencilState>::value_type >(); + mResources[D3DTraits<ID3D11BlendState>::getType()] = + std::map< typename D3DTraits<ID3D11BlendState>::key_type, typename D3DTraits<ID3D11BlendState>::value_type >(); +#endif + } + ~D3D11RendererResourceManager() + { +#if USE_ANY_AS_CONTAINER + for (PxU32 i = 0; i < D3DTypes::NUM_TYPES; ++i) + { + mResources[i].release(); + } +#else + for (PxU32 i = 0; i < D3DTypes::NUM_TYPES; ++i) + { + for (CacheType::iterator it = mResources[i].begin(); + it != mResources[i].end(); + ++it) + { + it->second.release(); + } + } +#endif + } + +public: + + template<typename d3d_type> + typename D3DTraits<d3d_type>::value_type + hasResource(const typename D3DTraits<d3d_type>::key_type& key) + { + typedef typename D3DTraits<d3d_type>::key_type key_type; + typedef typename D3DTraits<d3d_type>::value_type value_type; + typedef std::map<key_type,value_type> cache_type; + static const int resourceID = D3DTraits<d3d_type>::getType(); + RENDERER_ASSERT(resourceID != D3DTypes::INVALID, "Invalid D3D resource type"); +#if USE_ANY_AS_CONTAINER + RENDERER_ASSERT(!(mResources[resourceID] == Any()), "Invalid D3D resource container"); + cache_type& resources = any_cast< cache_type >(mResources[resourceID]); + typename cache_type::iterator it = resources.find(key); + return (it != resources.end()) ? it->second : NullTraits<value_type>::get(); +#else + Any::Temp<key_type> tempAny(key); + typename CacheType::iterator it = mResources[resourceID].find(tempAny()); + return (it != mResources[resourceID].end()) ? any_cast<value_type>(it->second) : NullTraits<value_type>::get(); +#endif + } + + template<typename d3d_type> + const typename D3DTraits<d3d_type>::value_type + hasResource(const typename D3DTraits<d3d_type>::key_type& key) const + { + typedef typename D3DTraits<d3d_type>::key_type key_type; + typedef typename D3DTraits<d3d_type>::value_type value_type; + typedef std::map<key_type,value_type> cache_type; + static const int resourceID = D3DTraits<d3d_type>::getType(); + RENDERER_ASSERT(resourceID != D3DTypes::INVALID, "Invalid D3D resource type"); +#if USE_ANY_AS_CONTAINER + RENDERER_ASSERT(!(mResources[resourceID] == Any()), "Invalid D3D resource container"); + const cache_type& resources = any_cast< cache_type >(mResources[resourceID]); + typename cache_type::const_iterator it = resources.find(key); + return (it != resources.end()) ? it->second : NullTraits<value_type>::get(); +#else + Any::Temp<key_type> tempAny(key); + typename CacheType::iterator it = mResources[resourceID].find(tempAny()); + return (it != mResources[resourceID].end()) ? any_cast<value_type>(it->second) : NullTraits<value_type>::get(); +#endif + } + + template<typename d3d_type> + void registerResource(const typename D3DTraits<d3d_type>::key_type& key, + const typename D3DTraits<d3d_type>::value_type& value) + { + typedef typename D3DTraits<d3d_type>::key_type key_type; + typedef typename D3DTraits<d3d_type>::value_type value_type; + typedef std::map<key_type,value_type> cache_type; + static const int resourceID = D3DTraits<d3d_type>::getType(); + RENDERER_ASSERT(resourceID != D3DTypes::INVALID, "Invalid D3D resource type"); +#if USE_ANY_AS_CONTAINER + RENDERER_ASSERT(!(mResources[resourceID] == Any()), "Invalid D3D resource container"); + cache_type& resources = any_cast< cache_type >(mResources[resourceID]); + //resources[key] = value; + resources.insert(std::make_pair(key, value)); +#else + Any::Temp<key_type> tempAny(key); + //mResources[resourceID][ tempAny() ] = value; + mResources[resourceID].insert(std::make_pair(tempAny(), value)); +#endif + } + +private: + CacheType mResources[D3DTypes::NUM_TYPES]; +}; + +} // namespace SampleRenderer + +#endif // #if defined(RENDERER_ENABLE_DIRECT3D11) + +#endif diff --git a/PhysX_3.4/Samples/SampleFramework/renderer/src/d3d11/D3D11RendererSpotLight.cpp b/PhysX_3.4/Samples/SampleFramework/renderer/src/d3d11/D3D11RendererSpotLight.cpp new file mode 100644 index 00000000..a2e47ae5 --- /dev/null +++ b/PhysX_3.4/Samples/SampleFramework/renderer/src/d3d11/D3D11RendererSpotLight.cpp @@ -0,0 +1,69 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved. + +#include <RendererConfig.h> + +#if defined(RENDERER_ENABLE_DIRECT3D11) + +#include "D3D11RendererSpotLight.h" +#include "D3D11RendererTexture2D.h" + +using namespace SampleRenderer; + +D3D11RendererSpotLight::D3D11RendererSpotLight(D3D11Renderer& renderer, const RendererSpotLightDesc& desc) : + RendererSpotLight(desc), + m_renderer(renderer) +{ + +} + +D3D11RendererSpotLight::~D3D11RendererSpotLight(void) +{ + +} + +void D3D11RendererSpotLight::bind(PxU32 lightIndex) const +{ + if (lightIndex < RENDERER_MAX_LIGHTS) + { + D3D11Renderer::D3D11ShaderEnvironment& shaderEnv = m_renderer.getShaderEnvironment(); + convertToD3D11(shaderEnv.lightColor[lightIndex], m_color); + shaderEnv.lightPosition[lightIndex] = m_position; + shaderEnv.lightDirection[lightIndex] = m_direction; + shaderEnv.lightIntensity[lightIndex] = m_intensity; + shaderEnv.lightInnerRadius[lightIndex] = m_innerRadius; + shaderEnv.lightOuterRadius[lightIndex] = m_outerRadius; + shaderEnv.lightInnerCone[lightIndex] = m_innerCone; + shaderEnv.lightOuterCone[lightIndex] = m_outerCone; + shaderEnv.lightType[lightIndex] = RendererMaterial::PASS_SPOT_LIGHT; + shaderEnv.lightShadowMap = m_shadowMap ? static_cast<D3D11RendererTexture2D*>(m_shadowMap) : NULL; + buildProjectMatrix(&shaderEnv.lightShadowMatrix.column0.x, m_shadowProjection, m_shadowTransform); + shaderEnv.bindLight(lightIndex); + } +} + +#endif // #if defined(RENDERER_ENABLE_DIRECT3D11) diff --git a/PhysX_3.4/Samples/SampleFramework/renderer/src/d3d11/D3D11RendererSpotLight.h b/PhysX_3.4/Samples/SampleFramework/renderer/src/d3d11/D3D11RendererSpotLight.h new file mode 100644 index 00000000..ed835ada --- /dev/null +++ b/PhysX_3.4/Samples/SampleFramework/renderer/src/d3d11/D3D11RendererSpotLight.h @@ -0,0 +1,57 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved. +#ifndef D3D11_RENDERER_SPOT_LIGHT_H +#define D3D11_RENDERER_SPOT_LIGHT_H + +#include <RendererConfig.h> + +#if defined(RENDERER_ENABLE_DIRECT3D11) + +#include <RendererSpotLight.h> + +#include "D3D11Renderer.h" + +namespace SampleRenderer +{ + +class D3D11RendererSpotLight : public RendererSpotLight +{ +public: + D3D11RendererSpotLight(D3D11Renderer& renderer, const RendererSpotLightDesc& desc); + virtual ~D3D11RendererSpotLight(void); + + virtual void bind(void) const { bind(0); } + virtual void bind(PxU32 lightIndex) const; + +private: + D3D11Renderer& m_renderer; +}; + +} // namespace SampleRenderer + +#endif // #if defined(RENDERER_ENABLE_DIRECT3D11) +#endif diff --git a/PhysX_3.4/Samples/SampleFramework/renderer/src/d3d11/D3D11RendererTarget.cpp b/PhysX_3.4/Samples/SampleFramework/renderer/src/d3d11/D3D11RendererTarget.cpp new file mode 100644 index 00000000..60627b1b --- /dev/null +++ b/PhysX_3.4/Samples/SampleFramework/renderer/src/d3d11/D3D11RendererTarget.cpp @@ -0,0 +1,151 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved. + +#include <RendererConfig.h> +#include "D3D11RendererTarget.h" + +#if defined(RENDERER_ENABLE_DIRECT3D11) && defined(RENDERER_ENABLE_DIRECT3D11_TARGET) + +#include <RendererTargetDesc.h> +#include "D3D11RendererTexture2D.h" +#include "D3D11RendererMemoryMacros.h" + +using namespace SampleRenderer; + +D3D11RendererTarget::D3D11RendererTarget(ID3D11Device& d3dDevice, ID3D11DeviceContext& d3dDeviceContext, const RendererTargetDesc& desc) : + m_d3dDevice(d3dDevice), + m_d3dDeviceContext(d3dDeviceContext), + m_depthStencilSurface(NULL), + m_d3dDSV(NULL), + m_d3dLastDSV(NULL), + m_d3dRS(NULL), + m_d3dLastRS(NULL) +{ + for (PxU32 i = 0; i < desc.numTextures; i++) + { + D3D11RendererTexture2D& texture = *static_cast<D3D11RendererTexture2D*>(desc.textures[i]); + m_textures.push_back(&texture); + RENDERER_ASSERT(texture.m_d3dRTV, "Invalid render target specification"); + if (texture.m_d3dRTV) + { + m_d3dRTVs.push_back(texture.m_d3dRTV); + } + } + m_depthStencilSurface = static_cast<D3D11RendererTexture2D*>(desc.depthStencilSurface); + RENDERER_ASSERT(m_depthStencilSurface && m_depthStencilSurface->m_d3dTexture, "Invalid Target Depth Stencil Surface!"); + m_d3dDSV = m_depthStencilSurface->m_d3dDSV; + onDeviceReset(); +} + +D3D11RendererTarget::~D3D11RendererTarget(void) +{ + dxSafeRelease(m_d3dRS); +} + +void D3D11RendererTarget::bind(void) +{ + RENDERER_ASSERT(m_d3dRS && m_d3dLastDSV == NULL && m_d3dLastRTVs.size() == 0, "Render target in a bad state"); + if (m_d3dRS && !m_d3dLastDSV && m_d3dLastRTVs.size() == 0) + { + m_d3dLastRTVs.resize(D3D11_SIMULTANEOUS_RENDER_TARGET_COUNT, NULL); + m_d3dLastDSV = NULL; + + m_d3dDeviceContext.OMGetRenderTargets(D3D11_SIMULTANEOUS_RENDER_TARGET_COUNT, + &m_d3dLastRTVs[0], + &m_d3dLastDSV); + m_d3dDeviceContext.RSGetState(&m_d3dLastRS); + + static const PxF32 black[4] = {0.f, 0.f, 0.f, 0.f}; + for (PxU32 i = 0; i < m_d3dRTVs.size(); ++i) + { + m_d3dDeviceContext.ClearRenderTargetView(m_d3dRTVs[i], black); + } + m_d3dDeviceContext.ClearDepthStencilView(m_d3dDSV, D3D11_CLEAR_DEPTH | D3D11_CLEAR_STENCIL, 1., 0); + + m_d3dDeviceContext.OMSetRenderTargets((UINT)m_d3dRTVs.size(), &m_d3dRTVs[0], m_d3dDSV); + m_d3dDeviceContext.RSSetState(m_d3dRS); + } +} + +void D3D11RendererTarget::unbind(void) +{ + RENDERER_ASSERT(m_d3dLastDSV && m_d3dLastRTVs.size() > 0, "Render Target in a bad state."); + if (m_d3dLastDSV && m_d3dLastRTVs.size() > 0) + { + m_d3dDeviceContext.OMSetRenderTargets((UINT)m_d3dLastRTVs.size(), &m_d3dLastRTVs[0], m_d3dLastDSV); + for (PxU32 i = 0; i < m_d3dLastRTVs.size(); ++i) + { + dxSafeRelease(m_d3dLastRTVs[i]); + } + m_d3dLastRTVs.clear(); + dxSafeRelease(m_d3dLastDSV); + } + if (m_d3dLastRS) + { + m_d3dDeviceContext.RSSetState(m_d3dLastRS); + dxSafeRelease(m_d3dLastRS); + } +} + +void D3D11RendererTarget::onDeviceLost(void) +{ + RENDERER_ASSERT(m_d3dLastRS == NULL, "Render Target in bad state!"); + RENDERER_ASSERT(m_d3dRS, "Render Target in bad state!"); + dxSafeRelease(m_d3dRS); +} + +void D3D11RendererTarget::onDeviceReset(void) +{ + RENDERER_ASSERT(m_d3dRS == NULL, "Render Target in a bad state!"); + if (!m_d3dRS) + { + D3D11_RASTERIZER_DESC rasterizerDesc = + { + D3D11_FILL_SOLID, // D3D11_FILL_MODE FillMode; + D3D11_CULL_NONE, // D3D11_CULL_MODE CullMode; + FALSE, // BOOL FrontCounterClockwise; + 0, // INT DepthBias; + 0, // FLOAT DepthBiasClamp; + 1.0, // FLOAT SlopeScaledDepthBias; + TRUE, // BOOL DepthClipEnable; + FALSE, // BOOL ScissorEnable; + TRUE, // BOOL MultisampleEnable; + FALSE, // BOOL AntialiasedLineEnable; + }; + + //float depthBias = 0.0001f; + //float biasSlope = 1.58f; +#if RENDERER_ENABLE_DRESSCODE + //depthBias = dcParam("depthBias", depthBias, 0.0f, 0.01f); + //biasSlope = dcParam("biasSlope", biasSlope, 0.0f, 5.0f); +#endif + + m_d3dDevice.CreateRasterizerState(&rasterizerDesc, &m_d3dRS); + } +} + +#endif //#if defined(RENDERER_ENABLE_DIRECT3D11) && defined(RENDERER_ENABLE_DIRECT3D11_TARGET) diff --git a/PhysX_3.4/Samples/SampleFramework/renderer/src/d3d11/D3D11RendererTarget.h b/PhysX_3.4/Samples/SampleFramework/renderer/src/d3d11/D3D11RendererTarget.h new file mode 100644 index 00000000..efa8bd53 --- /dev/null +++ b/PhysX_3.4/Samples/SampleFramework/renderer/src/d3d11/D3D11RendererTarget.h @@ -0,0 +1,80 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved. +#ifndef D3D11_RENDERER_TARGET_H +#define D3D11_RENDERER_TARGET_H + +#include <RendererConfig.h> + +#if defined(RENDERER_WINDOWS) +#define RENDERER_ENABLE_DIRECT3D11_TARGET +#endif + +#if defined(RENDERER_ENABLE_DIRECT3D11) && defined(RENDERER_ENABLE_DIRECT3D11_TARGET) + +#include <RendererTarget.h> +#include "D3D11Renderer.h" + +namespace SampleRenderer +{ +class D3D11RendererTexture2D; + +class D3D11RendererTarget : public RendererTarget, public D3D11RendererResource +{ +public: + D3D11RendererTarget(ID3D11Device& d3dDevice, ID3D11DeviceContext& d3dDeviceContext, const RendererTargetDesc& desc); + virtual ~D3D11RendererTarget(void); + +private: + D3D11RendererTarget& operator=(const D3D11RendererTarget&) {} + virtual void bind(void); + virtual void unbind(void); + +private: + virtual void onDeviceLost(void); + virtual void onDeviceReset(void); + +private: + ID3D11Device& m_d3dDevice; + ID3D11DeviceContext& m_d3dDeviceContext; + + std::vector<D3D11RendererTexture2D*> m_textures; + D3D11RendererTexture2D* m_depthStencilSurface; + + std::vector<ID3D11RenderTargetView*> m_d3dRTVs; + std::vector<ID3D11RenderTargetView*> m_d3dLastRTVs; + + ID3D11DepthStencilView* m_d3dDSV; + ID3D11DepthStencilView* m_d3dLastDSV; + + ID3D11RasterizerState* m_d3dRS; + ID3D11RasterizerState* m_d3dLastRS; +}; + +} // namespace SampleRenderer + +#endif // #if defined(RENDERER_ENABLE_DIRECT3D11) && defined(RENDERER_ENABLE_DIRECT3D11_TARGET) +#endif diff --git a/PhysX_3.4/Samples/SampleFramework/renderer/src/d3d11/D3D11RendererTexture2D.cpp b/PhysX_3.4/Samples/SampleFramework/renderer/src/d3d11/D3D11RendererTexture2D.cpp new file mode 100644 index 00000000..e96b8959 --- /dev/null +++ b/PhysX_3.4/Samples/SampleFramework/renderer/src/d3d11/D3D11RendererTexture2D.cpp @@ -0,0 +1,300 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved. + +#include <RendererConfig.h> + +#if defined(RENDERER_ENABLE_DIRECT3D11) + +#include "D3D11RendererTexture2D.h" +#include "D3D11RendererMemoryMacros.h" + +#include <RendererTexture2DDesc.h> + +using namespace SampleRenderer; + +D3D11RendererTexture2D::D3D11RendererTexture2D(ID3D11Device& d3dDevice, ID3D11DeviceContext& d3dDeviceContext, const RendererTexture2DDesc& desc) : + RendererTexture2D(desc), + m_d3dDevice(d3dDevice), + m_d3dDeviceContext(d3dDeviceContext), + m_d3dTexture(NULL), + m_d3dSamplerState(NULL), + m_d3dSRV(NULL), + m_d3dRTV(NULL), + m_d3dDSV(NULL) +{ + loadTextureDesc(desc); + onDeviceReset(); +} + +D3D11RendererTexture2D::~D3D11RendererTexture2D(void) +{ + dxSafeRelease(m_d3dTexture); + dxSafeRelease(m_d3dSamplerState); + dxSafeRelease(m_d3dSRV); + dxSafeRelease(m_d3dRTV); + dxSafeRelease(m_d3dDSV); + + if (m_data) + { + for (PxU32 i = 0; i < getNumLevels(); i++) + { + delete [] m_data[i]; + } + delete [] m_data; + } + if (m_resourceData) + { + delete [] m_resourceData; + } +} + +void* D3D11RendererTexture2D::lockLevel(PxU32 level, PxU32& pitch) +{ + void* buffer = 0; + RENDERER_ASSERT(level < getNumLevels(), "Level out of range!"); + if (level < getNumLevels()) + { + buffer = m_data[level]; + pitch = getFormatNumBlocks(getWidth() >> level, getFormat()) * getBlockSize(); + } + return buffer; +} + +void D3D11RendererTexture2D::unlockLevel(PxU32 level) +{ + RENDERER_ASSERT(level < getNumLevels(), "Level out of range!"); + + if (m_d3dTexture && level < getNumLevels()) + { + PxU32 w = getLevelDimension(getWidth(), level); + PxU32 h = getLevelDimension(getHeight(), level); + m_d3dDeviceContext.UpdateSubresource(m_d3dTexture, + level, + NULL, + m_data[level], + getFormatNumBlocks(w, getFormat()) * getBlockSize(), + computeImageByteSize(w, h, 1, getFormat())); + } +} + +void D3D11RendererTexture2D::bind(PxU32 samplerIndex, PxU32 flags) +{ + if (flags) + { + if (m_d3dSRV) + { + if (flags & BIND_VERTEX) + m_d3dDeviceContext.VSSetShaderResources(samplerIndex, 1, &m_d3dSRV); + if (flags & BIND_GEOMETRY) + m_d3dDeviceContext.GSSetShaderResources(samplerIndex, 1, &m_d3dSRV); + if (flags & BIND_PIXEL) + m_d3dDeviceContext.PSSetShaderResources(samplerIndex, 1, &m_d3dSRV); + if (flags & BIND_HULL) + m_d3dDeviceContext.HSSetShaderResources(samplerIndex, 1, &m_d3dSRV); + if (flags & BIND_DOMAIN) + m_d3dDeviceContext.DSSetShaderResources(samplerIndex, 1, &m_d3dSRV); + } + if (m_d3dSamplerState) + { + if (flags & BIND_VERTEX) + m_d3dDeviceContext.VSSetSamplers(samplerIndex, 1, &m_d3dSamplerState); + if (flags & BIND_GEOMETRY) + m_d3dDeviceContext.GSSetSamplers(samplerIndex, 1, &m_d3dSamplerState); + if (flags & BIND_PIXEL) + m_d3dDeviceContext.PSSetSamplers(samplerIndex, 1, &m_d3dSamplerState); + if (flags & BIND_HULL) + m_d3dDeviceContext.HSSetSamplers(samplerIndex, 1, &m_d3dSamplerState); + if (flags & BIND_DOMAIN) + m_d3dDeviceContext.DSSetSamplers(samplerIndex, 1, &m_d3dSamplerState); + } + } + else + { + ID3D11ShaderResourceView* nullResources[] = { NULL }; + m_d3dDeviceContext.VSSetShaderResources(samplerIndex, 1, nullResources); + m_d3dDeviceContext.GSSetShaderResources(samplerIndex, 1, nullResources); + m_d3dDeviceContext.PSSetShaderResources(samplerIndex, 1, nullResources); + m_d3dDeviceContext.HSSetShaderResources(samplerIndex, 1, nullResources); + m_d3dDeviceContext.DSSetShaderResources(samplerIndex, 1, nullResources); + ID3D11SamplerState* nullSamplers[] = { NULL }; + m_d3dDeviceContext.VSSetSamplers(samplerIndex, 1, nullSamplers); + m_d3dDeviceContext.GSSetSamplers(samplerIndex, 1, nullSamplers); + m_d3dDeviceContext.PSSetSamplers(samplerIndex, 1, nullSamplers); + m_d3dDeviceContext.HSSetSamplers(samplerIndex, 1, nullSamplers); + m_d3dDeviceContext.DSSetSamplers(samplerIndex, 1, nullSamplers); + } +} + +void D3D11RendererTexture2D::onDeviceLost(void) +{ + dxSafeRelease(m_d3dTexture); + dxSafeRelease(m_d3dSamplerState); + dxSafeRelease(m_d3dSRV); + dxSafeRelease(m_d3dRTV); + dxSafeRelease(m_d3dDSV); +} + +void D3D11RendererTexture2D::onDeviceReset(void) +{ + HRESULT result = S_OK; + if (!m_d3dTexture) + { + D3D11_SUBRESOURCE_DATA* pData = isDepthStencilFormat(getFormat()) ? NULL : m_resourceData; + result = m_d3dDevice.CreateTexture2D(&m_d3dTextureDesc, pData, &m_d3dTexture); + RENDERER_ASSERT(SUCCEEDED(result), "Unable to create D3D11 Texture."); + } + if (SUCCEEDED(result) && !m_d3dSamplerState) + { + result = m_d3dDevice.CreateSamplerState(&m_d3dSamplerDesc, &m_d3dSamplerState); + RENDERER_ASSERT(SUCCEEDED(result), "Unable to create D3D11 Sampler."); + } + if (SUCCEEDED(result) && m_d3dTextureDesc.BindFlags & D3D11_BIND_SHADER_RESOURCE && !m_d3dSRV) + { + result = m_d3dDevice.CreateShaderResourceView(m_d3dTexture, &m_d3dSRVDesc, &m_d3dSRV); + RENDERER_ASSERT(SUCCEEDED(result), "Unable to create D3D11 Shader Resource View."); + } + if (SUCCEEDED(result) && m_d3dTextureDesc.BindFlags & D3D11_BIND_RENDER_TARGET && !m_d3dRTV) + { + result = m_d3dDevice.CreateRenderTargetView(m_d3dTexture, &m_d3dRTVDesc, &m_d3dRTV); + RENDERER_ASSERT(SUCCEEDED(result), "Unable to create D3D11 Render Target View."); + } + if (SUCCEEDED(result) && m_d3dTextureDesc.BindFlags & D3D11_BIND_DEPTH_STENCIL && !m_d3dDSV) + { + result = m_d3dDevice.CreateDepthStencilView(m_d3dTexture, &m_d3dDSVDesc, &m_d3dDSV); + RENDERER_ASSERT(SUCCEEDED(result), "Unable to create D3D11 Depth Stencil View."); + } +} + + +void D3D11RendererTexture2D::loadTextureDesc(const RendererTexture2DDesc& desc) +{ + RENDERER_ASSERT(desc.depth == 1, "Invalid depth for 2D Texture!"); + + //memset(&m_d3dTextureDesc, 0, sizeof(m_d3dTextureDesc)); + m_d3dTextureDesc = D3D11_TEXTURE2D_DESC(); + m_d3dTextureDesc.Width = getWidth(); + m_d3dTextureDesc.Height = getHeight(); + m_d3dTextureDesc.MipLevels = getNumLevels(); + m_d3dTextureDesc.ArraySize = 1; + m_d3dTextureDesc.Format = getD3D11TextureFormat(desc.format); + m_d3dTextureDesc.SampleDesc.Count = 1; + m_d3dTextureDesc.SampleDesc.Quality = 0; + m_d3dTextureDesc.CPUAccessFlags = 0; + m_d3dTextureDesc.Usage = D3D11_USAGE_DEFAULT; + m_d3dTextureDesc.BindFlags = D3D11_BIND_SHADER_RESOURCE; + + loadResourceDesc(desc); + + if (isDepthStencilFormat(desc.format)) + { + m_d3dTextureDesc.BindFlags |= D3D11_BIND_DEPTH_STENCIL; + m_d3dTextureDesc.CPUAccessFlags = 0; + m_d3dTextureDesc.Usage = D3D11_USAGE_DEFAULT; + loadDepthStencilDesc(desc); + } + else if (desc.renderTarget) + { + m_d3dTextureDesc.BindFlags |= D3D11_BIND_RENDER_TARGET; + m_d3dTextureDesc.CPUAccessFlags = 0; + m_d3dTextureDesc.Usage = D3D11_USAGE_DEFAULT; + loadTargetDesc(desc); + } + + loadSamplerDesc(desc); + + //if (m_d3dTextureDesc.CPUAccessFlags) + { + m_data = new PxU8*[getNumLevels()]; + m_resourceData = new D3D11_SUBRESOURCE_DATA[getNumLevels()]; + memset(m_data, 0, sizeof(PxU8)*getNumLevels()); + memset(m_resourceData, 0, sizeof(D3D11_SUBRESOURCE_DATA)*getNumLevels()); + + for (PxU32 i = 0; i < desc.numLevels; i++) + { + PxU32 w = getLevelDimension(getWidth(), i); + PxU32 h = getLevelDimension(getHeight(), i); + PxU32 levelSize = computeImageByteSize(w, h, 1, desc.format); + m_data[i] = new PxU8[levelSize]; + memset(m_data[i], 0, levelSize); + m_resourceData[i].pSysMem = m_data[i]; + m_resourceData[i].SysMemPitch = levelSize / h; + m_resourceData[i].SysMemSlicePitch = 0; + } + } +} + +void D3D11RendererTexture2D::loadSamplerDesc(const RendererTexture2DDesc& desc) +{ + m_d3dSamplerDesc.Filter = getD3D11TextureFilter(desc.filter); + m_d3dSamplerDesc.AddressU = getD3D11TextureAddressing(desc.addressingU); + m_d3dSamplerDesc.AddressV = getD3D11TextureAddressing(desc.addressingV); + m_d3dSamplerDesc.AddressW = getD3D11TextureAddressing(desc.addressingW); + m_d3dSamplerDesc.MipLODBias = 0.f; + m_d3dSamplerDesc.MaxAnisotropy = 1; + m_d3dSamplerDesc.ComparisonFunc = D3D11_COMPARISON_ALWAYS; + m_d3dSamplerDesc.BorderColor[0] = m_d3dSamplerDesc.BorderColor[1] = m_d3dSamplerDesc.BorderColor[2] = m_d3dSamplerDesc.BorderColor[3] = 0.; + m_d3dSamplerDesc.MinLOD = 0; + if (desc.numLevels <= 1) + { + m_d3dSamplerDesc.MaxLOD = 0.; + } + else + { + m_d3dSamplerDesc.MaxLOD = D3D11_FLOAT32_MAX; + } + if(m_d3dDevice.GetFeatureLevel() <= D3D_FEATURE_LEVEL_9_3) + { + m_d3dSamplerDesc.MaxLOD = D3D11_FLOAT32_MAX; + } +} + +void D3D11RendererTexture2D::loadResourceDesc(const RendererTexture2DDesc& desc) +{ + m_d3dSRVDesc.Format = (m_d3dTextureDesc.Format == DXGI_FORMAT_R16_TYPELESS) ? DXGI_FORMAT_R16_UNORM : m_d3dTextureDesc.Format; + m_d3dSRVDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2D; + m_d3dSRVDesc.Texture2D.MipLevels = m_d3dTextureDesc.MipLevels; + m_d3dSRVDesc.Texture2D.MostDetailedMip = 0; + //m_d3dSRVDesc.Texture2D.MostDetailedMip = m_d3dTextureDesc.MipLevels-1; +} + +void D3D11RendererTexture2D::loadTargetDesc(const RendererTexture2DDesc& desc) +{ + m_d3dRTVDesc = D3D11_RENDER_TARGET_VIEW_DESC(); + m_d3dRTVDesc.Format = (m_d3dTextureDesc.Format == DXGI_FORMAT_R16_TYPELESS) ? DXGI_FORMAT_R16_UNORM : m_d3dTextureDesc.Format; + m_d3dRTVDesc.ViewDimension = D3D11_RTV_DIMENSION_TEXTURE2D; + m_d3dRTVDesc.Texture2D.MipSlice = 0; +} + +void D3D11RendererTexture2D::loadDepthStencilDesc(const RendererTexture2DDesc& desc) +{ + m_d3dDSVDesc = D3D11_DEPTH_STENCIL_VIEW_DESC(); + m_d3dDSVDesc.Format = (m_d3dTextureDesc.Format == DXGI_FORMAT_R16_TYPELESS) ? DXGI_FORMAT_D16_UNORM : m_d3dTextureDesc.Format; + m_d3dDSVDesc.ViewDimension = D3D11_DSV_DIMENSION_TEXTURE2D; + m_d3dDSVDesc.Texture2D.MipSlice = 0; +} + +#endif // #if defined(RENDERER_ENABLE_DIRECT3D11) diff --git a/PhysX_3.4/Samples/SampleFramework/renderer/src/d3d11/D3D11RendererTexture2D.h b/PhysX_3.4/Samples/SampleFramework/renderer/src/d3d11/D3D11RendererTexture2D.h new file mode 100644 index 00000000..89ac76b9 --- /dev/null +++ b/PhysX_3.4/Samples/SampleFramework/renderer/src/d3d11/D3D11RendererTexture2D.h @@ -0,0 +1,96 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved. +#ifndef D3D11_RENDERER_TEXTURE_2D_H +#define D3D11_RENDERER_TEXTURE_2D_H + +#include <RendererConfig.h> + +#if defined(RENDERER_ENABLE_DIRECT3D11) + +#include <RendererTexture2D.h> + +#include "D3D11Renderer.h" +#include "D3D11RendererTextureCommon.h" + +namespace SampleRenderer +{ + +class D3D11RendererTexture2D : public RendererTexture2D, public D3D11RendererResource +{ + friend class D3D11RendererTarget; + friend class D3D11RendererSpotLight; +public: + D3D11RendererTexture2D(ID3D11Device& d3dDevice, ID3D11DeviceContext& d3dDeviceContext, const RendererTexture2DDesc& desc); + virtual ~D3D11RendererTexture2D(void); + +public: + virtual void* lockLevel(PxU32 level, PxU32& pitch); + virtual void unlockLevel(PxU32 level); + + void bind(PxU32 samplerIndex, PxU32 flags = BIND_PIXEL); + + virtual void select(PxU32 stageIndex) + { + bind(stageIndex); + } + +private: + virtual void onDeviceLost(void); + virtual void onDeviceReset(void); + + void loadTextureDesc(const RendererTexture2DDesc&); + void loadSamplerDesc(const RendererTexture2DDesc&); + void loadResourceDesc(const RendererTexture2DDesc&); + void loadTargetDesc(const RendererTexture2DDesc&); + void loadDepthStencilDesc(const RendererTexture2DDesc&); + +private: + ID3D11Device& m_d3dDevice; + ID3D11DeviceContext& m_d3dDeviceContext; + ID3D11Texture2D* m_d3dTexture; + D3D11_TEXTURE2D_DESC m_d3dTextureDesc; + + ID3D11SamplerState* m_d3dSamplerState; + D3D11_SAMPLER_DESC m_d3dSamplerDesc; + + ID3D11ShaderResourceView* m_d3dSRV; + D3D11_SHADER_RESOURCE_VIEW_DESC m_d3dSRVDesc; + + ID3D11RenderTargetView* m_d3dRTV; + D3D11_RENDER_TARGET_VIEW_DESC m_d3dRTVDesc; + + ID3D11DepthStencilView* m_d3dDSV; + D3D11_DEPTH_STENCIL_VIEW_DESC m_d3dDSVDesc; + + PxU8** m_data; + D3D11_SUBRESOURCE_DATA* m_resourceData; +}; + +} // namespace SampleRenderer + +#endif // #if defined(RENDERER_ENABLE_DIRECT3D11) +#endif diff --git a/PhysX_3.4/Samples/SampleFramework/renderer/src/d3d11/D3D11RendererTexture3D.cpp b/PhysX_3.4/Samples/SampleFramework/renderer/src/d3d11/D3D11RendererTexture3D.cpp new file mode 100644 index 00000000..247340a3 --- /dev/null +++ b/PhysX_3.4/Samples/SampleFramework/renderer/src/d3d11/D3D11RendererTexture3D.cpp @@ -0,0 +1,247 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved. + +#include <RendererConfig.h> + +#if defined(RENDERER_ENABLE_DIRECT3D11) + +#include "D3D11RendererTexture3D.h" +#include "D3D11RendererMemoryMacros.h" +#include "D3D11RendererTextureCommon.h" + +#include <RendererTextureDesc.h> + +using namespace SampleRenderer; + +D3D11RendererTexture3D::D3D11RendererTexture3D(ID3D11Device& d3dDevice, ID3D11DeviceContext& d3dDeviceContext, const RendererTexture3DDesc& desc) : + RendererTexture3D(desc), + m_d3dDevice(d3dDevice), + m_d3dDeviceContext(d3dDeviceContext), + m_d3dTexture(NULL), + m_d3dSamplerState(NULL), + m_d3dSRV(NULL) +{ + loadTextureDesc(desc); + onDeviceReset(); +} + +D3D11RendererTexture3D::~D3D11RendererTexture3D(void) +{ + dxSafeRelease(m_d3dTexture); + dxSafeRelease(m_d3dSamplerState); + dxSafeRelease(m_d3dSRV); + + if (m_data) + { + for (PxU32 i = 0; i < getNumLevels(); i++) + { + delete [] m_data[i]; + } + delete [] m_data; + } + if (m_resourceData) + { + delete [] m_resourceData; + } +} + +void* D3D11RendererTexture3D::lockLevel(PxU32 level, PxU32& pitch) +{ + void* buffer = 0; + RENDERER_ASSERT(level < getNumLevels(), "Level out of range!"); + if (level < getNumLevels()) + { + buffer = m_data[level]; + pitch = getFormatNumBlocks(getWidth() >> level, getFormat()) * getBlockSize(); + } + return buffer; +} + +void D3D11RendererTexture3D::unlockLevel(PxU32 level) +{ + RENDERER_ASSERT(level < getNumLevels(), "Level out of range!"); + + if (m_d3dTexture && level < getNumLevels()) + { + PxU32 w = getLevelDimension(getWidth(), level); + PxU32 h = getLevelDimension(getHeight(), level); + m_d3dDeviceContext.UpdateSubresource(m_d3dTexture, + level, + NULL, + m_data[level], + getFormatNumBlocks(w, getFormat()) * getBlockSize(), + computeImageByteSize(w, h, 1, getFormat())); + } +} + +void D3D11RendererTexture3D::bind(PxU32 samplerIndex, PxU32 flags) +{ + if (flags) + { + if (m_d3dSRV) + { + if (flags & BIND_VERTEX) + m_d3dDeviceContext.VSSetShaderResources(samplerIndex, 1, &m_d3dSRV); + if (flags & BIND_GEOMETRY) + m_d3dDeviceContext.GSSetShaderResources(samplerIndex, 1, &m_d3dSRV); + if (flags & BIND_PIXEL) + m_d3dDeviceContext.PSSetShaderResources(samplerIndex, 1, &m_d3dSRV); + if (flags & BIND_HULL) + m_d3dDeviceContext.HSSetShaderResources(samplerIndex, 1, &m_d3dSRV); + if (flags & BIND_DOMAIN) + m_d3dDeviceContext.DSSetShaderResources(samplerIndex, 1, &m_d3dSRV); + } + if (m_d3dSamplerState) + { + if (flags & BIND_VERTEX) + m_d3dDeviceContext.VSSetSamplers(samplerIndex, 1, &m_d3dSamplerState); + if (flags & BIND_GEOMETRY) + m_d3dDeviceContext.GSSetSamplers(samplerIndex, 1, &m_d3dSamplerState); + if (flags & BIND_PIXEL) + m_d3dDeviceContext.PSSetSamplers(samplerIndex, 1, &m_d3dSamplerState); + if (flags & BIND_HULL) + m_d3dDeviceContext.HSSetSamplers(samplerIndex, 1, &m_d3dSamplerState); + if (flags & BIND_DOMAIN) + m_d3dDeviceContext.DSSetSamplers(samplerIndex, 1, &m_d3dSamplerState); + } + } + else + { + ID3D11ShaderResourceView* nullResources[] = { NULL }; + m_d3dDeviceContext.VSSetShaderResources(samplerIndex, 1, nullResources); + m_d3dDeviceContext.GSSetShaderResources(samplerIndex, 1, nullResources); + m_d3dDeviceContext.PSSetShaderResources(samplerIndex, 1, nullResources); + m_d3dDeviceContext.HSSetShaderResources(samplerIndex, 1, nullResources); + m_d3dDeviceContext.DSSetShaderResources(samplerIndex, 1, nullResources); + ID3D11SamplerState* nullSamplers[] = { NULL }; + m_d3dDeviceContext.VSSetSamplers(samplerIndex, 1, nullSamplers); + m_d3dDeviceContext.GSSetSamplers(samplerIndex, 1, nullSamplers); + m_d3dDeviceContext.PSSetSamplers(samplerIndex, 1, nullSamplers); + m_d3dDeviceContext.HSSetSamplers(samplerIndex, 1, nullSamplers); + m_d3dDeviceContext.DSSetSamplers(samplerIndex, 1, nullSamplers); + } +} + +void D3D11RendererTexture3D::onDeviceLost(void) +{ + dxSafeRelease(m_d3dTexture); + dxSafeRelease(m_d3dSamplerState); + dxSafeRelease(m_d3dSRV); +} + +void D3D11RendererTexture3D::onDeviceReset(void) +{ + HRESULT result = S_OK; + if (!m_d3dTexture) + { + D3D11_SUBRESOURCE_DATA* pData = isDepthStencilFormat(getFormat()) ? NULL : m_resourceData; + result = m_d3dDevice.CreateTexture3D(&m_d3dTextureDesc, pData, &m_d3dTexture); + RENDERER_ASSERT(SUCCEEDED(result), "Unable to create D3D11 Texture."); + } + if (SUCCEEDED(result) && !m_d3dSamplerState) + { + result = m_d3dDevice.CreateSamplerState(&m_d3dSamplerDesc, &m_d3dSamplerState); + RENDERER_ASSERT(SUCCEEDED(result), "Unable to create D3D11 Sampler."); + } + if (SUCCEEDED(result) && m_d3dTextureDesc.BindFlags & D3D11_BIND_SHADER_RESOURCE && !m_d3dSRV) + { + result = m_d3dDevice.CreateShaderResourceView(m_d3dTexture, &m_d3dSRVDesc, &m_d3dSRV); + RENDERER_ASSERT(SUCCEEDED(result), "Unable to create D3D11 Shader Resource View."); + } + RENDERER_ASSERT((m_d3dTextureDesc.BindFlags & D3D11_BIND_RENDER_TARGET) == 0, "D3D11 3D Texture cannot be bound as render target."); + RENDERER_ASSERT((m_d3dTextureDesc.BindFlags & D3D11_BIND_DEPTH_STENCIL) == 0, "D3D11 3D Texture cannot be bound as depth stencil."); +} + + +void D3D11RendererTexture3D::loadTextureDesc(const RendererTexture3DDesc& desc) +{ + //memset(&m_d3dTextureDesc, 0, sizeof(m_d3dTextureDesc)); + m_d3dTextureDesc = D3D11_TEXTURE3D_DESC(); + m_d3dTextureDesc.Width = getWidth(); + m_d3dTextureDesc.Height = getHeight(); + m_d3dTextureDesc.Depth = getDepth(); + m_d3dTextureDesc.MipLevels = getNumLevels(); + m_d3dTextureDesc.Format = getD3D11TextureFormat(desc.format); + m_d3dTextureDesc.CPUAccessFlags = 0; + m_d3dTextureDesc.Usage = D3D11_USAGE_DEFAULT; + m_d3dTextureDesc.BindFlags = D3D11_BIND_SHADER_RESOURCE; + + loadResourceDesc(desc); + + loadSamplerDesc(desc); + + { + m_data = new PxU8*[getNumLevels()]; + m_resourceData = new D3D11_SUBRESOURCE_DATA[getNumLevels()]; + memset(m_data, 0, sizeof(PxU8)*getNumLevels()); + memset(m_resourceData, 0, sizeof(D3D11_SUBRESOURCE_DATA)*getNumLevels()); + + for (PxU32 i = 0; i < desc.numLevels; i++) + { + PxU32 w = getLevelDimension(getWidth(), i); + PxU32 h = getLevelDimension(getHeight(), i); + PxU32 d = getLevelDimension(getDepth(), i); + PxU32 levelSize = computeImageByteSize(w, h, d, desc.format); + m_data[i] = new PxU8[levelSize]; + memset(m_data[i], 0, levelSize); + m_resourceData[i].pSysMem = m_data[i]; + m_resourceData[i].SysMemPitch = levelSize / d / h; + m_resourceData[i].SysMemSlicePitch = levelSize / d; + } + } +} + +void D3D11RendererTexture3D::loadSamplerDesc(const RendererTexture3DDesc& desc) +{ + m_d3dSamplerDesc.Filter = getD3D11TextureFilter(desc.filter); + m_d3dSamplerDesc.AddressU = getD3D11TextureAddressing(desc.addressingU); + m_d3dSamplerDesc.AddressV = getD3D11TextureAddressing(desc.addressingV); + m_d3dSamplerDesc.AddressW = getD3D11TextureAddressing(desc.addressingW); + m_d3dSamplerDesc.MipLODBias = 0.f; + m_d3dSamplerDesc.MaxAnisotropy = 1; + m_d3dSamplerDesc.ComparisonFunc = D3D11_COMPARISON_ALWAYS; + m_d3dSamplerDesc.BorderColor[0] = m_d3dSamplerDesc.BorderColor[1] = m_d3dSamplerDesc.BorderColor[2] = m_d3dSamplerDesc.BorderColor[3] = 0.; + m_d3dSamplerDesc.MinLOD = 0; + if (desc.numLevels <= 1) + { + m_d3dSamplerDesc.MaxLOD = 0.; + } + else + { + m_d3dSamplerDesc.MaxLOD = D3D11_FLOAT32_MAX; + } +} + +void D3D11RendererTexture3D::loadResourceDesc(const RendererTexture3DDesc& desc) +{ + m_d3dSRVDesc.Format = (m_d3dTextureDesc.Format == DXGI_FORMAT_R16_TYPELESS) ? DXGI_FORMAT_R16_UNORM : m_d3dTextureDesc.Format; + m_d3dSRVDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE3D; + m_d3dSRVDesc.Texture3D.MipLevels = m_d3dTextureDesc.MipLevels; + m_d3dSRVDesc.Texture3D.MostDetailedMip = 0; +} + +#endif // #if defined(RENDERER_ENABLE_DIRECT3D11) diff --git a/PhysX_3.4/Samples/SampleFramework/renderer/src/d3d11/D3D11RendererTexture3D.h b/PhysX_3.4/Samples/SampleFramework/renderer/src/d3d11/D3D11RendererTexture3D.h new file mode 100644 index 00000000..fa19382a --- /dev/null +++ b/PhysX_3.4/Samples/SampleFramework/renderer/src/d3d11/D3D11RendererTexture3D.h @@ -0,0 +1,88 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved. +#ifndef D3D11_RENDERER_TEXTURE_3D_H +#define D3D11_RENDERER_TEXTURE_3D_H + +#include <RendererConfig.h> + +#if defined(RENDERER_ENABLE_DIRECT3D11) + +#include <RendererTexture.h> + +#include "D3D11Renderer.h" +#include "D3D11RendererTextureCommon.h" + +namespace SampleRenderer +{ + +class D3D11RendererTexture3D : public RendererTexture3D, public D3D11RendererResource +{ + friend class D3D11RendererTarget; + friend class D3D11RendererSpotLight; +public: + D3D11RendererTexture3D(ID3D11Device& d3dDevice, ID3D11DeviceContext& d3dDeviceContext, const RendererTexture3DDesc& desc); + virtual ~D3D11RendererTexture3D(void); + +public: + virtual void* lockLevel(PxU32 level, PxU32& pitch); + virtual void unlockLevel(PxU32 level); + + void bind(PxU32 samplerIndex, PxU32 flags = BIND_PIXEL); + + virtual void select(PxU32 stageIndex) + { + bind(stageIndex); + } + +private: + virtual void onDeviceLost(void); + virtual void onDeviceReset(void); + + void loadTextureDesc(const RendererTexture3DDesc&); + void loadSamplerDesc(const RendererTexture3DDesc&); + void loadResourceDesc(const RendererTexture3DDesc&); + +private: + ID3D11Device& m_d3dDevice; + ID3D11DeviceContext& m_d3dDeviceContext; + ID3D11Texture3D* m_d3dTexture; + D3D11_TEXTURE3D_DESC m_d3dTextureDesc; + + ID3D11SamplerState* m_d3dSamplerState; + D3D11_SAMPLER_DESC m_d3dSamplerDesc; + + ID3D11ShaderResourceView* m_d3dSRV; + D3D11_SHADER_RESOURCE_VIEW_DESC m_d3dSRVDesc; + + PxU8** m_data; + D3D11_SUBRESOURCE_DATA* m_resourceData; +}; + +} // namespace SampleRenderer + +#endif // #if defined(RENDERER_ENABLE_DIRECT3D11) +#endif diff --git a/PhysX_3.4/Samples/SampleFramework/renderer/src/d3d11/D3D11RendererTextureCommon.h b/PhysX_3.4/Samples/SampleFramework/renderer/src/d3d11/D3D11RendererTextureCommon.h new file mode 100644 index 00000000..3d3321d0 --- /dev/null +++ b/PhysX_3.4/Samples/SampleFramework/renderer/src/d3d11/D3D11RendererTextureCommon.h @@ -0,0 +1,107 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved. +#ifndef D3D11_RENDERER_TEXTURE_COMMON_H +#define D3D11_RENDERER_TEXTURE_COMMON_H + +#include <RendererConfig.h> + +#if defined(RENDERER_ENABLE_DIRECT3D11) + +#include <RendererTexture.h> +#include <RendererTextureDesc.h> +#include <SamplePlatform.h> + +#include "D3D11RendererTraits.h" + + +namespace SampleRenderer +{ + +enum TEXTURE_BIND_FLAGS +{ + BIND_NONE = 0, + BIND_VERTEX = 1 << D3DTypes::SHADER_VERTEX, + BIND_GEOMETRY = 1 << D3DTypes::SHADER_GEOMETRY, + BIND_PIXEL = 1 << D3DTypes::SHADER_PIXEL, + BIND_HULL = 1 << D3DTypes::SHADER_HULL, + BIND_DOMAIN = 1 << D3DTypes::SHADER_DOMAIN, + BIND_ALL = (1 << D3DTypes::NUM_SHADER_TYPES) - 1 +}; + +PX_INLINE PxU32 getBindFlags(D3DType d3dType) { return 1 << d3dType; } + +PX_INLINE DXGI_FORMAT getD3D11TextureFormat(RendererTexture::Format format) +{ + DXGI_FORMAT dxgiFormat = static_cast<DXGI_FORMAT>(SampleFramework::SamplePlatform::platform()->getD3D11TextureFormat(format)); + RENDERER_ASSERT(dxgiFormat != DXGI_FORMAT_UNKNOWN, "Unable to convert to D3D11 Texture Format."); + return dxgiFormat; +} + +PX_INLINE D3D11_FILTER getD3D11TextureFilter(RendererTexture::Filter filter) +{ + D3D11_FILTER d3dFilter = D3D11_FILTER_MIN_MAG_MIP_LINEAR; + switch (filter) + { + case RendererTexture2D::FILTER_NEAREST: + d3dFilter = D3D11_FILTER_MIN_MAG_MIP_POINT; + break; + case RendererTexture2D::FILTER_LINEAR: + d3dFilter = D3D11_FILTER_MIN_MAG_MIP_LINEAR; + break; + case RendererTexture2D::FILTER_ANISOTROPIC: + d3dFilter = D3D11_FILTER_ANISOTROPIC; + break; + default: + RENDERER_ASSERT(0, "Unable to convert to D3D11 Filter mode."); + } + return d3dFilter; +} + +PX_INLINE D3D11_TEXTURE_ADDRESS_MODE getD3D11TextureAddressing(RendererTexture2D::Addressing addressing) +{ + D3D11_TEXTURE_ADDRESS_MODE d3dAddressing = (D3D11_TEXTURE_ADDRESS_MODE)0; + switch (addressing) + { + case RendererTexture2D::ADDRESSING_WRAP: + d3dAddressing = D3D11_TEXTURE_ADDRESS_WRAP; + break; + case RendererTexture2D::ADDRESSING_CLAMP: + d3dAddressing = D3D11_TEXTURE_ADDRESS_CLAMP; + break; + case RendererTexture2D::ADDRESSING_MIRROR: + d3dAddressing = D3D11_TEXTURE_ADDRESS_MIRROR; + break; + } + RENDERER_ASSERT(d3dAddressing != 0, "Unable to convert to D3D11 Addressing mode."); + return d3dAddressing; +} + +} + +#endif // #if defined(RENDERER_ENABLE_DIRECT3D11) + +#endif diff --git a/PhysX_3.4/Samples/SampleFramework/renderer/src/d3d11/D3D11RendererTraits.h b/PhysX_3.4/Samples/SampleFramework/renderer/src/d3d11/D3D11RendererTraits.h new file mode 100644 index 00000000..ca8cd29f --- /dev/null +++ b/PhysX_3.4/Samples/SampleFramework/renderer/src/d3d11/D3D11RendererTraits.h @@ -0,0 +1,317 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved. +#ifndef D3D11_RENDERER_TRAITS_H +#define D3D11_RENDERER_TRAITS_H + +#include <RendererConfig.h> + +#if defined(RENDERER_ENABLE_DIRECT3D11) + +#include <tuple> + +namespace SampleRenderer +{ + +namespace D3DTypes +{ + enum D3DType + { + SHADER_PIXEL = 0, + SHADER_VERTEX, + SHADER_GEOMETRY, + SHADER_HULL, + SHADER_DOMAIN, + LAYOUT_INPUT, + STATE_RASTERIZER, + STATE_BLEND, + STATE_DEPTHSTENCIL, + NUM_TYPES, + NUM_SHADER_TYPES = SHADER_DOMAIN + 1, + NUM_NON_PIXEL_SHADER_TYPES = NUM_SHADER_TYPES - 1, + INVALID = NUM_TYPES + }; +} +typedef D3DTypes::D3DType D3DType; + +typedef std::string D3DStringKey; + +template<typename d3d_type> +class D3DTraits +{ +public: + typedef D3DStringKey key_type; + typedef IUnknown* value_type; + static D3DType getType() { return D3DTypes::INVALID; } +}; + +template <> +class D3DTraits<ID3D11VertexShader> +{ +public: + // InputLayoutHash + Shader Name + typedef std::pair<PxU64, D3DStringKey> key_type; + typedef std::pair<ID3D11VertexShader*, ID3DBlob*> value_type; + static const char* getEntry() { return "vmain"; } + static const char* getProfile(D3D_FEATURE_LEVEL featureLevel = D3D_FEATURE_LEVEL_11_0) + { + switch(featureLevel) + { +#if PX_XBOXONE + case D3D_FEATURE_LEVEL_11_1: return "vs_5_0"; +#endif + case D3D_FEATURE_LEVEL_11_0: return "vs_5_0"; + case D3D_FEATURE_LEVEL_10_1: return "vs_4_1"; + case D3D_FEATURE_LEVEL_10_0: return "vs_4_0"; + case D3D_FEATURE_LEVEL_9_1: return "vs_4_0_level_9_1"; + case D3D_FEATURE_LEVEL_9_2: return "vs_4_0_level_9_2"; + case D3D_FEATURE_LEVEL_9_3: return "vs_4_0_level_9_3"; + default: RENDERER_ASSERT(0, "Invalid feature level"); return "vs_invalid"; + } + }; + static D3DType getType() { return D3DTypes::SHADER_VERTEX; } + static HRESULT create( ID3D11Device* pDevice, const void *pShaderBytecode, SIZE_T BytecodeLength, ID3D11ClassLinkage *pClassLinkage, ID3D11VertexShader **ppShader) + { + return pDevice->CreateVertexShader(pShaderBytecode, BytecodeLength, pClassLinkage, ppShader); + } + static void setConstants( ID3D11DeviceContext* pContext, UINT StartSlot, UINT NumBuffers, ID3D11Buffer *const *ppConstantBuffers ) + { + pContext->VSSetConstantBuffers(StartSlot, NumBuffers, ppConstantBuffers); + } +}; + +template <> +class D3DTraits<ID3D11PixelShader> +{ +public: + // Pass + Shader Name + typedef std::pair<PxU32, D3DStringKey> key_type; + typedef std::pair<ID3D11PixelShader*, ID3DBlob*> value_type; + static const char* getEntry() { return "fmain"; } + static const char* getProfile(D3D_FEATURE_LEVEL featureLevel = D3D_FEATURE_LEVEL_11_0) { + switch(featureLevel) + { +#if PX_XBOXONE + case D3D_FEATURE_LEVEL_11_1: return "ps_5_0"; +#endif + case D3D_FEATURE_LEVEL_11_0: return "ps_5_0"; + case D3D_FEATURE_LEVEL_10_1: return "ps_4_1"; + case D3D_FEATURE_LEVEL_10_0: return "ps_4_0"; + case D3D_FEATURE_LEVEL_9_1: return "ps_4_0_level_9_1"; + case D3D_FEATURE_LEVEL_9_2: return "ps_4_0_level_9_2"; + case D3D_FEATURE_LEVEL_9_3: return "ps_4_0_level_9_3"; + default: RENDERER_ASSERT(0, "Invalid feature level"); return "ps_invalid"; + }; + } + static D3DType getType() { return D3DTypes::SHADER_PIXEL; } + static HRESULT create( ID3D11Device* pDevice, const void *pShaderBytecode, SIZE_T BytecodeLength, ID3D11ClassLinkage *pClassLinkage, ID3D11PixelShader **ppShader) + { + return pDevice->CreatePixelShader(pShaderBytecode, BytecodeLength, pClassLinkage, ppShader); + } + static void setConstants( ID3D11DeviceContext* pContext, UINT StartSlot, UINT NumBuffers, ID3D11Buffer *const *ppConstantBuffers ) + { + pContext->PSSetConstantBuffers(StartSlot, NumBuffers, ppConstantBuffers); + } +}; + +template <> +class D3DTraits<ID3D11GeometryShader> +{ +public: + // Shader Name + typedef D3DStringKey key_type; + typedef std::pair<ID3D11GeometryShader*,ID3DBlob*> value_type; + static const char* getEntry() { return "gmain"; } + static const char* getProfile(D3D_FEATURE_LEVEL featureLevel = D3D_FEATURE_LEVEL_11_0) + { + switch(featureLevel) + { +#if PX_XBOXONE + case D3D_FEATURE_LEVEL_11_1: return "gs_5_0"; +#endif + case D3D_FEATURE_LEVEL_11_0: return "gs_5_0"; + case D3D_FEATURE_LEVEL_10_1: return "gs_4_1"; + case D3D_FEATURE_LEVEL_10_0: return "gs_4_0"; + default: RENDERER_ASSERT(0, "Invalid geometry shader feature level") return "gs_invalid"; + }; + } + + static D3DType getType() { return D3DTypes::SHADER_GEOMETRY; } + static HRESULT create( ID3D11Device* pDevice, const void *pShaderBytecode, SIZE_T BytecodeLength, ID3D11ClassLinkage *pClassLinkage, ID3D11GeometryShader **ppShader) + { + return pDevice->CreateGeometryShader(pShaderBytecode, BytecodeLength, pClassLinkage, ppShader); + } + static void setConstants( ID3D11DeviceContext* pContext, UINT StartSlot, UINT NumBuffers, ID3D11Buffer *const *ppConstantBuffers ) + { + pContext->GSSetConstantBuffers(StartSlot, NumBuffers, ppConstantBuffers); + } +}; + +template <> +class D3DTraits<ID3D11HullShader> +{ +public: + // Shader Name + typedef std::pair<PxU32, D3DStringKey> key_type; + typedef std::pair<ID3D11HullShader*,ID3DBlob*> value_type; + static const char* getEntry() { return "hmain"; } + static const char* getProfile(D3D_FEATURE_LEVEL featureLevel = D3D_FEATURE_LEVEL_11_0) + { + switch(featureLevel) + { +#if PX_XBOXONE + case D3D_FEATURE_LEVEL_11_1: return "hs_5_0"; +#endif + case D3D_FEATURE_LEVEL_11_0: return "hs_5_0"; + default: RENDERER_ASSERT(0, "Invalid hull shader feature level") return "hs_invalid"; + }; + } + static D3DType getType() { return D3DTypes::SHADER_HULL; } + static HRESULT create( ID3D11Device* pDevice, const void *pShaderBytecode, SIZE_T BytecodeLength, ID3D11ClassLinkage *pClassLinkage, ID3D11HullShader **ppShader) + { + return pDevice->CreateHullShader(pShaderBytecode, BytecodeLength, pClassLinkage, ppShader); + } + static void setConstants( ID3D11DeviceContext* pContext, UINT StartSlot, UINT NumBuffers, ID3D11Buffer *const *ppConstantBuffers ) + { + pContext->HSSetConstantBuffers(StartSlot, NumBuffers, ppConstantBuffers); + } +}; + +template <> +class D3DTraits<ID3D11DomainShader> +{ +public: + // Shader Name + typedef std::pair<PxU32, D3DStringKey> key_type; + typedef std::pair<ID3D11DomainShader*, ID3DBlob*> value_type; + static const char* getEntry() { return "dmain"; } + static const char* getProfile(D3D_FEATURE_LEVEL featureLevel = D3D_FEATURE_LEVEL_11_0) + { + switch(featureLevel) + { +#if PX_XBOXONE + case D3D_FEATURE_LEVEL_11_1: return "ds_5_0"; +#endif + case D3D_FEATURE_LEVEL_11_0: return "ds_5_0"; + default: RENDERER_ASSERT(0, "Invalid domain shader feature level") return "ds_invalid"; + }; + } + static D3DType getType() { return D3DTypes::SHADER_DOMAIN; } + static HRESULT create( ID3D11Device* pDevice, const void *pShaderBytecode, SIZE_T BytecodeLength, ID3D11ClassLinkage *pClassLinkage, ID3D11DomainShader **ppShader) + { + return pDevice->CreateDomainShader(pShaderBytecode, BytecodeLength, pClassLinkage, ppShader); + } + static void setConstants( ID3D11DeviceContext* pContext, UINT StartSlot, UINT NumBuffers, ID3D11Buffer *const *ppConstantBuffers ) + { + pContext->DSSetConstantBuffers(StartSlot, NumBuffers, ppConstantBuffers); + } +}; + +template <> +class D3DTraits<ID3D11InputLayout> +{ +public: + // InputLayoutHash + Shader Name + typedef std::pair<PxU64, ID3DBlob*> key_type; + typedef ID3D11InputLayout* value_type; + static D3DType getType() { return D3DTypes::LAYOUT_INPUT; } +}; + +template <> +class D3DTraits<ID3D11RasterizerState> +{ +public: + typedef std::tr1::tuple<D3D11_FILL_MODE, D3D11_CULL_MODE, int> key_type; + typedef ID3D11RasterizerState* value_type; + static D3DType getType() { return D3DTypes::STATE_RASTERIZER; } +}; + + +template <> +class D3DTraits<ID3D11DepthStencilState> +{ +public: + // Depth enable + stencil enable + typedef std::pair<bool, bool> key_type; + typedef ID3D11DepthStencilState* value_type; + static D3DType getType() { return D3DTypes::STATE_DEPTHSTENCIL; } +}; + + +template <> +class D3DTraits<ID3D11BlendState> +{ +public: + typedef D3D11_RENDER_TARGET_BLEND_DESC key_type; + typedef ID3D11BlendState* value_type; + static D3DType getType() { return D3DTypes::STATE_BLEND; } +}; + +// This lets us lookup a traits class based on the D3DType key, which is rather handy +template<PxU32 N> +class D3DTraitsLookup { }; +template<> +class D3DTraitsLookup<D3DTypes::SHADER_PIXEL> { typedef ID3D11PixelShader d3d_type; }; +template<> +class D3DTraitsLookup<D3DTypes::SHADER_VERTEX> { typedef ID3D11VertexShader d3d_type; }; +template<> +class D3DTraitsLookup<D3DTypes::SHADER_GEOMETRY> { typedef ID3D11GeometryShader d3d_type; }; +template<> +class D3DTraitsLookup<D3DTypes::SHADER_HULL> { typedef ID3D11HullShader d3d_type; }; +template<> +class D3DTraitsLookup<D3DTypes::SHADER_DOMAIN> { typedef ID3D11DomainShader d3d_type; }; +template<> +class D3DTraitsLookup<D3DTypes::LAYOUT_INPUT> { typedef ID3D11InputLayout d3d_type; }; +template<> +class D3DTraitsLookup<D3DTypes::STATE_BLEND> { typedef ID3D11BlendState d3d_type; }; +template<> +class D3DTraitsLookup<D3DTypes::STATE_DEPTHSTENCIL> { typedef ID3D11DepthStencilState d3d_type; }; +template<> +class D3DTraitsLookup<D3DTypes::STATE_RASTERIZER> { typedef ID3D11RasterizerState d3d_type; }; + +template <typename T> +struct NullTraits +{ + static T get() { return 0; } +}; + +template <typename T> +struct NullTraits<T*> +{ + static T* get() { return NULL; } +}; + +template<typename T1,typename T2> +struct NullTraits< std::pair<T1*,T2*> > +{ + static std::pair<T1*,T2*> get() { return std::pair<T1*,T2*>((T1*)NULL,(T2*)NULL); } +}; + +} // namespace SampleRenderer + +#endif // #if defined(RENDERER_ENABLE_DIRECT3D11) + +#endif diff --git a/PhysX_3.4/Samples/SampleFramework/renderer/src/d3d11/D3D11RendererUtils.cpp b/PhysX_3.4/Samples/SampleFramework/renderer/src/d3d11/D3D11RendererUtils.cpp new file mode 100644 index 00000000..3113ba50 --- /dev/null +++ b/PhysX_3.4/Samples/SampleFramework/renderer/src/d3d11/D3D11RendererUtils.cpp @@ -0,0 +1,502 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved. + +#include <RendererConfig.h> + +#if defined(RENDERER_ENABLE_DIRECT3D11) + +#include "D3D11RendererUtils.h" +#include "D3D11RendererMemoryMacros.h" + +#if !PX_XBOXONE +#include "D3DX11.h" +#endif +#include "D3Dcompiler.h" + +// for PsString.h +#include <PsString.h> +#include <PxTkFile.h> + +using namespace SampleRenderer; +namespace Ps = physx::shdfnd; + + +/****************************************** +* D3DX11::D3DX11 * +*******************************************/ + +D3DX11::D3DX11(void) + : m_pD3DX11CompileFromFile(NULL), + m_pD3DX11CompileFromMemory(NULL), + m_pD3DReflect(NULL) +{ +#if defined(RENDERER_WINDOWS) && !PX_XBOXONE + m_library = LoadLibraryA(D3DX11_DLL); + if (!m_library) + { + // This version should be present on all valid DX11 machines + m_library = LoadLibraryA("d3dx11_42.dll"); + if (!m_library) + { + MessageBoxA(0, "Unable to load " D3DX11_DLL ". Please install the latest DirectX End User Runtime available at www.microsoft.com/directx.", "Renderer Error.", MB_OK); + } + } + if (m_library) + { + m_pD3DX11CompileFromFile = (D3DX11COMPILEFROMFILE)GetProcAddress(m_library, "D3DX11CompileFromFileA"); + RENDERER_ASSERT(m_pD3DX11CompileFromFile, "Unable to find D3DX11 Function D3DX11CompileFromFile in " D3DX11_DLL "."); + m_pD3DX11CompileFromMemory = (D3DX11COMPILEFROMMEMORY)GetProcAddress(m_library, "D3DX11CompileFromMemory"); + RENDERER_ASSERT(m_pD3DX11CompileFromMemory, "Unable to find D3DX11 Function D3DX11CompileFromFile in " D3DX11_DLL "."); + m_pD3DX11SaveTextureToMemory = (D3DX11SAVETEXTURETOMEMORY)GetProcAddress(m_library, "D3DX11SaveTextureToMemory"); + RENDERER_ASSERT(m_pD3DX11SaveTextureToMemory, "Unable to find D3DX11 Function D3DX11SaveTextureToMemory in " D3DX11_DLL "."); + } + + m_compiler_library = LoadLibraryA(D3DCOMPILER_DLL); + if (!m_compiler_library) + { + // This version should be present on all valid DX11 machines + m_library = LoadLibraryA("D3DCompiler_42.dll"); + if (!m_compiler_library) + { + MessageBoxA(0, "Unable to load " D3DCOMPILER_DLL ". Please install the latest DirectX End User Runtime available at www.microsoft.com/directx.", "Renderer Error.", MB_OK); + } + } + if (m_compiler_library) + { + m_pD3DReflect = (D3DREFLECT)GetProcAddress(m_compiler_library, "D3DReflect"); + RENDERER_ASSERT(m_pD3DReflect, "Unable to find D3D Function D3DReflect in " D3DCOMPILER_DLL "."); + m_pD3DCreateBlob = (D3DCREATEBLOB)GetProcAddress(m_compiler_library, "D3DCreateBlob"); + RENDERER_ASSERT(m_pD3DCreateBlob, "Unable to find D3D Function D3DCreateBlob in " D3DCOMPILER_DLL "."); + } +#endif +} + +D3DX11::~D3DX11(void) +{ +#if defined(RENDERER_WINDOWS) + if (m_library) + { + FreeLibrary(m_library); + m_library = 0; + } + if (m_compiler_library) + { + FreeLibrary(m_compiler_library); + m_compiler_library = 0; + } +#endif +} + +HRESULT D3DX11::compileShaderFromFile(LPCSTR pSrcFile, + CONST D3D10_SHADER_MACRO* pDefines, + LPD3D10INCLUDE pInclude, + LPCSTR pFunctionName, + LPCSTR pProfile, + UINT Flags1, + UINT Flags2, + ID3DX11ThreadPump* pPump, + ID3D10Blob** ppShader, + ID3D10Blob** ppErrorMsgs, + HRESULT* pHResult) const +{ +#if !PX_XBOXONE + return m_pD3DX11CompileFromFile(pSrcFile, + pDefines, + pInclude, + pFunctionName, + pProfile, + Flags1, + Flags2, + pPump, + ppShader, + ppErrorMsgs, + pHResult); +#else + const size_t bufferSize = 256; + wchar_t wSrcFile[bufferSize]; + size_t length = 0; + mbstowcs_s(&length, wSrcFile, strlen(pSrcFile) + 1, pSrcFile, bufferSize); + HRESULT result = D3DCompileFromFile(wSrcFile, pDefines, pInclude, pFunctionName, pProfile, Flags1, Flags2, ppShader, ppErrorMsgs); + if(pHResult) + *pHResult = result; + return result; +#endif +} + +HRESULT D3DX11::compileShaderFromMemory(LPCSTR pSrcData, + SIZE_T SrcDataLen, + LPCSTR pFileName, + CONST D3D10_SHADER_MACRO* pDefines, + LPD3D10INCLUDE pInclude, + LPCSTR pFunctionName, + LPCSTR pProfile, + UINT Flags1, + UINT Flags2, + ID3DX11ThreadPump* pPump, + ID3D10Blob** ppShader, + ID3D10Blob** ppErrorMsgs, + HRESULT* pHResult) const +{ +#if !PX_XBOXONE + return m_pD3DX11CompileFromMemory(pSrcData, + SrcDataLen, + pFileName, + pDefines, + pInclude, + pFunctionName, + pProfile, + Flags1, + Flags2, + pPump, + ppShader, + ppErrorMsgs, + pHResult); +#else + HRESULT result = D3DCompile(pSrcData, SrcDataLen, pFileName, pDefines, pInclude, pFunctionName, pProfile, Flags1, Flags2, ppShader, ppErrorMsgs); + if(pHResult) + *pHResult = result; + return result; +#endif +} + +HRESULT D3DX11::reflect(LPCVOID pSrcData, SIZE_T SrcDataSize, REFIID pInterface, void** ppReflector) +{ +#if !PX_XBOXONE + return m_pD3DReflect(pSrcData, SrcDataSize, pInterface, ppReflector); +#else + return D3DReflect(pSrcData, SrcDataSize, pInterface, ppReflector); +#endif +} + +HRESULT D3DX11::saveTextureToMemory( ID3D11DeviceContext *pContext, ID3D11Resource *pSrcTexture, D3DX11_IMAGE_FILE_FORMAT DestFormat, LPD3D10BLOB *ppDestBuf, UINT Flags ) +{ + return m_pD3DX11SaveTextureToMemory(pContext, pSrcTexture, DestFormat, ppDestBuf, Flags); +} + +HRESULT D3DX11::createBlob(SIZE_T Size, ID3DBlob **ppBlob) +{ + return m_pD3DCreateBlob(Size, ppBlob); +} + +void D3DX11::processCompileErrors(ID3DBlob* errors) +{ +#if defined(RENDERER_WINDOWS) && !PX_XBOXONE + if (errors) + { + const char* errorStr = (const char*)errors->GetBufferPointer(); + if (errorStr) + { + static bool ignoreErrors = false; + if (!ignoreErrors) + { + int ret = MessageBoxA(0, errorStr, "D3DXCompileShaderFromFile Error", MB_ABORTRETRYIGNORE); + if (ret == IDABORT) + { + exit(0); + } + else if (ret == IDIGNORE) + { + ignoreErrors = true; + } + } + } + } +#endif +} + +PxU64 D3DX11::getInputHash(const std::vector<D3D11_INPUT_ELEMENT_DESC>& inputDesc) +{ + return getInputHash(&inputDesc[0], (UINT)inputDesc.size()); +} + +static PxU8 sizeOfFormatElement(DXGI_FORMAT format) +{ + switch( format ) + { + case DXGI_FORMAT_R32G32B32A32_TYPELESS: + case DXGI_FORMAT_R32G32B32A32_FLOAT: + case DXGI_FORMAT_R32G32B32A32_UINT: + case DXGI_FORMAT_R32G32B32A32_SINT: + return 128; + + case DXGI_FORMAT_R32G32B32_TYPELESS: + case DXGI_FORMAT_R32G32B32_FLOAT: + case DXGI_FORMAT_R32G32B32_UINT: + case DXGI_FORMAT_R32G32B32_SINT: + return 96; + + case DXGI_FORMAT_R16G16B16A16_TYPELESS: + case DXGI_FORMAT_R16G16B16A16_FLOAT: + case DXGI_FORMAT_R16G16B16A16_UNORM: + case DXGI_FORMAT_R16G16B16A16_UINT: + case DXGI_FORMAT_R16G16B16A16_SNORM: + case DXGI_FORMAT_R16G16B16A16_SINT: + case DXGI_FORMAT_R32G32_TYPELESS: + case DXGI_FORMAT_R32G32_FLOAT: + case DXGI_FORMAT_R32G32_UINT: + case DXGI_FORMAT_R32G32_SINT: + case DXGI_FORMAT_R32G8X24_TYPELESS: + case DXGI_FORMAT_D32_FLOAT_S8X24_UINT: + case DXGI_FORMAT_R32_FLOAT_X8X24_TYPELESS: + case DXGI_FORMAT_X32_TYPELESS_G8X24_UINT: + return 64; + + case DXGI_FORMAT_R10G10B10A2_TYPELESS: + case DXGI_FORMAT_R10G10B10A2_UNORM: + case DXGI_FORMAT_R10G10B10A2_UINT: + case DXGI_FORMAT_R11G11B10_FLOAT: + case DXGI_FORMAT_R8G8B8A8_TYPELESS: + case DXGI_FORMAT_R8G8B8A8_UNORM: + case DXGI_FORMAT_R8G8B8A8_UNORM_SRGB: + case DXGI_FORMAT_R8G8B8A8_UINT: + case DXGI_FORMAT_R8G8B8A8_SNORM: + case DXGI_FORMAT_R8G8B8A8_SINT: + case DXGI_FORMAT_R16G16_TYPELESS: + case DXGI_FORMAT_R16G16_FLOAT: + case DXGI_FORMAT_R16G16_UNORM: + case DXGI_FORMAT_R16G16_UINT: + case DXGI_FORMAT_R16G16_SNORM: + case DXGI_FORMAT_R16G16_SINT: + case DXGI_FORMAT_R32_TYPELESS: + case DXGI_FORMAT_D32_FLOAT: + case DXGI_FORMAT_R32_FLOAT: + case DXGI_FORMAT_R32_UINT: + case DXGI_FORMAT_R32_SINT: + case DXGI_FORMAT_R24G8_TYPELESS: + case DXGI_FORMAT_D24_UNORM_S8_UINT: + case DXGI_FORMAT_R24_UNORM_X8_TYPELESS: + case DXGI_FORMAT_X24_TYPELESS_G8_UINT: + case DXGI_FORMAT_B8G8R8A8_UNORM: + case DXGI_FORMAT_B8G8R8X8_UNORM: + return 32; + + case DXGI_FORMAT_R8G8_TYPELESS: + case DXGI_FORMAT_R8G8_UNORM: + case DXGI_FORMAT_R8G8_UINT: + case DXGI_FORMAT_R8G8_SNORM: + case DXGI_FORMAT_R8G8_SINT: + case DXGI_FORMAT_R16_TYPELESS: + case DXGI_FORMAT_R16_FLOAT: + case DXGI_FORMAT_D16_UNORM: + case DXGI_FORMAT_R16_UNORM: + case DXGI_FORMAT_R16_UINT: + case DXGI_FORMAT_R16_SNORM: + case DXGI_FORMAT_R16_SINT: + case DXGI_FORMAT_B5G6R5_UNORM: + case DXGI_FORMAT_B5G5R5A1_UNORM: + return 16; + + case DXGI_FORMAT_R8_TYPELESS: + case DXGI_FORMAT_R8_UNORM: + case DXGI_FORMAT_R8_UINT: + case DXGI_FORMAT_R8_SNORM: + case DXGI_FORMAT_R8_SINT: + case DXGI_FORMAT_A8_UNORM: + return 8; + + // Compressed format; http://msdn2.microso.../bb694531(VS.85).aspx + case DXGI_FORMAT_BC2_TYPELESS: + case DXGI_FORMAT_BC2_UNORM: + case DXGI_FORMAT_BC2_UNORM_SRGB: + case DXGI_FORMAT_BC3_TYPELESS: + case DXGI_FORMAT_BC3_UNORM: + case DXGI_FORMAT_BC3_UNORM_SRGB: + case DXGI_FORMAT_BC5_TYPELESS: + case DXGI_FORMAT_BC5_UNORM: + case DXGI_FORMAT_BC5_SNORM: + return 128; + + // Compressed format; http://msdn2.microso.../bb694531(VS.85).aspx + case DXGI_FORMAT_R1_UNORM: + case DXGI_FORMAT_BC1_TYPELESS: + case DXGI_FORMAT_BC1_UNORM: + case DXGI_FORMAT_BC1_UNORM_SRGB: + case DXGI_FORMAT_BC4_TYPELESS: + case DXGI_FORMAT_BC4_UNORM: + case DXGI_FORMAT_BC4_SNORM: + return 64; + + // Compressed format; http://msdn2.microso.../bb694531(VS.85).aspx + case DXGI_FORMAT_R9G9B9E5_SHAREDEXP: + return 32; + + // These are compressed, but bit-size information is unclear. + case DXGI_FORMAT_R8G8_B8G8_UNORM: + case DXGI_FORMAT_G8R8_G8B8_UNORM: + return 32; + + case DXGI_FORMAT_UNKNOWN: + default: + return 0; + } +} + +PxU64 D3DX11::getInputHash(const D3D11_INPUT_ELEMENT_DESC* inputDesc, UINT numInputDescs) +{ + enum ShaderInputFlag + { + USE_NONE = 0x00, + USE_POSITION = 0x01, + USE_NORMAL = USE_POSITION << 1, + USE_TANGENT = USE_POSITION << 2, + USE_COLOR = USE_POSITION << 3, + USE_TEXCOORD = USE_POSITION << 4, + NUM_INPUT_TYPES = 5, + }; + + // Each input element gets a certain number of bits in the hash + const PxU8 bitsPerElement = physx::PxMax((PxU8)((sizeof(PxU64) * 8) / numInputDescs), (PxU8)1); + + // Restrict the maximum amount each set of element bits can be shifted + const PxU8 maxSizeShift = physx::PxMin(bitsPerElement, (PxU8)NUM_INPUT_TYPES); + + PxU64 inputHash = 0; + for (UINT i = 0; i < numInputDescs; ++i) + { + if(inputDesc->SemanticName) + { + PxU8 flag = USE_NONE; + + if (Ps::stricmp(inputDesc[i].SemanticName, "TEXCOORD") == 0) + { + flag = USE_TEXCOORD; + } + else if (Ps::stricmp(inputDesc[i].SemanticName, "NORMAL") == 0) + { + flag = USE_NORMAL; + } + else if (Ps::stricmp(inputDesc[i].SemanticName, "TANGENT") == 0) + { + flag = USE_TANGENT; + } + else if (Ps::stricmp(inputDesc[i].SemanticName, "COLOR") == 0) + { + flag = USE_COLOR; + } + else if (Ps::stricmp(inputDesc[i].SemanticName, "POSITION") == 0) + { + flag = USE_POSITION; + } + + static const PxU8 bitsPerDefaultFormat = sizeOfFormatElement(DXGI_FORMAT_R8G8B8A8_UINT); + PX_ASSERT(bitsPerDefaultFormat > 0); + + // Shift the semantic bit depending on the element's relative format size + const PxU8 elementSizeShift = (sizeOfFormatElement(inputDesc[i].Format) / bitsPerDefaultFormat) & maxSizeShift; + + // Shift the semantic bit depending on it's order in the element array + const PxU8 elementOrderShift = (PxU8)(i * bitsPerElement); + + // Add the element's bits to the hash, shifted by it's order in the element array + inputHash |= (flag << (elementSizeShift + elementOrderShift)); + } + } + + return inputHash; +} + + +/******************************************* +* D3D11ShaderIncluder::D3D11ShaderIncluder * +*******************************************/ + +D3D11ShaderIncluder::D3D11ShaderIncluder(const char* assetDir) : m_assetDir(assetDir) {} + +HRESULT D3D11ShaderIncluder::Open( + D3D_INCLUDE_TYPE includeType, + LPCSTR fileName, + LPCVOID parentData, + LPCVOID* data, + UINT* dataSize +) +{ + HRESULT result = D3D11_ERROR_FILE_NOT_FOUND; + + char fullpath[1024]; + Ps::strlcpy(fullpath, 1024, m_assetDir); + Ps::strlcat(fullpath, 1024, "shaders/"); + if (includeType == D3D10_INCLUDE_SYSTEM) + { + Ps::strlcat(fullpath, 1024, "include/"); + } + Ps::strlcat(fullpath, 1024, fileName); + + FILE* file = 0; + PxToolkit::fopen_s(&file, fullpath, "r"); + if (file) + { + fseek(file, 0, SEEK_END); + size_t fileLen = ftell(file); + if (fileLen > 1) + { + fseek(file, 0, SEEK_SET); + char* fileData = new char[fileLen + 1]; + fileLen = fread(fileData, 1, fileLen, file); + fileData[fileLen] = 0; + *data = fileData; + *dataSize = (UINT)fileLen; + } + fclose(file); + result = S_OK; + } + RENDERER_ASSERT(result == S_OK, "Failed to include shader header."); + return result; +} + +HRESULT D3D11ShaderIncluder::Close(LPCVOID data) +{ + delete []((char*)data); + return S_OK; +} + +/*************************************** +* D3D11ShaderCacher::D3D11ShaderCacher * +***************************************/ + +D3D11ShaderCacher::D3D11ShaderCacher(D3D11RendererResourceManager* pResourceManager) +: mResourceManager(pResourceManager) +{ + RENDERER_ASSERT(pResourceManager, "Invalid D3D resource manager"); +} + + +/*************************************** +* D3D11ShaderLoader::D3D11ShaderLoader * +***************************************/ + +D3D11ShaderLoader::D3D11ShaderLoader(D3D11Renderer& renderer) + : mFeatureLevel(renderer.getFeatureLevel()), + mCacher(renderer.getResourceManager()), + mCompiler(renderer.getD3DX11()), + mIncluder(renderer.getAssetDir()), + mDevice(renderer.getD3DDevice()) +{ + RENDERER_ASSERT(mCompiler, "Invalid D3D compiler"); + RENDERER_ASSERT(mDevice, "Invalid D3D device"); +} + +#endif // #if defined(RENDERER_ENABLE_DIRECT3D11) diff --git a/PhysX_3.4/Samples/SampleFramework/renderer/src/d3d11/D3D11RendererUtils.h b/PhysX_3.4/Samples/SampleFramework/renderer/src/d3d11/D3D11RendererUtils.h new file mode 100644 index 00000000..86d42ddc --- /dev/null +++ b/PhysX_3.4/Samples/SampleFramework/renderer/src/d3d11/D3D11RendererUtils.h @@ -0,0 +1,296 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved. + +#ifndef D3D11_RENDERER_UTILS_H +#define D3D11_RENDERER_UTILS_H + +#include <RendererConfig.h> + +#if defined(RENDERER_ENABLE_DIRECT3D11) + +#include "D3D11Renderer.h" +#include "D3D11RendererTraits.h" + +#if !PX_XBOXONE +#include <d3dx11tex.h> +#else +#define D3D10_SHADER_MACRO D3D_SHADER_MACRO +#define LPD3D10INCLUDE LPD3DINCLUDE +#define D3DX11_IMAGE_FILE_FORMAT int +#endif + +struct ID3DX11ThreadPump; + +namespace SampleRenderer +{ + +PX_INLINE PxU32 fast_hash(const char *str, SIZE_T wrdlen) +{ + // "FNV" string hash + const PxU32 PRIME = 1607; + + PxU32 hash32 = 2166136261; + const char *p = str; + + for(; wrdlen >= sizeof(PxU32); wrdlen -= sizeof(PxU32), p += sizeof(PxU32)) { + hash32 = (hash32 ^ *(PxU32 *)p) * PRIME; + } + if (wrdlen & sizeof(PxU16)) { + hash32 = (hash32 ^ *(PxU16*)p) * PRIME; + p += sizeof(PxU16); + } + if (wrdlen & 1) + hash32 = (hash32 ^ *p) * PRIME; + + return hash32 ^ (hash32 >> 16); +} + +class D3D11StringKey +{ +public: + D3D11StringKey(const char* stringKey) : mStringHash(fast_hash(stringKey, strlen(stringKey))) { } + D3D11StringKey(const std::string& stringKey) : mStringHash(fast_hash(stringKey.c_str(), stringKey.length())) { } + bool operator<(const D3D11StringKey& other) const { return mStringHash < other.mStringHash; } +private: + D3D11StringKey(); + PxU32 mStringHash; +}; + +class D3DX11 +{ + friend class D3D11Renderer; +private: + D3DX11(void); + ~D3DX11(void); + +public: + HRESULT compileShaderFromFile(LPCSTR pSrcFile, CONST D3D10_SHADER_MACRO* pDefines, LPD3D10INCLUDE pInclude, + LPCSTR pFunctionName, LPCSTR pProfile, UINT Flags1, UINT Flags2, ID3DX11ThreadPump* pPump, ID3D10Blob** ppShader, ID3D10Blob** ppErrorMsgs, HRESULT* pHResult) const; + HRESULT compileShaderFromMemory(LPCSTR pSrcData, SIZE_T SrcDataLen, LPCSTR pFileName, CONST D3D10_SHADER_MACRO* pDefines, LPD3D10INCLUDE pInclude, + LPCSTR pFunctionName, LPCSTR pProfile, UINT Flags1, UINT Flags2, ID3DX11ThreadPump* pPump, ID3D10Blob** ppShader, ID3D10Blob** ppErrorMsgs, HRESULT* pHResult) const; + HRESULT reflect(LPCVOID pSrcData, SIZE_T SrcDataSize, REFIID pInterface, void** ppReflector); + HRESULT saveTextureToMemory(ID3D11DeviceContext *pContext, ID3D11Resource *pSrcTexture, D3DX11_IMAGE_FILE_FORMAT DestFormat, LPD3D10BLOB *ppDestBuf, UINT Flags); + HRESULT createBlob(SIZE_T Size, ID3DBlob **ppBlob); + +public: + static void processCompileErrors(ID3DBlob* errors); + + static PxU64 getInputHash(const std::vector<D3D11_INPUT_ELEMENT_DESC>& inputElementDesc); + static PxU64 getInputHash(const D3D11_INPUT_ELEMENT_DESC* inputElementDesc, UINT numInputElementDescs); + +private: +#if defined(RENDERER_WINDOWS) + HMODULE m_library; + HMODULE m_compiler_library; + + typedef HRESULT(WINAPI* D3DX11COMPILEFROMFILE)(LPCSTR, CONST D3D10_SHADER_MACRO*, LPD3D10INCLUDE, LPCSTR, LPCSTR, UINT, UINT, ID3DX11ThreadPump*, ID3D10Blob**, ID3D10Blob**, HRESULT*); + D3DX11COMPILEFROMFILE m_pD3DX11CompileFromFile; + typedef HRESULT(WINAPI* D3DX11COMPILEFROMMEMORY)(LPCSTR, SIZE_T, LPCSTR, CONST D3D10_SHADER_MACRO*, LPD3D10INCLUDE, LPCSTR, LPCSTR, UINT, UINT, ID3DX11ThreadPump*, ID3D10Blob**, ID3D10Blob**, HRESULT*); + D3DX11COMPILEFROMMEMORY m_pD3DX11CompileFromMemory; + typedef HRESULT(WINAPI* D3DREFLECT)(LPCVOID, SIZE_T, REFIID, void**); + D3DREFLECT m_pD3DReflect; + typedef HRESULT(WINAPI* D3DX11SAVETEXTURETOMEMORY)(ID3D11DeviceContext *, ID3D11Resource *, D3DX11_IMAGE_FILE_FORMAT, LPD3D10BLOB *, UINT); + D3DX11SAVETEXTURETOMEMORY m_pD3DX11SaveTextureToMemory; + typedef HRESULT(WINAPI* D3DCREATEBLOB)(SIZE_T, ID3DBlob**); + D3DCREATEBLOB m_pD3DCreateBlob; + +#endif + +}; + +class D3D11ShaderIncluder : public ID3DInclude +{ +public: + D3D11ShaderIncluder(const char* assetDir); + +private: + STDMETHOD(Open( + D3D_INCLUDE_TYPE includeType, + LPCSTR fileName, + LPCVOID parentData, + LPCVOID* data, + UINT* dataSize + )); + + STDMETHOD(Close(LPCVOID data)); + + const char* m_assetDir; +}; + + +class D3D11ShaderCacher +{ +public: + D3D11ShaderCacher(D3D11RendererResourceManager* pResourceManager); + + template<typename d3d_type> + bool check(const typename D3DTraits<d3d_type>::key_type& key, + d3d_type*& d3dResource, + ID3DBlob*& d3dResourceBlob) const + { + typename D3DTraits<d3d_type>::value_type value = mResourceManager->hasResource<d3d_type>(key); + d3dResource = value.first; + d3dResourceBlob = value.second; + return !((NULL == d3dResource) || (NULL == d3dResourceBlob)); + } + + template<typename d3d_type> + void cache(const typename D3DTraits<d3d_type>::key_type& key, + const typename D3DTraits<d3d_type>::value_type& value) + { + mResourceManager->registerResource<d3d_type>(key, value); + } + +private: + D3D11ShaderCacher(); + + D3D11RendererResourceManager* mResourceManager; +}; + +static void PxConvertToWchar(const char* inString, WCHAR* outString, int outSize) +{ + // convert to unicode + int succ = MultiByteToWideChar(CP_ACP, 0, inString, -1, outString, outSize); + + // validate + if (succ < 0) + succ = 0; + if (succ < outSize) + outString[succ] = 0; + else if (outString[outSize-1]) + outString[0] = 0; +} + +class D3D11ShaderLoader +{ +public: + D3D11ShaderLoader(D3D11Renderer& renderer); + + template<typename d3d_type> + HRESULT load(typename D3DTraits<d3d_type>::key_type shaderKey, + const char *pShaderPath, + const D3D10_SHADER_MACRO* pDefines, + d3d_type **ppShader = NULL, + ID3DBlob **ppShaderBlob = NULL, + bool bCheckCacheBeforeLoading = true, + bool *pbLoadedFromCache = NULL) + { + HRESULT result = S_OK; + d3d_type* pShader = NULL; + ID3DBlob* pShaderBlob = NULL; + + if (!bCheckCacheBeforeLoading || !mCacher.check<d3d_type>(shaderKey, pShader, pShaderBlob)) + { + result = internalLoad(pShaderPath, pDefines, &pShader, &pShaderBlob); + mCacher.cache<d3d_type>(shaderKey, std::make_pair(pShader, pShaderBlob)); + if (pbLoadedFromCache) *pbLoadedFromCache = false; + } + else if (pbLoadedFromCache) + { + *pbLoadedFromCache = true; + } + + if (SUCCEEDED(result)) + { + if (ppShader) *ppShader = pShader; + if (ppShaderBlob) *ppShaderBlob = pShaderBlob; + } + else + { + RENDERER_ASSERT(0, "Error loading D3D11 shader"); + } + + return result; + } + +protected: + template<typename d3d_type> + HRESULT internalLoad(const char* pShaderName, const D3D10_SHADER_MACRO* pDefines, d3d_type** ppShader, ID3DBlob** ppBlob) + { + HRESULT result = S_OK; + ID3DBlob* pErrorsBlob = NULL; + +#ifdef PX_USE_DX11_PRECOMPILED_SHADERS + //if(pDefines[0].Name == "RENDERER_FRAGMENT") + { + WCHAR bufferWchar[512]; + PxConvertToWchar(pShaderName,bufferWchar,512); + result = D3DReadFileToBlob(bufferWchar,ppBlob); + RENDERER_ASSERT(SUCCEEDED(result) && *ppBlob, "Failed to load precompiled shader."); + + char szBuff[1024]; + sprintf(szBuff,"Precompiled shader loaded: %s \n",pShaderName); + OutputDebugStringA(szBuff); + } +#else + const DWORD shaderFlags = D3DCOMPILE_ENABLE_BACKWARDS_COMPATIBILITY | D3DCOMPILE_PACK_MATRIX_ROW_MAJOR; + + result = mCompiler->compileShaderFromFile( + pShaderName, + pDefines, + &mIncluder, + D3DTraits<d3d_type>::getEntry(), + D3DTraits<d3d_type>::getProfile(mFeatureLevel), + shaderFlags, + 0, + NULL, + ppBlob, + &pErrorsBlob, + NULL + ); + D3DX11::processCompileErrors(pErrorsBlob); + RENDERER_ASSERT(SUCCEEDED(result) && *ppBlob, "Failed to compile shader."); +#endif + + if (SUCCEEDED(result) && *ppBlob) + { + result = D3DTraits<d3d_type>::create(mDevice, (*ppBlob)->GetBufferPointer(), (*ppBlob)->GetBufferSize(), NULL, ppShader); + RENDERER_ASSERT(SUCCEEDED(result) && *ppShader, "Failed to load Fragment Shader."); + } + if (pErrorsBlob) + { + pErrorsBlob->Release(); + } + return result; + } + +private: + D3D11ShaderLoader(); + D3D11ShaderLoader& operator=(const D3D11ShaderLoader&); + + D3D_FEATURE_LEVEL mFeatureLevel; + D3D11ShaderCacher mCacher; + D3D11ShaderIncluder mIncluder; + D3DX11* mCompiler; + ID3D11Device* mDevice; +}; + + +} + +#endif // #if defined(RENDERER_ENABLE_DIRECT3D11) +#endif diff --git a/PhysX_3.4/Samples/SampleFramework/renderer/src/d3d11/D3D11RendererVariableManager.cpp b/PhysX_3.4/Samples/SampleFramework/renderer/src/d3d11/D3D11RendererVariableManager.cpp new file mode 100644 index 00000000..24f1664a --- /dev/null +++ b/PhysX_3.4/Samples/SampleFramework/renderer/src/d3d11/D3D11RendererVariableManager.cpp @@ -0,0 +1,722 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved. + +#include <RendererConfig.h> + +#if defined(RENDERER_ENABLE_DIRECT3D11) + +#include "D3D11RendererVariableManager.h" + +#include "D3D11Renderer.h" +#include "D3D11RendererTexture2D.h" +#include "D3D11RendererTexture3D.h" +#include "D3D11RendererMemoryMacros.h" +#include "D3D11RendererUtils.h" + +#include "RendererMemoryMacros.h" + +#include <stdio.h> + +using namespace SampleRenderer; +static const PxU32 getShaderTypeKey(D3DType shaderType, RendererMaterial::Pass pass = RendererMaterial::NUM_PASSES) +{ + RENDERER_ASSERT(shaderType < D3DTypes::NUM_SHADER_TYPES && + ((shaderType > 0 && pass == RendererMaterial::NUM_PASSES) || + (shaderType == 0 && pass < RendererMaterial::NUM_PASSES)), + "Invalid shader index"); + // pass = NUM_PASSES for any non-pixel shader + // shaderType = 0 for any pixel shader + // pass + shaderType = UNIQUE for any combination + return (PxU32)shaderType + (PxU32)pass; +} + +static D3DType getD3DType(PxU32 shaderTypeKey) +{ + return D3DType(shaderTypeKey < RendererMaterial::NUM_PASSES ? D3DTypes::SHADER_PIXEL : shaderTypeKey-RendererMaterial::NUM_PASSES); +} + +class D3D11RendererVariableManager::D3D11ConstantBuffer +{ +public: + D3D11ConstantBuffer(ID3D11Buffer* pBuffer = NULL, PxU8* pData = NULL, PxU32 size = 0) + : buffer(pBuffer), + data(pData), + dataSize(size), + bDirty(false), + refCount(1) + { + + } + + ~D3D11ConstantBuffer() + { + RENDERER_ASSERT(refCount == 0, "Constant buffer not released as often as it was created."); + dxSafeRelease(buffer); + DELETEARRAY(data); + } + + void addref() + { + ++refCount; + } + + void release() + { + if(0 == --refCount) + { + delete this; + } + } + + ID3D11Buffer* buffer; + PxU8* data; + PxU32 dataSize; + mutable bool bDirty; + +protected: + PxU32 refCount; +}; + +/**************************************************** +* D3D11RendererVariableManager::D3D11SharedVariable * +****************************************************/ + +class D3D11RendererVariableManager::D3D11SharedVariable : public D3D11RendererMaterial::D3D11BaseVariable +{ + friend class D3D11RendererMaterial; + friend class D3D11RendererVariableManager; +public: + D3D11SharedVariable(const char* name, RendererMaterial::VariableType type, PxU32 offset, D3D11ConstantBuffer* pBuffer) + : D3D11RendererMaterial::D3D11BaseVariable(name, type, offset), m_pBuffer(pBuffer) + { + } + D3D11SharedVariable& operator=(const D3D11SharedVariable&) + { + return *this; + } +protected: + D3D11ConstantBuffer* m_pBuffer; +}; + +/************************************************** +* D3D11RendererVariableManager::D3D11DataVariable * +**************************************************/ + +class D3D11RendererVariableManager::D3D11DataVariable : public D3D11RendererMaterial::D3D11Variable +{ + friend class D3D11RendererMaterial; + friend class D3D11RendererVariableManager; +public: + D3D11DataVariable(const char* name, RendererMaterial::VariableType type, PxU32 offset) + : D3D11Variable(name, type, offset) + { + for (int i = 0; i < NUM_SHADER_TYPES; ++i) + { + m_pData[i] = NULL; + m_pDirtyFlags[i] = NULL; + } + } + + virtual void bind(RendererMaterial::Pass pass, const void* data) + { + for (PxU32 i = getShaderTypeKey(D3DTypes::SHADER_VERTEX); i < NUM_SHADER_TYPES; ++i) + { + internalBind(i, data); + } + internalBind(pass, data); + } + +private: + + void internalBind(PxU32 typeKey, const void* data) + { + if (m_pData[typeKey]) + { + memcpy(m_pData[typeKey], data, getDataSize()); + if (m_pDirtyFlags[typeKey]) + { + *(m_pDirtyFlags[typeKey]) = true; + } + } + } + + void addHandle(D3D11RendererVariableManager::ShaderTypeKey typeKey, PxU8* pData, bool* pDirtyFlag) + { + m_pData[typeKey] = pData; + m_pDirtyFlags[typeKey] = pDirtyFlag; + } + +private: + PxU8* m_pData[NUM_SHADER_TYPES]; + bool* m_pDirtyFlags[NUM_SHADER_TYPES]; +}; + + +/***************************************************** +* D3D11RendererVariableManager::D3D11TextureVariable * +*****************************************************/ + +class D3D11RendererVariableManager::D3D11TextureVariable : public D3D11RendererMaterial::D3D11Variable +{ + friend class D3D11RendererMaterial; + friend class D3D11RendererVariableManager; +public: + D3D11TextureVariable(const char* name, RendererMaterial::VariableType type, PxU32 offset) + : D3D11Variable(name, type, offset) + { + for (int i = 0; i < NUM_SHADER_TYPES; ++i) + { + m_bufferIndex[i] = -1; + } + } + + + virtual void bind(RendererMaterial::Pass pass, const void* data) + { + data = *(void**)data; + //RENDERER_ASSERT(data, "NULL Sampler."); + if (data) + { + for (PxU32 i = getShaderTypeKey(D3DTypes::SHADER_VERTEX); i < NUM_SHADER_TYPES; ++i) + { + internalBind(i, data); + } + internalBind(pass, data); + } + } + +private: + + void internalBind(PxU32 typeKey, const void* data) + { + if (m_bufferIndex[typeKey] != -1) + { + PxU32 bindFlags = getBindFlags(getD3DType(typeKey)); + if (RendererMaterial::VARIABLE_SAMPLER2D == getType()) + static_cast<D3D11RendererTexture2D*>((RendererTexture2D*)data)->bind(m_bufferIndex[typeKey], bindFlags); + else if (RendererMaterial::VARIABLE_SAMPLER3D == getType()) + static_cast<D3D11RendererTexture3D*>((RendererTexture2D*)data)->bind(m_bufferIndex[typeKey], bindFlags); + } + } + + void addHandle(D3D11RendererVariableManager::ShaderTypeKey typeKey, int bufferIndex) + { + m_bufferIndex[typeKey] = bufferIndex; + } + +private: + int m_bufferIndex[NUM_SHADER_TYPES]; +}; + +/******************************* +* D3D11RendererVariableManager * +*******************************/ + +D3D11RendererVariableManager::D3D11RendererVariableManager(D3D11Renderer& renderer, StringSet& cbNames, BindMode bindMode) + : mRenderer(renderer), mSharedBufferNames(cbNames), mBindMode(bindMode) +{ + +} + +D3D11RendererVariableManager::~D3D11RendererVariableManager(void) +{ + while (!mVariables.empty()) + { + delete mVariables.back(), mVariables.pop_back(); + } + + for (PxU32 i = 0; i < NUM_SHADER_TYPES; ++i) + { + for (ResourceBuffersMap::iterator it = mResourceToBuffers[i].begin(); + it != mResourceToBuffers[i].end(); + ++it) + { + for(PxU32 j = 0; j < it->second.size(); ++j) + { + it->second[j]->release(); + } + } + } +} + +class D3D11RendererResourceMapper +{ +public: + D3D11RendererResourceMapper( ID3D11DeviceContext *pContext, ID3D11Resource *pResource, UINT Subresource = 0, D3D11_MAP MapType = D3D11_MAP_WRITE_DISCARD ) + : mpContext(pContext), mpResource(pResource), mSubresource(Subresource) + { + pContext->Map(pResource, Subresource, MapType, NULL, &mMappedResource); + } + + void load(const void* pSrc, size_t srcSize) + { + RENDERER_ASSERT(mMappedResource.pData, "Invalid D3D11 mapped pointer"); + memcpy(mMappedResource.pData, pSrc, srcSize); + } + + ~D3D11RendererResourceMapper() + { + mpContext->Unmap(mpResource, mSubresource); + } + +protected: + ID3D11DeviceContext* mpContext; + ID3D11Resource* mpResource; + UINT mSubresource; + D3D11_MAPPED_SUBRESOURCE mMappedResource; +}; + +class D3D11RendererVariableBinder +{ +public: + D3D11RendererVariableBinder(ID3D11DeviceContext* pContext) + : mContext(pContext) + { + RENDERER_ASSERT(pContext, "Invalid D3D11 device context"); + } + + void bind(const D3DType d3dType, + const D3D11RendererVariableManager::ConstantBuffers* buffers, + D3D11RendererVariableManager::BindMode bindMode) + { + if (buffers && buffers->size() > 0) + { + D3D11RendererVariableManager::D3DBuffers pCBs(buffers->size()); + PxU32 cbIndex = 0; + for (D3D11RendererVariableManager::CBIterator cbIt = buffers->begin(); + cbIt != buffers->end(); + ++cbIt) + { + if ((*cbIt)->bDirty) + { + if (bindMode == D3D11RendererVariableManager::BIND_MAP) + { + D3D11RendererResourceMapper mappedResource(mContext, (*cbIt)->buffer); + mappedResource.load((*cbIt)->data, (*cbIt)->dataSize); + } + else + { + mContext->UpdateSubresource((*cbIt)->buffer, 0, NULL, (*cbIt)->data, 0, 0); + } + + (*cbIt)->bDirty = false; + } + pCBs[cbIndex++] = (*cbIt)->buffer; + } + switch (d3dType) + { + case D3DTypes::SHADER_PIXEL: D3DTraits<ID3D11PixelShader>::setConstants(mContext, 0, (UINT)pCBs.size(), &pCBs[0]); + break; + case D3DTypes::SHADER_VERTEX: D3DTraits<ID3D11VertexShader>::setConstants(mContext, 0, (UINT)pCBs.size(), &pCBs[0]); + break; + case D3DTypes::SHADER_GEOMETRY: D3DTraits<ID3D11GeometryShader>::setConstants(mContext, 0, (UINT)pCBs.size(), &pCBs[0]); + break; + case D3DTypes::SHADER_HULL: D3DTraits<ID3D11HullShader>::setConstants(mContext, 0, (UINT)pCBs.size(), &pCBs[0]); + break; + case D3DTypes::SHADER_DOMAIN: D3DTraits<ID3D11DomainShader>::setConstants(mContext, 0, (UINT)pCBs.size(), &pCBs[0]); + break; + default: + RENDERER_ASSERT(0, "Invalid D3D type"); + break; + } + } + + } + +private: + D3D11RendererVariableBinder(); + ID3D11DeviceContext* mContext; +}; + +void D3D11RendererVariableManager::bind(const void* pResource, D3DType type, RendererMaterial::Pass pass) const +{ + ID3D11DeviceContext* d3dDeviceContext = mRenderer.getD3DDeviceContext(); + ShaderTypeKey typeKey = getShaderTypeKey(type, pass); + + if (pResource && d3dDeviceContext && typeKey < NUM_SHADER_TYPES) + { + ResourceBuffersMap::const_iterator cbIterator = mResourceToBuffers[typeKey].find(pResource); + const ConstantBuffers* cb = (cbIterator != mResourceToBuffers[typeKey].end()) ? &(cbIterator->second) : NULL; + + D3D11RendererVariableBinder binder(d3dDeviceContext); + binder.bind(type, cb, mBindMode); + } +} + +void D3D11RendererVariableManager::setSharedVariable(const char* sharedBufferName, const char* variableName, const void* data, UINT size, UINT offset) +{ + NameVariablesMap::const_iterator svIt = mNameToSharedVariables.find(VariableKey(sharedBufferName, variableName)); + if (svIt != mNameToSharedVariables.end() && svIt->second) + { + D3D11SharedVariable* pSV = svIt->second; + RENDERER_ASSERT(pSV, "Invalid shared variable"); + internalSetVariable(pSV->m_pBuffer, pSV->getDataOffset()+offset, data, size ? size : pSV->getDataSize()); + } + else + { +#if RENDERER_ASSERT_SHARED_VARIABLE_EXISTS + RENDERER_ASSERT(0, "Shared variable has not been created!"); +#endif + } +} + +void D3D11RendererVariableManager::internalSetVariable(D3D11ConstantBuffer* pBuffer, PxU32 offset, const void* data, PxU32 size) +{ + RENDERER_ASSERT(pBuffer, "Invalid constant buffer"); + memcpy(pBuffer->data + offset, data, size); + pBuffer->bDirty = true; +} + +static RendererMaterial::VariableType getVariableType(const D3D11_SHADER_TYPE_DESC& desc) +{ + RendererMaterial::VariableType vt = RendererMaterial::NUM_VARIABLE_TYPES; + switch (desc.Type) + { + case D3D_SVT_INT: + if (desc.Rows == 1 && desc.Columns == 1) + { + vt = RendererMaterial::VARIABLE_INT; + } + break; + case D3D_SVT_FLOAT: + if (desc.Rows == 4 && desc.Columns == 4) + { + vt = RendererMaterial::VARIABLE_FLOAT4x4; + } + else if (desc.Rows == 1 && desc.Columns == 1) + { + vt = RendererMaterial::VARIABLE_FLOAT; + } + else if (desc.Rows == 1 && desc.Columns == 2) + { + vt = RendererMaterial::VARIABLE_FLOAT2; + } + else if (desc.Rows == 1 && desc.Columns == 3) + { + vt = RendererMaterial::VARIABLE_FLOAT3; + } + else if (desc.Rows == 1 && desc.Columns == 4) + { + vt = RendererMaterial::VARIABLE_FLOAT4; + } + break; + case D3D_SVT_SAMPLER2D: + vt = RendererMaterial::VARIABLE_SAMPLER2D; + break; + case D3D_SVT_SAMPLER3D: + vt = RendererMaterial::VARIABLE_SAMPLER3D; + break; + } + RENDERER_ASSERT(vt < RendererMaterial::NUM_VARIABLE_TYPES, "Unable to convert shader variable type."); + return vt; +} + +D3D11RendererVariableManager::D3D11ConstantBuffer* +D3D11RendererVariableManager::loadBuffer(std::vector<D3D11RendererMaterial::Variable*>& variables, + PxU32& variableBufferSize, + ShaderTypeKey typeKey, + ID3D11ShaderReflectionConstantBuffer* pReflectionBuffer, + const D3D11_SHADER_BUFFER_DESC& sbDesc, + const D3D11_BUFFER_DESC& cbDesc) +{ + ID3D11Buffer* pBuffer = NULL; + D3D11ConstantBuffer* pCB = NULL; + HRESULT result = mRenderer.getD3DDevice()->CreateBuffer(&cbDesc, NULL, &pBuffer); + RENDERER_ASSERT(SUCCEEDED(result), "Error creating D3D11 constant buffer."); + if (SUCCEEDED(result)) + { + pCB = new D3D11ConstantBuffer(pBuffer, new PxU8[sbDesc.Size], sbDesc.Size); + + try + { + for (PxU32 i = 0; i < sbDesc.Variables; ++i) + { + ID3D11ShaderReflectionVariable* pVariable = pReflectionBuffer->GetVariableByIndex(i); + D3D11_SHADER_VARIABLE_DESC vDesc; + pVariable->GetDesc(&vDesc); + + ID3D11ShaderReflectionType* pType = pVariable->GetType(); + D3D11_SHADER_TYPE_DESC tDesc; + pType->GetDesc(&tDesc); + + RendererMaterial::VariableType type = getVariableType(tDesc); + + D3D11DataVariable* var = 0; + + // Search to see if the variable already exists... + PxU32 numVariables = (PxU32)variables.size(); + for (PxU32 j = 0; j < numVariables; ++j) + { + if (!strcmp(variables[j]->getName(), vDesc.Name)) + { + var = static_cast<D3D11DataVariable*>(variables[j]); + break; + } + } + + // Check to see if the variable is of the same type. + if (var) + { + RENDERER_ASSERT(var->getType() == type, "Variable changes type!"); + } + + // If we couldn't find the variable... create a new variable... + if (!var) + { + var = new D3D11DataVariable(vDesc.Name, type, variableBufferSize); + variables.push_back(var); + variableBufferSize += var->getDataSize(); + } + + PxU8* varData = pCB->data + vDesc.StartOffset; + var->addHandle(typeKey, varData, &(pCB->bDirty)); + } + } + catch(...) + { + RENDERER_ASSERT(0, "Exception in processing D3D shader variables"); + delete pCB; + } + + } + return pCB; +} + +D3D11RendererVariableManager::D3D11ConstantBuffer* +D3D11RendererVariableManager::loadSharedBuffer(ShaderTypeKey typeKey, + ID3D11ShaderReflectionConstantBuffer* pReflectionBuffer, + const D3D11_SHADER_BUFFER_DESC& sbDesc, + const D3D11_BUFFER_DESC& cbDesc) +{ + D3D11ConstantBuffer* pCB = NULL; + // Check to see if the specified shared constant buffer has already been created + NameBuffersMap::iterator cbIt = mNameToSharedBuffer.find(sbDesc.Name); + if (cbIt != mNameToSharedBuffer.end()) + { + pCB = cbIt->second; + if( pCB ) + { + pCB->addref(); + } + } + else + { + ID3D11Buffer* pBuffer = NULL; + HRESULT result = mRenderer.getD3DDevice()->CreateBuffer(&cbDesc, NULL, &pBuffer); + RENDERER_ASSERT(SUCCEEDED(result), "Error creating D3D11 constant buffer."); + if (SUCCEEDED(result)) + { + pCB = new D3D11ConstantBuffer(pBuffer, new PxU8[sbDesc.Size], sbDesc.Size); + for (PxU32 i = 0; i < sbDesc.Variables; ++i) + { + ID3D11ShaderReflectionVariable* pVariable = pReflectionBuffer->GetVariableByIndex(i); + D3D11_SHADER_VARIABLE_DESC vDesc; + pVariable->GetDesc(&vDesc); + + ID3D11ShaderReflectionType* pType = pVariable->GetType(); + D3D11_SHADER_TYPE_DESC tDesc; + pType->GetDesc(&tDesc); + + mVariables.push_back(new D3D11SharedVariable(vDesc.Name, getVariableType(tDesc), vDesc.StartOffset, pCB)); + mNameToSharedVariables[VariableKey(sbDesc.Name, vDesc.Name)] = mVariables.back(); + } + mNameToSharedBuffer[sbDesc.Name] = pCB; + } + } + + return pCB; +} + +void D3D11RendererVariableManager::loadVariables(D3D11RendererMaterial* pMaterial, + ID3DBlob* pShader, + D3DType type, + RendererMaterial::Pass pass) +{ + D3DX11* pD3DX = mRenderer.getD3DX11(); + RENDERER_ASSERT(pD3DX, "Invalid D3D11 shader compiler"); + + ID3D11ShaderReflection* pReflection = NULL; + HRESULT result = pD3DX->reflect(pShader->GetBufferPointer(), + pShader->GetBufferSize(), + IID_ID3D11ShaderReflection, + (void**) &pReflection); + + RENDERER_ASSERT(SUCCEEDED(result) && pReflection, "Failure in processing D3D11 shader reflection") + if (SUCCEEDED(result) && pReflection) + { + loadConstantVariables(pMaterial, pShader, getShaderTypeKey(type, pass), pReflection, &pMaterial->m_variables, &pMaterial->m_variableBufferSize); + loadTextureVariables(pMaterial, pShader, getShaderTypeKey(type, pass), pReflection); + } +} + +void D3D11RendererVariableManager::loadSharedVariables(const void* pResource, + ID3DBlob* pShader, + D3DType type, + RendererMaterial::Pass pass) +{ + D3DX11* pD3DX = mRenderer.getD3DX11(); + RENDERER_ASSERT(pD3DX, "Invalid D3D11 shader compiler"); + + ID3D11ShaderReflection* pReflection = NULL; + HRESULT result = pD3DX->reflect(pShader->GetBufferPointer(), + pShader->GetBufferSize(), + IID_ID3D11ShaderReflection, + (void**) &pReflection); + + RENDERER_ASSERT(SUCCEEDED(result) && pReflection, "Failure in processing D3D11 shader reflection") + if (SUCCEEDED(result) && pReflection) + { + loadConstantVariables(pResource, pShader, getShaderTypeKey(type, pass), pReflection); + } +} + +void D3D11RendererVariableManager::loadConstantVariables(const void* pResource, + ID3DBlob* pShader, + ShaderTypeKey typeKey, + ID3D11ShaderReflection* pReflection, + MaterialVariables* pVariables, + PxU32* pVariableBufferSize) +{ + D3D11_SHADER_DESC desc; + pReflection->GetDesc(&desc); + + for (PxU32 i = 0; i < desc.ConstantBuffers; ++i) + { + D3D11_BUFFER_DESC cbDesc; + cbDesc.CPUAccessFlags = (mBindMode == BIND_MAP) ? D3D11_CPU_ACCESS_WRITE : 0; + cbDesc.Usage = (mBindMode == BIND_MAP) ? D3D11_USAGE_DYNAMIC : D3D11_USAGE_DEFAULT; + cbDesc.BindFlags = D3D11_BIND_CONSTANT_BUFFER; + cbDesc.MiscFlags = 0; + + ID3D11ShaderReflectionConstantBuffer* pConstBuffer = pReflection->GetConstantBufferByIndex(i); + + D3D11_SHADER_BUFFER_DESC sbDesc; + pConstBuffer->GetDesc(&sbDesc); + cbDesc.ByteWidth = sbDesc.Size; + + D3D11ConstantBuffer* pCB = NULL; + // Check to see if the constant buffer's name has been specified as s shared buffer + if (mSharedBufferNames.find(sbDesc.Name) != mSharedBufferNames.end()) + { + pCB = loadSharedBuffer(typeKey, pConstBuffer, sbDesc, cbDesc); + } + else if (pVariables && pVariableBufferSize) + { + pCB = loadBuffer(*pVariables, *pVariableBufferSize, typeKey, pConstBuffer, sbDesc, cbDesc); + } + else + { + RENDERER_ASSERT(0, "Only materials support non-shared variables."); + } + + RENDERER_ASSERT(pCB, "Error creating shared buffer"); + if (pCB) + { + mResourceToBuffers[typeKey][pResource].push_back(pCB); + } + } +} + +RendererMaterial::VariableType getTextureVariableType(const D3D11_SHADER_INPUT_BIND_DESC& resourceDesc) +{ + switch (resourceDesc.Dimension) + { + case D3D_SRV_DIMENSION_TEXTURE1D: + case D3D_SRV_DIMENSION_TEXTURE2D: + return RendererMaterial::VARIABLE_SAMPLER2D; + case D3D_SRV_DIMENSION_TEXTURE3D: + return RendererMaterial::VARIABLE_SAMPLER3D; + default: + RENDERER_ASSERT(0, "Invalid texture type."); + return RendererMaterial::NUM_VARIABLE_TYPES; + } +} + +void D3D11RendererVariableManager::loadTextureVariables(D3D11RendererMaterial* pMaterial, + ID3DBlob* pShader, + ShaderTypeKey typeKey, + ID3D11ShaderReflection* pReflection) +{ + D3D11_SHADER_DESC desc; + pReflection->GetDesc(&desc); + + // Load texture variables for the specified shader + for (PxU32 i = 0; i < desc.BoundResources; ++i) + { + D3D11_SHADER_INPUT_BIND_DESC resourceDesc; + HRESULT result = pReflection->GetResourceBindingDesc(i, &resourceDesc); + if (SUCCEEDED(result) && resourceDesc.Type == D3D10_SIT_TEXTURE) + { + D3D11TextureVariable* var = NULL; + // Search to see if the variable already exists... + PxU32 numVariables = (PxU32)pMaterial->m_variables.size(); + for (PxU32 j = 0; j < numVariables; ++j) + { + if (!strcmp(pMaterial->m_variables[j]->getName(), resourceDesc.Name)) + { + var = static_cast<D3D11TextureVariable*>(pMaterial->m_variables[j]); + break; + } + } + + RendererMaterial::VariableType varType = getTextureVariableType(resourceDesc); + + // Check to see if the variable is of the same type. + if (var) + { + RENDERER_ASSERT(var->getType() == varType, "Variable changes type!"); + } + + // If we couldn't find the variable... create a new variable... + if (!var && (varType == RendererMaterial::VARIABLE_SAMPLER2D || varType == RendererMaterial::VARIABLE_SAMPLER3D) ) + { + var = new D3D11TextureVariable(resourceDesc.Name, varType, pMaterial->m_variableBufferSize); + pMaterial->m_variables.push_back(var); + pMaterial->m_variableBufferSize += var->getDataSize(); + } + + var->addHandle(typeKey, resourceDesc.BindPoint); + } + } +} + +void D3D11RendererVariableManager::unloadVariables( const void* pResource ) +{ + for (PxU32 i = 0; i < NUM_SHADER_TYPES; ++i) + { + ResourceBuffersMap::iterator it = mResourceToBuffers[i].find(pResource); + if (it != mResourceToBuffers[i].end()) + { + for (PxU32 j = 0; j < it->second.size(); ++j) + { + it->second[j]->release(); + } + mResourceToBuffers[i].erase(it); + } + } +} +#endif diff --git a/PhysX_3.4/Samples/SampleFramework/renderer/src/d3d11/D3D11RendererVariableManager.h b/PhysX_3.4/Samples/SampleFramework/renderer/src/d3d11/D3D11RendererVariableManager.h new file mode 100644 index 00000000..fdd8a86c --- /dev/null +++ b/PhysX_3.4/Samples/SampleFramework/renderer/src/d3d11/D3D11RendererVariableManager.h @@ -0,0 +1,152 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved. +#ifndef D3D11_RENDERER_VARIABLE_MANAGER_H +#define D3D11_RENDERER_VARIABLE_MANAGER_H + +#include <RendererConfig.h> + +#if defined(RENDERER_ENABLE_DIRECT3D11) + +#include <RendererMaterial.h> + +#include "D3D11RendererMaterial.h" +#include "D3D11RendererTraits.h" +#include "D3D11RendererUtils.h" +#include "D3Dcompiler.h" + +#include <set> +#include <string> +#include <limits> + +// Enable to check that binding a shared variable by name actually +// finds the specified shared variable +#define RENDERER_ASSERT_SHARED_VARIABLE_EXISTS 0 + +namespace SampleRenderer +{ + +static const PxU32 NUM_SHADER_TYPES = D3DTypes::NUM_SHADER_TYPES + RendererMaterial::NUM_PASSES; + +class D3D11RendererVariableManager +{ +public: + enum SharedVariableSize + { + USE_DEFAULT = 0, + }; + + enum BindMode + { + BIND_MAP = 0, + BIND_SUBRESOURCE + }; + +public: + typedef std::set<std::string> StringSet; + + D3D11RendererVariableManager(D3D11Renderer& renderer, StringSet& cbNames, BindMode bindMode = BIND_SUBRESOURCE); + virtual ~D3D11RendererVariableManager(void); + +public: + void bind(const void* pResource, D3DType shaderType, RendererMaterial::Pass pass = RendererMaterial::NUM_PASSES) const; + void setSharedVariable(const char* sharedBufferName, const char* variableName, const void* data, UINT size = USE_DEFAULT, UINT offset = 0); + void loadVariables(D3D11RendererMaterial* pMaterial, ID3DBlob* pShader, D3DType shaderType, RendererMaterial::Pass pass = RendererMaterial::NUM_PASSES); + void loadSharedVariables(const void* pResource, ID3DBlob* pShader, D3DType shaderType, RendererMaterial::Pass pass = RendererMaterial::NUM_PASSES); + void unloadVariables(const void* pResource); + + class D3D11ConstantBuffer; + class D3D11DataVariable; + class D3D11TextureVariable; + class D3D11SharedVariable; + + typedef std::vector<D3D11ConstantBuffer*> ConstantBuffers; + typedef std::vector<ID3D11Buffer*> D3DBuffers; + typedef std::vector<D3D11SharedVariable*> Variables; + typedef std::vector<D3D11RendererMaterial::Variable*> MaterialVariables; + + typedef D3D11StringKey StringKey; + typedef const void* ResourceKey; + typedef PxU32 ShaderTypeKey; + typedef std::pair<StringKey, StringKey> VariableKey; + + typedef std::map<StringKey, D3D11ConstantBuffer*> NameBuffersMap; + typedef std::map<VariableKey, D3D11SharedVariable*> NameVariablesMap; + typedef std::map<ResourceKey, ConstantBuffers> ResourceBuffersMap; + + typedef ConstantBuffers::const_iterator CBIterator; + +private: + D3D11RendererVariableManager& operator=(const D3D11RendererVariableManager&) + { + return *this; + } + + D3D11ConstantBuffer* loadBuffer(MaterialVariables& variables, + PxU32& variableBufferSize, + ShaderTypeKey typeKey, + ID3D11ShaderReflectionConstantBuffer* pReflectionBuffer, + const D3D11_SHADER_BUFFER_DESC& sbDesc, + const D3D11_BUFFER_DESC& cbDesc); + D3D11ConstantBuffer* loadSharedBuffer(ShaderTypeKey typeKey, + ID3D11ShaderReflectionConstantBuffer* pReflectionBuffer, + const D3D11_SHADER_BUFFER_DESC& sbDesc, + const D3D11_BUFFER_DESC& cbDesc); + + void loadConstantVariables(const void* pResource, + ID3DBlob* pShader, + ShaderTypeKey typeKey, + ID3D11ShaderReflection* pReflection, + MaterialVariables* pVariables = NULL, + PxU32* pVariableBufferSize = NULL); + void loadTextureVariables(D3D11RendererMaterial* pMaterial, + ID3DBlob* pShader, + ShaderTypeKey typeKey, + ID3D11ShaderReflection* pReflection); + + void internalSetVariable(D3D11ConstantBuffer* pBuffer, PxU32 offset, const void* data, PxU32 size); + void updateVariables(const ConstantBuffers*) const; + void bindVariables(const ConstantBuffers*, bool bFragment) const; + +private: + + D3D11Renderer& mRenderer; + StringSet mSharedBufferNames; + + BindMode mBindMode; + + Variables mVariables; + + NameBuffersMap mNameToSharedBuffer; + NameVariablesMap mNameToSharedVariables; + + ResourceBuffersMap mResourceToBuffers[NUM_SHADER_TYPES]; +}; + +} // namespace SampleRenderer + +#endif // #if defined(RENDERER_ENABLE_DIRECT3D11) +#endif diff --git a/PhysX_3.4/Samples/SampleFramework/renderer/src/d3d11/D3D11RendererVertexBuffer.cpp b/PhysX_3.4/Samples/SampleFramework/renderer/src/d3d11/D3D11RendererVertexBuffer.cpp new file mode 100644 index 00000000..88c6ba25 --- /dev/null +++ b/PhysX_3.4/Samples/SampleFramework/renderer/src/d3d11/D3D11RendererVertexBuffer.cpp @@ -0,0 +1,374 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved. + +#include <RendererConfig.h> + +#if defined(RENDERER_ENABLE_DIRECT3D11) + +#include "D3D11RendererVertexBuffer.h" +#include <RendererVertexBufferDesc.h> + +#if PX_WINDOWS +#include <task/PxTask.h> +#endif + +using namespace SampleRenderer; + +static D3D_FEATURE_LEVEL gFeatureLevel = D3D_FEATURE_LEVEL_9_1; + +static D3D11_INPUT_ELEMENT_DESC buildVertexElement(LPCSTR name, UINT index, DXGI_FORMAT format, UINT inputSlot, UINT alignedByOffset, D3D11_INPUT_CLASSIFICATION inputSlotClass, UINT instanceDataStepRate) +{ + D3D11_INPUT_ELEMENT_DESC element; + element.SemanticName = name; + element.SemanticIndex = index; + element.Format = format; + element.InputSlot = inputSlot; + element.AlignedByteOffset = alignedByOffset; + element.InputSlotClass = inputSlotClass; + element.InstanceDataStepRate = instanceDataStepRate; + return element; +} + +static DXGI_FORMAT getD3DFormat(RendererVertexBuffer::Format format) +{ + DXGI_FORMAT d3dFormat = DXGI_FORMAT_UNKNOWN; + if(gFeatureLevel <= D3D_FEATURE_LEVEL_9_3) + { + switch (format) + { + case RendererVertexBuffer::FORMAT_FLOAT1: + d3dFormat = DXGI_FORMAT_R32_FLOAT; + break; + case RendererVertexBuffer::FORMAT_FLOAT2: + d3dFormat = DXGI_FORMAT_R32G32_FLOAT; + break; + case RendererVertexBuffer::FORMAT_FLOAT3: + d3dFormat = DXGI_FORMAT_R32G32B32_FLOAT; + break; + case RendererVertexBuffer::FORMAT_FLOAT4: + d3dFormat = DXGI_FORMAT_R32G32B32A32_FLOAT; + break; + case RendererVertexBuffer::FORMAT_UBYTE4: + d3dFormat = DXGI_FORMAT_R8G8B8A8_UINT; + break; + case RendererVertexBuffer::FORMAT_USHORT4: + d3dFormat = DXGI_FORMAT_R16G16B16A16_UINT; + break; + case RendererVertexBuffer::FORMAT_COLOR_BGRA: + d3dFormat = DXGI_FORMAT_R8G8B8A8_UINT; + break; + case RendererVertexBuffer::FORMAT_COLOR_RGBA: + d3dFormat = DXGI_FORMAT_R8G8B8A8_UINT; + break; + case RendererVertexBuffer::FORMAT_COLOR_NATIVE: + d3dFormat = DXGI_FORMAT_R32_FLOAT; + break; + } + } + else + { + switch (format) + { + case RendererVertexBuffer::FORMAT_FLOAT1: + d3dFormat = DXGI_FORMAT_R32_FLOAT; + break; + case RendererVertexBuffer::FORMAT_FLOAT2: + d3dFormat = DXGI_FORMAT_R32G32_FLOAT; + break; + case RendererVertexBuffer::FORMAT_FLOAT3: + d3dFormat = DXGI_FORMAT_R32G32B32_FLOAT; + break; + case RendererVertexBuffer::FORMAT_FLOAT4: + d3dFormat = DXGI_FORMAT_R32G32B32A32_FLOAT; + break; + case RendererVertexBuffer::FORMAT_UBYTE4: + d3dFormat = DXGI_FORMAT_R8G8B8A8_UINT; + break; + case RendererVertexBuffer::FORMAT_USHORT4: + d3dFormat = DXGI_FORMAT_R16G16B16A16_UINT; + break; + case RendererVertexBuffer::FORMAT_COLOR_BGRA: + d3dFormat = DXGI_FORMAT_B8G8R8A8_UNORM; + break; + case RendererVertexBuffer::FORMAT_COLOR_RGBA: + d3dFormat = DXGI_FORMAT_R8G8B8A8_UNORM; + break; + case RendererVertexBuffer::FORMAT_COLOR_NATIVE: + //d3dFormat = DXGI_FORMAT_R32G32B32_FLOAT; + d3dFormat = DXGI_FORMAT_R8G8B8A8_UNORM; + break; + } + } + RENDERER_ASSERT(d3dFormat != DXGI_FORMAT_UNKNOWN, "Invalid DIRECT3D11 vertex type."); + return d3dFormat; +} + +static void getD3DUsage(RendererVertexBuffer::Semantic semantic, LPCSTR& usageName, PxU8& usageIndex) +{ + usageName = "POSITION"; + usageIndex = 0; + if (semantic >= RendererVertexBuffer::SEMANTIC_TEXCOORD0 && semantic <= RendererVertexBuffer::SEMANTIC_TEXCOORDMAX) + { + usageName = "TEXCOORD"; + usageIndex = (PxU8)(semantic - RendererVertexBuffer::SEMANTIC_TEXCOORD0); + } + else + { + switch (semantic) + { + case RendererVertexBuffer::SEMANTIC_POSITION: + usageName = "POSITION"; + break; + case RendererVertexBuffer::SEMANTIC_NORMAL: + usageName = "NORMAL"; + break; + case RendererVertexBuffer::SEMANTIC_TANGENT: + usageName = "TANGENT"; + break; + case RendererVertexBuffer::SEMANTIC_COLOR: + usageName = "COLOR"; + break; + case RendererVertexBuffer::SEMANTIC_BONEINDEX: + usageName = "TEXCOORD"; + usageIndex = RENDERER_BONEINDEX_CHANNEL; + break; + case RendererVertexBuffer::SEMANTIC_BONEWEIGHT: + usageName = "TEXCOORD"; + usageIndex = RENDERER_BONEWEIGHT_CHANNEL; + break; + case RendererVertexBuffer::SEMANTIC_DISPLACEMENT_TEXCOORD: + usageName = "TEXCOORD"; + usageIndex = RENDERER_DISPLACEMENT_CHANNEL; + break; + case RendererVertexBuffer::SEMANTIC_DISPLACEMENT_FLAGS: + usageName = "TEXCOORD"; + usageIndex = RENDERER_DISPLACEMENT_FLAGS_CHANNEL; + break; + } + } +} + +D3D11RendererVertexBuffer::D3D11RendererVertexBuffer(ID3D11Device& d3dDevice, ID3D11DeviceContext& d3dDeviceContext, const RendererVertexBufferDesc& desc, bool bUseMapForLocking) : + RendererVertexBuffer(desc), + m_d3dDevice(d3dDevice), + m_d3dDeviceContext(d3dDeviceContext), + m_d3dVertexBuffer(NULL), + m_bUseMapForLocking(bUseMapForLocking && (!desc.registerInCUDA)), + m_buffer(NULL) +{ + gFeatureLevel = d3dDevice.GetFeatureLevel(); + + memset(&m_d3dBufferDesc, 0, sizeof(D3D11_BUFFER_DESC)); + m_d3dBufferDesc.BindFlags = D3D11_BIND_VERTEX_BUFFER; + m_d3dBufferDesc.ByteWidth = (UINT)(desc.maxVertices * m_stride); + + if (m_bUseMapForLocking) + { + m_d3dBufferDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE; + m_d3dBufferDesc.Usage = D3D11_USAGE_DYNAMIC; + } + else + { + m_d3dBufferDesc.CPUAccessFlags = 0; + m_d3dBufferDesc.Usage = D3D11_USAGE_DEFAULT; + m_buffer = new PxU8[m_d3dBufferDesc.ByteWidth]; + memset(m_buffer, 0, sizeof(PxU8)*m_d3dBufferDesc.ByteWidth); + } + + m_bBufferWritten = false; + + onDeviceReset(); + + if (m_d3dVertexBuffer) + { + m_maxVertices = desc.maxVertices; + } +} + +D3D11RendererVertexBuffer::~D3D11RendererVertexBuffer(void) +{ + if (m_d3dVertexBuffer) + { +#if PX_WINDOWS && PX_SUPPORT_GPU_PHYSX + if (m_interopContext && m_registeredInCUDA) + { + m_registeredInCUDA = !m_interopContext->unregisterResourceInCuda(m_InteropHandle); + } +#endif + m_d3dVertexBuffer->Release(); + m_d3dVertexBuffer = NULL; + } + + delete [] m_buffer; +} + +void D3D11RendererVertexBuffer::addVertexElements(PxU32 streamIndex, std::vector<D3D11_INPUT_ELEMENT_DESC> &vertexElements) const +{ + for (PxU32 i = 0; i < NUM_SEMANTICS; i++) + { + Semantic semantic = (Semantic)i; + const SemanticDesc& sm = m_semanticDescs[semantic]; + if (sm.format < NUM_FORMATS) + { + PxU8 d3dUsageIndex = 0; + LPCSTR d3dUsageName = ""; + getD3DUsage(semantic, d3dUsageName, d3dUsageIndex); + vertexElements.push_back(buildVertexElement(d3dUsageName, + d3dUsageIndex, + getD3DFormat(sm.format), + streamIndex, + (UINT)sm.offset, + D3D11_INPUT_PER_VERTEX_DATA, + 0)); + } + } +} + +void D3D11RendererVertexBuffer::swizzleColor(void* colors, PxU32 stride, PxU32 numColors, RendererVertexBuffer::Format inFormat) +{ +/* + if (inFormat == RendererVertexBuffer::FORMAT_COLOR_BGRA) + { + const void* end = ((PxU8*)colors) + (stride * numColors); + for (PxU8* iterator = (PxU8*)colors; iterator < end; iterator += stride) + { + std::swap(((PxU8*)iterator)[0], ((PxU8*)iterator)[2]); + } + } +*/ +} + +void* D3D11RendererVertexBuffer::lock(void) +{ + // For now NO_OVERWRITE is the only mapping that functions properly + return internalLock(getHint() == HINT_STATIC ? /* D3D11_MAP_WRITE_DISCARD */ D3D11_MAP_WRITE_NO_OVERWRITE : D3D11_MAP_WRITE_NO_OVERWRITE); +} + +void* D3D11RendererVertexBuffer::internalLock(D3D11_MAP MapType) +{ + void* lockedBuffer = 0; + if (m_d3dVertexBuffer) + { + if (m_bUseMapForLocking) + { + D3D11_MAPPED_SUBRESOURCE mappedRead; + m_d3dDeviceContext.Map(m_d3dVertexBuffer, 0, MapType, NULL, &mappedRead); + RENDERER_ASSERT(mappedRead.pData, "Failed to lock DIRECT3D11 Vertex Buffer."); + lockedBuffer = mappedRead.pData; + } + else + { + lockedBuffer = m_buffer; + } + } + m_bBufferWritten = true; + return lockedBuffer; +} + +void D3D11RendererVertexBuffer::unlock(void) +{ + if (m_d3dVertexBuffer) + { + if (m_bUseMapForLocking) + { + m_d3dDeviceContext.Unmap(m_d3dVertexBuffer, 0); + } + else + { + m_d3dDeviceContext.UpdateSubresource(m_d3dVertexBuffer, 0, NULL, m_buffer, m_d3dBufferDesc.ByteWidth, 0); + } + } +} + +void D3D11RendererVertexBuffer::bind(PxU32 streamID, PxU32 firstVertex) +{ + prepareForRender(); + if (m_d3dVertexBuffer) + { + ID3D11Buffer* pBuffers[1] = { m_d3dVertexBuffer }; + UINT strides[1] = { m_stride }; + UINT offsets[1] = { firstVertex* m_stride }; + m_d3dDeviceContext.IASetVertexBuffers(streamID, 1, pBuffers, strides, offsets); + } +} + +void D3D11RendererVertexBuffer::unbind(PxU32 streamID) +{ + ID3D11Buffer* pBuffers[1] = { NULL }; + UINT strides[1] = { 0 }; + UINT offsets[1] = { 0 }; + m_d3dDeviceContext.IASetVertexBuffers(streamID, 1, pBuffers, strides, offsets); +} + +void D3D11RendererVertexBuffer::onDeviceLost(void) +{ +#if PX_WINDOWS && PX_SUPPORT_GPU_PHYSX + if (m_interopContext && m_registeredInCUDA) + { + m_interopContext->unregisterResourceInCuda(m_InteropHandle); + } +#endif + + m_registeredInCUDA = false; + + if (m_d3dVertexBuffer) + { + m_d3dVertexBuffer->Release(); + m_d3dVertexBuffer = 0; + } +} + +void D3D11RendererVertexBuffer::onDeviceReset(void) +{ + if (!m_d3dVertexBuffer) + { + m_d3dDevice.CreateBuffer(&m_d3dBufferDesc, NULL, &m_d3dVertexBuffer); + RENDERER_ASSERT(m_d3dVertexBuffer, "Failed to create DIRECT3D11 Vertex Buffer."); +#if PX_WINDOWS && PX_SUPPORT_GPU_PHYSX + if (m_interopContext && m_d3dVertexBuffer && m_mustBeRegisteredInCUDA) + { + RENDERER_ASSERT(m_deferredUnlock == false, "Deferred VB Unlock must be disabled when CUDA Interop is in use.") + m_registeredInCUDA = m_interopContext->registerResourceInCudaD3D(m_InteropHandle, m_d3dVertexBuffer); + } +#endif + m_bBufferWritten = false; + } +} + +bool D3D11RendererVertexBuffer::checkBufferWritten(void) +{ + if (m_InteropHandle) + { + return true; + } + else + { + return m_bBufferWritten; + } +} + +#endif // #if defined(RENDERER_ENABLE_DIRECT3D11) diff --git a/PhysX_3.4/Samples/SampleFramework/renderer/src/d3d11/D3D11RendererVertexBuffer.h b/PhysX_3.4/Samples/SampleFramework/renderer/src/d3d11/D3D11RendererVertexBuffer.h new file mode 100644 index 00000000..e37e27e3 --- /dev/null +++ b/PhysX_3.4/Samples/SampleFramework/renderer/src/d3d11/D3D11RendererVertexBuffer.h @@ -0,0 +1,79 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved. +#ifndef D3D11_RENDERER_VERTEXBUFFER_H +#define D3D11_RENDERER_VERTEXBUFFER_H + +#include <RendererConfig.h> + +#if defined(RENDERER_ENABLE_DIRECT3D11) + +#include <RendererVertexBuffer.h> +#include "D3D11Renderer.h" + +namespace SampleRenderer +{ + +class D3D11RendererVertexBuffer : public RendererVertexBuffer, public D3D11RendererResource +{ + friend class D3D11Renderer; +public: + D3D11RendererVertexBuffer(ID3D11Device& d3dDevice, ID3D11DeviceContext& d3dDeviceContext, const RendererVertexBufferDesc& desc, bool bUseMapForLocking = TRUE); + virtual ~D3D11RendererVertexBuffer(void); + + void addVertexElements(PxU32 streamIndex, std::vector<D3D11_INPUT_ELEMENT_DESC> &vertexElements) const; + + virtual bool checkBufferWritten(void); + +protected: + virtual void swizzleColor(void* colors, PxU32 stride, PxU32 numColors, RendererVertexBuffer::Format inFormat); + + virtual void* lock(void); + virtual void unlock(void); + + virtual void bind(PxU32 streamID, PxU32 firstVertex); + virtual void unbind(PxU32 streamID); + +private: + virtual void onDeviceLost(void); + virtual void onDeviceReset(void); + + void* internalLock(D3D11_MAP MapType); + +private: + ID3D11Device& m_d3dDevice; + ID3D11DeviceContext& m_d3dDeviceContext; + ID3D11Buffer* m_d3dVertexBuffer; + D3D11_BUFFER_DESC m_d3dBufferDesc; + bool m_bUseMapForLocking; + PxU8* m_buffer; + bool m_bBufferWritten; +}; + +} // namespace SampleRenderer + +#endif // #if defined(RENDERER_ENABLE_DIRECT3D11) +#endif diff --git a/PhysX_3.4/Samples/SampleFramework/renderer/src/d3d9/D3D9Renderer.cpp b/PhysX_3.4/Samples/SampleFramework/renderer/src/d3d9/D3D9Renderer.cpp new file mode 100644 index 00000000..2c650e4b --- /dev/null +++ b/PhysX_3.4/Samples/SampleFramework/renderer/src/d3d9/D3D9Renderer.cpp @@ -0,0 +1,1183 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved. + +#include <RendererConfig.h> + +#if defined(RENDERER_ENABLE_DIRECT3D9) + +#include "D3D9Renderer.h" + +#include <RendererDesc.h> + +#include <RendererProjection.h> + +#include <RendererVertexBufferDesc.h> +#include "D3D9RendererVertexBuffer.h" + +#include <RendererIndexBufferDesc.h> +#include "D3D9RendererIndexBuffer.h" + +#include <RendererInstanceBufferDesc.h> +#include "D3D9RendererInstanceBuffer.h" + +#include <RendererMeshDesc.h> +#include <RendererMeshContext.h> +#include "D3D9RendererMesh.h" + +#include <RendererMaterialDesc.h> +#include <RendererMaterialInstance.h> +#include "D3D9RendererMaterial.h" + +#include <RendererLightDesc.h> +#include <RendererDirectionalLightDesc.h> +#include "D3D9RendererDirectionalLight.h" +#include <RendererSpotLightDesc.h> +#include "D3D9RendererSpotLight.h" + +#include <RendererTexture2DDesc.h> +#include "D3D9RendererTexture2D.h" + +#include <RendererTargetDesc.h> +#include "D3D9RendererTarget.h" + +#include <SamplePlatform.h> + +using namespace SampleRenderer; + +void SampleRenderer::convertToD3D9(D3DCOLOR &dxcolor, const RendererColor &color) +{ + const float inv255 = 1.0f / 255.0f; + dxcolor = D3DXCOLOR(color.r*inv255, color.g*inv255, color.b*inv255, color.a*inv255); +} + +void SampleRenderer::convertToD3D9(float *dxvec, const PxVec3 &vec) +{ + dxvec[0] = vec.x; + dxvec[1] = vec.y; + dxvec[2] = vec.z; +} + +void SampleRenderer::convertToD3D9(D3DMATRIX &dxmat, const physx::PxMat44 &mat) +{ + PxMat44 mat44 = mat.getTranspose(); + memcpy(&dxmat._11, mat44.front(), 4 * 4 * sizeof (float)); +} + +void SampleRenderer::convertToD3D9(D3DMATRIX &dxmat, const RendererProjection &mat) +{ + float temp[16]; + mat.getColumnMajor44(temp); + for(PxU32 r=0; r<4; r++) + for(PxU32 c=0; c<4; c++) + { + dxmat.m[r][c] = temp[c*4+r]; + } +} + +/****************************** +* D3D9Renderer::D3DXInterface * +******************************/ + +D3D9Renderer::D3DXInterface::D3DXInterface(void) +{ + memset(this, 0, sizeof(*this)); +#if defined(RENDERER_WINDOWS) +#define D3DX_DLL "d3dx9_" RENDERER_TEXT2(D3DX_SDK_VERSION) ".dll" + + m_library = LoadLibraryA(D3DX_DLL); + if(!m_library) + { + MessageBoxA(0, "Unable to load " D3DX_DLL ". Please install the latest DirectX End User Runtime available at www.microsoft.com/directx.", "Renderer Error.", MB_OK); + } + if(m_library) + { +#define FIND_D3DX_FUNCTION(_name) \ +m_##_name = (LP##_name)GetProcAddress(m_library, #_name); \ +RENDERER_ASSERT(m_##_name, "Unable to find D3DX9 Function " #_name " in " D3DX_DLL "."); + + FIND_D3DX_FUNCTION(D3DXCompileShaderFromFileA) + FIND_D3DX_FUNCTION(D3DXGetVertexShaderProfile) + FIND_D3DX_FUNCTION(D3DXGetPixelShaderProfile) + FIND_D3DX_FUNCTION(D3DXSaveSurfaceToFileInMemory) + FIND_D3DX_FUNCTION(D3DXCreateBuffer) + FIND_D3DX_FUNCTION(D3DXSaveSurfaceToFileA) + FIND_D3DX_FUNCTION(D3DXGetShaderConstantTable) + +#undef FIND_D3DX_FUNCTION + } + +#define D3DCOMPILER_DLL "D3DCompiler_" RENDERER_TEXT2(D3DX_SDK_VERSION) ".dll" + m_compiler_library = LoadLibraryA(D3DCOMPILER_DLL); + if(!m_library) + { + MessageBoxA(0, "Unable to load " D3DCOMPILER_DLL ". Please install the latest DirectX End User Runtime available at www.microsoft.com/directx.", "Renderer Error.", MB_OK); + } + + +#undef D3DX_DLL +#endif +} + +D3D9Renderer::D3DXInterface::~D3DXInterface(void) +{ +#if defined(RENDERER_WINDOWS) + if(m_library) + { + FreeLibrary(m_library); + m_library = 0; + FreeLibrary(m_compiler_library); + m_compiler_library = 0; + } +#endif +} + +#if defined(RENDERER_WINDOWS) +#define CALL_D3DX_FUNCTION(_name, _params) if(m_##_name) result = m_##_name _params; +#else +#define CALL_D3DX_FUNCTION(_name, _params) result = _name _params; +#endif + +HRESULT D3D9Renderer::D3DXInterface::CompileShaderFromFileA(LPCSTR srcFile, CONST D3DXMACRO *defines, LPD3DXINCLUDE include, LPCSTR functionName, LPCSTR profile, DWORD flags, LPD3DXBUFFER *shader, LPD3DXBUFFER *errorMsgs, LPD3DXCONSTANTTABLE *constantTable) +{ + + HRESULT result = D3DERR_NOTAVAILABLE; + CALL_D3DX_FUNCTION(D3DXCompileShaderFromFileA, (srcFile, defines, include, functionName, profile, flags, shader, errorMsgs, constantTable)); + return result; + +} + +HRESULT D3D9Renderer::D3DXInterface::GetShaderConstantTable(const DWORD* pFunction, LPD3DXCONSTANTTABLE *constantTable) +{ + HRESULT result = D3DERR_NOTAVAILABLE; + CALL_D3DX_FUNCTION(D3DXGetShaderConstantTable, (pFunction, constantTable)); + return result; +} + +HRESULT D3D9Renderer::D3DXInterface::SaveSurfaceToFileA( LPCSTR pDestFile, D3DXIMAGE_FILEFORMAT DestFormat, LPDIRECT3DSURFACE9 pSrcSurface, CONST PALETTEENTRY* pSrcPalette, CONST RECT* pSrcRect) +{ + + HRESULT result = D3DERR_NOTAVAILABLE; + CALL_D3DX_FUNCTION(D3DXSaveSurfaceToFileA, (pDestFile, DestFormat, pSrcSurface, pSrcPalette, pSrcRect)); + return result; + +} + +LPCSTR D3D9Renderer::D3DXInterface::GetVertexShaderProfile(LPDIRECT3DDEVICE9 device) +{ + + LPCSTR result = 0; + CALL_D3DX_FUNCTION(D3DXGetVertexShaderProfile, (device)); + return result; + +} + +LPCSTR D3D9Renderer::D3DXInterface::GetPixelShaderProfile(LPDIRECT3DDEVICE9 device) +{ + LPCSTR result = 0; + CALL_D3DX_FUNCTION(D3DXGetPixelShaderProfile, (device)); + return result; +} + +HRESULT D3D9Renderer::D3DXInterface::SaveSurfaceToFileInMemory(LPD3DXBUFFER *ppDestBuf, D3DXIMAGE_FILEFORMAT DestFormat, LPDIRECT3DSURFACE9 pSrcSurface, const PALETTEENTRY *pSrcPalette, const RECT *pSrcRect) +{ + HRESULT result = D3DERR_NOTAVAILABLE; + CALL_D3DX_FUNCTION(D3DXSaveSurfaceToFileInMemory, (ppDestBuf, DestFormat, pSrcSurface, pSrcPalette, pSrcRect)); + return result; +} + +HRESULT D3D9Renderer::D3DXInterface::CreateBuffer(DWORD NumBytes, LPD3DXBUFFER *ppBuffer) +{ + HRESULT result = D3DERR_NOTAVAILABLE; + CALL_D3DX_FUNCTION(D3DXCreateBuffer, (NumBytes, ppBuffer)); + return result; +} + + +#undef CALL_D3DX_FUNCTION + +/********************************** +* D3D9Renderer::ShaderEnvironment * +**********************************/ + +D3D9Renderer::ShaderEnvironment::ShaderEnvironment(void) +{ + memset(this, 0, sizeof(*this)); +} + +/*************** +* D3D9Renderer * +***************/ + +D3D9Renderer::D3D9Renderer(IDirect3D9* inDirect3d, const char* devName, PxU32 dispWidth, PxU32 dispHeight, IDirect3DDevice9* inDevice, bool inIsDeviceEx, const char* assetDir) + : Renderer( DRIVER_DIRECT3D9, NULL, assetDir ) +{ + initialize(inIsDeviceEx); + m_d3d = inDirect3d; + strcpy_s( m_deviceName, 256, devName ); + m_displayWidth = dispWidth; + m_displayHeight = dispHeight; + m_d3dDevice = inDevice; + //Users must call + // checkResize(false); + // onDeviceReset(); +} + + +void D3D9Renderer::initialize( bool isDeviceEx ) +{ + m_textVDecl = NULL; + m_useShadersForTextRendering = true; + m_pixelCenterOffset = 0.5f; + m_displayWidth = 0; + m_displayHeight = 0; + m_displayBuffer = 0; + m_d3d = 0; + m_d3dDevice = 0; + m_d3dDepthStencilSurface = 0; + m_d3dSurface = 0; + m_d3dSwapChain = 0; + m_d3dSwapDepthStencilSurface = 0; + m_d3dSwapSurface = 0; + m_isDeviceEx = isDeviceEx; + + m_viewMatrix = PxMat44(PxIdentity); +} + +D3D9Renderer::D3D9Renderer(const RendererDesc &desc, const char* assetDir) : +Renderer (DRIVER_DIRECT3D9, desc.errorCallback, assetDir) +{ + initialize(false); + SampleFramework::SamplePlatform* m_platform = SampleFramework::SamplePlatform::platform(); + m_d3d = static_cast<IDirect3D9*>(m_platform->initializeD3D9()); + RENDERER_ASSERT(m_d3d, "Could not create Direct3D9 Interface."); + if(m_d3d) + { + memset(&m_d3dPresentParams, 0, sizeof(m_d3dPresentParams)); + m_d3dPresentParams.Windowed = 1; + m_d3dPresentParams.SwapEffect = D3DSWAPEFFECT_DISCARD; + m_d3dPresentParams.BackBufferFormat = D3DFMT_X8R8G8B8; + m_d3dPresentParams.EnableAutoDepthStencil = 0; + m_d3dPresentParams.AutoDepthStencilFormat = D3DFMT_D24S8; + m_d3dPresentParams.PresentationInterval = desc.vsync ? D3DPRESENT_INTERVAL_ONE : D3DPRESENT_INTERVAL_IMMEDIATE; + + HRESULT res = m_platform->initializeD3D9Display(&m_d3dPresentParams, + m_deviceName, + m_displayWidth, + m_displayHeight, + &m_d3dDevice); + + RENDERER_ASSERT(res==D3D_OK, "Failed to create Direct3D9 Device."); + if(res==D3D_OK) + { + m_d3dPresentParamsChanged = false; + checkResize(false); + onDeviceReset(); + } + } +} + +D3D9Renderer::~D3D9Renderer(void) +{ + assert(!m_textVDecl); + SampleFramework::SamplePlatform* m_platform = SampleFramework::SamplePlatform::platform(); + + releaseAllMaterials(); + + releaseSwapchain(); + + if(m_d3dDepthStencilSurface) + { + m_d3dDevice->SetDepthStencilSurface(NULL); + m_platform->D3D9BlockUntilNotBusy(m_d3dDepthStencilSurface); + m_d3dDepthStencilSurface->Release(); + } + m_platform->D3D9DeviceBlockUntilIdle(); + if(m_d3dDevice) m_d3dDevice->Release(); + if(m_d3d) m_d3d->Release(); + if(m_displayBuffer) m_displayBuffer->Release(); +} + +bool D3D9Renderer::checkResize(bool isDeviceLost) +{ + bool isDeviceReset = false; +#if defined(RENDERER_WINDOWS) + if(SampleFramework::SamplePlatform::platform()->getWindowHandle() && m_d3dDevice) + { + PxU32 width = 0; + PxU32 height = 0; + SampleFramework::SamplePlatform::platform()->getWindowSize(width, height); + if(width && height && (width != m_displayWidth || height != m_displayHeight) || isDeviceLost) + { + bool needsReset = (m_displayWidth&&m_displayHeight&&(isDeviceLost||!useSwapchain()) ? true : false); + m_displayWidth = width; + m_displayHeight = height; + + m_d3dPresentParams.BackBufferWidth = (UINT)m_displayWidth; + m_d3dPresentParams.BackBufferHeight = (UINT)m_displayHeight; + + D3DVIEWPORT9 viewport = {0}; + m_d3dDevice->GetViewport(&viewport); + viewport.Width = (DWORD)m_displayWidth; + viewport.Height = (DWORD)m_displayHeight; + viewport.MinZ = 0.0f; + viewport.MaxZ = 1.0f; + + if(needsReset) + { + physx::PxU64 res = m_d3dDevice->TestCooperativeLevel(); + if(res == D3D_OK || res == D3DERR_DEVICENOTRESET) //if device is lost, device has to be ready for reset + { + onDeviceLost(); + isDeviceReset = resetDevice(); + if (isDeviceReset) + { + onDeviceReset(); + m_d3dDevice->SetViewport(&viewport); + } + } + } + else + { + if(m_d3dSurface == NULL) + m_d3dDevice->GetBackBuffer(0, 0, D3DBACKBUFFER_TYPE_MONO, &m_d3dSurface); + buildSwapchain(); + m_d3dDevice->SetViewport(&viewport); + } + } + } +#endif + return isDeviceReset; +} + +bool D3D9Renderer::resetDevice(void) +{ + + HRESULT res = m_d3dDevice->Reset(&m_d3dPresentParams); + RENDERER_ASSERT(res == D3D_OK, "Failed to reset Direct3D9 Device."); + if(res == D3D_OK) + { + m_d3dPresentParamsChanged = false; + return true; + } + else + { + return false; + } +} + +void D3D9Renderer::buildSwapchain(void) +{ + if (!useSwapchain()) + return; + +#if RENDERER_ENABLE_DIRECT3D9_SWAPCHAIN + // Set the DX9 surfaces back to the originals + m_d3dDevice->SetRenderTarget(0, m_d3dSurface); + m_d3dDevice->SetDepthStencilSurface(m_d3dDepthStencilSurface); + + // Release the swapchain resources + releaseSwapchain(); + + // Recreate the swapchain resources + m_d3dDevice->CreateAdditionalSwapChain(&m_d3dPresentParams, &m_d3dSwapChain); + m_d3dSwapChain->GetBackBuffer(0, D3DBACKBUFFER_TYPE_MONO, &m_d3dSwapSurface); + m_d3dDevice->CreateDepthStencilSurface(m_displayWidth,m_displayHeight,D3DFMT_D24S8, D3DMULTISAMPLE_NONE, 0, false, &m_d3dSwapDepthStencilSurface, 0); + + // Re-assign the DX9 surfaces to use the swapchain + m_d3dDevice->SetRenderTarget(0, m_d3dSwapSurface); + m_d3dDevice->SetDepthStencilSurface(m_d3dSwapDepthStencilSurface); +#endif +} + +void SampleRenderer::D3D9Renderer::releaseSwapchain() +{ +#if RENDERER_ENABLE_DIRECT3D9_SWAPCHAIN + if(m_d3dSwapChain) + { + m_d3dSwapChain->Release(); + m_d3dSwapChain = 0; + } + if(m_d3dSwapDepthStencilSurface) + { + m_d3dSwapDepthStencilSurface->Release(); + m_d3dSwapDepthStencilSurface = 0; + } + if(m_d3dSwapSurface) + { + m_d3dSwapSurface->Release(); + m_d3dSwapSurface = 0; + } +#endif +} + +bool SampleRenderer::D3D9Renderer::useSwapchain() const +{ + return RENDERER_ENABLE_DIRECT3D9_SWAPCHAIN==1; +} + +bool SampleRenderer::D3D9Renderer::validSwapchain() const +{ +#if RENDERER_ENABLE_DIRECT3D9_SWAPCHAIN + return m_d3dSwapChain && m_d3dSwapDepthStencilSurface && m_d3dSwapSurface; +#else + return false; +#endif +} + +HRESULT SampleRenderer::D3D9Renderer::presentSwapchain() +{ +#if RENDERER_ENABLE_DIRECT3D9_SWAPCHAIN + RENDERER_ASSERT(m_d3dSwapChain, "Invalid D3D9 swapchain"); + if(m_d3dSwapChain) + return m_d3dSwapChain->Present(0, 0, 0, 0, 0); + else +#endif + return D3DERR_NOTAVAILABLE; +} + +void D3D9Renderer::releaseDepthStencilSurface(void) +{ + if(m_d3dDepthStencilSurface) + { + m_d3dDepthStencilSurface->Release(); + m_d3dDepthStencilSurface = 0; + } +} + +void D3D9Renderer::onDeviceLost(void) +{ + notifyResourcesLostDevice(); + if(m_d3dDepthStencilSurface) + { + m_d3dDepthStencilSurface->Release(); + m_d3dDepthStencilSurface = 0; + } + if (m_d3dSurface) + { + m_d3dSurface->Release(); + m_d3dSurface = 0; + } + releaseSwapchain(); +} + +void D3D9Renderer::onDeviceReset(void) +{ + if(m_d3dDevice) + { + // set out initial states... + m_d3dDevice->SetRenderState(D3DRS_CULLMODE, D3DCULL_CCW); +#if defined(RENDERER_WINDOWS) + m_d3dDevice->SetRenderState(D3DRS_LIGHTING, 0); +#endif + m_d3dDevice->SetRenderState(D3DRS_ZENABLE, 1); + m_d3dDevice->GetBackBuffer(0, 0, D3DBACKBUFFER_TYPE_MONO, &m_d3dSurface); + buildDepthStencilSurface(); + buildSwapchain(); + } + notifyResourcesResetDevice(); +} + +void D3D9Renderer::buildDepthStencilSurface(void) +{ + if(m_d3dDevice) + { + PxU32 width = m_displayWidth; + PxU32 height = m_displayHeight; + if(m_d3dDepthStencilSurface) + { + D3DSURFACE_DESC dssdesc; + m_d3dDepthStencilSurface->GetDesc(&dssdesc); + if(width != (PxU32)dssdesc.Width || height != (PxU32)dssdesc.Height) + { + m_d3dDepthStencilSurface->Release(); + m_d3dDepthStencilSurface = 0; + } + } + if(!m_d3dDepthStencilSurface) + { + const D3DFORMAT depthFormat = D3DFMT_D24S8; + const D3DMULTISAMPLE_TYPE multisampleType = D3DMULTISAMPLE_NONE; + const DWORD multisampleQuality = 0; + const BOOL discard = 0; + IDirect3DSurface9 *depthSurface = 0; + HRESULT result = m_d3dDevice->CreateDepthStencilSurface((UINT)width, (UINT)height, depthFormat, multisampleType, multisampleQuality, discard, &depthSurface, 0); + RENDERER_ASSERT(result == D3D_OK, "Failed to create Direct3D9 DepthStencil Surface."); + if(result == D3D_OK) + { + m_d3dDepthStencilSurface = depthSurface; + } + } + m_d3dDevice->SetDepthStencilSurface(m_d3dDepthStencilSurface); + } +} + +// clears the offscreen buffers. +void D3D9Renderer::clearBuffers(void) +{ + if(m_d3dDevice) + { + const DWORD flags = D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER | D3DCLEAR_STENCIL; + m_d3dDevice->Clear(0, NULL, flags, D3DCOLOR_RGBA(getClearColor().r, getClearColor().g, getClearColor().b, getClearColor().a), 1.0f, 0); + } +} + +// presents the current color buffer to the screen. +// returns true on device reset and if buffers need to be rewritten. +bool D3D9Renderer::swapBuffers(void) +{ + bool isDeviceReset = false; + if(m_d3dDevice) + { + HRESULT result = S_OK; + if (useSwapchain() && validSwapchain()) + result = presentSwapchain(); + else + result = SampleFramework::SamplePlatform::platform()->D3D9Present(); + RENDERER_ASSERT(result == D3D_OK || result == D3DERR_DEVICELOST, "Unknown Direct3D9 error when swapping buffers."); + if(result == D3D_OK || result == D3DERR_DEVICELOST) + { + isDeviceReset = checkResize(result == D3DERR_DEVICELOST || m_d3dPresentParamsChanged); + } + } + return isDeviceReset; +} + +void D3D9Renderer::getWindowSize(PxU32 &width, PxU32 &height) const +{ + RENDERER_ASSERT(m_displayHeight * m_displayWidth > 0, "variables not initialized properly"); + width = m_displayWidth; + height = m_displayHeight; +} + +RendererVertexBuffer *D3D9Renderer::createVertexBuffer(const RendererVertexBufferDesc &desc) +{ + PX_PROFILE_ZONE("D3D9Renderer_createVertexBuffer",0); + D3D9RendererVertexBuffer *vb = 0; + if(m_d3dDevice) + { + RENDERER_ASSERT(desc.isValid(), "Invalid Vertex Buffer Descriptor."); + if(desc.isValid()) + { + vb = new D3D9RendererVertexBuffer(*m_d3dDevice, *this, desc); + } + } + if(vb) addResource(*vb); + return vb; +} + +RendererIndexBuffer *D3D9Renderer::createIndexBuffer(const RendererIndexBufferDesc &desc) +{ + PX_PROFILE_ZONE("D3D9Renderer_createIndexBuffer",0); + D3D9RendererIndexBuffer *ib = 0; + if(m_d3dDevice) + { + RENDERER_ASSERT(desc.isValid(), "Invalid Index Buffer Descriptor."); + if(desc.isValid()) + { + ib = new D3D9RendererIndexBuffer(*m_d3dDevice, *this, desc); + } + } + if(ib) addResource(*ib); + return ib; +} + +RendererInstanceBuffer *D3D9Renderer::createInstanceBuffer(const RendererInstanceBufferDesc &desc) +{ + PX_PROFILE_ZONE("D3D9Renderer_createInstanceBuffer",0); + D3D9RendererInstanceBuffer *ib = 0; + if(m_d3dDevice) + { + RENDERER_ASSERT(desc.isValid(), "Invalid Instance Buffer Descriptor."); + if(desc.isValid()) + { + ib = new D3D9RendererInstanceBuffer(*m_d3dDevice, *this, desc); + } + } + if(ib) addResource(*ib); + return ib; +} + +RendererTexture2D *D3D9Renderer::createTexture2D(const RendererTexture2DDesc &desc) +{ + PX_PROFILE_ZONE("D3D9Renderer_createTexture2D",0); + D3D9RendererTexture2D *texture = 0; + if(m_d3dDevice) + { + RENDERER_ASSERT(desc.isValid(), "Invalid Texture 2D Descriptor."); + if(desc.isValid()) + { + texture = new D3D9RendererTexture2D(*m_d3dDevice, *this, desc); + } + } + if(texture) addResource(*texture); + return texture; +} + +RendererTexture3D *D3D9Renderer::createTexture3D(const RendererTexture3DDesc &desc) +{ + //RENDERER_ASSERT(0, "Not implemented!"); + // TODO: Properly implement. + return 0; +} + +RendererTarget *D3D9Renderer::createTarget(const RendererTargetDesc &desc) +{ + PX_PROFILE_ZONE("D3D9Renderer_createTarget",0); + RendererTarget *target = 0; +#if defined(RENDERER_ENABLE_DIRECT3D9_TARGET) + D3D9RendererTarget *d3dTarget = 0; + RENDERER_ASSERT(desc.isValid(), "Invalid Target Descriptor."); + if(desc.isValid()) + { + d3dTarget = new D3D9RendererTarget(*m_d3dDevice, desc); + } + if(d3dTarget) addResource(*d3dTarget); + target = d3dTarget; +#endif + return target; +} + +RendererMaterial *D3D9Renderer::createMaterial(const RendererMaterialDesc &desc) +{ + RendererMaterial *mat = hasMaterialAlready(desc); + RENDERER_ASSERT(desc.isValid(), "Invalid Material Descriptor."); + if(!mat && desc.isValid()) + { + PX_PROFILE_ZONE("D3D9Renderer_createMaterial",0); + mat = new D3D9RendererMaterial(*this, desc); + + registerMaterial(desc, mat); + } + return mat; +} + +RendererMesh *D3D9Renderer::createMesh(const RendererMeshDesc &desc) +{ + PX_PROFILE_ZONE("D3D9Renderer_createMesh",0); + D3D9RendererMesh *mesh = 0; + RENDERER_ASSERT(desc.isValid(), "Invalid Mesh Descriptor."); + if(desc.isValid()) + { + mesh = new D3D9RendererMesh(*this, desc); + } + return mesh; +} + +RendererLight *D3D9Renderer::createLight(const RendererLightDesc &desc) +{ + PX_PROFILE_ZONE("D3D9Renderer_createLight",0); + RendererLight *light = 0; + if(m_d3dDevice) + { + RENDERER_ASSERT(desc.isValid(), "Invalid Light Descriptor."); + if(desc.isValid()) + { + switch(desc.type) + { + case RendererLight::TYPE_DIRECTIONAL: + light = new D3D9RendererDirectionalLight(*this, *(RendererDirectionalLightDesc*)&desc); + break; + case RendererLight::TYPE_SPOT: + light = new D3D9RendererSpotLight(*this, *(RendererSpotLightDesc*)&desc); + break; + default: + RENDERER_ASSERT(0, "Not implemented!"); + } + } + } + return light; +} + +void D3D9Renderer::setVsync(bool on) +{ + UINT newVal = on ? D3DPRESENT_INTERVAL_ONE : D3DPRESENT_INTERVAL_IMMEDIATE; + m_d3dPresentParamsChanged |= m_d3dPresentParams.PresentationInterval != newVal; + m_d3dPresentParams.PresentationInterval = newVal; + //RENDERER_ASSERT(0, "Not implemented!"); +} + +void D3D9Renderer::disableDepthTest() +{ + m_d3dDevice->SetRenderState(D3DRS_ZENABLE, 0); +} + +void D3D9Renderer::enableDepthTest() +{ + m_d3dDevice->SetRenderState(D3DRS_ZENABLE, 1); +} + +bool D3D9Renderer::beginRender(void) +{ + bool ok = false; + if(m_d3dDevice) + { + ok = m_d3dDevice->BeginScene() == D3D_OK; + } + return ok; +} + +void D3D9Renderer::endRender(void) +{ + if(m_d3dDevice) + { + m_d3dDevice->EndScene(); + } +} + +void D3D9Renderer::bindViewProj(const physx::PxMat44 &eye, const RendererProjection &proj) +{ + m_viewMatrix = eye.inverseRT(); + convertToD3D9(m_environment.viewMatrix, m_viewMatrix); + convertToD3D9(m_environment.projMatrix, proj); + + const PxVec3 eyePosition = eye.getPosition(); + const PxVec3 eyeDirection = -eye.getBasis(2); + memcpy(m_environment.eyePosition, &eyePosition.x, sizeof(float)*3); + memcpy(m_environment.eyeDirection, &eyeDirection.x, sizeof(float)*3); +} + +void D3D9Renderer::bindFogState(const RendererColor &fogColor, float fogDistance) +{ + const float inv255 = 1.0f / 255.0f; + + m_environment.fogColorAndDistance[0] = fogColor.r*inv255; + m_environment.fogColorAndDistance[1] = fogColor.g*inv255; + m_environment.fogColorAndDistance[2] = fogColor.b*inv255; + m_environment.fogColorAndDistance[3] = fogDistance; +} + +void D3D9Renderer::bindAmbientState(const RendererColor &ambientColor) +{ + convertToD3D9(m_environment.ambientColor, ambientColor); +} + +void D3D9Renderer::bindDeferredState(void) +{ + RENDERER_ASSERT(0, "Not implemented!"); +} + +void D3D9Renderer::bindMeshContext(const RendererMeshContext &context) +{ + physx::PxMat44 model; + physx::PxMat44 modelView; + if(context.transform) model = *context.transform; + else model = PxMat44(PxIdentity); + modelView = m_viewMatrix * model; + + convertToD3D9(m_environment.modelMatrix, model); + convertToD3D9(m_environment.modelViewMatrix, modelView); + + // it appears that D3D winding is backwards, so reverse them... + DWORD cullMode = D3DCULL_CCW; + switch(context.cullMode) + { + case RendererMeshContext::CLOCKWISE: + cullMode = context.negativeScale ? D3DCULL_CW : D3DCULL_CCW; + break; + case RendererMeshContext::COUNTER_CLOCKWISE: + cullMode = context.negativeScale ? D3DCULL_CCW : D3DCULL_CW; + break; + case RendererMeshContext::NONE: + cullMode = D3DCULL_NONE; + break; + default: + RENDERER_ASSERT(0, "Invalid Cull Mode"); + } + if (!blendingCull() && NULL != context.material && context.material->getBlending()) + cullMode = D3DCULL_NONE; + + m_d3dDevice->SetRenderState(D3DRS_CULLMODE, cullMode); + + DWORD fillMode = D3DFILL_SOLID; + switch(context.fillMode) + { + case RendererMeshContext::SOLID: + fillMode = D3DFILL_SOLID; + break; + case RendererMeshContext::LINE: + fillMode = D3DFILL_WIREFRAME; + break; + case RendererMeshContext::POINT: + fillMode = D3DFILL_POINT; + break; + } + m_d3dDevice->SetRenderState(D3DRS_FILLMODE, fillMode); + + RENDERER_ASSERT(context.numBones <= RENDERER_MAX_BONES, "Too many bones."); + if(context.boneMatrices && context.numBones>0 && context.numBones <= RENDERER_MAX_BONES) + { + for(PxU32 i=0; i<context.numBones; i++) + { + convertToD3D9(m_environment.boneMatrices[i], context.boneMatrices[i]); + } + m_environment.numBones = context.numBones; + } +} + +void D3D9Renderer::beginMultiPass(void) +{ + if(m_d3dDevice) + { + m_d3dDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, 1); + m_d3dDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_ONE); + m_d3dDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_ONE); + m_d3dDevice->SetRenderState(D3DRS_ZFUNC, D3DCMP_EQUAL); + } +} + +void D3D9Renderer::endMultiPass(void) +{ + if(m_d3dDevice) + { + m_d3dDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, 0); + m_d3dDevice->SetRenderState(D3DRS_ZFUNC, D3DCMP_LESS); + } +} + +void D3D9Renderer::beginTransparentMultiPass(void) +{ + if(m_d3dDevice) + { + setEnableBlendingOverride(true); + m_d3dDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, 1); + m_d3dDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA); + m_d3dDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_ONE); + //m_d3dDevice->SetRenderState(D3DRS_ZFUNC, D3DCMP_EQUAL); + m_d3dDevice->SetRenderState(D3DRS_ZFUNC, D3DCMP_LESSEQUAL); + m_d3dDevice->SetRenderState(D3DRS_ZWRITEENABLE, false); + } +} + +void D3D9Renderer::endTransparentMultiPass(void) +{ + if(m_d3dDevice) + { + setEnableBlendingOverride(false); + m_d3dDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, 0); + m_d3dDevice->SetRenderState(D3DRS_ZFUNC, D3DCMP_LESS); + m_d3dDevice->SetRenderState(D3DRS_ZWRITEENABLE, true); + } +} + +void D3D9Renderer::renderDeferredLight(const RendererLight &light) +{ + RENDERER_ASSERT(0, "Not implemented!"); +} + +PxU32 D3D9Renderer::convertColor(const RendererColor& color) const +{ + D3DCOLOR outColor; + convertToD3D9(outColor, color); + + return outColor; +} + +bool D3D9Renderer::isOk(void) const +{ + bool ok = true; + if(!m_d3d) ok = false; + if(!m_d3dDevice) ok = false; +#if defined(RENDERER_WINDOWS) + ok = SampleFramework::SamplePlatform::platform()->isD3D9ok(); + if(!m_d3dx.m_library) ok = false; + // note: we could assert m_compiler_library here too, but actually loading that one is optional, so the app still may work without it. +#endif + return ok; +} + +void D3D9Renderer::addResource(D3D9RendererResource &resource) +{ + RENDERER_ASSERT(resource.m_d3dRenderer==0, "Resource already in added to the Renderer!"); + if(resource.m_d3dRenderer==0) + { + resource.m_d3dRenderer = this; + m_resources.push_back(&resource); + } +} + +void D3D9Renderer::removeResource(D3D9RendererResource &resource) +{ + RENDERER_ASSERT(resource.m_d3dRenderer==this, "Resource not part of this Renderer!"); + if(resource.m_d3dRenderer==this) + { + resource.m_d3dRenderer = 0; + const PxU32 numResources = (PxU32)m_resources.size(); + for (PxU32 i = 0; i < numResources; i++) + { + if(m_resources[i] == &resource) + { + // the order of resources needs to remain intact, otherwise a render target that has a dependency on a texture might get onDeviceReset'ed earlier which is an error + m_resources.erase(m_resources.begin() + i); + break; + } + } + } +} + +void D3D9Renderer::notifyResourcesLostDevice(void) +{ + const PxU32 numResources = (PxU32)m_resources.size(); + for(PxU32 i=0; i<numResources; i++) + { + m_resources[i]->onDeviceLost(); + } +} + +void D3D9Renderer::notifyResourcesResetDevice(void) +{ + const PxU32 numResources = (PxU32)m_resources.size(); + for(PxU32 i=0; i<numResources; i++) + { + m_resources[i]->onDeviceReset(); + } +} + + +/////////////////////////////////////////////////////////////////////////////// + +static DWORD gCullMode; +static DWORD gAlphaBlendEnable; +static DWORD gSrcBlend; +static DWORD gDstBlend; +static DWORD gFillMode; +static DWORD gZWrite; + +bool D3D9Renderer::initTexter() +{ + if(!Renderer::initTexter()) + return false; + + if(!m_textVDecl) + { + D3DVERTEXELEMENT9 vdecl[4]; + vdecl[0].Stream = 0; + vdecl[0].Offset = 0; + vdecl[0].Type = D3DDECLTYPE_FLOAT4; + vdecl[0].Method = D3DDECLMETHOD_DEFAULT; +#if defined(RENDERER_XBOX360) + vdecl[0].Usage = D3DDECLUSAGE_POSITION; // PT: D3DDECLUSAGE_POSITIONT is not available on Xbox +#endif +#if defined(RENDERER_WINDOWS) + vdecl[0].Usage = D3DDECLUSAGE_POSITIONT; +#endif + vdecl[0].UsageIndex = 0; + + vdecl[1].Stream = 0; + vdecl[1].Offset = 4*4; + vdecl[1].Type = D3DDECLTYPE_D3DCOLOR; + vdecl[1].Method = D3DDECLMETHOD_DEFAULT; + vdecl[1].Usage = D3DDECLUSAGE_COLOR; + vdecl[1].UsageIndex = 0; + + vdecl[2].Stream = 0; + vdecl[2].Offset = 4*4 + 4; + vdecl[2].Type = D3DDECLTYPE_FLOAT2; + vdecl[2].Method = D3DDECLMETHOD_DEFAULT; + vdecl[2].Usage = D3DDECLUSAGE_TEXCOORD; + vdecl[2].UsageIndex = 0; + + vdecl[3].Stream = 0xFF; + vdecl[3].Offset = 0; + vdecl[3].Type = (DWORD)D3DDECLTYPE_UNUSED; + vdecl[3].Method = 0; + vdecl[3].Usage = 0; + vdecl[3].UsageIndex = 0; + + m_d3dDevice->CreateVertexDeclaration(vdecl, &m_textVDecl); + if(!m_textVDecl) + { + closeTexter(); + return false; + } + } + + return true; +} + +void D3D9Renderer::closeTexter() +{ + if(m_textVDecl) + { + IDirect3DVertexDeclaration9* currDecl = NULL; + m_d3dDevice->GetVertexDeclaration(&currDecl); + if (currDecl == m_textVDecl) + { + m_d3dDevice->SetVertexDeclaration(NULL); + } + m_textVDecl->Release(); + m_textVDecl = NULL; + } + + Renderer::closeTexter(); +} + + +void D3D9Renderer::setupTextRenderStates() +{ + // PT: save render states. Let's just hope this isn't a pure device, else the Get method won't work + m_d3dDevice->GetRenderState(D3DRS_CULLMODE, &gCullMode); + m_d3dDevice->GetRenderState(D3DRS_ALPHABLENDENABLE, &gAlphaBlendEnable); + m_d3dDevice->GetRenderState(D3DRS_SRCBLEND, &gSrcBlend); + m_d3dDevice->GetRenderState(D3DRS_DESTBLEND, &gDstBlend); + m_d3dDevice->GetRenderState(D3DRS_FILLMODE, &gFillMode); + m_d3dDevice->GetRenderState(D3DRS_ZWRITEENABLE, &gZWrite); + + // PT: setup render states for text rendering + m_d3dDevice->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE); + m_d3dDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, true); + m_d3dDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA); + m_d3dDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA); + m_d3dDevice->SetRenderState(D3DRS_FILLMODE, D3DFILL_SOLID); + m_d3dDevice->SetRenderState(D3DRS_ZWRITEENABLE, false); + +#if defined(RENDERER_XBOX360) + // PT: D3DDECLUSAGE_POSITIONT is not available on Xbox, this is the workaround + m_d3dDevice->SetRenderState(D3DRS_VIEWPORTENABLE, false); +#endif +} + +void D3D9Renderer::resetTextRenderStates() +{ + // PT: restore render states. We want text rendering not to interfere with existing render states. + // For example the text should never be rendered in wireframe, even if the scene is. + m_d3dDevice->SetRenderState(D3DRS_CULLMODE, gCullMode); + m_d3dDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, gAlphaBlendEnable); + m_d3dDevice->SetRenderState(D3DRS_SRCBLEND, gSrcBlend); + m_d3dDevice->SetRenderState(D3DRS_DESTBLEND, gDstBlend); + m_d3dDevice->SetRenderState(D3DRS_FILLMODE, gFillMode); + m_d3dDevice->SetRenderState(D3DRS_ZWRITEENABLE, gZWrite); +#if defined(RENDERER_XBOX360) + m_d3dDevice->SetRenderState(D3DRS_VIEWPORTENABLE, true); +#endif +} + +void D3D9Renderer::renderTextBuffer(const void* vertices, PxU32 nbVerts, const PxU16* indices, PxU32 nbIndices, RendererMaterial* material) +{ + PX_UNUSED(material); + // PT: font texture must have been selected prior to calling this function + const int PrimCount = nbIndices/3; + const int Stride = sizeof(TextVertex); + + if(m_textVDecl && FAILED(m_d3dDevice->SetVertexDeclaration(m_textVDecl))) + { + assert(0); + return; + } + + DWORD hr = m_d3dDevice->DrawIndexedPrimitiveUP(D3DPT_TRIANGLELIST, 0, nbVerts, PrimCount, indices, D3DFMT_INDEX16, vertices, Stride); + if(FAILED(hr)) + { + // printf("Error!\n"); + } +} + +void D3D9Renderer::renderLines2D(const void* vertices, PxU32 nbVerts) +{ + const int PrimCount = nbVerts-1; + const int Stride = sizeof(TextVertex); + + if(m_textVDecl && FAILED(m_d3dDevice->SetVertexDeclaration(m_textVDecl))) + { + assert(0); + return; + } + + DWORD hr = m_d3dDevice->DrawPrimitiveUP(D3DPT_LINESTRIP, PrimCount, vertices, Stride); + if(FAILED(hr)) + { + // printf("Error!\n"); + } +} + +void D3D9Renderer::setupScreenquadRenderStates() +{ + m_d3dDevice->GetRenderState(D3DRS_CULLMODE, &gCullMode); + m_d3dDevice->GetRenderState(D3DRS_FILLMODE, &gFillMode); + + m_d3dDevice->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE); + m_d3dDevice->SetRenderState(D3DRS_FILLMODE, D3DFILL_SOLID); + + m_d3dDevice->SetRenderState(D3DRS_ZWRITEENABLE, false); +#if defined(RENDERER_XBOX360) + m_d3dDevice->SetRenderState(D3DRS_VIEWPORTENABLE, false); +#endif +} + +void D3D9Renderer::resetScreenquadRenderStates() +{ + m_d3dDevice->SetRenderState(D3DRS_CULLMODE, gCullMode); + m_d3dDevice->SetRenderState(D3DRS_FILLMODE, gFillMode); + m_d3dDevice->SetRenderState(D3DRS_ZWRITEENABLE, true); +#if defined(RENDERER_XBOX360) + m_d3dDevice->SetRenderState(D3DRS_VIEWPORTENABLE, true); +#endif +} + +bool D3D9Renderer::captureScreen( PxU32 &width, PxU32& height, PxU32& sizeInBytes, const void*& screenshotData ) +{ +#if defined(RENDERER_XBOX360) + return false; +#else + bool bSuccess = false; + + IDirect3DSurface9* backBuffer = NULL; + if (useSwapchain() && validSwapchain()) + { +#if RENDERER_ENABLE_DIRECT3D9_SWAPCHAIN + bSuccess = SUCCEEDED(m_d3dSwapChain->GetBackBuffer(0, D3DBACKBUFFER_TYPE_MONO, &backBuffer)); +#endif + } + else + { + bSuccess = SUCCEEDED(m_d3dDevice->GetBackBuffer(0, 0, D3DBACKBUFFER_TYPE_MONO, &backBuffer)); + } + + if (bSuccess) + { + bSuccess = false; + if(m_displayBuffer) + { + m_displayBuffer->Release(); + m_displayBuffer = 0; + } + + if(SUCCEEDED(m_d3dx.SaveSurfaceToFileInMemory(&m_displayBuffer, D3DXIFF_BMP, backBuffer, NULL, NULL))) + { + getWindowSize(width, height); + sizeInBytes = (physx::PxU32)m_displayBuffer->GetBufferSize(); + screenshotData = m_displayBuffer->GetBufferPointer(); + bSuccess = true; + } + backBuffer->Release(); + } + + return bSuccess; +#endif +} + +#endif // #if defined(RENDERER_ENABLE_DIRECT3D9) + diff --git a/PhysX_3.4/Samples/SampleFramework/renderer/src/d3d9/D3D9Renderer.h b/PhysX_3.4/Samples/SampleFramework/renderer/src/d3d9/D3D9Renderer.h new file mode 100644 index 00000000..645d2314 --- /dev/null +++ b/PhysX_3.4/Samples/SampleFramework/renderer/src/d3d9/D3D9Renderer.h @@ -0,0 +1,299 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved. +#ifndef D3D9_RENDERER_H +#define D3D9_RENDERER_H + +#include <RendererConfig.h> + +#if defined(RENDERER_ENABLE_DIRECT3D9) + +#include <Renderer.h> +#include <vector> + +#if defined(RENDERER_DEBUG) + //#define D3D_DEBUG_INFO 1 +#endif + +#if defined(RENDERER_XBOX360) +#include <xtl.h> +#endif +#include <d3d9.h> +#include <d3dx9.h> + +// Enables/Disables use of non-managed resources for vertex/instance buffers. +// Disabled for now as it appears to actually slow us down significantly on particles. +#if defined(RENDERER_XBOX360) +#define RENDERER_ENABLE_DYNAMIC_VB_POOLS 0 +#define RENDERER_ENABLE_DIRECT3D9_SWAPCHAIN 0 +#else +#define RENDERER_ENABLE_DYNAMIC_VB_POOLS 1 +#define RENDERER_ENABLE_DIRECT3D9_SWAPCHAIN 1 +#endif +struct IDirect3DSwapChain9; + +namespace SampleRenderer +{ + + class RendererDesc; + class RendererColor; + + void convertToD3D9(D3DCOLOR &dxcolor, const RendererColor &color); + void convertToD3D9(float *dxvec, const PxVec3 &vec); + void convertToD3D9(D3DMATRIX &dxmat, const physx::PxMat44 &mat); + void convertToD3D9(D3DMATRIX &dxmat, const RendererProjection &mat); + + class D3D9RendererResource; + + class D3D9Renderer : public Renderer + { + friend class D3D9RendererResource; + public: + class D3DXInterface + { + friend class D3D9Renderer; + private: + D3DXInterface(void); + ~D3DXInterface(void); + + public: + HRESULT CompileShaderFromFileA(LPCSTR srcFile, CONST D3DXMACRO *defines, LPD3DXINCLUDE include, LPCSTR functionName, LPCSTR profile, DWORD flags, LPD3DXBUFFER *shader, LPD3DXBUFFER *errorMsgs, LPD3DXCONSTANTTABLE *constantTable); + HRESULT GetShaderConstantTable(const DWORD* pFunction, LPD3DXCONSTANTTABLE *constantTable); + LPCSTR GetVertexShaderProfile(LPDIRECT3DDEVICE9 device); + LPCSTR GetPixelShaderProfile(LPDIRECT3DDEVICE9 device); + HRESULT SaveSurfaceToFileInMemory(LPD3DXBUFFER *ppDestBuf, D3DXIMAGE_FILEFORMAT DestFormat, LPDIRECT3DSURFACE9 pSrcSurface, const PALETTEENTRY *pSrcPalette, const RECT *pSrcRect); + HRESULT CreateBuffer(DWORD NumBytes, LPD3DXBUFFER *ppBuffer); + HRESULT SaveSurfaceToFileA( LPCSTR pDestFile, D3DXIMAGE_FILEFORMAT DestFormat, LPDIRECT3DSURFACE9 pSrcSurface, CONST PALETTEENTRY* pSrcPalette, CONST RECT* pSrcRect); + + public: +#if defined(RENDERER_WINDOWS) + HMODULE m_library; + HMODULE m_compiler_library; + +#define DEFINE_D3DX_FUNCTION(_name, _return, _params) \ + typedef _return (WINAPI* LP##_name) _params; \ + LP##_name m_##_name; + + DEFINE_D3DX_FUNCTION(D3DXCompileShaderFromFileA, HRESULT, (LPCSTR, CONST D3DXMACRO*, LPD3DXINCLUDE, LPCSTR, LPCSTR, DWORD, LPD3DXBUFFER*, LPD3DXBUFFER*, LPD3DXCONSTANTTABLE *)) + DEFINE_D3DX_FUNCTION(D3DXGetVertexShaderProfile, LPCSTR, (LPDIRECT3DDEVICE9)); + DEFINE_D3DX_FUNCTION(D3DXGetPixelShaderProfile, LPCSTR, (LPDIRECT3DDEVICE9)); + DEFINE_D3DX_FUNCTION(D3DXSaveSurfaceToFileInMemory, HRESULT, (LPD3DXBUFFER*, D3DXIMAGE_FILEFORMAT, LPDIRECT3DSURFACE9, const PALETTEENTRY*, const RECT*)); + DEFINE_D3DX_FUNCTION(D3DXSaveSurfaceToFileA, HRESULT, (LPCSTR ,D3DXIMAGE_FILEFORMAT , LPDIRECT3DSURFACE9 , CONST PALETTEENTRY* , CONST RECT* )); + DEFINE_D3DX_FUNCTION(D3DXGetShaderConstantTable, HRESULT, (const DWORD* , LPD3DXCONSTANTTABLE*)); + DEFINE_D3DX_FUNCTION(D3DXCreateBuffer, HRESULT, (DWORD, LPD3DXBUFFER*)); + +#undef DEFINE_D3DX_FUNCTION +#endif + }; + + class ShaderEnvironment + { + public: + D3DMATRIX modelMatrix; + D3DMATRIX viewMatrix; + D3DMATRIX projMatrix; + D3DMATRIX modelViewMatrix; + D3DMATRIX modelViewProjMatrix; + + D3DXMATRIX boneMatrices[RENDERER_MAX_BONES]; + PxU32 numBones; + + float fogColorAndDistance[4]; + + float eyePosition[3]; + float eyeDirection[3]; + + D3DCOLOR ambientColor; + + D3DCOLOR lightColor; + float lightIntensity; + float lightDirection[3]; + float lightPosition[3]; + float lightInnerRadius; + float lightOuterRadius; + float lightInnerCone; + float lightOuterCone; + IDirect3DTexture9 *lightShadowMap; + D3DXMATRIX lightShadowMatrix; + + public: + ShaderEnvironment(void); + }; + + protected: + D3D9Renderer(IDirect3D9* inDirect3d, const char* devName, PxU32 dispWidth, PxU32 dispHeight, IDirect3DDevice9* inDevice, bool isDeviceEx, const char* assetDir); + void initialize(bool isDeviceEx); + + public: + D3D9Renderer(const RendererDesc &desc, const char* assetDir); + virtual ~D3D9Renderer(void); + + IDirect3DDevice9 *getD3DDevice(void) { return m_d3dDevice; } + D3DXInterface &getD3DX(void) { return m_d3dx; } + ShaderEnvironment &getShaderEnvironment(void) { return m_environment; } + const ShaderEnvironment &getShaderEnvironment(void) const { return m_environment; } + + protected: + virtual bool checkResize(bool isDeviceLost); + void buildDepthStencilSurface(void); + void buildSwapchain(); + void releaseSwapchain(); + bool useSwapchain() const; + bool validSwapchain() const; + HRESULT presentSwapchain(); + + void releaseDepthStencilSurface(void); + public: + bool resetDevice(void); + void onDeviceLost(void); + void onDeviceReset(void); + + public: + // clears the offscreen buffers. + virtual void clearBuffers(void); + + // presents the current color buffer to the screen. + // returns true on device reset and if buffers need to be rewritten. + virtual bool swapBuffers(void); + + // get the device pointer (void * abstraction) + virtual void *getDevice() { return static_cast<void*>(getD3DDevice()); } + + // get the window size + void getWindowSize(PxU32 &width, PxU32 &height) const; + + // gets a handle to the current frame's data, in bitmap format + // note: subsequent calls will invalidate any previously returned data + // return true on successful screenshot capture + virtual bool captureScreen(PxU32 &width, PxU32& height, PxU32& sizeInBytes, const void*& screenshotData); + + virtual RendererVertexBuffer *createVertexBuffer( const RendererVertexBufferDesc &desc); + virtual RendererIndexBuffer *createIndexBuffer( const RendererIndexBufferDesc &desc); + virtual RendererInstanceBuffer *createInstanceBuffer(const RendererInstanceBufferDesc &desc); + virtual RendererTexture2D *createTexture2D( const RendererTexture2DDesc &desc); + virtual RendererTexture3D *createTexture3D( const RendererTexture3DDesc &desc); + virtual RendererTarget *createTarget( const RendererTargetDesc &desc); + virtual RendererMaterial *createMaterial( const RendererMaterialDesc &desc); + virtual RendererMesh *createMesh( const RendererMeshDesc &desc); + virtual RendererLight *createLight( const RendererLightDesc &desc); + + virtual void disableDepthTest(); + virtual void enableDepthTest(); + + virtual void setVsync(bool on); + + virtual bool initTexter(); + virtual void closeTexter(); + + virtual bool beginRender(void); + virtual void endRender(void); + + bool canUseManagedResources() { return !m_isDeviceEx; } + + virtual void bindViewProj(const physx::PxMat44 &eye, const RendererProjection &proj); + virtual void bindFogState(const RendererColor &fogColor, float fogDistance); + virtual void bindAmbientState(const RendererColor &ambientColor); + virtual void bindDeferredState(void); + virtual void bindMeshContext(const RendererMeshContext &context); + virtual void beginMultiPass(void); + virtual void endMultiPass(void); + virtual void beginTransparentMultiPass(void); + virtual void endTransparentMultiPass(void); + virtual void renderDeferredLight(const RendererLight &light); + virtual PxU32 convertColor(const RendererColor& color) const; + + virtual bool isOk(void) const; + + virtual void setupTextRenderStates(); + virtual void resetTextRenderStates(); + virtual void renderTextBuffer(const void* vertices, PxU32 nbVerts, const PxU16* indices, PxU32 nbIndices, RendererMaterial* material); + virtual void renderLines2D(const void* vertices, PxU32 nbVerts); + virtual void setupScreenquadRenderStates(); + virtual void resetScreenquadRenderStates(); + + private: + void addResource(D3D9RendererResource &resource); + void removeResource(D3D9RendererResource &resource); + void notifyResourcesLostDevice(void); + void notifyResourcesResetDevice(void); + + protected: + PxU32 m_displayWidth; + PxU32 m_displayHeight; + ID3DXBuffer *m_displayBuffer; + + IDirect3D9 *m_d3d; + IDirect3DDevice9 *m_d3dDevice; + IDirect3DSurface9 *m_d3dDepthStencilSurface; + IDirect3DSurface9 *m_d3dSurface; + + IDirect3DSwapChain9 *m_d3dSwapChain; + IDirect3DSurface9 *m_d3dSwapDepthStencilSurface; + IDirect3DSurface9 *m_d3dSwapSurface; + private: + bool m_isDeviceEx; //implications all over the place + + D3DXInterface m_d3dx; + + ShaderEnvironment m_environment; + + D3DPRESENT_PARAMETERS m_d3dPresentParams; + bool m_d3dPresentParamsChanged; + + physx::PxMat44 m_viewMatrix; + + // non-managed resources... + std::vector<D3D9RendererResource*> m_resources; + + IDirect3DVertexDeclaration9* m_textVDecl; + }; + + class D3D9RendererResource + { + friend class D3D9Renderer; + public: + D3D9RendererResource(void) + { + m_d3dRenderer = 0; + } + + virtual ~D3D9RendererResource(void) + { + if(m_d3dRenderer) m_d3dRenderer->removeResource(*this); + } + + public: + virtual void onDeviceLost(void)=0; + virtual void onDeviceReset(void)=0; + + private: + D3D9Renderer *m_d3dRenderer; + }; + +} // namespace SampleRenderer + +#endif // #if defined(RENDERER_ENABLE_DIRECT3D9) +#endif diff --git a/PhysX_3.4/Samples/SampleFramework/renderer/src/d3d9/D3D9RendererDirectionalLight.cpp b/PhysX_3.4/Samples/SampleFramework/renderer/src/d3d9/D3D9RendererDirectionalLight.cpp new file mode 100644 index 00000000..e76c20e0 --- /dev/null +++ b/PhysX_3.4/Samples/SampleFramework/renderer/src/d3d9/D3D9RendererDirectionalLight.cpp @@ -0,0 +1,56 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved. + +#include <RendererConfig.h> + +#if defined(RENDERER_ENABLE_DIRECT3D9) + +#include "D3D9RendererDirectionalLight.h" + +using namespace SampleRenderer; + +D3D9RendererDirectionalLight::D3D9RendererDirectionalLight(D3D9Renderer &renderer, const RendererDirectionalLightDesc &desc) : + RendererDirectionalLight(desc), + m_renderer(renderer) +{ + +} + +D3D9RendererDirectionalLight::~D3D9RendererDirectionalLight(void) +{ + +} + +void D3D9RendererDirectionalLight::bind(void) const +{ + D3D9Renderer::ShaderEnvironment &shaderEnv = m_renderer.getShaderEnvironment(); + convertToD3D9(shaderEnv.lightColor, m_color); + shaderEnv.lightIntensity = m_intensity; + convertToD3D9(shaderEnv.lightDirection, m_direction); +} + +#endif // #if defined(RENDERER_ENABLE_DIRECT3D9) diff --git a/PhysX_3.4/Samples/SampleFramework/renderer/src/d3d9/D3D9RendererDirectionalLight.h b/PhysX_3.4/Samples/SampleFramework/renderer/src/d3d9/D3D9RendererDirectionalLight.h new file mode 100644 index 00000000..1e5f8b6b --- /dev/null +++ b/PhysX_3.4/Samples/SampleFramework/renderer/src/d3d9/D3D9RendererDirectionalLight.h @@ -0,0 +1,56 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved. +#ifndef D3D9_RENDERER_DIRECTIONAL_LIGHT_H +#define D3D9_RENDERER_DIRECTIONAL_LIGHT_H + +#include <RendererConfig.h> + +#if defined(RENDERER_ENABLE_DIRECT3D9) + +#include <RendererDirectionalLight.h> + +#include "D3D9Renderer.h" + +namespace SampleRenderer +{ + + class D3D9RendererDirectionalLight : public RendererDirectionalLight + { + public: + D3D9RendererDirectionalLight(D3D9Renderer &renderer, const RendererDirectionalLightDesc &desc); + virtual ~D3D9RendererDirectionalLight(void); + + virtual void bind(void) const; + + private: + D3D9Renderer &m_renderer; + }; + +} // namespace SampleRenderer + +#endif // #if defined(RENDERER_ENABLE_DIRECT3D9) +#endif diff --git a/PhysX_3.4/Samples/SampleFramework/renderer/src/d3d9/D3D9RendererIndexBuffer.cpp b/PhysX_3.4/Samples/SampleFramework/renderer/src/d3d9/D3D9RendererIndexBuffer.cpp new file mode 100644 index 00000000..af56f974 --- /dev/null +++ b/PhysX_3.4/Samples/SampleFramework/renderer/src/d3d9/D3D9RendererIndexBuffer.cpp @@ -0,0 +1,161 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved. + +#include <RendererConfig.h> + +#if defined(RENDERER_ENABLE_DIRECT3D9) + +#include "D3D9RendererIndexBuffer.h" +#include <RendererIndexBufferDesc.h> + +#if PX_WINDOWS +#include <task/PxTask.h> +#endif + +using namespace SampleRenderer; + +static D3DFORMAT getD3D9Format(RendererIndexBuffer::Format format) +{ + D3DFORMAT d3dFormat = D3DFMT_UNKNOWN; + switch(format) + { + case RendererIndexBuffer::FORMAT_UINT16: d3dFormat = D3DFMT_INDEX16; break; + case RendererIndexBuffer::FORMAT_UINT32: d3dFormat = D3DFMT_INDEX32; break; + } + RENDERER_ASSERT(d3dFormat != D3DFMT_UNKNOWN, "Unable to convert to D3DFORMAT."); + return d3dFormat; +} + +D3D9RendererIndexBuffer::D3D9RendererIndexBuffer(IDirect3DDevice9 &d3dDevice, D3D9Renderer& renderer, const RendererIndexBufferDesc &desc) : + RendererIndexBuffer(desc), + m_d3dDevice(d3dDevice) +{ + m_d3dIndexBuffer = 0; + + m_usage = D3DUSAGE_WRITEONLY; + m_pool = renderer.canUseManagedResources() ? D3DPOOL_MANAGED : D3DPOOL_DEFAULT; + PxU32 indexSize = getFormatByteSize(desc.format); + m_format = getD3D9Format(desc.format); + m_bufferSize = indexSize * desc.maxIndices; + +#if RENDERER_ENABLE_DYNAMIC_VB_POOLS + if(desc.hint == RendererIndexBuffer::HINT_DYNAMIC ) + { + m_usage = desc.registerInCUDA ? 0 : D3DUSAGE_DYNAMIC | D3DUSAGE_WRITEONLY; + m_pool = D3DPOOL_DEFAULT; + } +#endif + + onDeviceReset(); + + if(m_d3dIndexBuffer) + { + m_maxIndices = desc.maxIndices; + } +} + +D3D9RendererIndexBuffer::~D3D9RendererIndexBuffer(void) +{ + if(m_d3dIndexBuffer) + { +#if PX_WINDOWS && PX_SUPPORT_GPU_PHYSX + if(m_interopContext && m_registeredInCUDA) + { + m_registeredInCUDA = !m_interopContext->unregisterResourceInCuda(m_InteropHandle); + } +#endif + m_d3dIndexBuffer->Release(); + } +} + +void D3D9RendererIndexBuffer::onDeviceLost(void) +{ + m_registeredInCUDA = false; + + if(m_pool != D3DPOOL_MANAGED && m_d3dIndexBuffer) + { +#if PX_WINDOWS && PX_SUPPORT_GPU_PHYSX + if(m_interopContext && m_registeredInCUDA) + { + m_registeredInCUDA = !m_interopContext->unregisterResourceInCuda(m_InteropHandle); + } +#endif + m_d3dIndexBuffer->Release(); + m_d3dIndexBuffer = 0; + } +} + +void D3D9RendererIndexBuffer::onDeviceReset(void) +{ + if(!m_d3dIndexBuffer) + { + m_d3dDevice.CreateIndexBuffer(m_bufferSize, m_usage, m_format, m_pool, &m_d3dIndexBuffer, 0); + RENDERER_ASSERT(m_d3dIndexBuffer, "Failed to create Direct3D9 Index Buffer."); +#if PX_WINDOWS && PX_SUPPORT_GPU_PHYSX + if(m_interopContext && m_d3dIndexBuffer && m_mustBeRegisteredInCUDA) + { + m_registeredInCUDA = m_interopContext->registerResourceInCudaD3D(m_InteropHandle, m_d3dIndexBuffer); + } +#endif + } +} + +void *D3D9RendererIndexBuffer::lock(void) +{ + void *buffer = 0; + if(m_d3dIndexBuffer) + { + const Format format = getFormat(); + const PxU32 maxIndices = getMaxIndices(); + const PxU32 bufferSize = maxIndices * getFormatByteSize(format); + if(bufferSize > 0) + { + m_d3dIndexBuffer->Lock(0, (UINT)bufferSize, &buffer, 0); + } + } + return buffer; +} + +void D3D9RendererIndexBuffer::unlock(void) +{ + if(m_d3dIndexBuffer) + { + m_d3dIndexBuffer->Unlock(); + } +} + +void D3D9RendererIndexBuffer::bind(void) const +{ + m_d3dDevice.SetIndices(m_d3dIndexBuffer); +} + +void D3D9RendererIndexBuffer::unbind(void) const +{ + m_d3dDevice.SetIndices(0); +} + +#endif // #if defined(RENDERER_ENABLE_DIRECT3D9) diff --git a/PhysX_3.4/Samples/SampleFramework/renderer/src/d3d9/D3D9RendererIndexBuffer.h b/PhysX_3.4/Samples/SampleFramework/renderer/src/d3d9/D3D9RendererIndexBuffer.h new file mode 100644 index 00000000..7a8ac9d7 --- /dev/null +++ b/PhysX_3.4/Samples/SampleFramework/renderer/src/d3d9/D3D9RendererIndexBuffer.h @@ -0,0 +1,70 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved. +#ifndef D3D9_RENDERER_INDEXBUFFER_H +#define D3D9_RENDERER_INDEXBUFFER_H + +#include <RendererConfig.h> + +#if defined(RENDERER_ENABLE_DIRECT3D9) + +#include <RendererIndexBuffer.h> +#include "D3D9Renderer.h" + +namespace SampleRenderer +{ + + class D3D9RendererIndexBuffer : public RendererIndexBuffer, public D3D9RendererResource + { + public: + D3D9RendererIndexBuffer(IDirect3DDevice9 &d3dDevice, D3D9Renderer& renderer, const RendererIndexBufferDesc &desc); + virtual ~D3D9RendererIndexBuffer(void); + + public: + virtual void *lock(void); + virtual void unlock(void); + + private: + virtual void bind(void) const; + virtual void unbind(void) const; + + virtual void onDeviceLost(void); + virtual void onDeviceReset(void); + + private: + IDirect3DDevice9 &m_d3dDevice; + IDirect3DIndexBuffer9 *m_d3dIndexBuffer; + + DWORD m_usage; + D3DPOOL m_pool; + UINT m_bufferSize; + D3DFORMAT m_format; + }; + +} // namespace SampleRenderer + +#endif // #if defined(RENDERER_ENABLE_DIRECT3D9) +#endif diff --git a/PhysX_3.4/Samples/SampleFramework/renderer/src/d3d9/D3D9RendererInstanceBuffer.cpp b/PhysX_3.4/Samples/SampleFramework/renderer/src/d3d9/D3D9RendererInstanceBuffer.cpp new file mode 100644 index 00000000..573baba9 --- /dev/null +++ b/PhysX_3.4/Samples/SampleFramework/renderer/src/d3d9/D3D9RendererInstanceBuffer.cpp @@ -0,0 +1,266 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved. + +#include <RendererConfig.h> +#if defined(RENDERER_ENABLE_DIRECT3D9) + +#include "D3D9RendererInstanceBuffer.h" +#include <RendererInstanceBufferDesc.h> + +#if PX_WINDOWS +#include <task/PxTask.h> +#endif + +using namespace SampleRenderer; + +static D3DVERTEXELEMENT9 buildVertexElement(WORD stream, WORD offset, D3DDECLTYPE type, BYTE method, BYTE usage, BYTE usageIndex) +{ + D3DVERTEXELEMENT9 element; + element.Stream = stream; + element.Offset = offset; +#if defined(RENDERER_WINDOWS) + element.Type = (BYTE)type; +#else + element.Type = type; +#endif + element.Method = method; + element.Usage = usage; + element.UsageIndex = usageIndex; + return element; +} + +static D3DDECLTYPE getD3DType(RendererInstanceBuffer::Format format) +{ + D3DDECLTYPE d3dType = D3DDECLTYPE_UNUSED; + switch(format) + { + case RendererInstanceBuffer::FORMAT_FLOAT1: d3dType = D3DDECLTYPE_FLOAT1; break; + case RendererInstanceBuffer::FORMAT_FLOAT2: d3dType = D3DDECLTYPE_FLOAT2; break; + case RendererInstanceBuffer::FORMAT_FLOAT3: d3dType = D3DDECLTYPE_FLOAT3; break; + case RendererInstanceBuffer::FORMAT_FLOAT4: d3dType = D3DDECLTYPE_FLOAT4; break; + } + RENDERER_ASSERT(d3dType != D3DDECLTYPE_UNUSED, "Invalid Direct3D9 vertex type."); + return d3dType; +} + +static D3DDECLUSAGE getD3DUsage(RendererInstanceBuffer::Semantic semantic, PxU8 &usageIndex) +{ + D3DDECLUSAGE d3dUsage = D3DDECLUSAGE_FOG; + usageIndex = 0; + switch(semantic) + { + case RendererInstanceBuffer::SEMANTIC_POSITION: + d3dUsage = D3DDECLUSAGE_TEXCOORD; + usageIndex = RENDERER_INSTANCE_POSITION_CHANNEL; + break; + case RendererInstanceBuffer::SEMANTIC_NORMALX: + d3dUsage = D3DDECLUSAGE_TEXCOORD; + usageIndex = RENDERER_INSTANCE_NORMALX_CHANNEL; + break; + case RendererInstanceBuffer::SEMANTIC_NORMALY: + d3dUsage = D3DDECLUSAGE_TEXCOORD; + usageIndex = RENDERER_INSTANCE_NORMALY_CHANNEL; + break; + case RendererInstanceBuffer::SEMANTIC_NORMALZ: + d3dUsage = D3DDECLUSAGE_TEXCOORD; + usageIndex = RENDERER_INSTANCE_NORMALZ_CHANNEL; + break; + case RendererInstanceBuffer::SEMANTIC_VELOCITY_LIFE: + d3dUsage = D3DDECLUSAGE_TEXCOORD; + usageIndex = RENDERER_INSTANCE_VEL_LIFE_CHANNEL; + break; + case RendererInstanceBuffer::SEMANTIC_DENSITY: + d3dUsage = D3DDECLUSAGE_TEXCOORD; + usageIndex = RENDERER_INSTANCE_DENSITY_CHANNEL; + break; + case RendererInstanceBuffer::SEMANTIC_UV_OFFSET: + d3dUsage = D3DDECLUSAGE_TEXCOORD; + usageIndex = RENDERER_INSTANCE_UV_CHANNEL; + break; + case RendererInstanceBuffer::SEMANTIC_LOCAL_OFFSET: + d3dUsage = D3DDECLUSAGE_TEXCOORD; + usageIndex = RENDERER_INSTANCE_LOCAL_CHANNEL; + break; + } + RENDERER_ASSERT(d3dUsage != D3DDECLUSAGE_FOG, "Invalid Direct3D9 vertex usage."); + return d3dUsage; +} + +D3D9RendererInstanceBuffer::D3D9RendererInstanceBuffer(IDirect3DDevice9 &d3dDevice, D3D9Renderer& renderer, const RendererInstanceBufferDesc &desc) : +RendererInstanceBuffer(desc) +#if RENDERER_INSTANCING + ,m_d3dDevice(d3dDevice) +#endif +{ +#if RENDERER_INSTANCING + m_d3dVertexBuffer = 0; +#endif + + m_usage = D3DUSAGE_WRITEONLY; + m_pool = renderer.canUseManagedResources() ? D3DPOOL_MANAGED : D3DPOOL_DEFAULT; + m_bufferSize = (UINT)(desc.maxInstances * m_stride); + +#if RENDERER_ENABLE_DYNAMIC_VB_POOLS + if(desc.hint==RendererInstanceBuffer::HINT_DYNAMIC ) + { + m_usage = desc.registerInCUDA ? 0 : D3DUSAGE_DYNAMIC | D3DUSAGE_WRITEONLY; + m_pool = D3DPOOL_DEFAULT; + } +#endif + + onDeviceReset(); + +#if RENDERER_INSTANCING + if(m_d3dVertexBuffer) + { + m_maxInstances = desc.maxInstances; + } +#else + m_maxInstances = desc.maxInstances; + mInstanceBuffer = malloc(m_maxInstances*m_stride); // PX_ALLOC(m_maxInstances*m_stride); +#endif +} + +D3D9RendererInstanceBuffer::~D3D9RendererInstanceBuffer(void) +{ +#if RENDERER_INSTANCING +#if PX_WINDOWS && PX_SUPPORT_GPU_PHYSX + if(m_interopContext && m_registeredInCUDA) + { + PX_ASSERT(m_d3dVertexBuffer); + m_registeredInCUDA = !m_interopContext->unregisterResourceInCuda(m_InteropHandle); + } +#endif + if(m_d3dVertexBuffer) m_d3dVertexBuffer->Release(); +#else + free(mInstanceBuffer); // PX_FREE(mInstanceBuffer); +#endif +} + +void D3D9RendererInstanceBuffer::addVertexElements(PxU32 streamIndex, std::vector<D3DVERTEXELEMENT9> &vertexElements) const +{ + for(PxU32 i=0; i<NUM_SEMANTICS; i++) + { + Semantic semantic = (Semantic)i; + const SemanticDesc &sm = m_semanticDescs[semantic]; + if(sm.format < NUM_FORMATS) + { + PxU8 d3dUsageIndex = 0; + D3DDECLUSAGE d3dUsage = getD3DUsage(semantic, d3dUsageIndex); + vertexElements.push_back(buildVertexElement((WORD)streamIndex, (WORD)sm.offset, getD3DType(sm.format), D3DDECLMETHOD_DEFAULT, (BYTE)d3dUsage, d3dUsageIndex)); + } + } +} + +void *D3D9RendererInstanceBuffer::lock(void) +{ + PX_PROFILE_ZONE("D3D9RenderIBlock",0); + + void *lockedBuffer = 0; +#if RENDERER_INSTANCING + if(m_d3dVertexBuffer) + { + const PxU32 bufferSize = m_maxInstances * m_stride; + m_d3dVertexBuffer->Lock(0, (UINT)bufferSize, &lockedBuffer, 0); + RENDERER_ASSERT(lockedBuffer, "Failed to lock Direct3D9 Vertex Buffer."); + } +#else + lockedBuffer = mInstanceBuffer; +#endif + return lockedBuffer; +} + +void D3D9RendererInstanceBuffer::unlock(void) +{ + PX_PROFILE_ZONE("D3D9RenderIBunlock",0); +#if RENDERER_INSTANCING + if(m_d3dVertexBuffer) + { + m_d3dVertexBuffer->Unlock(); + } +#endif +} + +void D3D9RendererInstanceBuffer::bind(PxU32 streamID, PxU32 firstInstance) const +{ +#if RENDERER_INSTANCING + if(m_d3dVertexBuffer) + { + m_d3dDevice.SetStreamSourceFreq((UINT)streamID, (UINT)(D3DSTREAMSOURCE_INSTANCEDATA | 1)); + m_d3dDevice.SetStreamSource( (UINT)streamID, m_d3dVertexBuffer, firstInstance*m_stride, m_stride); + } +#endif +} + +void D3D9RendererInstanceBuffer::unbind(PxU32 streamID) const +{ +#if RENDERER_INSTANCING + m_d3dDevice.SetStreamSource((UINT)streamID, 0, 0, 0); +#endif +} + +void D3D9RendererInstanceBuffer::onDeviceLost(void) +{ +#if RENDERER_INSTANCING + +#if PX_WINDOWS && PX_SUPPORT_GPU_PHYSX + if(m_interopContext && m_registeredInCUDA) + { + PX_ASSERT(m_d3dVertexBuffer); + m_interopContext->unregisterResourceInCuda(m_InteropHandle); + } +#endif + + m_registeredInCUDA = false; + + if(m_pool != D3DPOOL_MANAGED && m_d3dVertexBuffer) + { + m_d3dVertexBuffer->Release(); + m_d3dVertexBuffer = 0; + } +#endif +} + +void D3D9RendererInstanceBuffer::onDeviceReset(void) +{ +#if RENDERER_INSTANCING + if(!m_d3dVertexBuffer) + { + m_d3dDevice.CreateVertexBuffer(m_bufferSize, m_usage, 0, m_pool, &m_d3dVertexBuffer, 0); + RENDERER_ASSERT(m_d3dVertexBuffer, "Failed to create Direct3D9 Vertex Buffer."); + +#if PX_WINDOWS && PX_SUPPORT_GPU_PHYSX + if(m_interopContext && m_d3dVertexBuffer && m_mustBeRegisteredInCUDA) + { + m_registeredInCUDA = m_interopContext->registerResourceInCudaD3D(m_InteropHandle, m_d3dVertexBuffer); + } +#endif + } +#endif +} + +#endif // #if defined(RENDERER_ENABLE_DIRECT3D9) diff --git a/PhysX_3.4/Samples/SampleFramework/renderer/src/d3d9/D3D9RendererInstanceBuffer.h b/PhysX_3.4/Samples/SampleFramework/renderer/src/d3d9/D3D9RendererInstanceBuffer.h new file mode 100644 index 00000000..bc32d885 --- /dev/null +++ b/PhysX_3.4/Samples/SampleFramework/renderer/src/d3d9/D3D9RendererInstanceBuffer.h @@ -0,0 +1,74 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved. +#ifndef D3D9_RENDERER_INSTANCEBUFFER_H +#define D3D9_RENDERER_INSTANCEBUFFER_H + +#include <RendererConfig.h> + +#if defined(RENDERER_ENABLE_DIRECT3D9) + +#include <RendererInstanceBuffer.h> +#include "D3D9Renderer.h" + +namespace SampleRenderer +{ + + class D3D9RendererInstanceBuffer : public RendererInstanceBuffer, public D3D9RendererResource + { + public: + D3D9RendererInstanceBuffer(IDirect3DDevice9 &d3dDevice, D3D9Renderer& renderer, const RendererInstanceBufferDesc &desc); + virtual ~D3D9RendererInstanceBuffer(void); + + void addVertexElements(PxU32 streamIndex, std::vector<D3DVERTEXELEMENT9> &vertexElements) const; + + protected: + virtual void *lock(void); + virtual void unlock(void); + + virtual void bind(PxU32 streamID, PxU32 firstInstance) const; + virtual void unbind(PxU32 streamID) const; + + private: + virtual void onDeviceLost(void); + virtual void onDeviceReset(void); + + private: +#if RENDERER_INSTANCING + IDirect3DDevice9 &m_d3dDevice; + IDirect3DVertexBuffer9 *m_d3dVertexBuffer; +#else + void *mInstanceBuffer; +#endif + DWORD m_usage; + D3DPOOL m_pool; + UINT m_bufferSize; + }; + +} // namespace SampleRenderer + +#endif // #if defined(RENDERER_ENABLE_DIRECT3D9) +#endif diff --git a/PhysX_3.4/Samples/SampleFramework/renderer/src/d3d9/D3D9RendererMaterial.cpp b/PhysX_3.4/Samples/SampleFramework/renderer/src/d3d9/D3D9RendererMaterial.cpp new file mode 100644 index 00000000..247e4665 --- /dev/null +++ b/PhysX_3.4/Samples/SampleFramework/renderer/src/d3d9/D3D9RendererMaterial.cpp @@ -0,0 +1,950 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved. + +#include <RendererConfig.h> + +#if defined(RENDERER_ENABLE_DIRECT3D9) + +#include "D3D9RendererMaterial.h" +#include <RendererMaterialDesc.h> + +#include "D3D9RendererTexture2D.h" + +#include <stdio.h> + +// for PsString.h +#include <PsString.h> +#include <PxTkFile.h> +#include "SampleDirManager.h" + +namespace Ps = physx::shdfnd; + +using namespace SampleRenderer; + +void D3D9RendererMaterial::setModelMatrix(const float* matrix) +{ + if (m_instancedVertexConstants.table && m_instancedVertexConstants.modelMatrix) + { + m_instancedVertexConstants.table->SetMatrix(m_renderer.getD3DDevice(), m_instancedVertexConstants.modelMatrix, (const D3DXMATRIX*)matrix); + } +} + +D3D9RendererMaterial::ShaderConstants::ShaderConstants(void) +{ + memset(this, 0, sizeof(*this)); +} + +D3D9RendererMaterial::ShaderConstants::~ShaderConstants(void) +{ + if (table) + { + table->Release(); + } +} + +static D3DXHANDLE getShaderConstantByName(ID3DXConstantTable& table, const char* name) +{ + D3DXHANDLE found = 0; + D3DXCONSTANTTABLE_DESC desc; + table.GetDesc(&desc); + for (UINT i = 0; i < desc.Constants; i++) + { + D3DXHANDLE constant = table.GetConstant(0, i); + RENDERER_ASSERT(constant, "Unable to find constant"); + if (constant) + { + D3DXCONSTANT_DESC cdesc; + UINT count = 1; + table.GetConstantDesc(constant, &cdesc, &count); + RENDERER_ASSERT(count == 1, "Unable to obtain Constant Descriptor."); + if (count == 1 && !strcmp(cdesc.Name, name)) + { + found = constant; + break; + } + } + } + return found; +} + +static D3DBLEND getD3DBlendFunc(RendererMaterial::BlendFunc func) +{ + D3DBLEND d3dfunc = D3DBLEND_FORCE_DWORD; + switch (func) + { + case RendererMaterial::BLEND_ZERO: + d3dfunc = D3DBLEND_ZERO; + break; + case RendererMaterial::BLEND_ONE: + d3dfunc = D3DBLEND_ONE; + break; + case RendererMaterial::BLEND_SRC_COLOR: + d3dfunc = D3DBLEND_SRCCOLOR; + break; + case RendererMaterial::BLEND_ONE_MINUS_SRC_COLOR: + d3dfunc = D3DBLEND_INVSRCCOLOR; + break; + case RendererMaterial::BLEND_SRC_ALPHA: + d3dfunc = D3DBLEND_SRCALPHA; + break; + case RendererMaterial::BLEND_ONE_MINUS_SRC_ALPHA: + d3dfunc = D3DBLEND_INVSRCALPHA; + break; + case RendererMaterial::BLEND_DST_ALPHA: + d3dfunc = D3DBLEND_DESTALPHA; + break; + case RendererMaterial::BLEND_ONE_MINUS_DST_ALPHA: + d3dfunc = D3DBLEND_INVDESTALPHA; + break; + case RendererMaterial::BLEND_DST_COLOR: + d3dfunc = D3DBLEND_DESTCOLOR; + break; + case RendererMaterial::BLEND_ONE_MINUS_DST_COLOR: + d3dfunc = D3DBLEND_INVDESTCOLOR; + break; + case RendererMaterial::BLEND_SRC_ALPHA_SATURATE: + d3dfunc = D3DBLEND_SRCALPHASAT; + break; + } + RENDERER_ASSERT(d3dfunc != D3DBLEND_FORCE_DWORD, "Failed to look up D3D Blend Func."); + return d3dfunc; +} + +void D3D9RendererMaterial::ShaderConstants::loadConstants(void) +{ + if (table) + { + modelMatrix = table->GetConstantByName(0, "g_" "modelMatrix"); + viewMatrix = table->GetConstantByName(0, "g_" "viewMatrix"); + projMatrix = table->GetConstantByName(0, "g_" "projMatrix"); + modelViewMatrix = table->GetConstantByName(0, "g_" "modelViewMatrix"); + modelViewProjMatrix = table->GetConstantByName(0, "g_" "modelViewProjMatrix"); + + boneMatrices = getShaderConstantByName(*table, "g_" "boneMatrices"); + + fogColorAndDistance = table->GetConstantByName(0, "g_" "fogColorAndDistance"); + + eyePosition = table->GetConstantByName(0, "g_" "eyePosition"); + eyeDirection = table->GetConstantByName(0, "g_" "eyeDirection"); + + ambientColor = table->GetConstantByName(0, "g_" "ambientColor"); + + lightColor = table->GetConstantByName(0, "g_" "lightColor"); + lightIntensity = table->GetConstantByName(0, "g_" "lightIntensity"); + lightDirection = table->GetConstantByName(0, "g_" "lightDirection"); + lightPosition = table->GetConstantByName(0, "g_" "lightPosition"); + lightInnerRadius = table->GetConstantByName(0, "g_" "lightInnerRadius"); + lightOuterRadius = table->GetConstantByName(0, "g_" "lightOuterRadius"); + lightInnerCone = table->GetConstantByName(0, "g_" "lightInnerCone"); + lightOuterCone = table->GetConstantByName(0, "g_" "lightOuterCone"); + + lightShadowMap = table->GetConstantByName(0, "g_" "lightShadowMap"); + lightShadowMatrix = table->GetConstantByName(0, "g_" "lightShadowMatrix"); + + vfaceScale = table->GetConstantByName(0, "g_" "vfaceScale"); + } +} + +void D3D9RendererMaterial::ShaderConstants::bindEnvironment(IDirect3DDevice9& d3dDevice, const D3D9Renderer::ShaderEnvironment& shaderEnv) const +{ + if (table) + { +#define SET_MATRIX(_name) \ + if(_name) \ + { \ + const D3DXMATRIX xm(shaderEnv._name); \ + table->SetMatrix(&d3dDevice, _name, &xm); \ + } + +#define SET_FLOAT3(_name) \ + if(_name) \ + { \ + const D3DXVECTOR4 xv(shaderEnv._name[0], \ + shaderEnv._name[1], \ + shaderEnv._name[2], 1); \ + table->SetVector(&d3dDevice, _name, &xv); \ + } + +#define SET_FLOAT4(_name) \ + if(_name) \ + { \ + const D3DXVECTOR4 xv(shaderEnv._name[0], \ + shaderEnv._name[1], \ + shaderEnv._name[2], \ + shaderEnv._name[3]); \ + table->SetVector(&d3dDevice, _name, &xv); \ + } + +#define SET_COLOR(_name) \ + if(_name) \ + { \ + const D3DXCOLOR xc(shaderEnv._name); \ + const D3DXVECTOR4 xv(xc.r, xc.g, xc.b, xc.a); \ + table->SetVector(&d3dDevice, _name, &xv); \ + } + +#define SET_FLOAT(_name) \ + if(_name) table->SetFloat(&d3dDevice, _name, shaderEnv._name); + + SET_MATRIX(modelMatrix) + SET_MATRIX(viewMatrix) + SET_MATRIX(projMatrix) + SET_MATRIX(modelViewMatrix) + SET_MATRIX(modelViewProjMatrix) + + if (boneMatrices && shaderEnv.numBones > 0) + { + table->SetMatrixArray(&d3dDevice, boneMatrices, shaderEnv.boneMatrices, shaderEnv.numBones); + } + + SET_FLOAT4(fogColorAndDistance) + + + SET_FLOAT3(eyePosition) + SET_FLOAT3(eyeDirection) + + SET_COLOR(ambientColor) + + SET_COLOR(lightColor) + SET_FLOAT(lightIntensity) + SET_FLOAT3(lightDirection) + SET_FLOAT3(lightPosition) + SET_FLOAT(lightInnerRadius) + SET_FLOAT(lightOuterRadius) + SET_FLOAT(lightInnerCone) + SET_FLOAT(lightOuterCone) + if (lightShadowMap) + { + UINT index = table->GetSamplerIndex(lightShadowMap); + d3dDevice.SetSamplerState((DWORD)index, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR); + d3dDevice.SetSamplerState((DWORD)index, D3DSAMP_MINFILTER, D3DTEXF_LINEAR); + d3dDevice.SetSamplerState((DWORD)index, D3DSAMP_MIPFILTER, D3DTEXF_LINEAR); + d3dDevice.SetSamplerState((DWORD)index, D3DSAMP_ADDRESSU, D3DTADDRESS_CLAMP); + d3dDevice.SetSamplerState((DWORD)index, D3DSAMP_ADDRESSV, D3DTADDRESS_CLAMP); + d3dDevice.SetTexture(index, shaderEnv.lightShadowMap); + } + SET_MATRIX(lightShadowMatrix) + + if (vfaceScale) + { + float vfs = 1.0f; + DWORD cullmode = 0; + d3dDevice.GetRenderState(D3DRS_CULLMODE, &cullmode); + if (cullmode == D3DCULL_CW) + { + vfs = -1.0f; + } +#if defined(RENDERER_XBOX360) + else if (cullmode == D3DCULL_NONE) + { + vfs = -1.0f; + } +#endif + table->SetFloat(&d3dDevice, vfaceScale, vfs); + } + +#undef SET_MATRIX +#undef SET_FLOAT3 +#undef SET_FLOAT4 +#undef SET_COLOR +#undef SET_FLOAT + } +} + +/************************************** +* D3D9RendererMaterial::D3D9Variable * +**************************************/ + +D3D9RendererMaterial::D3D9Variable::D3D9Variable(const char* name, VariableType type, PxU32 offset) : + Variable(name, type, offset) +{ + m_vertexHandle = 0; + memset(m_fragmentHandles, 0, sizeof(m_fragmentHandles)); +} + +D3D9RendererMaterial::D3D9Variable::~D3D9Variable(void) +{ + +} + +void D3D9RendererMaterial::D3D9Variable::addVertexHandle(ID3DXConstantTable& table, D3DXHANDLE handle) +{ + m_vertexHandle = handle; + D3DXCONSTANT_DESC cdesc; + UINT count = 1; + table.GetConstantDesc(handle, &cdesc, &count); + m_vertexRegister = cdesc.RegisterIndex; +} + +void D3D9RendererMaterial::D3D9Variable::addFragmentHandle(ID3DXConstantTable& table, D3DXHANDLE handle, Pass pass) +{ + m_fragmentHandles[pass] = handle; + D3DXCONSTANT_DESC cdesc; + UINT count = 1; + table.GetConstantDesc(handle, &cdesc, &count); + m_fragmentRegisters[pass] = cdesc.RegisterIndex; +} + +/********************************* +* D3D Shader Compiler Callbacks * +*********************************/ + +static void processCompileErrors(LPD3DXBUFFER errors) +{ +#if defined(RENDERER_WINDOWS) + if (errors) + { + const char* errorStr = (const char*)errors->GetBufferPointer(); + if (errorStr) + { + static bool ignoreErrors = false; + if (!ignoreErrors) + { + int ret = MessageBoxA(0, errorStr, "D3DXCompileShaderFromFile Error", MB_ABORTRETRYIGNORE); + if (ret == IDABORT) + { + exit(0); + } + else if (ret == IDIGNORE) + { + ignoreErrors = true; + } + } + } + } +#elif defined(RENDERER_XBOX360) + // this allows to watch errors in the debugger + if(errors) + { + const char *errorStr = (const char*)errors->GetBufferPointer(); + PX_UNUSED(errorStr); + } +#endif +} + +class D3D9ShaderIncluder : public ID3DXInclude +{ +public: + D3D9ShaderIncluder(const char* assetDir) : m_assetDir(assetDir) {} + +private: +#if defined(RENDERER_XBOX360) + STDMETHOD(Open)(THIS_ D3DXINCLUDE_TYPE includeType, LPCSTR fileName, LPCVOID parentData, LPCVOID* data, UINT* dataSize, LPSTR pFullPath, DWORD cbFullPath) +#else + STDMETHOD(Open)(THIS_ D3DXINCLUDE_TYPE includeType, LPCSTR fileName, LPCVOID parentData, LPCVOID* data, UINT* dataSize) +#endif + { + HRESULT result = D3DERR_NOTFOUND; + + char fullpath[1024]; + Ps::strlcpy(fullpath, 1024, m_assetDir); + Ps::strlcat(fullpath, 1024, "shaders/"); + if (includeType == D3DXINC_SYSTEM) + { + Ps::strlcat(fullpath, 1024, "include/"); + } + Ps::strlcat(fullpath, 1024, fileName); + + FILE* file = 0; + PxToolkit::fopen_s(&file, fullpath, "r"); + if (file) + { + fseek(file, 0, SEEK_END); + size_t fileLen = ftell(file); + if (fileLen > 1) + { + fseek(file, 0, SEEK_SET); + char* fileData = new char[fileLen + 1]; + fileLen = fread(fileData, 1, fileLen, file); + fileData[fileLen] = 0; + *data = fileData; + *dataSize = (UINT)fileLen; + } + fclose(file); + result = D3D_OK; + } + RENDERER_ASSERT(result == D3D_OK, "Failed to include shader header."); + return result; + } + + STDMETHOD(Close)(THIS_ LPCVOID data) + { + delete []((char*)data); + return D3D_OK; + } + + const char* m_assetDir; +}; + +D3D9RendererMaterial::D3D9RendererMaterial(D3D9Renderer& renderer, const RendererMaterialDesc& desc) : + RendererMaterial(desc, renderer.getEnableMaterialCaching()), + m_renderer(renderer) +{ + m_d3dAlphaTestFunc = D3DCMP_ALWAYS; + m_vertexShader = 0; + m_instancedVertexShader = 0; + memset(m_fragmentPrograms, 0, sizeof(m_fragmentPrograms)); + + AlphaTestFunc alphaTestFunc = getAlphaTestFunc(); + switch (alphaTestFunc) + { + case ALPHA_TEST_ALWAYS: + m_d3dAlphaTestFunc = D3DCMP_ALWAYS; + break; + case ALPHA_TEST_EQUAL: + m_d3dAlphaTestFunc = D3DCMP_EQUAL; + break; + case ALPHA_TEST_NOT_EQUAL: + m_d3dAlphaTestFunc = D3DCMP_NOTEQUAL; + break; + case ALPHA_TEST_LESS: + m_d3dAlphaTestFunc = D3DCMP_LESS; + break; + case ALPHA_TEST_LESS_EQUAL: + m_d3dAlphaTestFunc = D3DCMP_LESSEQUAL; + break; + case ALPHA_TEST_GREATER: + m_d3dAlphaTestFunc = D3DCMP_GREATER; + break; + case ALPHA_TEST_GREATER_EQUAL: + m_d3dAlphaTestFunc = D3DCMP_GREATEREQUAL; + break; + default: + RENDERER_ASSERT(0, "Unknown Alpha Test Func."); + } + + m_d3dSrcBlendFunc = getD3DBlendFunc(getSrcBlendFunc()); + m_d3dDstBlendFunc = getD3DBlendFunc(getDstBlendFunc()); + + D3D9Renderer::D3DXInterface& d3dx = m_renderer.getD3DX(); + IDirect3DDevice9* d3dDevice = m_renderer.getD3DDevice(); + if (d3dDevice) + { + D3D9ShaderIncluder shaderIncluder(m_renderer.getAssetDir()); + + const char* vertexEntry = "vmain"; + const char* vertexProfile = d3dx.GetVertexShaderProfile(d3dDevice); + const char* vertexShaderPath = desc.vertexShaderPath; + const DWORD vertexFlags = D3DXSHADER_PACKMATRIX_COLUMNMAJOR; + const D3DXMACRO vertexDefines[] = + { + {"RENDERER_VERTEX", "1"}, + {"RENDERER_D3D", "1"}, + {"SEMANTIC_TANGENT", "TANGENT"}, // This will prevent mapping tangent to texcoord5 and instead to the proper TANGENT semantic + {0, 0} + }; + + LPD3DXBUFFER vshader = 0; + + HRESULT result = loadCacheShader(vertexShaderPath, ".cache", vertexDefines, &shaderIncluder, vertexEntry, vertexProfile, vertexFlags, vshader, &m_vertexConstants.table); + + if (result == D3D_OK && vshader) + { + result = d3dDevice->CreateVertexShader((const DWORD*)vshader->GetBufferPointer(), &m_vertexShader); + RENDERER_ASSERT(result == D3D_OK && m_vertexShader, "Failed to load Vertex Shader."); + if (result == D3D_OK && m_vertexShader) + { + m_vertexConstants.loadConstants(); + if (m_vertexConstants.table) + { + loadCustomConstants(*m_vertexConstants.table, NUM_PASSES); + } + } + } + + if(vshader) + { + vshader->Release(); + } + +#if RENDERER_INSTANCING + const D3DXMACRO vertexDefinesInstanced[] = + { + {"RENDERER_VERTEX", "1"}, + {"RENDERER_D3D", "1"}, + {"RENDERER_INSTANCED", "1"}, + {"SEMANTIC_TANGENT", "TANGENT"}, +#if PX_WINDOWS + {"PX_WINDOWS", "1"}, +#endif + {0, 0} + }; +#else + const D3DXMACRO vertexDefinesInstanced[] = + { + {"RENDERER_VERTEX", "1"}, + {"RENDERER_INSTANCED", "0"}, + {"SEMANTIC_TANGENT", "TANGENT"}, +#if PX_WINDOWS + {"PX_WINDOWS", "1"}, +#endif + {0, 0} + }; +#endif + vshader = 0; + result = loadCacheShader(vertexShaderPath, ".instcache", vertexDefinesInstanced, &shaderIncluder, vertexEntry, vertexProfile, vertexFlags, vshader, &m_instancedVertexConstants.table); + + if (result == D3D_OK && vshader) + { + result = d3dDevice->CreateVertexShader((const DWORD*)vshader->GetBufferPointer(), &m_instancedVertexShader); + RENDERER_ASSERT(result == D3D_OK && m_vertexShader, "Failed to load Vertex Shader."); + if (result == D3D_OK && m_vertexShader) + { + m_instancedVertexConstants.loadConstants(); + if (m_instancedVertexConstants.table) + { + loadCustomConstants(*m_instancedVertexConstants.table, NUM_PASSES); + } + } + } + if (vshader) + { + vshader->Release(); + } + + const char* fragmentEntry = "fmain"; + const char* fragmentProfile = d3dx.GetPixelShaderProfile(d3dDevice); + const char* fragmentShaderPath = desc.fragmentShaderPath; + const DWORD fragmentFlags = D3DXSHADER_PACKMATRIX_COLUMNMAJOR; + + // profile string in the format "ps_x_x" + int majorVersion = fragmentProfile[3]-'0'; + + // vface is sm3.0 and up + bool vFaceSupported = majorVersion > 2; + // shadow shader pushes fragment prog registers > 32 which limits support to sm 3.0 as well + bool shadowsSupported = majorVersion > 2; + PX_UNUSED(shadowsSupported); + + for (PxU32 i = 0; i < NUM_PASSES; i++) + { + const D3DXMACRO fragmentDefines[] = + { + {"RENDERER_FRAGMENT", "1"}, + {getPassName((Pass)i), "1"}, + {"ENABLE_VFACE", vFaceSupported?"1":"0"}, + {"ENABLE_VFACE_SCALE", vFaceSupported?"1":"0"}, +#if PX_WINDOWS + {"PX_WINDOWS", "1"}, + {"ENABLE_SHADOWS", shadowsSupported?"1":"0"}, +#endif + {0, 0} + }; + LPD3DXBUFFER fshader = 0; + char suffix[32]; + Ps::snprintf(suffix, 32, ".cache%d", i); + result = loadCacheShader(fragmentShaderPath, suffix, fragmentDefines, &shaderIncluder, fragmentEntry, fragmentProfile, fragmentFlags, fshader, &m_fragmentConstants[i].table); + if (result == D3D_OK && fshader) + { + result = d3dDevice->CreatePixelShader((const DWORD*)fshader->GetBufferPointer(), &m_fragmentPrograms[i]); + RENDERER_ASSERT(result == D3D_OK && m_fragmentPrograms[i], "Failed to load Fragment Shader."); + if (result == D3D_OK && m_fragmentPrograms[i]) + { + m_fragmentConstants[i].loadConstants(); + if (m_fragmentConstants[i].table) + { + loadCustomConstants(*m_fragmentConstants[i].table, (Pass)i); + } + } + } + if (fshader) + { + fshader->Release(); + } + } + } +} + +D3D9RendererMaterial::~D3D9RendererMaterial(void) +{ + if (m_vertexShader) + { + m_vertexShader->Release(); + } + if (m_instancedVertexShader) + { + m_instancedVertexShader->Release(); + } + for (PxU32 i = 0; i < NUM_PASSES; i++) + { + IDirect3DPixelShader9* fp = m_fragmentPrograms[i]; + if (fp) + { + fp->Release(); + } + } +} + +void D3D9RendererMaterial::bind(RendererMaterial::Pass pass, RendererMaterialInstance* materialInstance, bool instanced) const +{ + IDirect3DDevice9* d3dDevice = m_renderer.getD3DDevice(); + RENDERER_ASSERT(pass < NUM_PASSES, "Invalid Material Pass."); + if (d3dDevice && pass < NUM_PASSES) + { + const D3D9Renderer::ShaderEnvironment& shaderEnv = m_renderer.getShaderEnvironment(); + + if (m_d3dAlphaTestFunc == D3DCMP_ALWAYS) + { + d3dDevice->SetRenderState(D3DRS_ALPHATESTENABLE, 0); + } + else + { + PxU8 alphaTestRef = (PxU8)(PxClamp(getAlphaTestRef(), 0.0f, 1.0f) * 255.0f); + d3dDevice->SetRenderState(D3DRS_ALPHATESTENABLE, 1); + d3dDevice->SetRenderState(D3DRS_ALPHAFUNC, (DWORD)m_d3dAlphaTestFunc); + d3dDevice->SetRenderState(D3DRS_ALPHAREF , (DWORD)alphaTestRef); + } + + if (getBlending()) + { + d3dDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, 1); + d3dDevice->SetRenderState(D3DRS_ZWRITEENABLE, 0); + d3dDevice->SetRenderState(D3DRS_SRCBLEND, (DWORD)m_d3dSrcBlendFunc); + d3dDevice->SetRenderState(D3DRS_DESTBLEND, (DWORD)m_d3dDstBlendFunc); + } + + if (instanced) + { + d3dDevice->SetVertexShader(m_instancedVertexShader); + } + else + { + d3dDevice->SetVertexShader(m_vertexShader); + } + + m_fragmentConstants[pass].bindEnvironment(*d3dDevice, shaderEnv); + d3dDevice->SetPixelShader(m_fragmentPrograms[pass]); + + RendererMaterial::bind(pass, materialInstance, instanced); + } +} + +void D3D9RendererMaterial::bindMeshState(bool instanced) const +{ + IDirect3DDevice9* d3dDevice = m_renderer.getD3DDevice(); + if (d3dDevice) + { + const D3D9Renderer::ShaderEnvironment& shaderEnv = m_renderer.getShaderEnvironment(); + + if (instanced) + { + m_instancedVertexConstants.bindEnvironment(*d3dDevice, shaderEnv); + } + else + { + m_vertexConstants.bindEnvironment(*d3dDevice, shaderEnv); + } + } +} + +void D3D9RendererMaterial::unbind(void) const +{ + IDirect3DDevice9* d3dDevice = m_renderer.getD3DDevice(); + if (d3dDevice) + { + if (getBlending()) + { + d3dDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, 0); + d3dDevice->SetRenderState(D3DRS_ZWRITEENABLE, 1); + } + + d3dDevice->SetVertexShader(0); + d3dDevice->SetPixelShader(0); + } +} + +template<class TextureType, class D3DTextureType> +static void bindSamplerVariable(IDirect3DDevice9& d3dDevice, ID3DXConstantTable& table, D3DXHANDLE handle, TextureType& texture) +{ + if (handle) + { + UINT samplerIndex = table.GetSamplerIndex(handle); + static_cast<D3DTextureType*>(&texture)->bind(samplerIndex); + } +} + +void D3D9RendererMaterial::bindVariable(Pass pass, const Variable& variable, const void* data) const +{ + D3D9Variable& var = *(D3D9Variable*)&variable; + IDirect3DDevice9* d3dDevice = m_renderer.getD3DDevice(); + if (d3dDevice) + { + switch (var.getType()) + { + case VARIABLE_FLOAT: + { + const float fdata[4] = {*(const float*)data, 0, 0, 0}; + if (var.m_vertexHandle) + { + d3dDevice->SetVertexShaderConstantF(var.m_vertexRegister, fdata, 1); + } + else if (var.m_fragmentHandles[pass]) + { + d3dDevice->SetPixelShaderConstantF(var.m_fragmentRegisters[pass], fdata, 1); + } + break; + } + case VARIABLE_FLOAT2: + { + const float fdata[4] = {((const float*)data)[0], ((const float*)data)[1], 0, 0}; + if (var.m_vertexHandle) + { + d3dDevice->SetVertexShaderConstantF(var.m_vertexRegister, fdata, 1); + } + else if (var.m_fragmentHandles[pass]) + { + d3dDevice->SetPixelShaderConstantF(var.m_fragmentRegisters[pass], fdata, 1); + } + break; + } + case VARIABLE_FLOAT3: + { + const float fdata[4] = {((const float*)data)[0], ((const float*)data)[1], ((const float*)data)[2], 0}; + if (var.m_vertexHandle) + { + d3dDevice->SetVertexShaderConstantF(var.m_vertexRegister, fdata, 1); + } + else if (var.m_fragmentHandles[pass]) + { + d3dDevice->SetPixelShaderConstantF(var.m_fragmentRegisters[pass], fdata, 1); + } + break; + } + case VARIABLE_FLOAT4: + { + const float fdata[4] = {((const float*)data)[0], ((const float*)data)[1], ((const float*)data)[2], ((const float*)data)[3]}; + if (var.m_vertexHandle) + { + d3dDevice->SetVertexShaderConstantF(var.m_vertexRegister, fdata, 1); + } + else if (var.m_fragmentHandles[pass]) + { + d3dDevice->SetPixelShaderConstantF(var.m_fragmentRegisters[pass], fdata, 1); + } + break; + } + case VARIABLE_SAMPLER2D: + data = *(void**)data; + RENDERER_ASSERT(data, "NULL Sampler."); + if (data) + { + bindSamplerVariable<RendererTexture2D, D3D9RendererTexture2D>(*m_renderer.getD3DDevice(), *m_vertexConstants.table, var.m_vertexHandle, *(RendererTexture2D*)data); + bindSamplerVariable<RendererTexture2D, D3D9RendererTexture2D>(*m_renderer.getD3DDevice(), *m_fragmentConstants[pass].table, var.m_fragmentHandles[pass], *(RendererTexture2D*)data); + } + break; + case VARIABLE_SAMPLER3D: + RENDERER_ASSERT(0, "3D D3D9 Textures Not Implemented."); + /* + data = *(void**)data; + RENDERER_ASSERT(data, "NULL Sampler."); + if (data) + { + bindSamplerVariable<RendererTexture3D, D3D9RendererTexture3D>(*m_renderer.getD3DDevice(), *m_vertexConstants.table, var.m_vertexHandle, *(RendererTexture2D*)data); + bindSamplerVariable<RendererTexture3D, D3D9RendererTexture3D>(*m_renderer.getD3DDevice(), *m_fragmentConstants[pass].table, var.m_fragmentHandles[pass], *(RendererTexture2D*)data); + } + */ + break; + } + } +} + +static RendererMaterial::VariableType getVariableType(const D3DXCONSTANT_DESC& desc) +{ + RendererMaterial::VariableType vt = RendererMaterial::NUM_VARIABLE_TYPES; + switch (desc.Type) + { + case D3DXPT_FLOAT: + if (desc.Rows == 4 && desc.Columns == 4) + { + vt = RendererMaterial::VARIABLE_FLOAT4x4; + } + else if (desc.Rows == 1 && desc.Columns == 1) + { + vt = RendererMaterial::VARIABLE_FLOAT; + } + else if (desc.Rows == 1 && desc.Columns == 2) + { + vt = RendererMaterial::VARIABLE_FLOAT2; + } + else if (desc.Rows == 1 && desc.Columns == 3) + { + vt = RendererMaterial::VARIABLE_FLOAT3; + } + else if (desc.Rows == 1 && desc.Columns == 4) + { + vt = RendererMaterial::VARIABLE_FLOAT4; + } + break; + case D3DXPT_SAMPLER2D: + vt = RendererMaterial::VARIABLE_SAMPLER2D; + break; + } + RENDERER_ASSERT(vt < RendererMaterial::NUM_VARIABLE_TYPES, "Unable to convert shader variable type."); + return vt; +} + +void D3D9RendererMaterial::loadCustomConstants(ID3DXConstantTable& table, Pass pass) +{ + D3DXCONSTANTTABLE_DESC desc; + table.GetDesc(&desc); + for (UINT i = 0; i < desc.Constants; i++) + { + D3DXHANDLE constant = table.GetConstant(0, i); + RENDERER_ASSERT(constant, "Unable to find constant"); + if (constant) + { + D3DXCONSTANT_DESC cdesc; + UINT count = 1; + table.GetConstantDesc(constant, &cdesc, &count); + PX_ASSERT(count == 1); + if (count == 1 && strncmp(cdesc.Name, "g_", 2)) + { + VariableType type = getVariableType(cdesc); + if (type < NUM_VARIABLE_TYPES) + { + D3D9Variable* var = 0; + // search to see if the variable already exists... + PxU32 numVariables = (PxU32)m_variables.size(); + for (PxU32 j = 0; j < numVariables; j++) + { + if (!strcmp(m_variables[j]->getName(), cdesc.Name)) + { + var = static_cast<D3D9Variable*>(m_variables[j]); + break; + } + } + // check to see if the variable is of the same type. + if (var) + { + RENDERER_ASSERT(var->getType() == type, "Variable changes type!"); + } + // if we couldn't find the variable... create a new variable... + if (!var) + { + var = new D3D9Variable(cdesc.Name, type, m_variableBufferSize); + m_variables.push_back(var); + m_variableBufferSize += var->getDataSize(); + } + // add the handle to the variable... + if (pass < NUM_PASSES) + { + var->addFragmentHandle(table, constant, pass); + } + else + { + var->addVertexHandle(table, constant); + } + } + } + } + } +} + +HRESULT D3D9RendererMaterial::loadCacheShader(LPCSTR shaderFilePath, const char* suffix, CONST D3DXMACRO *defines, LPD3DXINCLUDE shaderIncluder, LPCSTR functionName, LPCSTR profile, DWORD flags, LPD3DXBUFFER &shader, LPD3DXCONSTANTTABLE *constantTable) +{ + const char* cacheDir = m_renderer.getCacheShaderDir(); + D3D9Renderer::D3DXInterface &d3dx = m_renderer.getD3DX(); + char fullpath[1024]; + FILE* file = NULL; + WIN32_FIND_DATA FindFileData; + + if(cacheDir) + { + //get shader file time + char originpath[1024]; + Ps::strlcpy(originpath, 1024, m_renderer.getAssetDir()); + Ps::strlcat(originpath, 1024, "shaders/"); + Ps::strlcat(originpath, 1024, shaderFilePath); + + HANDLE hFind = FindFirstFile(originpath, &FindFileData); + if (hFind == INVALID_HANDLE_VALUE) + return D3DERR_NOTAVAILABLE; + FindClose(hFind); + + //read cached file + char relativepath[512]; + Ps::strlcpy(relativepath, 512, shaderFilePath); + Ps::strlcat(relativepath, 512, suffix); + + SampleFramework::SampleDirManager cacheOutputDirManager(cacheDir, false); + cacheOutputDirManager.getFilePath(relativepath, fullpath, false); + + PxToolkit::fopen_s(&file, fullpath, "rb"); + if(file) + { + FILETIME lastWriteTime1; + fread(&lastWriteTime1, 1, sizeof(FILETIME), file); + + if( CompareFileTime(&FindFileData.ftLastWriteTime, &lastWriteTime1) == 0) + { + PxU32 shaderSize; + size_t len = fread(&shaderSize, 1, sizeof(PxU32), file); + + HRESULT result = d3dx.CreateBuffer( shaderSize, &shader); + PX_ASSERT( result == D3D_OK); + if(result == D3D_OK) + { + len = fread(shader->GetBufferPointer(), 1, shader->GetBufferSize(), file); + PX_ASSERT(len == shaderSize); + result = d3dx.GetShaderConstantTable((const DWORD*)shader->GetBufferPointer(), constantTable); + } + fclose(file); + return result; + } + fclose(file); + } + } + + LPD3DXBUFFER errors = 0; + + HRESULT result = d3dx.CompileShaderFromFileA(shaderFilePath, defines, shaderIncluder, functionName, profile, flags, &shader, &errors, constantTable); + processCompileErrors(errors); + RENDERER_ASSERT(result == D3D_OK && shader, "Failed to compile shader."); + if(errors) + { + errors->Release(); + } + + //save compiled shader + if(cacheDir && result == D3D_OK && shader) + { + PxToolkit::fopen_s(&file, fullpath, "wb"); + if(file) + { + fwrite(&FindFileData.ftLastWriteTime, 1, sizeof(FILETIME), file); + + PxU32 shaderSize = shader->GetBufferSize(); + fwrite(&shaderSize, 1, sizeof(PxU32), file); + fwrite(shader->GetBufferPointer(), 1, shaderSize, file); + fclose(file); + } + } + + return result; +} + +#endif diff --git a/PhysX_3.4/Samples/SampleFramework/renderer/src/d3d9/D3D9RendererMaterial.h b/PhysX_3.4/Samples/SampleFramework/renderer/src/d3d9/D3D9RendererMaterial.h new file mode 100644 index 00000000..10ba4e64 --- /dev/null +++ b/PhysX_3.4/Samples/SampleFramework/renderer/src/d3d9/D3D9RendererMaterial.h @@ -0,0 +1,146 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved. +#ifndef D3D9_RENDERER_MATERIAL_H +#define D3D9_RENDERER_MATERIAL_H + +#include <RendererConfig.h> + +#if defined(RENDERER_ENABLE_DIRECT3D9) + +#include <RendererMaterial.h> + +#include "D3D9Renderer.h" + +namespace SampleRenderer +{ + + class D3D9Renderer; + + class D3D9RendererMaterial : public RendererMaterial + { + public: + D3D9RendererMaterial(D3D9Renderer &renderer, const RendererMaterialDesc &desc); + virtual ~D3D9RendererMaterial(void); + virtual void setModelMatrix(const float *matrix); + + private: + virtual const Renderer& getRenderer() const { return m_renderer; } + virtual void bind(RendererMaterial::Pass pass, RendererMaterialInstance *materialInstance, bool instanced) const; + virtual void bindMeshState(bool instanced) const; + virtual void unbind(void) const; + virtual void bindVariable(Pass pass, const Variable &variable, const void *data) const; + + void loadCustomConstants(ID3DXConstantTable &table, Pass pass); + HRESULT loadCacheShader(LPCSTR shaderFilePath, const char* suffix, CONST D3DXMACRO *defines, LPD3DXINCLUDE shaderIncluder, + LPCSTR functionName, LPCSTR profile, DWORD flags, LPD3DXBUFFER &shader, LPD3DXCONSTANTTABLE *constantTable); + + private: + class ShaderConstants + { + public: + LPD3DXCONSTANTTABLE table; + + D3DXHANDLE modelMatrix; + D3DXHANDLE viewMatrix; + D3DXHANDLE projMatrix; + D3DXHANDLE modelViewMatrix; + D3DXHANDLE modelViewProjMatrix; + + D3DXHANDLE boneMatrices; + + D3DXHANDLE fogColorAndDistance; + + D3DXHANDLE eyePosition; + D3DXHANDLE eyeDirection; + + D3DXHANDLE ambientColor; + + D3DXHANDLE lightColor; + D3DXHANDLE lightIntensity; + D3DXHANDLE lightDirection; + D3DXHANDLE lightPosition; + D3DXHANDLE lightInnerRadius; + D3DXHANDLE lightOuterRadius; + D3DXHANDLE lightInnerCone; + D3DXHANDLE lightOuterCone; + D3DXHANDLE lightShadowMap; + D3DXHANDLE lightShadowMatrix; + + D3DXHANDLE vfaceScale; + + public: + ShaderConstants(void); + ~ShaderConstants(void); + + void loadConstants(void); + + void bindEnvironment(IDirect3DDevice9 &d3dDevice, const D3D9Renderer::ShaderEnvironment &shaderEnv) const; + }; + + class D3D9Variable : public Variable + { + friend class D3D9RendererMaterial; + public: + D3D9Variable(const char *name, VariableType type, PxU32 offset); + virtual ~D3D9Variable(void); + + void addVertexHandle(ID3DXConstantTable &table, D3DXHANDLE handle); + void addFragmentHandle(ID3DXConstantTable &table, D3DXHANDLE handle, Pass pass); + + private: + D3D9Variable &operator=(const D3D9Variable&) { return *this; } + + private: + D3DXHANDLE m_vertexHandle; + UINT m_vertexRegister; + D3DXHANDLE m_fragmentHandles[NUM_PASSES]; + UINT m_fragmentRegisters[NUM_PASSES]; + }; + + private: + D3D9RendererMaterial &operator=(const D3D9RendererMaterial&) { return *this; } + + private: + D3D9Renderer &m_renderer; + + D3DCMPFUNC m_d3dAlphaTestFunc; + D3DBLEND m_d3dSrcBlendFunc; + D3DBLEND m_d3dDstBlendFunc; + + IDirect3DVertexShader9 *m_vertexShader; + IDirect3DVertexShader9 *m_instancedVertexShader; + IDirect3DPixelShader9 *m_fragmentPrograms[NUM_PASSES]; + + ShaderConstants m_vertexConstants; + ShaderConstants m_instancedVertexConstants; + ShaderConstants m_fragmentConstants[NUM_PASSES]; + }; + +} // namespace SampleRenderer + +#endif // #if defined(RENDERER_ENABLE_DIRECT3D9) +#endif diff --git a/PhysX_3.4/Samples/SampleFramework/renderer/src/d3d9/D3D9RendererMesh.cpp b/PhysX_3.4/Samples/SampleFramework/renderer/src/d3d9/D3D9RendererMesh.cpp new file mode 100644 index 00000000..f403c7f0 --- /dev/null +++ b/PhysX_3.4/Samples/SampleFramework/renderer/src/d3d9/D3D9RendererMesh.cpp @@ -0,0 +1,333 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved. + +#include <RendererConfig.h> + +#if defined(RENDERER_ENABLE_DIRECT3D9) + +#include "D3D9RendererMesh.h" +#include "D3D9RendererVertexBuffer.h" +#include "D3D9RendererInstanceBuffer.h" + +#include <RendererMeshDesc.h> + +#include <SamplePlatform.h> + +#pragma warning(disable:4702 4189) + +using namespace SampleRenderer; + +static D3DVERTEXELEMENT9 buildVertexElement(WORD stream, WORD offset, D3DDECLTYPE type, BYTE method, BYTE usage, BYTE usageIndex) +{ + D3DVERTEXELEMENT9 element; + element.Stream = stream; + element.Offset = offset; +#if defined(RENDERER_WINDOWS) + element.Type = (BYTE)type; +#else + element.Type = type; +#endif + element.Method = method; + element.Usage = usage; + element.UsageIndex = usageIndex; + return element; +} + +D3D9RendererMesh::D3D9RendererMesh(D3D9Renderer &renderer, const RendererMeshDesc &desc) : +RendererMesh(desc), + m_renderer(renderer) +{ + m_d3dVertexDecl = 0; + + IDirect3DDevice9 *d3dDevice = m_renderer.getD3DDevice(); + RENDERER_ASSERT(d3dDevice, "Renderer's D3D Device not found!"); + if(d3dDevice) + { + PxU32 numVertexBuffers = getNumVertexBuffers(); + const RendererVertexBuffer *const*vertexBuffers = getVertexBuffers(); + std::vector<D3DVERTEXELEMENT9> vertexElements; + for(PxU32 i=0; i<numVertexBuffers; i++) + { + const RendererVertexBuffer *vb = vertexBuffers[i]; + if(vb) + { + const D3D9RendererVertexBuffer &d3dVb = *static_cast<const D3D9RendererVertexBuffer*>(vb); + d3dVb.addVertexElements(i, vertexElements); + } + } +#if RENDERER_INSTANCING + if(m_instanceBuffer) + { + static_cast<const D3D9RendererInstanceBuffer*>(m_instanceBuffer)->addVertexElements(numVertexBuffers, vertexElements); + } +#endif + vertexElements.push_back(buildVertexElement(0xFF, 0, D3DDECLTYPE_UNUSED, 0, 0, 0)); + + d3dDevice->CreateVertexDeclaration(&vertexElements[0], &m_d3dVertexDecl); + RENDERER_ASSERT(m_d3dVertexDecl, "Failed to create Direct3D9 Vertex Declaration."); + } +} + +D3D9RendererMesh::~D3D9RendererMesh(void) +{ + if(m_d3dVertexDecl) + { + SampleFramework::SamplePlatform::platform()->D3D9BlockUntilNotBusy(m_d3dVertexDecl); + m_d3dVertexDecl->Release(); + m_d3dVertexDecl = 0; + } +} + +static D3DPRIMITIVETYPE getD3DPrimitive(RendererMesh::Primitive primitive) +{ + D3DPRIMITIVETYPE d3dPrimitive = D3DPT_FORCE_DWORD; + switch(primitive) + { + case RendererMesh::PRIMITIVE_POINTS: d3dPrimitive = D3DPT_POINTLIST; break; + case RendererMesh::PRIMITIVE_LINES: d3dPrimitive = D3DPT_LINELIST; break; + case RendererMesh::PRIMITIVE_LINE_STRIP: d3dPrimitive = D3DPT_LINESTRIP; break; + case RendererMesh::PRIMITIVE_TRIANGLES: d3dPrimitive = D3DPT_TRIANGLELIST; break; + case RendererMesh::PRIMITIVE_TRIANGLE_STRIP: d3dPrimitive = D3DPT_TRIANGLESTRIP; break; + case RendererMesh::PRIMITIVE_POINT_SPRITES: d3dPrimitive = D3DPT_POINTLIST; break; + } + RENDERER_ASSERT(d3dPrimitive != D3DPT_FORCE_DWORD, "Unable to find Direct3D9 Primitive."); + return d3dPrimitive; +} + +static PxU32 computePrimitiveCount(RendererMesh::Primitive primitive, PxU32 vertexCount) +{ + PxU32 numPrimitives = 0; + switch(primitive) + { + case RendererMesh::PRIMITIVE_POINTS: numPrimitives = vertexCount; break; + case RendererMesh::PRIMITIVE_LINES: numPrimitives = vertexCount / 2; break; + case RendererMesh::PRIMITIVE_LINE_STRIP: numPrimitives = vertexCount>=2 ? vertexCount - 1 : 0; break; + case RendererMesh::PRIMITIVE_TRIANGLES: numPrimitives = vertexCount / 3; break; + case RendererMesh::PRIMITIVE_TRIANGLE_STRIP: numPrimitives = vertexCount>=3 ? vertexCount - 2 : 0; break; + case RendererMesh::PRIMITIVE_POINT_SPRITES: numPrimitives = vertexCount; break; + } + RENDERER_ASSERT(numPrimitives, "Unable to compute the number of Primitives."); + return numPrimitives; +} + +void D3D9RendererMesh::renderIndices(PxU32 numVertices, PxU32 firstIndex, PxU32 numIndices, RendererIndexBuffer::Format indexFormat, RendererMaterial *material) const +{ + PX_PROFILE_ZONE("D3D9RendererMesh_renderIndices",0); + IDirect3DDevice9 *d3dDevice = m_renderer.getD3DDevice(); + if(d3dDevice && m_d3dVertexDecl) + { + d3dDevice->SetVertexDeclaration(m_d3dVertexDecl); + Primitive primitive = getPrimitives(); +#if RENDERER_INSTANCING + PxU32 numVertexBuffers = getNumVertexBuffers(); + // Only reset stream source when multiple vertex buffers are given + // This fixes issues with several GPU vendors when rendering a given indexed mesh multiple times + static const physx::PxU32 minVertexBuffersForStreamSourceReset = 2; + if (numVertexBuffers >= minVertexBuffersForStreamSourceReset) + { + for(PxU32 i=0; i<numVertexBuffers; i++) + { + d3dDevice->SetStreamSourceFreq((UINT)i, D3DSTREAMSOURCE_INDEXEDDATA | 1); + } + } +#endif + if(primitive == RendererMesh::PRIMITIVE_POINT_SPRITES) d3dDevice->SetRenderState(D3DRS_POINTSPRITEENABLE, 1); + + d3dDevice->DrawIndexedPrimitive(getD3DPrimitive(primitive), 0, 0, numVertices, firstIndex, computePrimitiveCount(primitive, numIndices)); + + if(primitive == RendererMesh::PRIMITIVE_POINT_SPRITES) d3dDevice->SetRenderState(D3DRS_POINTSPRITEENABLE, 0); + } +} + +void D3D9RendererMesh::renderVertices(PxU32 numVertices, RendererMaterial *material) const +{ + PX_PROFILE_ZONE("D3D9RendererMesh_renderVertices",0); + IDirect3DDevice9 *d3dDevice = m_renderer.getD3DDevice(); + if(d3dDevice && m_d3dVertexDecl) + { + d3dDevice->SetVertexDeclaration(m_d3dVertexDecl); + Primitive primitive = getPrimitives(); +#if RENDERER_INSTANCING + PxU32 numVertexBuffers = getNumVertexBuffers(); + for(PxU32 i=0; i<numVertexBuffers; i++) + { + d3dDevice->SetStreamSourceFreq((UINT)i, 1); + } +#endif + if(primitive == RendererMesh::PRIMITIVE_POINT_SPRITES) d3dDevice->SetRenderState(D3DRS_POINTSPRITEENABLE, 1); + + D3DPRIMITIVETYPE d3dPrimitive = getD3DPrimitive(primitive); + PxU32 numPrimitives = computePrimitiveCount(primitive, numVertices); + PX_ASSERT(d3dPrimitive != D3DPT_LINELIST || (numVertices&1)==0); // can't have an odd number of verts when drawing lines...! + d3dDevice->DrawPrimitive(d3dPrimitive, 0, numPrimitives); + + if(primitive == RendererMesh::PRIMITIVE_POINT_SPRITES) d3dDevice->SetRenderState(D3DRS_POINTSPRITEENABLE, 0); + } +} + +void D3D9RendererMesh::renderIndicesInstanced(PxU32 numVertices, PxU32 firstIndex, PxU32 numIndices, RendererIndexBuffer::Format indexFormat,RendererMaterial *material) const +{ + PX_PROFILE_ZONE("D3D9RendererMesh_renderIndicesInstanced",0); + IDirect3DDevice9 *d3dDevice = m_renderer.getD3DDevice(); + if(d3dDevice && m_d3dVertexDecl) + { +#if RENDERER_INSTANCING + PxU32 numVertexBuffers = getNumVertexBuffers(); + for(PxU32 i=0; i<numVertexBuffers; i++) + { + d3dDevice->SetStreamSourceFreq((UINT)i, D3DSTREAMSOURCE_INDEXEDDATA | m_numInstances); + } +#endif + + d3dDevice->SetVertexDeclaration(m_d3dVertexDecl); + + Primitive primitive = getPrimitives(); + + if(primitive == RendererMesh::PRIMITIVE_POINT_SPRITES) + { + d3dDevice->SetRenderState(D3DRS_POINTSPRITEENABLE, 1); + } + +#if RENDERER_INSTANCING + d3dDevice->DrawIndexedPrimitive(getD3DPrimitive(primitive), 0, 0, numVertices, firstIndex, computePrimitiveCount(primitive, numIndices)); +#else + const PxU8 *ibuffer = (const PxU8 *)m_instanceBuffer->lock(); + ibuffer+=m_instanceBuffer->getStride()*m_firstInstance; + D3DXMATRIX m; + D3DXMatrixIdentity(&m); + for (PxU32 i=0; i<m_numInstances; i++) + { + PxF32 *dest = (PxF32 *)&m; + + const PxF32 *src = (const PxF32 *)ibuffer; + + dest[0] = src[3]; + dest[1] = src[6]; + dest[2] = src[9]; + dest[3] = src[0]; + + dest[4] = src[4]; + dest[5] = src[7]; + dest[6] = src[10]; + dest[7] = src[1]; + + dest[8] = src[5]; + dest[9] = src[8]; + dest[10] = src[11]; + dest[11] = src[2]; + + dest[12] = 0; + dest[13] = 0; + dest[14] = 0; + dest[15] = 1; + + material->setModelMatrix(dest); + d3dDevice->DrawIndexedPrimitive(getD3DPrimitive(primitive), 0, 0, numVertices, firstIndex, computePrimitiveCount(primitive, numIndices)); + ibuffer+=m_instanceBuffer->getStride(); + } +#endif + + if(primitive == RendererMesh::PRIMITIVE_POINT_SPRITES) + { + d3dDevice->SetRenderState(D3DRS_POINTSPRITEENABLE, 0); + } + } +} + +void D3D9RendererMesh::renderVerticesInstanced(PxU32 numVertices,RendererMaterial *material) const +{ + PX_PROFILE_ZONE("D3D9RendererMesh_renderVerticesInstanced",0); + IDirect3DDevice9 *d3dDevice = m_renderer.getD3DDevice(); + if(d3dDevice && m_d3dVertexDecl) + { +#if RENDERER_INSTANCING + PxU32 numVertexBuffers = getNumVertexBuffers(); + for(PxU32 i=0; i<numVertexBuffers; i++) + { + d3dDevice->SetStreamSourceFreq((UINT)i, m_numInstances); + } +#endif + + d3dDevice->SetVertexDeclaration(m_d3dVertexDecl); + + Primitive primitive = getPrimitives(); + + if(primitive == RendererMesh::PRIMITIVE_POINT_SPRITES) + { + d3dDevice->SetRenderState(D3DRS_POINTSPRITEENABLE, 1); + } + + +#if RENDERER_INSTANCING + d3dDevice->DrawPrimitive(getD3DPrimitive(primitive), 0, computePrimitiveCount(primitive, numVertices)); +#else + const PxU8 *ibuffer = (const PxU8 *)m_instanceBuffer->lock(); + D3DXMATRIX m; + D3DXMatrixIdentity(&m); + for (PxU32 i=0; i<m_numInstances; i++) + { + PxF32 *dest = (PxF32 *)&m; + + const PxF32 *src = (const PxF32 *)ibuffer; + + dest[0] = src[3]; + dest[1] = src[6]; + dest[2] = src[9]; + dest[3] = src[0]; + + dest[4] = src[4]; + dest[5] = src[7]; + dest[6] = src[10]; + dest[7] = src[1]; + + dest[8] = src[5]; + dest[9] = src[8]; + dest[10] = src[11]; + dest[11] = src[2]; + + dest[12] = 0; + dest[13] = 0; + dest[14] = 0; + dest[15] = 1; + + + material->setModelMatrix(dest); + + d3dDevice->DrawPrimitive(getD3DPrimitive(primitive), 0, computePrimitiveCount(primitive, numVertices)); + + ibuffer+=m_instanceBuffer->getStride(); + } +#endif + + if(primitive == RendererMesh::PRIMITIVE_POINT_SPRITES) + { + d3dDevice->SetRenderState(D3DRS_POINTSPRITEENABLE, 0); + } + } +} + +#endif // #if defined(RENDERER_ENABLE_DIRECT3D9) diff --git a/PhysX_3.4/Samples/SampleFramework/renderer/src/d3d9/D3D9RendererMesh.h b/PhysX_3.4/Samples/SampleFramework/renderer/src/d3d9/D3D9RendererMesh.h new file mode 100644 index 00000000..d0e8f0b0 --- /dev/null +++ b/PhysX_3.4/Samples/SampleFramework/renderer/src/d3d9/D3D9RendererMesh.h @@ -0,0 +1,66 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved. +#ifndef D3D9_RENDERER_MESH_H +#define D3D9_RENDERER_MESH_H + +#include <RendererConfig.h> + +#if defined(RENDERER_ENABLE_DIRECT3D9) + +#include <RendererMesh.h> +#include "D3D9Renderer.h" + +namespace SampleRenderer +{ + + class D3D9RendererMesh : public RendererMesh + { + public: + D3D9RendererMesh(D3D9Renderer &renderer, const RendererMeshDesc &desc); + virtual ~D3D9RendererMesh(void); + + public: + virtual void renderIndices(PxU32 numVertices, PxU32 firstIndex, PxU32 numIndices, RendererIndexBuffer::Format indexFormat,RendererMaterial *material) const; + virtual void renderVertices(PxU32 numVertices,RendererMaterial *material) const; + + virtual void renderIndicesInstanced(PxU32 numVertices, PxU32 firstIndex, PxU32 numIndices, RendererIndexBuffer::Format indexFormat,RendererMaterial *material) const; + virtual void renderVerticesInstanced(PxU32 numVertices,RendererMaterial *material) const; + + protected: + D3D9RendererMesh &operator=(const D3D9RendererMesh &) { return *this; } + + Renderer& renderer() { return m_renderer; } + + private: + D3D9Renderer &m_renderer; + IDirect3DVertexDeclaration9 *m_d3dVertexDecl; + }; + +} // namespace SampleRenderer + +#endif // #if defined(RENDERER_ENABLE_DIRECT3D9) +#endif diff --git a/PhysX_3.4/Samples/SampleFramework/renderer/src/d3d9/D3D9RendererSpotLight.cpp b/PhysX_3.4/Samples/SampleFramework/renderer/src/d3d9/D3D9RendererSpotLight.cpp new file mode 100644 index 00000000..4be8e978 --- /dev/null +++ b/PhysX_3.4/Samples/SampleFramework/renderer/src/d3d9/D3D9RendererSpotLight.cpp @@ -0,0 +1,64 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved. + +#include <RendererConfig.h> + +#if defined(RENDERER_ENABLE_DIRECT3D9) + +#include "D3D9RendererSpotLight.h" +#include "D3D9RendererTexture2D.h" + +using namespace SampleRenderer; + +D3D9RendererSpotLight::D3D9RendererSpotLight(D3D9Renderer &renderer, const RendererSpotLightDesc &desc) : + RendererSpotLight(desc), +m_renderer(renderer) +{ + +} + +D3D9RendererSpotLight::~D3D9RendererSpotLight(void) +{ + +} + +void D3D9RendererSpotLight::bind(void) const +{ + D3D9Renderer::ShaderEnvironment &shaderEnv = m_renderer.getShaderEnvironment(); + convertToD3D9(shaderEnv.lightColor, m_color); + shaderEnv.lightIntensity = m_intensity; + convertToD3D9(shaderEnv.lightPosition, m_position); + convertToD3D9(shaderEnv.lightDirection, m_direction); + shaderEnv.lightInnerRadius = m_innerRadius; + shaderEnv.lightOuterRadius = m_outerRadius; + shaderEnv.lightInnerCone = m_innerCone; + shaderEnv.lightOuterCone = m_outerCone; + shaderEnv.lightShadowMap = m_shadowMap ? static_cast<D3D9RendererTexture2D*>(m_shadowMap)->m_d3dTexture : 0; + buildProjectMatrix(shaderEnv.lightShadowMatrix, m_shadowProjection, m_shadowTransform); +} + +#endif // #if defined(RENDERER_ENABLE_DIRECT3D9) diff --git a/PhysX_3.4/Samples/SampleFramework/renderer/src/d3d9/D3D9RendererSpotLight.h b/PhysX_3.4/Samples/SampleFramework/renderer/src/d3d9/D3D9RendererSpotLight.h new file mode 100644 index 00000000..cbeb668b --- /dev/null +++ b/PhysX_3.4/Samples/SampleFramework/renderer/src/d3d9/D3D9RendererSpotLight.h @@ -0,0 +1,56 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved. +#ifndef D3D9_RENDERER_SPOT_LIGHT_H +#define D3D9_RENDERER_SPOT_LIGHT_H + +#include <RendererConfig.h> + +#if defined(RENDERER_ENABLE_DIRECT3D9) + +#include <RendererSpotLight.h> + +#include "D3D9Renderer.h" + +namespace SampleRenderer +{ + + class D3D9RendererSpotLight : public RendererSpotLight + { + public: + D3D9RendererSpotLight(D3D9Renderer &renderer, const RendererSpotLightDesc &desc); + virtual ~D3D9RendererSpotLight(void); + + virtual void bind(void) const; + + private: + D3D9Renderer &m_renderer; + }; + +} // namespace SampleRenderer + +#endif // #if defined(RENDERER_ENABLE_DIRECT3D9) +#endif diff --git a/PhysX_3.4/Samples/SampleFramework/renderer/src/d3d9/D3D9RendererTarget.cpp b/PhysX_3.4/Samples/SampleFramework/renderer/src/d3d9/D3D9RendererTarget.cpp new file mode 100644 index 00000000..0428ad04 --- /dev/null +++ b/PhysX_3.4/Samples/SampleFramework/renderer/src/d3d9/D3D9RendererTarget.cpp @@ -0,0 +1,143 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved. + +// suppress LNK4221 on Xbox +namespace {char dummySymbol; } + +#include <RendererConfig.h> +#include "D3D9RendererTarget.h" + +#if defined(RENDERER_ENABLE_DIRECT3D9) && defined(RENDERER_ENABLE_DIRECT3D9_TARGET) + +#include <RendererTargetDesc.h> +#include "D3D9RendererTexture2D.h" + +using namespace SampleRenderer; + +D3D9RendererTarget::D3D9RendererTarget(IDirect3DDevice9 &d3dDevice, const RendererTargetDesc &desc) : + m_d3dDevice(d3dDevice) +{ + m_d3dLastSurface = 0; + m_d3dLastDepthStencilSurface = 0; + m_d3dDepthStencilSurface = 0; + for(PxU32 i=0; i<desc.numTextures; i++) + { + D3D9RendererTexture2D &texture = *static_cast<D3D9RendererTexture2D*>(desc.textures[i]); + m_textures.push_back(&texture); + } + m_depthStencilSurface = static_cast<D3D9RendererTexture2D*>(desc.depthStencilSurface); + RENDERER_ASSERT(m_depthStencilSurface && m_depthStencilSurface->m_d3dTexture, "Invalid Target Depth Stencil Surface!"); + onDeviceReset(); +} + +D3D9RendererTarget::~D3D9RendererTarget(void) +{ + if(m_d3dDepthStencilSurface) m_d3dDepthStencilSurface->Release(); +} + +void D3D9RendererTarget::bind(void) +{ + RENDERER_ASSERT(m_d3dLastSurface==0 && m_d3dLastDepthStencilSurface==0, "Render Target in bad state!"); + if(m_d3dDepthStencilSurface && !m_d3dLastSurface && !m_d3dLastDepthStencilSurface) + { + m_d3dDevice.GetRenderTarget(0, &m_d3dLastSurface); + m_d3dDevice.GetDepthStencilSurface(&m_d3dLastDepthStencilSurface); + const PxU32 numTextures = (PxU32)m_textures.size(); + for(PxU32 i=0; i<numTextures; i++) + { + IDirect3DSurface9 *d3dSurcace = 0; + D3D9RendererTexture2D &texture = *m_textures[i]; + /* HRESULT result = */ texture.m_d3dTexture->GetSurfaceLevel(0, &d3dSurcace); + RENDERER_ASSERT(d3dSurcace, "Cannot get Texture Surface!"); + if(d3dSurcace) + { + m_d3dDevice.SetRenderTarget(i, d3dSurcace); + d3dSurcace->Release(); + } + } + m_d3dDevice.SetDepthStencilSurface(m_d3dDepthStencilSurface); + const DWORD flags = D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER; + m_d3dDevice.Clear(0, 0, flags, 0x00000000, 1.0f, 0); + } + float depthBias = 0.0001f; + float biasSlope = 1.58f; +#if RENDERER_ENABLE_DRESSCODE + depthBias = dcParam("depthBias", depthBias, 0.0f, 0.01f); + biasSlope = dcParam("biasSlope", biasSlope, 0.0f, 5.0f); +#endif + m_d3dDevice.SetRenderState(D3DRS_DEPTHBIAS, *(DWORD*)&depthBias); + m_d3dDevice.SetRenderState(D3DRS_SLOPESCALEDEPTHBIAS, *(DWORD*)&biasSlope); +} + +void D3D9RendererTarget::unbind(void) +{ + RENDERER_ASSERT(m_d3dLastSurface && m_d3dLastDepthStencilSurface, "Render Target in bad state!"); + if(m_d3dDepthStencilSurface && m_d3dLastSurface && m_d3dLastDepthStencilSurface) + { + m_d3dDevice.SetDepthStencilSurface(m_d3dLastDepthStencilSurface); + m_d3dDevice.SetRenderTarget(0, m_d3dLastSurface); + const PxU32 numTextures = (PxU32)m_textures.size(); + for(PxU32 i=1; i<numTextures; i++) + { + m_d3dDevice.SetRenderTarget(i, 0); + } + m_d3dLastSurface->Release(); + m_d3dLastSurface = 0; + m_d3dLastDepthStencilSurface->Release(); + m_d3dLastDepthStencilSurface = 0; + } + float depthBias = 0; + float biasSlope = 0; + m_d3dDevice.SetRenderState(D3DRS_DEPTHBIAS, *(DWORD*)&depthBias); + m_d3dDevice.SetRenderState(D3DRS_SLOPESCALEDEPTHBIAS, *(DWORD*)&biasSlope); +} + +void D3D9RendererTarget::onDeviceLost(void) +{ + RENDERER_ASSERT(m_d3dLastDepthStencilSurface==0, "Render Target in bad state!"); + RENDERER_ASSERT(m_d3dDepthStencilSurface, "Render Target in bad state!"); + if(m_d3dDepthStencilSurface) + { + m_d3dDepthStencilSurface->Release(); + m_d3dDepthStencilSurface = 0; + } +} + +void D3D9RendererTarget::onDeviceReset(void) +{ + RENDERER_ASSERT(m_d3dDepthStencilSurface==0, "Render Target in bad state!"); + if(!m_d3dDepthStencilSurface && m_depthStencilSurface && m_depthStencilSurface->m_d3dTexture) + { + bool ok = m_depthStencilSurface->m_d3dTexture->GetSurfaceLevel(0, &m_d3dDepthStencilSurface) == D3D_OK; + if(!ok) + { + RENDERER_ASSERT(ok, "Failed to create Render Target Depth Stencil Surface."); + } + } +} + +#endif //#if defined(RENDERER_ENABLE_DIRECT3D9) && defined(RENDERER_ENABLE_DIRECT3D9_TARGET) diff --git a/PhysX_3.4/Samples/SampleFramework/renderer/src/d3d9/D3D9RendererTarget.h b/PhysX_3.4/Samples/SampleFramework/renderer/src/d3d9/D3D9RendererTarget.h new file mode 100644 index 00000000..495f9cd2 --- /dev/null +++ b/PhysX_3.4/Samples/SampleFramework/renderer/src/d3d9/D3D9RendererTarget.h @@ -0,0 +1,76 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved. +#ifndef D3D9_RENDERER_TARGET_H +#define D3D9_RENDERER_TARGET_H + +#include <RendererConfig.h> + +// TODO: 360 can't render directly into texture memory, so we need to create a pool of +// surfaces to share internally and then "resolve" them into the textures inside of +// the 'unbind' call. +#if defined(RENDERER_WINDOWS) + #define RENDERER_ENABLE_DIRECT3D9_TARGET +#endif + +#if defined(RENDERER_ENABLE_DIRECT3D9) && defined(RENDERER_ENABLE_DIRECT3D9_TARGET) + +#include <RendererTarget.h> +#include "D3D9Renderer.h" + +namespace SampleRenderer +{ + + class D3D9RendererTexture2D; + + class D3D9RendererTarget : public RendererTarget, public D3D9RendererResource + { + public: + D3D9RendererTarget(IDirect3DDevice9 &d3dDevice, const RendererTargetDesc &desc); + virtual ~D3D9RendererTarget(void); + + private: + D3D9RendererTarget& operator=( const D3D9RendererTarget& ) {} + virtual void bind(void); + virtual void unbind(void); + + private: + virtual void onDeviceLost(void); + virtual void onDeviceReset(void); + + private: + IDirect3DDevice9 &m_d3dDevice; + IDirect3DSurface9 *m_d3dLastSurface; + IDirect3DSurface9 *m_d3dLastDepthStencilSurface; + IDirect3DSurface9 *m_d3dDepthStencilSurface; + std::vector<D3D9RendererTexture2D*> m_textures; + D3D9RendererTexture2D *m_depthStencilSurface; + }; + +} // namespace SampleRenderer + +#endif // #if defined(RENDERER_ENABLE_DIRECT3D9) && defined(RENDERER_ENABLE_DIRECT3D9_TARGET) +#endif diff --git a/PhysX_3.4/Samples/SampleFramework/renderer/src/d3d9/D3D9RendererTexture2D.cpp b/PhysX_3.4/Samples/SampleFramework/renderer/src/d3d9/D3D9RendererTexture2D.cpp new file mode 100644 index 00000000..a1c4e09f --- /dev/null +++ b/PhysX_3.4/Samples/SampleFramework/renderer/src/d3d9/D3D9RendererTexture2D.cpp @@ -0,0 +1,190 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved. + +#include <RendererConfig.h> + +#if defined(RENDERER_ENABLE_DIRECT3D9) + +#include "D3D9RendererTexture2D.h" +#include <RendererTexture2DDesc.h> + +#include <SamplePlatform.h> + +using namespace SampleRenderer; + +static void supportsAnisotropic(IDirect3DDevice9& device, bool& min, bool& mag, bool& mip) +{ + D3DCAPS9 caps; + device.GetDeviceCaps(&caps); + min = (caps.TextureFilterCaps & D3DPTFILTERCAPS_MINFANISOTROPIC) != 0; + mag = (caps.TextureFilterCaps & D3DPTFILTERCAPS_MAGFANISOTROPIC) != 0; + mip = false; +} + +static D3DFORMAT getD3D9TextureFormat(RendererTexture2D::Format format) +{ + D3DFORMAT d3dFormat = static_cast<D3DFORMAT>(SampleFramework::SamplePlatform::platform()->getD3D9TextureFormat(format)); + RENDERER_ASSERT(d3dFormat != D3DFMT_UNKNOWN, "Unable to convert to D3D9 Texture Format."); + return d3dFormat; +} + +static D3DTEXTUREFILTERTYPE getD3D9TextureFilter(RendererTexture2D::Filter filter, bool anisoSupport) +{ + D3DTEXTUREFILTERTYPE d3dFilter = D3DTEXF_FORCE_DWORD; + switch(filter) + { + case RendererTexture2D::FILTER_NEAREST: d3dFilter = D3DTEXF_POINT; break; + case RendererTexture2D::FILTER_LINEAR: d3dFilter = D3DTEXF_LINEAR; break; + case RendererTexture2D::FILTER_ANISOTROPIC: d3dFilter = anisoSupport ? D3DTEXF_ANISOTROPIC : D3DTEXF_LINEAR; break; + } + RENDERER_ASSERT(d3dFilter != D3DTEXF_FORCE_DWORD, "Unable to convert to D3D9 Filter mode."); + return d3dFilter; +} + +static D3DTEXTUREADDRESS getD3D9TextureAddressing(RendererTexture2D::Addressing addressing) +{ + D3DTEXTUREADDRESS d3dAddressing = D3DTADDRESS_FORCE_DWORD; + switch(addressing) + { + case RendererTexture2D::ADDRESSING_WRAP: d3dAddressing = D3DTADDRESS_WRAP; break; + case RendererTexture2D::ADDRESSING_CLAMP: d3dAddressing = D3DTADDRESS_CLAMP; break; + case RendererTexture2D::ADDRESSING_MIRROR: d3dAddressing = D3DTADDRESS_MIRROR; break; + } + RENDERER_ASSERT(d3dAddressing != D3DTADDRESS_FORCE_DWORD, "Unable to convert to D3D9 Addressing mode."); + return d3dAddressing; +} + +D3D9RendererTexture2D::D3D9RendererTexture2D(IDirect3DDevice9 &d3dDevice, D3D9Renderer& renderer, const RendererTexture2DDesc &desc) + : RendererTexture2D(desc) + , m_d3dDevice(d3dDevice) +{ + RENDERER_ASSERT(desc.depth == 1, "Invalid depth for 2D Texture!"); + + m_d3dTexture = 0; + //managed textures can't be locked. +#ifdef DIRECT3D9_SUPPORT_D3DUSAGE_DYNAMIC + m_usage = renderer.canUseManagedResources() ? 0 : D3DUSAGE_DYNAMIC; +#else + m_usage = 0; +#endif + m_pool = renderer.canUseManagedResources() ? D3DPOOL_MANAGED : D3DPOOL_DEFAULT; + m_format = getD3D9TextureFormat(desc.format); + + bool minAniso, magAniso, mipAniso; + supportsAnisotropic(d3dDevice, minAniso, magAniso, mipAniso); + m_d3dMinFilter = getD3D9TextureFilter(desc.filter, minAniso); + m_d3dMagFilter = getD3D9TextureFilter(desc.filter, magAniso); + m_d3dMipFilter = getD3D9TextureFilter(desc.filter, mipAniso); + m_d3dAddressingU = getD3D9TextureAddressing(desc.addressingU); + m_d3dAddressingV = getD3D9TextureAddressing(desc.addressingV); + if(desc.renderTarget) + { + m_usage = D3DUSAGE_RENDERTARGET; + m_pool = D3DPOOL_DEFAULT; + } + if(isDepthStencilFormat(desc.format)) + { + m_usage = D3DUSAGE_DEPTHSTENCIL; + m_pool = D3DPOOL_DEFAULT; + } + onDeviceReset(); +} + +D3D9RendererTexture2D::~D3D9RendererTexture2D(void) +{ + if(m_d3dTexture) + { + D3DCAPS9 pCaps; + m_d3dDevice.GetDeviceCaps(&pCaps); + DWORD i = pCaps.MaxTextureBlendStages; + while(i--) m_d3dDevice.SetTexture(i, NULL); + SampleFramework::SamplePlatform::platform()->D3D9BlockUntilNotBusy(m_d3dTexture); + m_d3dTexture->Release(); + } +} + +void *D3D9RendererTexture2D::lockLevel(PxU32 level, PxU32 &pitch) +{ + void *buffer = 0; + if(m_d3dTexture) + { + D3DLOCKED_RECT lockedRect; + HRESULT result = m_d3dTexture->LockRect((DWORD)level, &lockedRect, 0, D3DLOCK_NOSYSLOCK); + RENDERER_ASSERT(result == D3D_OK, "Unable to lock Texture 2D."); + if(result == D3D_OK) + { + buffer = lockedRect.pBits; + pitch = (PxU32)lockedRect.Pitch; + } + } + return buffer; +} + +void D3D9RendererTexture2D::unlockLevel(PxU32 level) +{ + if(m_d3dTexture) + { + m_d3dTexture->UnlockRect(level); + } +} + +void D3D9RendererTexture2D::bind(PxU32 samplerIndex) +{ + m_d3dDevice.SetTexture( (DWORD)samplerIndex, m_d3dTexture); + m_d3dDevice.SetSamplerState((DWORD)samplerIndex, D3DSAMP_MINFILTER, m_d3dMinFilter); + m_d3dDevice.SetSamplerState((DWORD)samplerIndex, D3DSAMP_MAGFILTER, m_d3dMagFilter); + m_d3dDevice.SetSamplerState((DWORD)samplerIndex, D3DSAMP_MIPFILTER, m_d3dMipFilter); + m_d3dDevice.SetSamplerState((DWORD)samplerIndex, D3DSAMP_ADDRESSU, m_d3dAddressingU); + m_d3dDevice.SetSamplerState((DWORD)samplerIndex, D3DSAMP_ADDRESSV, m_d3dAddressingV); +} + +void D3D9RendererTexture2D::onDeviceLost(void) +{ + if(m_pool != D3DPOOL_MANAGED) + { + if(m_d3dTexture) + { + m_d3dTexture->Release(); + m_d3dTexture = 0; + } + } +} + +void D3D9RendererTexture2D::onDeviceReset(void) +{ + if(!m_d3dTexture) + { + HRESULT result = m_d3dDevice.CreateTexture((UINT)getWidth(), (UINT)getHeight(), (UINT)getNumLevels(), m_usage, m_format, m_pool, &m_d3dTexture, 0); + RENDERER_ASSERT(result == D3D_OK, "Unable to create D3D9 Texture."); + if(result == D3D_OK) + { + + } + } +} + +#endif // #if defined(RENDERER_ENABLE_DIRECT3D9) diff --git a/PhysX_3.4/Samples/SampleFramework/renderer/src/d3d9/D3D9RendererTexture2D.h b/PhysX_3.4/Samples/SampleFramework/renderer/src/d3d9/D3D9RendererTexture2D.h new file mode 100644 index 00000000..29166103 --- /dev/null +++ b/PhysX_3.4/Samples/SampleFramework/renderer/src/d3d9/D3D9RendererTexture2D.h @@ -0,0 +1,82 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved. +#ifndef D3D9_RENDERER_TEXTURE_2D_H +#define D3D9_RENDERER_TEXTURE_2D_H + +#include <RendererConfig.h> + +#if defined(RENDERER_ENABLE_DIRECT3D9) + +#include <RendererTexture2D.h> +#include "D3D9Renderer.h" + +namespace SampleRenderer +{ + class D3D9Renderer; + class D3D9RendererTexture2D : public RendererTexture2D, public D3D9RendererResource + { + friend class D3D9RendererTarget; + friend class D3D9RendererSpotLight; + public: + D3D9RendererTexture2D(IDirect3DDevice9 &d3dDevice, D3D9Renderer& renderer, const RendererTexture2DDesc &desc); + virtual ~D3D9RendererTexture2D(void); + + public: + virtual void *lockLevel(PxU32 level, PxU32 &pitch); + virtual void unlockLevel(PxU32 level); + + void bind(PxU32 samplerIndex); + + virtual void select(PxU32 stageIndex) + { + bind(stageIndex); + } + + private: + + virtual void onDeviceLost(void); + virtual void onDeviceReset(void); + + private: + IDirect3DDevice9 &m_d3dDevice; + IDirect3DTexture9 *m_d3dTexture; + + DWORD m_usage; + D3DPOOL m_pool; + D3DFORMAT m_format; + + D3DTEXTUREFILTERTYPE m_d3dMinFilter; + D3DTEXTUREFILTERTYPE m_d3dMagFilter; + D3DTEXTUREFILTERTYPE m_d3dMipFilter; + D3DTEXTUREADDRESS m_d3dAddressingU; + D3DTEXTUREADDRESS m_d3dAddressingV; + }; + +} // namespace SampleRenderer + +#endif // #if defined(RENDERER_ENABLE_DIRECT3D9) +#endif diff --git a/PhysX_3.4/Samples/SampleFramework/renderer/src/d3d9/D3D9RendererVertexBuffer.cpp b/PhysX_3.4/Samples/SampleFramework/renderer/src/d3d9/D3D9RendererVertexBuffer.cpp new file mode 100644 index 00000000..383154a2 --- /dev/null +++ b/PhysX_3.4/Samples/SampleFramework/renderer/src/d3d9/D3D9RendererVertexBuffer.cpp @@ -0,0 +1,299 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved. + +#include <RendererConfig.h> + +#if defined(RENDERER_ENABLE_DIRECT3D9) + +#include "D3D9RendererVertexBuffer.h" +#include <RendererVertexBufferDesc.h> + +#if PX_WINDOWS +#include <task/PxTask.h> +#endif + +using namespace SampleRenderer; + +static D3DVERTEXELEMENT9 buildVertexElement(WORD stream, WORD offset, D3DDECLTYPE type, BYTE method, BYTE usage, BYTE usageIndex) +{ + D3DVERTEXELEMENT9 element; + element.Stream = stream; + element.Offset = offset; +#if defined(RENDERER_WINDOWS) + element.Type = (BYTE)type; +#else + element.Type = type; +#endif + element.Method = method; + element.Usage = usage; + element.UsageIndex = usageIndex; + return element; +} + +static D3DDECLTYPE getD3DType(RendererVertexBuffer::Format format) +{ + D3DDECLTYPE d3dType = D3DDECLTYPE_UNUSED; + switch(format) + { + case RendererVertexBuffer::FORMAT_FLOAT1: d3dType = D3DDECLTYPE_FLOAT1; break; + case RendererVertexBuffer::FORMAT_FLOAT2: d3dType = D3DDECLTYPE_FLOAT2; break; + case RendererVertexBuffer::FORMAT_FLOAT3: d3dType = D3DDECLTYPE_FLOAT3; break; + case RendererVertexBuffer::FORMAT_FLOAT4: d3dType = D3DDECLTYPE_FLOAT4; break; + case RendererVertexBuffer::FORMAT_UBYTE4: d3dType = D3DDECLTYPE_UBYTE4; break; + case RendererVertexBuffer::FORMAT_USHORT4: d3dType = D3DDECLTYPE_SHORT4; break; + case RendererVertexBuffer::FORMAT_COLOR_BGRA: d3dType = D3DDECLTYPE_D3DCOLOR; break; + case RendererVertexBuffer::FORMAT_COLOR_RGBA: d3dType = D3DDECLTYPE_D3DCOLOR; break; + case RendererVertexBuffer::FORMAT_COLOR_NATIVE: d3dType = D3DDECLTYPE_D3DCOLOR; break; + } + RENDERER_ASSERT(d3dType != D3DDECLTYPE_UNUSED, "Invalid Direct3D9 vertex type."); + return d3dType; +} + +static D3DDECLUSAGE getD3DUsage(RendererVertexBuffer::Semantic semantic, PxU8 &usageIndex) +{ + D3DDECLUSAGE d3dUsage = D3DDECLUSAGE_FOG; + usageIndex = 0; + if(semantic >= RendererVertexBuffer::SEMANTIC_TEXCOORD0 && semantic <= RendererVertexBuffer::SEMANTIC_TEXCOORDMAX) + { + d3dUsage = D3DDECLUSAGE_TEXCOORD; + usageIndex = (PxU8)(semantic - RendererVertexBuffer::SEMANTIC_TEXCOORD0); + } + else + { + switch(semantic) + { + case RendererVertexBuffer::SEMANTIC_POSITION: d3dUsage = D3DDECLUSAGE_POSITION; break; + case RendererVertexBuffer::SEMANTIC_NORMAL: d3dUsage = D3DDECLUSAGE_NORMAL; break; + case RendererVertexBuffer::SEMANTIC_TANGENT: d3dUsage = D3DDECLUSAGE_TANGENT; break; + case RendererVertexBuffer::SEMANTIC_COLOR: d3dUsage = D3DDECLUSAGE_COLOR; break; + case RendererVertexBuffer::SEMANTIC_BONEINDEX: + d3dUsage = D3DDECLUSAGE_TEXCOORD; + usageIndex = RENDERER_BONEINDEX_CHANNEL; + break; + case RendererVertexBuffer::SEMANTIC_BONEWEIGHT: + d3dUsage = D3DDECLUSAGE_TEXCOORD; + usageIndex = RENDERER_BONEWEIGHT_CHANNEL; + break; + } + } + // There's absolutely no reason why there can't be semantics for which Direct3D9 has no support + //RENDERER_ASSERT(d3dUsage != D3DDECLUSAGE_FOG, "Invalid Direct3D9 vertex usage."); + return d3dUsage; +} + +D3D9RendererVertexBuffer::D3D9RendererVertexBuffer(IDirect3DDevice9 &d3dDevice, D3D9Renderer& renderer, const RendererVertexBufferDesc &desc) : +RendererVertexBuffer(desc), + m_d3dDevice(d3dDevice), + m_savedData(NULL) +{ + m_d3dVertexBuffer = 0; + + m_usage = D3DUSAGE_WRITEONLY; + m_lockFlags = 0; + m_pool = renderer.canUseManagedResources() ? D3DPOOL_MANAGED : D3DPOOL_DEFAULT; + m_bufferSize = (UINT)(desc.maxVertices * m_stride); + + m_bufferWritten = false; + +#if RENDERER_ENABLE_DYNAMIC_VB_POOLS + if(desc.hint==RendererVertexBuffer::HINT_DYNAMIC ) + { + if (!desc.registerInCUDA) + { + m_usage = D3DUSAGE_DYNAMIC | D3DUSAGE_WRITEONLY; + // discard all that data if we are going to overwrite it again (saves some time waiting to copy everything back) + m_lockFlags = D3DLOCK_DISCARD; + } + else + { + m_usage = 0; + } + + m_pool = D3DPOOL_DEFAULT; + } +#endif + + onDeviceReset(); + + if(m_d3dVertexBuffer) + { + m_maxVertices = desc.maxVertices; + } +} + +D3D9RendererVertexBuffer::~D3D9RendererVertexBuffer(void) +{ + if(m_d3dVertexBuffer) + { +#if PX_WINDOWS && PX_SUPPORT_GPU_PHYSX + if(m_interopContext && m_registeredInCUDA) + { + m_registeredInCUDA = !m_interopContext->unregisterResourceInCuda(m_InteropHandle); + } +#endif + + m_d3dVertexBuffer->Release(); + } + + delete[] m_savedData; +} + +void D3D9RendererVertexBuffer::addVertexElements(PxU32 streamIndex, std::vector<D3DVERTEXELEMENT9> &vertexElements) const +{ + for(PxU32 i=0; i<NUM_SEMANTICS; i++) + { + Semantic semantic = (Semantic)i; + const SemanticDesc &sm = m_semanticDescs[semantic]; + if(sm.format < NUM_FORMATS) + { + PxU8 d3dUsageIndex = 0; + D3DDECLUSAGE d3dUsage = getD3DUsage(semantic, d3dUsageIndex); + if (D3DDECLUSAGE_FOG != d3dUsage) + { + vertexElements.push_back(buildVertexElement((WORD)streamIndex, (WORD)sm.offset, getD3DType(sm.format), D3DDECLMETHOD_DEFAULT, (BYTE)d3dUsage, d3dUsageIndex)); + } + } + } +} + +void D3D9RendererVertexBuffer::swizzleColor(void *colors, PxU32 stride, PxU32 numColors, RendererVertexBuffer::Format inFormat) +{ + if (inFormat == RendererVertexBuffer::FORMAT_COLOR_RGBA) + { + const void *end = ((PxU8*)colors)+(stride*numColors); + for(PxU8* iterator = (PxU8*)colors; iterator < end; iterator+=stride) + { + std::swap(((PxU8*)iterator)[0], ((PxU8*)iterator)[2]); + } + } +} + +void *D3D9RendererVertexBuffer::lock(void) +{ + PX_PROFILE_ZONE("D3D9RenderVBlock",0); + void *lockedBuffer = 0; + if(m_d3dVertexBuffer) + { + const PxU32 bufferSize = m_maxVertices * m_stride; + HRESULT res = m_d3dVertexBuffer->Lock(0, (UINT)bufferSize, &lockedBuffer, m_lockFlags); + if(res != S_OK) + lockedBuffer = NULL; + RENDERER_ASSERT(lockedBuffer, "Failed to lock Direct3D9 Vertex Buffer."); + } + m_bufferWritten = true; + return lockedBuffer; +} + +void D3D9RendererVertexBuffer::unlock(void) +{ + PX_PROFILE_ZONE("D3D9RenderVBunlock",0); + if(m_d3dVertexBuffer) + { + m_d3dVertexBuffer->Unlock(); + } +} + +void D3D9RendererVertexBuffer::bind(PxU32 streamID, PxU32 firstVertex) +{ + prepareForRender(); + if(m_d3dVertexBuffer) + { + m_d3dDevice.SetStreamSource((UINT)streamID, m_d3dVertexBuffer, firstVertex*m_stride, m_stride); + } +} + +void D3D9RendererVertexBuffer::unbind(PxU32 streamID) +{ + m_d3dDevice.SetStreamSource((UINT)streamID, 0, 0, 0); +} + +void D3D9RendererVertexBuffer::onDeviceLost(void) +{ +#if PX_WINDOWS && PX_SUPPORT_GPU_PHYSX + if(m_interopContext && m_registeredInCUDA) + { + m_interopContext->unregisterResourceInCuda(m_InteropHandle); + } +#endif + m_registeredInCUDA = false; + + if(m_pool != D3DPOOL_MANAGED && m_d3dVertexBuffer) + { + if (m_bufferWritten) + { + if (NULL == m_savedData) + m_savedData = new char[m_bufferSize]; + + void* lockedBuffer = 0; + m_d3dVertexBuffer->Lock(0, m_bufferSize, &lockedBuffer, m_lockFlags); + RENDERER_ASSERT(lockedBuffer, "Failed to lock Direct3D9 Vertex Buffer."); + + memcpy(m_savedData, lockedBuffer, m_bufferSize); + m_d3dVertexBuffer->Unlock(); + } + + m_d3dVertexBuffer->Release(); + m_d3dVertexBuffer = 0; + } +} + +void D3D9RendererVertexBuffer::onDeviceReset(void) +{ + if(!m_d3dVertexBuffer) + { + m_d3dDevice.CreateVertexBuffer(m_bufferSize, m_usage, 0, m_pool, &m_d3dVertexBuffer, 0); + RENDERER_ASSERT(m_d3dVertexBuffer, "Failed to create Direct3D9 Vertex Buffer."); +#if PX_WINDOWS && PX_SUPPORT_GPU_PHYSX + if(m_interopContext && m_d3dVertexBuffer && m_mustBeRegisteredInCUDA) + { + RENDERER_ASSERT(m_deferredUnlock == false, "Deferred VB Unlock must be disabled when CUDA Interop is in use.") + m_registeredInCUDA = m_interopContext->registerResourceInCudaD3D(m_InteropHandle, m_d3dVertexBuffer); + } +#endif + + if (m_bufferWritten) + { + void* lockedBuffer = 0; + m_d3dVertexBuffer->Lock(0, m_bufferSize, &lockedBuffer, m_lockFlags); + RENDERER_ASSERT(lockedBuffer, "Failed to lock Direct3D9 Vertex Buffer."); + + RENDERER_ASSERT(m_savedData != NULL, "Data buffer must have been allocated."); + memcpy(lockedBuffer, m_savedData, m_bufferSize); + m_d3dVertexBuffer->Unlock(); + } + } +} + +bool D3D9RendererVertexBuffer::checkBufferWritten(void) +{ + if(m_InteropHandle) + return true; + else + return m_bufferWritten; +} + +#endif // #if defined(RENDERER_ENABLE_DIRECT3D9) diff --git a/PhysX_3.4/Samples/SampleFramework/renderer/src/d3d9/D3D9RendererVertexBuffer.h b/PhysX_3.4/Samples/SampleFramework/renderer/src/d3d9/D3D9RendererVertexBuffer.h new file mode 100644 index 00000000..7f95f6d7 --- /dev/null +++ b/PhysX_3.4/Samples/SampleFramework/renderer/src/d3d9/D3D9RendererVertexBuffer.h @@ -0,0 +1,79 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved. +#ifndef D3D9_RENDERER_VERTEXBUFFER_H +#define D3D9_RENDERER_VERTEXBUFFER_H + +#include <RendererConfig.h> + +#if defined(RENDERER_ENABLE_DIRECT3D9) + +#include <RendererVertexBuffer.h> +#include "D3D9Renderer.h" + +namespace SampleRenderer +{ + + class D3D9RendererVertexBuffer : public RendererVertexBuffer, public D3D9RendererResource + { + public: + D3D9RendererVertexBuffer(IDirect3DDevice9 &d3dDevice, D3D9Renderer& renderer, const RendererVertexBufferDesc &desc); + virtual ~D3D9RendererVertexBuffer(void); + + void addVertexElements(PxU32 streamIndex, std::vector<D3DVERTEXELEMENT9> &vertexElements) const; + + virtual bool checkBufferWritten(void); + + protected: + virtual void swizzleColor(void *colors, PxU32 stride, PxU32 numColors, RendererVertexBuffer::Format inFormat); + + virtual void *lock(void); + virtual void unlock(void); + + virtual void bind(PxU32 streamID, PxU32 firstVertex); + virtual void unbind(PxU32 streamID); + + private: + virtual void onDeviceLost(void); + virtual void onDeviceReset(void); + + private: + IDirect3DDevice9 &m_d3dDevice; + IDirect3DVertexBuffer9 *m_d3dVertexBuffer; + + DWORD m_usage; + DWORD m_lockFlags; + D3DPOOL m_pool; + UINT m_bufferSize; + + bool m_bufferWritten; + void* m_savedData; + }; + +} // namespace SampleRenderer + +#endif // #if defined(RENDERER_ENABLE_DIRECT3D9) +#endif diff --git a/PhysX_3.4/Samples/SampleFramework/renderer/src/d3d9/D3D9WPFRenderer.cpp b/PhysX_3.4/Samples/SampleFramework/renderer/src/d3d9/D3D9WPFRenderer.cpp new file mode 100644 index 00000000..41426bb6 --- /dev/null +++ b/PhysX_3.4/Samples/SampleFramework/renderer/src/d3d9/D3D9WPFRenderer.cpp @@ -0,0 +1,350 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved. +#ifdef WIN32 // win32 only + +#include "D3D9WPFRenderer.h" +#include "SamplePlatform.h" + +#define APP_NAME "D3D9WPFRenderer" + +namespace SampleRenderer +{ + + + static volatile LONG classRefCount = 0; + + static LONG incrementClassReference() + { + return InterlockedIncrement( &classRefCount ); + } + static LONG decrementClassReference() + { + return InterlockedDecrement( &classRefCount ); + } + + D3D9WPFRenderer::D3D9WPFRenderer( HWND hWnd + , IDirect3D9* inDirect3d + , IDirect3DDevice9* inDevice + , const char* devName + , PxU32 dispWidth + , PxU32 dispHeight + , const char* assetDir + , bool lockable + , bool isDeviceEx ) + : D3D9Renderer( inDirect3d, devName, 0, 0, inDevice, isDeviceEx, assetDir ) + , mHwnd( hWnd ) + , mDesiredWidth( dispWidth ) + , mDesiredHeight( dispHeight ) + , mCanonicalSurface( NULL ) + , mLockable( lockable ) + , mListener( NULL ) + { + SampleFramework::createPlatform(NULL); + } + + D3D9WPFRenderer::~D3D9WPFRenderer() + { + releaseSurface(); + DestroyWindow(mHwnd); + if ( mListener ) mListener->release(); mListener = NULL; + if ( decrementClassReference() == 0 ) + UnregisterClass(TEXT(APP_NAME), NULL); + } + + WPFRendererListener* D3D9WPFRenderer::getListener() { return mListener; } + void D3D9WPFRenderer::setListener( WPFRendererListener* listener ) + { + if ( mListener != listener ) + { + if ( mListener ) mListener->release(); mListener = NULL; + mListener = listener; + if ( mCanonicalSurface && mListener ) mListener->afterSurfaceCreated( mCanonicalSurface ); + } + } + + void D3D9WPFRenderer::onResize( PxU32 newWidth, PxU32 newHeight ) + { + mDesiredWidth = newWidth; + mDesiredHeight = newHeight; + checkResize( false ); + } + + bool D3D9WPFRenderer::swapBuffers() + { + return true; //does nothing, that is up for the parent context to do. + } + + bool D3D9WPFRenderer::isOk() const + { + return true;} + + void D3D9WPFRenderer::onDeviceLost() + { + releaseSurface(); + D3D9Renderer::onDeviceLost(); + } + + void D3D9WPFRenderer::onDeviceReset() + { + allocateSurface(); + D3D9Renderer::onDeviceReset(); + } + + void D3D9WPFRenderer::releaseSurface() + { + if( mListener ) mListener->beforeSurfaceRelease( mCanonicalSurface ); + if ( mCanonicalSurface ) mCanonicalSurface->Release(); + mCanonicalSurface = NULL; + } + + void D3D9WPFRenderer::allocateSurface() + { + PX_ASSERT( mCanonicalSurface == NULL ); + + HRESULT result = m_d3dDevice->CreateRenderTarget( + m_displayWidth + , m_displayHeight + , D3DFMT_X8R8G8B8 + , D3DMULTISAMPLE_NONE + , 0 + , mLockable + , &mCanonicalSurface + , NULL ); + PX_ASSERT( mCanonicalSurface ); + PX_ASSERT( result == D3D_OK ); + + if ( mCanonicalSurface != NULL ) + m_d3dDevice->SetRenderTarget(0, mCanonicalSurface); + + if ( mListener ) mListener->afterSurfaceCreated( mCanonicalSurface ); + } + + bool D3D9WPFRenderer::checkResize( bool isDeviceLost ) + { + bool isDeviceReset = false; + //resize the system if the desired width or height is more than we can support. + if ( mDesiredWidth > m_displayWidth + || mDesiredHeight > m_displayHeight + || isDeviceLost ) + { + m_displayWidth = PxMax( mDesiredWidth, m_displayWidth ); + m_displayHeight = PxMax( mDesiredHeight, m_displayHeight ); + if ( isDeviceLost ) + { + physx::PxU64 res = m_d3dDevice->TestCooperativeLevel(); + if(res == D3D_OK || res == D3DERR_DEVICENOTRESET) //if device is lost, device has to be ready for reset + { + isDeviceReset = true; + onDeviceLost(); + onDeviceReset(); + } + } + else + { + releaseSurface(); + releaseDepthStencilSurface(); + allocateSurface(); + buildDepthStencilSurface(); + // set out initial states... + m_d3dDevice->SetRenderState(D3DRS_CULLMODE, D3DCULL_CCW); + m_d3dDevice->SetRenderState(D3DRS_LIGHTING, 0); + m_d3dDevice->SetRenderState(D3DRS_ZENABLE, 1); + } + } + //else just mess with the viewport so we only render pixel-by-pixel + D3DVIEWPORT9 viewport = {0}; + m_d3dDevice->GetViewport(&viewport); + if ( viewport.Width != mDesiredWidth + || viewport.Height != mDesiredHeight ) + { + viewport.X = 0; + viewport.Y = 0; + viewport.Width = (DWORD)mDesiredWidth; + viewport.Height = (DWORD)mDesiredHeight; + viewport.MinZ = 0.0f; + viewport.MaxZ = 1.0f; + m_d3dDevice->SetViewport(&viewport); + } + return isDeviceReset; + } + + void D3D9WPFRenderer::setupAlphaBlendState() + { + m_d3dDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, 1); + m_d3dDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_ONE); + m_d3dDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA); + } + + void D3D9WPFRenderer::restoreAlphaBlendState() + { + m_d3dDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, 0); + } + + void D3D9WPFRenderer::disableZWrite() + { + m_d3dDevice->SetRenderState(D3DRS_ZWRITEENABLE, 0); + } + void D3D9WPFRenderer::enableZWrite() + { + m_d3dDevice->SetRenderState(D3DRS_ZWRITEENABLE, 1); + } + + static DWORD GetVertexProcessingCaps(IDirect3D9* d3d) + { + D3DCAPS9 caps; + DWORD dwVertexProcessing = D3DCREATE_SOFTWARE_VERTEXPROCESSING; + if (SUCCEEDED(d3d->GetDeviceCaps(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, &caps))) + { + if ((caps.DevCaps & D3DDEVCAPS_HWTRANSFORMANDLIGHT) == D3DDEVCAPS_HWTRANSFORMANDLIGHT) + { + dwVertexProcessing = D3DCREATE_HARDWARE_VERTEXPROCESSING; + } + } + return dwVertexProcessing; + } + + + HRESULT InitializeD3D(HWND hWnd, D3DPRESENT_PARAMETERS d3dpp, IDirect3D9*& d3d, IDirect3DDevice9*& d3dDevice ) + { + d3d = NULL; + d3dDevice = NULL; + // initialize Direct3D + d3d = Direct3DCreate9(D3D_SDK_VERSION); + if ( d3d != NULL ) + { + // determine what type of vertex processing to use based on the device capabilities + DWORD dwVertexProcessing = GetVertexProcessingCaps(d3d); + // create the D3D device + return d3d->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hWnd, + dwVertexProcessing | D3DCREATE_MULTITHREADED | D3DCREATE_FPU_PRESERVE, + &d3dpp, &d3dDevice); + } + return -1; + } + + typedef HRESULT (WINAPI *D3DEXCreateFn)( DWORD version, IDirect3D9Ex** result ); + + + HRESULT InitializeD3DEx(HWND hWnd, D3DPRESENT_PARAMETERS d3dpp, IDirect3D9*& d3d, IDirect3DDevice9*& d3dDevice, D3DEXCreateFn createFn ) + { + d3d = NULL; + d3dDevice = NULL; + IDirect3D9Ex* d3dEx = NULL; + // initialize Direct3D using the Ex function + HRESULT result = createFn( D3D_SDK_VERSION, &d3dEx ); + if ( FAILED( result ) ) return result; + + result = d3dEx->QueryInterface(__uuidof(IDirect3D9), reinterpret_cast<void **>(&d3d) ); + if ( FAILED( result ) ) { d3dEx->Release(); return result; } + + // determine what type of vertex processing to use based on the device capabilities + DWORD dwVertexProcessing = GetVertexProcessingCaps(d3d); + + // create the D3D device using the Ex function + IDirect3DDevice9Ex* deviceEx = NULL; + result = d3dEx->CreateDeviceEx(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hWnd, + dwVertexProcessing | D3DCREATE_MULTITHREADED | D3DCREATE_FPU_PRESERVE, + &d3dpp, NULL, &deviceEx); + + if ( FAILED(result) ) { d3dEx->Release(); d3d->Release(); return result; } + + // obtain the standard D3D device interface + deviceEx->QueryInterface(__uuidof(IDirect3DDevice9), reinterpret_cast<void **>(&d3dDevice) ); + + deviceEx->Release(); + d3dEx->Release(); + + return 0; + } + + D3D9WPFRenderer* D3D9WPFRenderer::createWPFRenderer( const char* inAssetDir, PxU32 initialWidth, PxU32 initialHeight ) + { + if ( incrementClassReference() == 1 ) + { + WNDCLASS wndclass; + memset( &wndclass, 0, sizeof( WNDCLASS ) ); + + wndclass.style = CS_HREDRAW | CS_VREDRAW; + wndclass.lpfnWndProc = DefWindowProc; + wndclass.lpszClassName = TEXT(APP_NAME); + + RegisterClass(&wndclass); + } + + HWND hWnd = CreateWindow(TEXT(APP_NAME), + TEXT(APP_NAME), + WS_OVERLAPPEDWINDOW, + 0, // Initial X + 0, // Initial Y + 0, // Width + 0, // Height + NULL, + NULL, + NULL, + NULL); + if ( hWnd == 0 ) return NULL; + + HMODULE hD3D9 = LoadLibrary(TEXT("d3d9.dll")); + D3DEXCreateFn exCreateFn = reinterpret_cast<D3DEXCreateFn>( GetProcAddress(hD3D9, "Direct3DCreate9Ex") ); + bool is9x = exCreateFn != NULL; + IDirect3D9* d3d = NULL; + IDirect3DDevice9* d3dDevice = NULL; + D3DPRESENT_PARAMETERS d3dpp; + ZeroMemory(&d3dpp, sizeof(d3dpp)); + d3dpp.Windowed = TRUE; + d3dpp.BackBufferHeight = 1; + d3dpp.BackBufferWidth = 1; + d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD; + d3dpp.BackBufferFormat = D3DFMT_A8R8G8B8; + d3dpp.hDeviceWindow = hWnd; + HRESULT result; + + if (is9x) + { + result = InitializeD3DEx(NULL, d3dpp, d3d, d3dDevice, exCreateFn); + } + else + { + result = InitializeD3D(NULL, d3dpp, d3d, d3dDevice); + } + PX_ASSERT( result >= 0 ); + if ( result >= 0 ) + { + bool lockable = !is9x; + //We only lock earlier interface, not later ones because the later ones use a hardware transfer mechanism + //where you seem to not need to lock according to some... + D3D9WPFRenderer* retval = new D3D9WPFRenderer( hWnd, d3d, d3dDevice, "Direct3d", initialWidth, initialHeight, inAssetDir, !is9x, is9x ); + retval->checkResize( false ); //setup viewport. + //Can we create a vertex buffer here? + PX_ASSERT( result == D3D_OK ); + return retval; + } + return NULL; + } +} + +#endif
\ No newline at end of file diff --git a/PhysX_3.4/Samples/SampleFramework/renderer/src/d3d9/D3D9WPFRenderer.h b/PhysX_3.4/Samples/SampleFramework/renderer/src/d3d9/D3D9WPFRenderer.h new file mode 100644 index 00000000..b21b815c --- /dev/null +++ b/PhysX_3.4/Samples/SampleFramework/renderer/src/d3d9/D3D9WPFRenderer.h @@ -0,0 +1,100 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved. +#ifndef D3D9_WPF_RENDERER_H +#define D3D9_WPF_RENDERER_H +#include "D3D9Renderer.h" + +namespace SampleRenderer +{ + class WPFRendererListener + { + protected: + virtual ~WPFRendererListener(){} + public: + + virtual void beforeSurfaceRelease( IDirect3DSurface9* surface ) = 0; + virtual void afterSurfaceCreated( IDirect3DSurface9* surface ) = 0; + virtual void release() = 0; + }; + + //This renderer has special interop needs with WFP so it needs to use a slightly slowing + //device specification. Also it uses some special creation mechanisms so we get as much + //performance as we can on various platforms taking the interop considerations into account. + + //One component is that SamplePlatform isn't initialized nor available thus forcing us to override + //details on some functions + class D3D9WPFRenderer : public D3D9Renderer + { + HWND mHwnd; + IDirect3DSurface9* mCanonicalSurface; + PxU32 mDesiredWidth; + PxU32 mDesiredHeight; + const bool mLockable; + WPFRendererListener* mListener; + + protected: + + D3D9WPFRenderer( HWND hWnd + , IDirect3D9* inDirect3d + , IDirect3DDevice9* inDevice + , const char* devName + , PxU32 dispWidth + , PxU32 dispHeight + , const char* assetDir + , bool lockable + , bool isDeviceEx ); + + public: + static D3D9WPFRenderer* createWPFRenderer(const char* inAssetDir, PxU32 initialWidth = 1024, PxU32 initialHeight = 768 ); + + virtual ~D3D9WPFRenderer(); + + virtual IDirect3DSurface9* getSurface() { return mCanonicalSurface; } + virtual WPFRendererListener* getListener(); + virtual void setListener( WPFRendererListener* listener ); + + virtual void onResize( PxU32 newWidth, PxU32 newHeight ); + virtual bool swapBuffers(); + virtual bool isOk() const; + virtual void onDeviceLost(); + virtual void onDeviceReset(); + + virtual PxU32 getWidth() { return mDesiredWidth; } + virtual PxU32 getHeight() { return mDesiredHeight; } + virtual void render() { beginRender(); endRender(); } + virtual void setupAlphaBlendState(); + virtual void restoreAlphaBlendState(); + virtual void disableZWrite(); + virtual void enableZWrite(); + protected: + virtual bool checkResize( bool isDeviceLost ); + void releaseSurface(); + void allocateSurface(); + }; +} + +#endif
\ No newline at end of file diff --git a/PhysX_3.4/Samples/SampleFramework/renderer/src/gles2/GLES2Renderer.cpp b/PhysX_3.4/Samples/SampleFramework/renderer/src/gles2/GLES2Renderer.cpp new file mode 100644 index 00000000..fb2aeb4f --- /dev/null +++ b/PhysX_3.4/Samples/SampleFramework/renderer/src/gles2/GLES2Renderer.cpp @@ -0,0 +1,746 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved. + + +#include "GLES2Renderer.h" + +#if defined(RENDERER_ENABLE_GLES2) + +#include <RendererDesc.h> + +#include <RendererVertexBufferDesc.h> +#include "GLES2RendererVertexBuffer.h" + +#include <RendererIndexBufferDesc.h> +#include "GLES2RendererIndexBuffer.h" + +#include <RendererInstanceBufferDesc.h> +#include "GLES2RendererInstanceBuffer.h" + +#include <RendererMeshDesc.h> +#include <RendererMeshContext.h> +#include "GLES2RendererMesh.h" + +#include <RendererMaterialDesc.h> +#include <RendererMaterialInstance.h> +#include "GLES2RendererMaterial.h" + +#include <RendererLightDesc.h> +#include <RendererDirectionalLightDesc.h> +#include "GLES2RendererDirectionalLight.h" + +#include <RendererTexture2DDesc.h> +#include "GLES2RendererTexture2D.h" + +#include <RendererProjection.h> + +#include <SamplePlatform.h> + +#include "foundation/PxMat44.h" + +#if defined(RENDERER_ANDROID) +PFNGLMAPBUFFEROESPROC glMapBufferOES = 0; +PFNGLUNMAPBUFFEROESPROC glUnmapBufferOES = 0; +#endif +bool GLEW_ARB_vertex_buffer_object = true; + +void SampleRenderer::PxToGL(GLfloat *gl44, const physx::PxMat44 &mat) +{ + PxMat44 mat44 = mat.getTranspose(); + memcpy(gl44, mat44.front(), 4 * 4 * sizeof (GLfloat)); +} + +void SampleRenderer::PxToGLColumnMajor(GLfloat *gl44, const physx::PxMat44 &mat44) +{ + memcpy(gl44, mat44.front(), 4 * 4 * sizeof (GLfloat)); +} + +void SampleRenderer::RenToGL(GLfloat *gl44, const RendererProjection &proj) +{ + proj.getRowMajor44(gl44); +} + +void SampleRenderer::RenToGLColumnMajor(GLfloat *gl44, const RendererProjection &proj) +{ + proj.getColumnMajor44(gl44); +} + +namespace SampleRenderer +{ + +GLES2Renderer::GLES2Renderer(const RendererDesc &desc, const char* assetDir) : + Renderer(DRIVER_GLES2, desc.errorCallback, assetDir), m_platform(SampleFramework::SamplePlatform::platform()) +{ + m_displayWidth = 0; + m_displayHeight = 0; + + m_viewMatrix = PxMat44(PxIdentity); + m_platform->initializeOGLDisplay(desc, m_displayWidth, m_displayHeight); + +#if defined RENDERER_ANDROID + glMapBufferOES = (PFNGLMAPBUFFEROESPROC) eglGetProcAddress("glMapBufferOES"); + glUnmapBufferOES = (PFNGLUNMAPBUFFEROESPROC) eglGetProcAddress("glUnmapBufferOES"); + + if (!glMapBufferOES || !glUnmapBufferOES) + { + GLEW_ARB_vertex_buffer_object = false; + } +#endif + + checkResize(); + + RendererColor& clearColor = getClearColor(); + glClearColor(clearColor.r/255.0f, clearColor.g/255.0f, clearColor.b/255.0f, clearColor.a/255.0f); + glEnable(GL_CULL_FACE); + glCullFace(GL_BACK); + glFrontFace(GL_CW); + glEnable(GL_DEPTH_TEST); + glEnable(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glDepthMask(GL_TRUE); + glDepthFunc(GL_LESS); +} + +RendererTexture3D* GLES2Renderer::createTexture3D(const RendererTexture3DDesc &desc) +{ + // TODO: Implement + return 0; +} + +void GLES2Renderer::setVsync(bool on) +{ + // TODO: Implement +} + +void GLES2Renderer::bindFogState(const RendererColor &fogColor, float fogDistance) +{ + m_fogColorAndDistance[0] = fogColor.r; + m_fogColorAndDistance[1] = fogColor.g; + m_fogColorAndDistance[2] = fogColor.b; + m_fogColorAndDistance[3] = fogDistance; +} + +GLES2Renderer::~GLES2Renderer(void) +{ + m_platform->freeDisplay(); +} + +bool GLES2Renderer::begin(void) +{ + return true; +} + +void GLES2Renderer::end(void) +{ + +} +void* GLES2Renderer::getDevice() +{ + /* @dduka, TODO: return something valid here */ + return NULL; +} + +bool GLES2Renderer::captureScreen(const char*) +{ + return false; +} + +bool GLES2Renderer::captureScreen(PxU32 &, PxU32&, PxU32&, const void*&) +{ + return false; +} + +void GLES2Renderer::getWindowSize(PxU32 &width, PxU32 &height) const +{ + RENDERER_ASSERT(m_displayHeight * m_displayWidth > 0, "variables not initialized properly"); + width = m_displayWidth; + height = m_displayHeight; +} + +PxU32 GLES2Renderer::convertColor(const RendererColor& color) const +{ + return GLES2RendererVertexBuffer::convertColor(color); +} + +void GLES2Renderer::checkResize(void) +{ + PxU32 width = m_displayWidth; + PxU32 height = m_displayHeight; + m_platform->getWindowSize(width, height); + if(width != m_displayWidth || height != m_displayHeight) + { + m_displayWidth = width; + m_displayHeight = height; + glViewport(0, 0, (GLsizei)m_displayWidth, (GLsizei)m_displayHeight); + glScissor( 0, 0, (GLsizei)m_displayWidth, (GLsizei)m_displayHeight); + } +} + +void GLES2Renderer::finishRendering() +{ + glFinish(); + glFlush(); +} + +// clears the offscreen buffers. +void GLES2Renderer::clearBuffers(void) +{ + if(begin()) + { + glFinish(); + GLbitfield glbuf = GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT; + //glDepthMask(1); + RendererColor& clearColor = getClearColor(); + glClearColor(clearColor.r/255.0f, clearColor.g/255.0f, clearColor.b/255.0f, clearColor.a/255.0f); + glClear(glbuf); + } + end(); +} + +// presents the current color buffer to the screen. +bool GLES2Renderer::swapBuffers(void) +{ + if(begin()) + { + m_platform->swapBuffers(); + checkResize(); + } + end(); + return false; +} + +RendererVertexBuffer *GLES2Renderer::createVertexBuffer(const RendererVertexBufferDesc &desc) +{ + GLES2RendererVertexBuffer *vb = 0; + RENDERER_ASSERT(desc.isValid(), "Invalid Vertex Buffer Descriptor."); + if(desc.isValid()) + { + vb = new GLES2RendererVertexBuffer(desc); + } + return vb; +} + +RendererIndexBuffer *GLES2Renderer::createIndexBuffer(const RendererIndexBufferDesc &desc) +{ + GLES2RendererIndexBuffer *ib = 0; + RENDERER_ASSERT(desc.isValid(), "Invalid Index Buffer Descriptor."); + if(desc.isValid()) + { + ib = new GLES2RendererIndexBuffer(desc); + } + return ib; +} + +RendererInstanceBuffer *GLES2Renderer::createInstanceBuffer(const RendererInstanceBufferDesc &desc) +{ + GLES2RendererInstanceBuffer *ib = 0; + RENDERER_ASSERT(desc.isValid(), "Invalid Instance Buffer Descriptor."); + if(desc.isValid()) + { + ib = new GLES2RendererInstanceBuffer(desc); + } + return ib; +} + +RendererTexture2D *GLES2Renderer::createTexture2D(const RendererTexture2DDesc &desc) +{ + GLES2RendererTexture2D *texture = 0; + RENDERER_ASSERT(desc.isValid(), "Invalid Texture 2D Descriptor."); + if(desc.isValid()) + { + texture = new GLES2RendererTexture2D(desc); + } + return texture; +} + +RendererTarget *GLES2Renderer::createTarget(const RendererTargetDesc &desc) +{ + RENDERER_ASSERT(0, "Not Implemented."); + return 0; +} + +RendererMaterial *GLES2Renderer::createMaterial(const RendererMaterialDesc &desc) +{ + GLES2RendererMaterial *mat = 0; + RENDERER_ASSERT(desc.isValid(), "Invalid Material Descriptor."); + if(desc.isValid()) + { + mat = new GLES2RendererMaterial(*this, desc); + } + return mat; +} + +RendererMesh *GLES2Renderer::createMesh(const RendererMeshDesc &desc) +{ + GLES2RendererMesh *mesh = 0; + RENDERER_ASSERT(desc.isValid(), "Invalid Mesh Descriptor."); + if(desc.isValid()) + { + mesh = new GLES2RendererMesh(*this, desc); + } + return mesh; +} + +RendererLight *GLES2Renderer::createLight(const RendererLightDesc &desc) +{ + RendererLight *light = 0; + RENDERER_ASSERT(desc.isValid(), "Invalid Light Descriptor."); + if(desc.isValid()) + { + switch(desc.type) + { + case RendererLight::TYPE_DIRECTIONAL: + light = new GLES2RendererDirectionalLight(*static_cast<const RendererDirectionalLightDesc*>(&desc), *this, m_lightColor, m_intensity, m_lightDirection); + break; + default: + break; + } + } + return light; +} + + +void GLES2Renderer::bindViewProj(const physx::PxMat44 &eye, const RendererProjection &proj) +{ + physx::PxMat44 inveye = eye.inverseRT(); + + // load the projection matrix... + RenToGL(m_glProjectionMatrix, proj); + RenToGL(m_glProjectionMatrixC, proj); + + // load the view matrix... + m_viewMatrix = inveye; + + m_eyePosition = eye.getPosition(); + m_eyeDirection = -eye.getBasis(2); +} + +extern GLES2RendererMaterial* g_hackCurrentMat; +extern RendererMaterialInstance* g_hackCurrentMatInstance; + +void GLES2Renderer::bindAmbientState(const RendererColor &ambient) +{ + m_ambientColor[0] = ambient.r/255.0f; + m_ambientColor[1] = ambient.g/255.0f; + m_ambientColor[2] = ambient.b/255.0f; +} + +void GLES2Renderer::bindDeferredState(void) +{ + RENDERER_ASSERT(0, "Not implemented!"); +} + +void GLES2Renderer::setCommonRendererParameters() +{ + // if we use MojoShader + GLES2RendererMaterial::shaderProgram& program = g_hackCurrentMat->m_program[g_hackCurrentMat->m_currentPass]; + + if((program.vertexMojoResult || program.fragmentMojoResult) && (g_hackCurrentMatInstance != NULL)) + { + // eye position + const RendererMaterial::Variable* var = g_hackCurrentMat->findVariable("g_eyePosition", RendererMaterial::VARIABLE_FLOAT3); + if(var) g_hackCurrentMatInstance->writeData(*var, &m_eyePosition.x); + // eye direction + var = g_hackCurrentMat->findVariable("g_eyeDirection", RendererMaterial::VARIABLE_FLOAT3); + if(var) + { + g_hackCurrentMatInstance->writeData(*var, &m_eyeDirection.x); + } + // ambient color + var = g_hackCurrentMat->findVariable("g_ambientColor", RendererMaterial::VARIABLE_FLOAT3); + if(var) + { + g_hackCurrentMatInstance->writeData(*var, m_ambientColor); + } + // light color + m_lightColor[0] = .8f; + m_lightColor[1] = .8f; + m_lightColor[2] = .8f; + var = g_hackCurrentMat->findVariable("g_lightColor", RendererMaterial::VARIABLE_FLOAT3); + if(var) g_hackCurrentMatInstance->writeData(*var, m_lightColor); + // light intensity + var = g_hackCurrentMat->findVariable("g_lightIntensity", RendererMaterial::VARIABLE_FLOAT); + if(var) + { + g_hackCurrentMatInstance->writeData(*var, &m_intensity); + } + // light direction + var = g_hackCurrentMat->findVariable("g_lightDirection", RendererMaterial::VARIABLE_FLOAT3); + if(var) + { + g_hackCurrentMatInstance->writeData(*var, m_lightDirection); + } + // fog color and distance + var = g_hackCurrentMat->findVariable("g_fogColorAndDistance", RendererMaterial::VARIABLE_FLOAT3); + if(var) g_hackCurrentMatInstance->writeData(*var, m_fogColorAndDistance); + } +} + +void GLES2Renderer::bindMeshContext(const RendererMeshContext &context) +{ + physx::PxMat44 model = physx::PxMat44(PxIdentity); + physx::PxMat44 modelView; + + if(context.transform) model = *context.transform; + + GLfloat glmvp[16]; + GLfloat glmodel[16]; + GLfloat glview[16]; + GLfloat glmodelview[16]; + + GLES2RendererMaterial::shaderProgram& program = g_hackCurrentMat->m_program[g_hackCurrentMat->m_currentPass]; + + // if we don't use MojoShader + if (program.modelMatrixUniform != -1) + { + PxToGLColumnMajor(glmodel, model); + glUniformMatrix4fv(program.modelMatrixUniform, 1, GL_FALSE, glmodel); + } + if (program.viewMatrixUniform != -1) + { + PxToGLColumnMajor(glview, m_viewMatrix); + glUniformMatrix4fv(program.viewMatrixUniform, 1, GL_FALSE, glview); + } + if (program.projMatrixUniform != -1) + { + glUniformMatrix4fv(program.projMatrixUniform, 1, GL_FALSE, m_glProjectionMatrix); + } + if (program.modelViewMatrixUniform != -1) + { + modelView = m_viewMatrix * model; + PxToGLColumnMajor(glmodelview, modelView); + glUniformMatrix4fv(program.modelViewMatrixUniform, 1, GL_FALSE, glmodelview); + } + if (program.modelViewProjMatrixUniform != -1) + { + physx::PxMat44 MVP = physx::PxMat44(m_glProjectionMatrix); + modelView = m_viewMatrix * model; + PxToGL(glmodelview, modelView); + + MVP = modelView.getTranspose() * MVP; + memcpy(glmvp, MVP.front(), sizeof(MVP)); + + glUniformMatrix4fv(program.modelViewProjMatrixUniform, 1, GL_FALSE, glmvp); + } + + RENDERER_ASSERT(context.numBones <= RENDERER_MAX_BONES, "Too many bones."); + if(context.boneMatrices && context.numBones>0 && context.numBones <= RENDERER_MAX_BONES && + g_hackCurrentMat->m_program[g_hackCurrentMat->m_currentPass].boneMatricesUniform != -1) + { + GLfloat glbonematrix[16 * RENDERER_MAX_BONES]; + for(PxU32 i=0; i<context.numBones; i++) + { + PxToGL(glbonematrix+(16*i), context.boneMatrices[i]); + } + glUniformMatrix4fv(g_hackCurrentMat->m_program[g_hackCurrentMat->m_currentPass].boneMatricesUniform, context.numBones, GL_FALSE, glbonematrix); + } + + // if we use MojoShader + if(program.vertexMojoResult || program.fragmentMojoResult) + { + // view matrix + const RendererMaterial::Variable* var = g_hackCurrentMat->findVariable("g_viewMatrix", RendererMaterial::VARIABLE_FLOAT4x4); + if(var) + { + GLfloat glview[16]; + PxToGL(glview, m_viewMatrix); + g_hackCurrentMatInstance->writeData(*var, glview); + } + // projection matrix + var = g_hackCurrentMat->findVariable("g_projMatrix", RendererMaterial::VARIABLE_FLOAT4x4); + if(var) + { + g_hackCurrentMatInstance->writeData(*var, m_glProjectionMatrix); + } + // boneMatrices matrix + RENDERER_ASSERT(context.numBones <= RENDERER_MAX_BONES, "Too many bones."); // Not enough cash? CALL CASH BONE! + var = g_hackCurrentMat->findVariable("g_boneMatrices", RendererMaterial::VARIABLE_FLOAT4x4); + if(var) + { + GLfloat glbonematrices[16 * RENDERER_MAX_BONES]; + if(context.boneMatrices && context.numBones > 0 && context.numBones <= RENDERER_MAX_BONES) { + for(size_t i = 0; i < context.numBones; ++i) { + PxToGL(glbonematrices + 16 * i, context.boneMatrices[i]); + } + g_hackCurrentMat->bindVariable(g_hackCurrentMat->m_currentPass, *var, glbonematrices); + } + } + // model matrix + var = g_hackCurrentMat->findVariable("g_modelMatrix", RendererMaterial::VARIABLE_FLOAT4x4); + if(var) + { + PxToGL(glmodel, model); + g_hackCurrentMat->bindVariable(g_hackCurrentMat->m_currentPass, *var, glmodel); + } + // model-view matrix + var = g_hackCurrentMat->findVariable("g_modelViewMatrix", RendererMaterial::VARIABLE_FLOAT4x4); + if(var) + { + modelView = m_viewMatrix * model; + PxToGL(glmodelview, modelView); + g_hackCurrentMat->bindVariable(g_hackCurrentMat->m_currentPass, *var, glmodelview); + } + // model-view-projection matrix + var = g_hackCurrentMat->findVariable("g_MVP", RendererMaterial::VARIABLE_FLOAT4x4); + if(var) + { + physx::PxMat44 MVP = physx::PxMat44(m_glProjectionMatrix); + modelView = m_viewMatrix * model; + PxToGL(glmodelview, modelView); + + MVP = modelView.getTranspose() * MVP; + memcpy(glmvp, MVP.front(), sizeof(MVP)); + + g_hackCurrentMat->bindVariable(g_hackCurrentMat->m_currentPass, *var, glmvp); + } + } else LOGI("Couldn't bind uniform values! vr = %p, fr = %p, inst = %p, -- %p", g_hackCurrentMat->m_program[g_hackCurrentMat->m_currentPass].vertexMojoResult, + g_hackCurrentMat->m_program[g_hackCurrentMat->m_currentPass].fragmentMojoResult, g_hackCurrentMatInstance, g_hackCurrentMat); + + g_hackCurrentMat->submitUniforms(); + + switch(context.cullMode) + { + case RendererMeshContext::CLOCKWISE: + glFrontFace( GL_CW ); + glCullFace( GL_BACK ); + glEnable( GL_CULL_FACE ); + break; + case RendererMeshContext::COUNTER_CLOCKWISE: + glFrontFace( GL_CCW ); + glCullFace( GL_BACK ); + glEnable( GL_CULL_FACE ); + break; + case RendererMeshContext::NONE: + glDisable( GL_CULL_FACE ); + break; + default: + RENDERER_ASSERT(0, "Invalid Cull Mode"); + } +} + +void GLES2Renderer::beginMultiPass(void) +{ +} + +void GLES2Renderer::endMultiPass(void) +{ +} + +void GLES2Renderer::beginTransparentMultiPass(void) +{ +} + +void GLES2Renderer::endTransparentMultiPass(void) +{ +} + +void GLES2Renderer::renderDeferredLight(const RendererLight &/*light*/) +{ + RENDERER_ASSERT(0, "Not implemented!"); +} + +bool GLES2Renderer::isOk(void) const +{ + bool ok = true; + return ok; +} + +void GLES2Renderer::setupTextRenderStates() +{ + glDisable(GL_CULL_FACE); + glDisable(GL_DEPTH_TEST); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glDepthMask(false); + glEnable(GL_TEXTURE_2D); +} + +void GLES2Renderer::resetTextRenderStates() +{ + glEnable(GL_CULL_FACE); + glEnable(GL_DEPTH_TEST); + glDepthMask(true); + glDisable(GL_TEXTURE_2D); +} + +bool GLES2Renderer::initTexter() +{ + Renderer::initTexter(); + + PxU32 width, height; + getWindowSize(width, height); + const PxU32 MIN_CHARACTER_WIDTH = 8; + const PxU32 TEXT_MAX_VERTICES = 4 * (width / MIN_CHARACTER_WIDTH); + const PxU32 TEXT_MAX_INDICES = TEXT_MAX_VERTICES * 1.5f; // we need 1.5 times more indices than vertices to describe text quads + + // Although text buffers (vertex and index buffers) are constantly updating, I received information that STATIC hint set on these buffers + // results in slightly better performance due to a bug (possibly) in GLES2 drivers on Android/Tegra. + // initialize vertex buffer -- will be used by all texts + RendererVertexBufferDesc vbdesc; + vbdesc.hint = RendererVertexBuffer::HINT_STATIC; + vbdesc.maxVertices = TEXT_MAX_VERTICES; + vbdesc.semanticFormats[RendererVertexBuffer::SEMANTIC_POSITION] = RendererVertexBuffer::FORMAT_FLOAT3; + vbdesc.semanticFormats[RendererVertexBuffer::SEMANTIC_TEXCOORD0] = RendererVertexBuffer::FORMAT_FLOAT2; + vbdesc.semanticFormats[RendererVertexBuffer::SEMANTIC_COLOR] = RendererVertexBuffer::FORMAT_COLOR_NATIVE; + m_textVertexBuffer = createVertexBuffer(vbdesc); + RENDERER_ASSERT(m_textVertexBuffer, "Failed to create Vertex Buffer."); + // initialize index buffer + RendererIndexBufferDesc inbdesc; + inbdesc.hint = RendererIndexBuffer::HINT_STATIC; + inbdesc.format = RendererIndexBuffer::FORMAT_UINT16; + inbdesc.maxIndices = TEXT_MAX_INDICES; + m_textIndexBuffer = createIndexBuffer(inbdesc); + RENDERER_ASSERT(m_textIndexBuffer, "Failed to create Instance Buffer."); + RendererMeshDesc meshdesc; + meshdesc.primitives = RendererMesh::PRIMITIVE_TRIANGLES; + meshdesc.vertexBuffers = &m_textVertexBuffer; + meshdesc.numVertexBuffers = 1; + meshdesc.firstVertex = 0; + meshdesc.numVertices = m_textVertexBuffer->getMaxVertices(); + meshdesc.indexBuffer = m_textIndexBuffer; + meshdesc.firstIndex = 0; + meshdesc.numIndices = m_textIndexBuffer->getMaxIndices(); + meshdesc.instanceBuffer = NULL; + meshdesc.firstInstance = 0; + meshdesc.numInstances = 0; + m_textMesh = createMesh(meshdesc); + RENDERER_ASSERT(m_textMesh, "Failed to create Mesh."); + + //m_textMaterial = NULL; + //m_textVertexBufferOffset = 0; + //m_textIndexBufferOffset = 0; + return true; +} + +void GLES2Renderer::renderTextBuffer(const void* verts, PxU32 nbVerts, const PxU16* indices, PxU32 nbIndices, RendererMaterial* material) +{ + PxU32 positionStride = 0, colorStride = 0, texcoordStride = 0; + PxU8* locked_positions = static_cast<PxU8*>(m_textVertexBuffer->lockSemantic(RendererVertexBuffer::SEMANTIC_POSITION, positionStride)); + PxU8* locked_texcoords = static_cast<PxU8*>(m_textVertexBuffer->lockSemantic(RendererVertexBuffer::SEMANTIC_TEXCOORD0, texcoordStride)); + PxU8* locked_colors = static_cast<PxU8*>(m_textVertexBuffer->lockSemantic(RendererVertexBuffer::SEMANTIC_COLOR, colorStride)); + + // copy indices + PxU16* locked_indices = static_cast<PxU16*>(m_textIndexBuffer->lock()); + memcpy(locked_indices, indices, nbIndices * sizeof(PxU16)); + m_textIndexBuffer->unlock(); + + PxU32 windowWidth, windowHeight; + getWindowSize(windowWidth, windowHeight); + PxReal windowWidthHalf = windowWidth / 2.0f, + windowHeightHalf = windowHeight / 2.0f; + + TextVertex* tv = (TextVertex*)verts; + for(PxU32 i = 0; i < nbVerts; ++i, + locked_positions += positionStride, + locked_colors += colorStride, + locked_texcoords += texcoordStride, + tv += 1) + { + PxVec3 pos = PxVec3(tv->p.x / windowWidthHalf - 1.0f, 1.0f - tv->p.y / windowHeightHalf, 0.0f); + memcpy(locked_positions, &(pos), sizeof(tv->p)); + memcpy(locked_colors, &(tv->color), sizeof(tv->color)); + memcpy(locked_texcoords, &(tv->u), sizeof(PxReal)); + memcpy(locked_texcoords + sizeof(PxReal), &(tv->v), sizeof(PxReal)); + } + m_textVertexBuffer->unlockSemantic(RendererVertexBuffer::SEMANTIC_COLOR); + m_textVertexBuffer->unlockSemantic(RendererVertexBuffer::SEMANTIC_TEXCOORD0); + m_textVertexBuffer->unlockSemantic(RendererVertexBuffer::SEMANTIC_POSITION); + + // rendering goes here + m_textMesh->setVertexBufferRange(0, nbVerts); + m_textMesh->setIndexBufferRange(0, nbIndices); + m_textMesh->bind(); + m_textMesh->render(m_textMaterial); + m_textMesh->unbind(); +} + +void GLES2Renderer::renderLines2D(const void* vertices, PxU32 nbVerts) +{ + // @dduka, TODO: glEnableClientState is not available on GL ES 2.0 + /* + const int stride = sizeof(TextVertex); + char* data = (char*)vertices; + + glEnableClientState(GL_VERTEX_ARRAY); + glDisableClientState(GL_NORMAL_ARRAY); + glEnableClientState(GL_COLOR_ARRAY); + glEnableClientState(GL_TEXTURE_COORD_ARRAY); + + // pos + glVertexPointer(3, GL_FLOAT, stride, data); + data += 3*sizeof(float); + + // rhw + PxU32 width, height; + getWindowSize(width, height); + + glMatrixMode(GL_PROJECTION); + glPushMatrix(); + glLoadIdentity(); + glOrtho(0, width, height, 0, -1, 1); + glMatrixMode(GL_MODELVIEW); + glPushMatrix(); + glLoadIdentity(); + data += sizeof(float); + + // Diffuse color + glColorPointer(4, GL_UNSIGNED_BYTE, stride, data); + data += sizeof(int); + + // Texture coordinates + glTexCoordPointer(2, GL_FLOAT, stride, data); + data += 2*sizeof(float); + + glDrawArrays(GL_LINE_STRIP, 0, nbVerts); + + glPopMatrix(); + glMatrixMode(GL_PROJECTION); + glPopMatrix(); + glMatrixMode(GL_MODELVIEW); + + glDisableClientState(GL_VERTEX_ARRAY); + glDisableClientState(GL_COLOR_ARRAY); + glDisableClientState(GL_TEXTURE_COORD_ARRAY); + */ +} + +void GLES2Renderer::setupScreenquadRenderStates() +{ + //glDisable(GL_DEPTH_TEST); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glDisable(GL_CULL_FACE); + glDepthMask(false); +} + +void GLES2Renderer::resetScreenquadRenderStates() +{ + //glEnable(GL_DEPTH_TEST); + glEnable(GL_CULL_FACE); + glDepthMask(true); +} + +} +#endif // #if defined(RENDERER_ENABLE_GLES2) diff --git a/PhysX_3.4/Samples/SampleFramework/renderer/src/gles2/GLES2Renderer.h b/PhysX_3.4/Samples/SampleFramework/renderer/src/gles2/GLES2Renderer.h new file mode 100644 index 00000000..60f3a586 --- /dev/null +++ b/PhysX_3.4/Samples/SampleFramework/renderer/src/gles2/GLES2Renderer.h @@ -0,0 +1,189 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved. + +#ifndef GLES2_RENDERER_H +#define GLES2_RENDERER_H + +#include <RendererConfig.h> + +#if defined(RENDERER_ENABLE_GLES2) + +#if defined(RENDERER_ANDROID) +#include <GLES2/gl2.h> +#include <GLES2/gl2ext.h> +#include <EGL/egl.h> + +extern PFNGLMAPBUFFEROESPROC glMapBufferOES; +extern PFNGLUNMAPBUFFEROESPROC glUnmapBufferOES; + +#elif defined(RENDERER_IOS) + +#include <OpenGLES/ES2/gl.h> +#include <OpenGLES/ES2/glext.h> + +#endif + +#define GL_TEXTURE0_ARB GL_TEXTURE0 +#define glBindBufferARB glBindBuffer +#define glBufferDataARB glBufferData +#define GL_ELEMENT_ARRAY_BUFFER_ARB GL_ELEMENT_ARRAY_BUFFER +#define GL_ARRAY_BUFFER_ARB GL_ARRAY_BUFFER +#define GL_STATIC_DRAW_ARB GL_STATIC_DRAW +#define GL_DYNAMIC_DRAW_ARB GL_DYNAMIC_DRAW +#define glGenBuffersARB glGenBuffers +#define glDeleteBuffersARB glDeleteBuffers +#define GL_CLAMP GL_CLAMP_TO_EDGE +#define GL_WRITE_ONLY GL_WRITE_ONLY_OES +#define GL_READ_WRITE GL_WRITE_ONLY_OES + +extern bool GLEW_ARB_vertex_buffer_object; + +#define glActiveTextureARB glActiveTexture +#define glClientActiveTextureARB(a) + +/* GL_EXT_texture_compression_dxt1 */ +#ifndef GL_EXT_texture_compression_dxt1 +#define GL_COMPRESSED_RGB_S3TC_DXT1_EXT 0x83F0 +#define GL_COMPRESSED_RGBA_S3TC_DXT1_EXT 0x83F1 +#endif + +/* GL_EXT_texture_compression_s3tc */ +#ifndef GL_EXT_texture_compression_s3tc +/* GL_COMPRESSED_RGB_S3TC_DXT1_EXT defined in GL_EXT_texture_compression_dxt1 already. */ +/* GL_COMPRESSED_RGBA_S3TC_DXT1_EXT defined in GL_EXT_texture_compression_dxt1 already. */ +#define GL_COMPRESSED_RGBA_S3TC_DXT3_EXT 0x83F2 +#define GL_COMPRESSED_RGBA_S3TC_DXT5_EXT 0x83F3 +#endif + +#define GL_RGBA8 GL_RGBA +#define GL_BGRA8 GL_BGRA + +#include <Renderer.h> + +namespace SampleFramework { + class SamplePlatform; +} + +namespace SampleRenderer +{ + +class RendererVertexBuffer; +class RendererIndexBuffer; +class RendererMaterial; + +void PxToGL(GLfloat *gl44, const physx::PxMat44 &mat); +void PxToGLColumnMajor(GLfloat *gl44, const physx::PxMat44 &mat); +void RenToGL(GLfloat *gl44, const RendererProjection &proj); +void RenToGLColumnMajor(GLfloat *gl44, const RendererProjection &proj); + +class GLES2Renderer : public Renderer +{ + public: + GLES2Renderer(const RendererDesc &desc, const char* assetDir); + virtual ~GLES2Renderer(void); + + private: + bool begin(void); + void end(void); + void checkResize(void); + + public: + // clears the offscreen buffers. + virtual void clearBuffers(void); + + // presents the current color buffer to the screen. + virtual bool swapBuffers(void); + // get the device pointer (void * abstraction) + virtual void *getDevice(); + + virtual bool captureScreen(const char*); + virtual bool captureScreen(PxU32 &width, PxU32& height, PxU32& sizeInBytes, const void*& screenshotData); + + // get the window size + void getWindowSize(PxU32 &width, PxU32 &height) const; + // copy common renderer variables to the material (like g_MVP, g_modelMatrix, etc) + virtual void setCommonRendererParameters(); + + virtual RendererVertexBuffer *createVertexBuffer( const RendererVertexBufferDesc &desc); + virtual RendererIndexBuffer *createIndexBuffer( const RendererIndexBufferDesc &desc); + virtual RendererInstanceBuffer *createInstanceBuffer(const RendererInstanceBufferDesc &desc); + virtual RendererTexture2D *createTexture2D( const RendererTexture2DDesc &desc); + virtual RendererTexture3D *createTexture3D( const RendererTexture3DDesc &desc); + virtual RendererTarget *createTarget( const RendererTargetDesc &desc); + virtual RendererMaterial *createMaterial( const RendererMaterialDesc &desc); + virtual RendererMesh *createMesh( const RendererMeshDesc &desc); + virtual RendererLight *createLight( const RendererLightDesc &desc); + + void finalizeTextRender(); + void finishRendering(); + virtual void setVsync(bool on); + private: + virtual void bindViewProj(const physx::PxMat44 &inveye, const RendererProjection &proj); + virtual void bindFogState(const RendererColor &fogColor, float fogDistance); + virtual void bindAmbientState(const RendererColor &ambientColor); + virtual void bindDeferredState(void); + virtual void bindMeshContext(const RendererMeshContext &context); + virtual void beginMultiPass(void); + virtual void endMultiPass(void); + virtual void beginTransparentMultiPass(void); + virtual void endTransparentMultiPass(void); + virtual void renderDeferredLight(const RendererLight &light); + virtual PxU32 convertColor(const RendererColor& color) const; + + virtual bool isOk(void) const; + + virtual bool initTexter(); + virtual void setupTextRenderStates(); + virtual void resetTextRenderStates(); + virtual void renderTextBuffer(const void* vertices, PxU32 nbVerts, const PxU16* indices, PxU32 nbIndices, SampleRenderer::RendererMaterial* material); + virtual void renderLines2D(const void* vertices, PxU32 nbVerts); + virtual void setupScreenquadRenderStates(); + virtual void resetScreenquadRenderStates(); + private: + SampleFramework::SamplePlatform* m_platform; + RendererVertexBuffer* m_textVertexBuffer; + RendererIndexBuffer* m_textIndexBuffer; + PxU32 m_textVertexBufferOffset; + PxU32 m_textIndexBufferOffset; + RendererMaterial* m_textMaterial; + RendererMesh* m_textMesh; + PxU32 m_displayWidth; + PxU32 m_displayHeight; + + physx::PxMat44 m_viewMatrix; + GLfloat m_glProjectionMatrix[16], m_glProjectionMatrixC[16]; + PxVec3 m_eyePosition; + PxVec3 m_eyeDirection; + GLfloat m_ambientColor[3]; + GLfloat m_lightColor[3]; + GLfloat m_intensity; + GLfloat m_lightDirection[3]; + GLfloat m_fogColorAndDistance[4]; +}; +} +#endif // #if defined(RENDERER_ENABLE_GLES2) +#endif diff --git a/PhysX_3.4/Samples/SampleFramework/renderer/src/gles2/GLES2RendererDirectionalLight.cpp b/PhysX_3.4/Samples/SampleFramework/renderer/src/gles2/GLES2RendererDirectionalLight.cpp new file mode 100644 index 00000000..2f1fe5b9 --- /dev/null +++ b/PhysX_3.4/Samples/SampleFramework/renderer/src/gles2/GLES2RendererDirectionalLight.cpp @@ -0,0 +1,65 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved. + + +#include "GLES2RendererDirectionalLight.h" +#include "GLES2RendererMaterial.h" +#include "GLES2Renderer.h" +#include "RendererMaterialInstance.h" + +#if defined(RENDERER_ENABLE_GLES2) +namespace SampleRenderer +{ + +GLES2RendererDirectionalLight::GLES2RendererDirectionalLight(const RendererDirectionalLightDesc &desc, + GLES2Renderer &renderer, GLfloat (&_lightColor)[3], + GLfloat& _lightIntensity, GLfloat (&_lightDirection)[3]) : + RendererDirectionalLight(desc), m_lightColor(_lightColor), m_lightIntensity(_lightIntensity), m_lightDirection(_lightDirection) +{ +} + +GLES2RendererDirectionalLight::~GLES2RendererDirectionalLight(void) +{ +} + +extern GLES2RendererMaterial* g_hackCurrentMat; +extern RendererMaterialInstance* g_hackCurrentMatInstance; + +void GLES2RendererDirectionalLight::bind(void) const +{ + m_lightColor[0] = m_color.r/255.0f; + m_lightColor[1] = m_color.g/255.0f; + m_lightColor[2] = m_color.b/255.0f; + m_lightIntensity = m_intensity; + m_lightDirection[0] = m_direction.x; + m_lightDirection[1] = m_direction.y; + m_lightDirection[2] = m_direction.z; +} + +} + +#endif // #if defined(RENDERER_ENABLE_GLES2) diff --git a/PhysX_3.4/Samples/SampleFramework/renderer/src/gles2/GLES2RendererDirectionalLight.h b/PhysX_3.4/Samples/SampleFramework/renderer/src/gles2/GLES2RendererDirectionalLight.h new file mode 100644 index 00000000..d3b6dbe4 --- /dev/null +++ b/PhysX_3.4/Samples/SampleFramework/renderer/src/gles2/GLES2RendererDirectionalLight.h @@ -0,0 +1,61 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved. + + +#ifndef GLES2_RENDERER_DIRECTIONAL_LIGHT_H +#define GLES2_RENDERER_DIRECTIONAL_LIGHT_H + +#include <RendererConfig.h> + +#if defined(RENDERER_ENABLE_GLES2) + +#include <RendererDirectionalLight.h> + +#include "GLES2Renderer.h" + +namespace SampleRenderer +{ +class RendererDirectionalLightDesc; + +class GLES2RendererDirectionalLight : public RendererDirectionalLight +{ + public: + GLES2RendererDirectionalLight(const RendererDirectionalLightDesc &desc, + GLES2Renderer &renderer, + GLfloat (&_lightColor)[3], GLfloat& _lightIntensity, GLfloat (&_lightDirection)[3]); + virtual ~GLES2RendererDirectionalLight(void); + + virtual void bind(void) const; + private: + GLfloat (&m_lightColor)[3]; + GLfloat& m_lightIntensity; + GLfloat (&m_lightDirection)[3]; +}; +} + +#endif // #if defined(RENDERER_ENABLE_GLES2) +#endif diff --git a/PhysX_3.4/Samples/SampleFramework/renderer/src/gles2/GLES2RendererIndexBuffer.cpp b/PhysX_3.4/Samples/SampleFramework/renderer/src/gles2/GLES2RendererIndexBuffer.cpp new file mode 100644 index 00000000..a12230c2 --- /dev/null +++ b/PhysX_3.4/Samples/SampleFramework/renderer/src/gles2/GLES2RendererIndexBuffer.cpp @@ -0,0 +1,115 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved. + + +#include "GLES2RendererIndexBuffer.h" + +#if defined(RENDERER_ENABLE_GLES2) +#include <RendererIndexBufferDesc.h> + +namespace SampleRenderer +{ + +GLES2RendererIndexBuffer::GLES2RendererIndexBuffer(const RendererIndexBufferDesc &desc) : + RendererIndexBuffer(desc) +{ + m_indexSize = getFormatByteSize(getFormat()); + RENDERER_ASSERT(GLEW_ARB_vertex_buffer_object, "Vertex Buffer Objects not supported on this machine!"); + if(GLEW_ARB_vertex_buffer_object) + { + RENDERER_ASSERT(desc.maxIndices > 0 && desc.maxIndices > 0, "Cannot create zero size Index Buffer."); + if(desc.maxIndices > 0 && desc.maxIndices > 0) + { + GLenum usage = GL_STATIC_DRAW_ARB; + if(getHint() == HINT_DYNAMIC) + { + usage = GL_DYNAMIC_DRAW_ARB; + } + + glGenBuffersARB(1, &m_ibo); + RENDERER_ASSERT(m_ibo, "Failed to create Index Buffer."); + if(m_ibo) + { + m_maxIndices = desc.maxIndices; + const PxU32 bufferSize = m_indexSize * m_maxIndices; + + glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, m_ibo); + glBufferDataARB(GL_ELEMENT_ARRAY_BUFFER_ARB, bufferSize, 0, usage); + glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, 0); + } + } + } +} + +GLES2RendererIndexBuffer::~GLES2RendererIndexBuffer(void) +{ + if(m_ibo) + { + glDeleteBuffersARB(1, &m_ibo); + } +} + +void *GLES2RendererIndexBuffer::lock(void) +{ + void *buffer = 0; + if(m_ibo) + { + glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, m_ibo); + buffer = glMapBufferOES(GL_ELEMENT_ARRAY_BUFFER_ARB, GL_WRITE_ONLY); + glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, 0); + } + return buffer; +} + +void GLES2RendererIndexBuffer::unlock(void) +{ + if(m_ibo) + { + glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, m_ibo); + glUnmapBufferOES(GL_ELEMENT_ARRAY_BUFFER_ARB); + glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, 0); + } +} + +void GLES2RendererIndexBuffer::bind(void) const +{ + if(m_ibo) + { + glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, m_ibo); + } +} + +void GLES2RendererIndexBuffer::unbind(void) const +{ + if(m_ibo) + { + glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, 0); + } + } +} + +#endif // #if defined(RENDERER_ENABLE_GLES2) diff --git a/PhysX_3.4/Samples/SampleFramework/renderer/src/gles2/GLES2RendererIndexBuffer.h b/PhysX_3.4/Samples/SampleFramework/renderer/src/gles2/GLES2RendererIndexBuffer.h new file mode 100644 index 00000000..3f489a25 --- /dev/null +++ b/PhysX_3.4/Samples/SampleFramework/renderer/src/gles2/GLES2RendererIndexBuffer.h @@ -0,0 +1,61 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved. + + +#ifndef GLES2_RENDERER_INDEXBUFFER_H +#define GLES2_RENDERER_INDEXBUFFER_H + +#include <RendererConfig.h> + +#if defined(RENDERER_ENABLE_GLES2) + +#include <RendererIndexBuffer.h> +#include "GLES2Renderer.h" + +namespace SampleRenderer +{ +class GLES2RendererIndexBuffer : public RendererIndexBuffer +{ + public: + GLES2RendererIndexBuffer(const RendererIndexBufferDesc &desc); + virtual ~GLES2RendererIndexBuffer(void); + + public: + virtual void *lock(void); + virtual void unlock(void); + + private: + virtual void bind(void) const; + virtual void unbind(void) const; + + private: + GLuint m_ibo; + PxU32 m_indexSize; +}; +} +#endif // #if defined(RENDERER_ENABLE_GLES2) +#endif diff --git a/PhysX_3.4/Samples/SampleFramework/renderer/src/gles2/GLES2RendererInstanceBuffer.cpp b/PhysX_3.4/Samples/SampleFramework/renderer/src/gles2/GLES2RendererInstanceBuffer.cpp new file mode 100644 index 00000000..a78ddeac --- /dev/null +++ b/PhysX_3.4/Samples/SampleFramework/renderer/src/gles2/GLES2RendererInstanceBuffer.cpp @@ -0,0 +1,90 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved. + +#include <RendererConfig.h> + +#if defined(RENDERER_ENABLE_GLES2) + +#include "GLES2RendererInstanceBuffer.h" +#include <RendererInstanceBufferDesc.h> + +using namespace SampleRenderer; + +GLES2RendererInstanceBuffer::GLES2RendererInstanceBuffer(const RendererInstanceBufferDesc &desc) : + RendererInstanceBuffer(desc) +{ + m_bufferSize = (PxU32)(desc.maxInstances * m_stride); + m_buffer = malloc(m_bufferSize);//PX_ALLOC(m_bufferSize); + m_maxInstances = desc.maxInstances; +} + +GLES2RendererInstanceBuffer::~GLES2RendererInstanceBuffer(void) +{ + if(m_buffer) free(m_buffer);//PX_FREE(m_buffer); +} + +physx::PxMat44 GLES2RendererInstanceBuffer::getModelMatrix(PxU32 index) const +{ + physx::PxMat44 model = PxMat44(PxIdentity); + if(index < m_maxInstances) + { + const void *instance = ((PxU8*)m_buffer)+(m_stride*index); + model = PxMat44(getInstanceColumn(instance, m_semanticDescs[SEMANTIC_NORMALX]), + getInstanceColumn(instance, m_semanticDescs[SEMANTIC_NORMALY]), + getInstanceColumn(instance, m_semanticDescs[SEMANTIC_NORMALZ]), + getInstanceColumn(instance, m_semanticDescs[SEMANTIC_POSITION])); + } + return model; +} + +PxVec3 GLES2RendererInstanceBuffer::getInstanceColumn(const void *instance, const GLES2RendererInstanceBuffer::SemanticDesc &sd) const +{ + PxVec3 col = *(PxVec3*)(((PxU8*)instance)+sd.offset); + return col; +} + +void *GLES2RendererInstanceBuffer::lock(void) +{ + return m_buffer; +} + +void GLES2RendererInstanceBuffer::unlock(void) +{ + +} + +void GLES2RendererInstanceBuffer::bind(PxU32 streamID, PxU32 firstInstance) const +{ + +} + +void GLES2RendererInstanceBuffer::unbind(PxU32 streamID) const +{ + +} + +#endif // #if defined(RENDERER_ENABLE_GLES2) diff --git a/PhysX_3.4/Samples/SampleFramework/renderer/src/gles2/GLES2RendererInstanceBuffer.h b/PhysX_3.4/Samples/SampleFramework/renderer/src/gles2/GLES2RendererInstanceBuffer.h new file mode 100644 index 00000000..67c719cc --- /dev/null +++ b/PhysX_3.4/Samples/SampleFramework/renderer/src/gles2/GLES2RendererInstanceBuffer.h @@ -0,0 +1,67 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved. +#ifndef GLES2_RENDERER_INSTANCEBUFFER_H +#define GLES2_RENDERER_INSTANCEBUFFER_H + +#include <RendererConfig.h> + +#if defined(RENDERER_ENABLE_GLES2) + +#include <RendererInstanceBuffer.h> +#include "GLES2Renderer.h" + +namespace SampleRenderer +{ + + class GLES2RendererInstanceBuffer : public RendererInstanceBuffer + { + public: + GLES2RendererInstanceBuffer(const RendererInstanceBufferDesc &desc); + virtual ~GLES2RendererInstanceBuffer(void); + + physx::PxMat44 getModelMatrix(PxU32 index) const; + + private: + PxVec3 getInstanceColumn(const void *instance, const GLES2RendererInstanceBuffer::SemanticDesc &sd) const; + + public: + + virtual void *lock(void); + virtual void unlock(void); + + virtual void bind(PxU32 streamID, PxU32 firstInstance) const; + virtual void unbind(PxU32 streamID) const; + + private: + PxU32 m_bufferSize; + void *m_buffer; + }; + +} // namespace SampleRenderer + +#endif // #if defined(RENDERER_ENABLE_GLES2) +#endif diff --git a/PhysX_3.4/Samples/SampleFramework/renderer/src/gles2/GLES2RendererMaterial.cpp b/PhysX_3.4/Samples/SampleFramework/renderer/src/gles2/GLES2RendererMaterial.cpp new file mode 100644 index 00000000..252cc0c5 --- /dev/null +++ b/PhysX_3.4/Samples/SampleFramework/renderer/src/gles2/GLES2RendererMaterial.cpp @@ -0,0 +1,667 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved. + + +#include "GLES2RendererMaterial.h" + +#if defined(RENDERER_ENABLE_GLES2) + +#include <RendererMaterialDesc.h> +#include <RendererMemoryMacros.h> + +#include "GLES2RendererTexture2D.h" + +#include <stdio.h> + +#include "mojoshader.h" + +namespace SampleRenderer +{ + +class GLESVariable : public RendererMaterial::Variable +{ +public: + GLESVariable(const char *name, RendererMaterial::VariableType type, PxU32 offset) + : Variable(name, type, offset) + { + } + + virtual ~GLESVariable(void) {} + + GLint m_location[RendererMaterial::NUM_PASSES]; + GLint m_sampler[RendererMaterial::NUM_PASSES]; +}; + +const std::string vertexUniformArrayName = "vs_uniforms_vec4"; +const std::string pixelUniformArrayName = "ps_uniforms_vec4"; + +std::string load_file(const char* file) +{ + LOG_INFO("GLES2RendererMaterial", "Opening: \"%s\"", file); + char file2[512]; + sprintf(file2, "/sdcard/media/SampleRenderer/4/shaders/%s", file); + FILE *f = fopen(file2, "rb"); + assert(f); + + fseek(f, 0, SEEK_END); + size_t size = ftell(f); + fseek(f, 0, SEEK_SET); + char *buffer = new char[size+1]; + fread(buffer, 1, size, f); + fclose(f); + buffer[size] = '\0'; + + std::string result(buffer); + delete[] buffer; + return result; +} + + +static int glsl_log(GLuint obj, GLenum check_compile) +{ + if (check_compile == GL_COMPILE_STATUS) + { + int len = 0; + glGetShaderiv(obj, GL_INFO_LOG_LENGTH, &len); + if(len > 0) + { + char *str = (char *) malloc(len * sizeof(char)); + if (str) + { + glGetShaderInfoLog(obj, len, NULL, str); + LOG_INFO("nv_shader", "shader_debug: %s\n", str); + free(str); + } + } + } + else + { + int len = 0; + glGetProgramiv(obj, GL_INFO_LOG_LENGTH, &len); + if(len > 0) + { + char *str = (char *)malloc(len * sizeof(char)); + if (str) + { + glGetProgramInfoLog(obj, len, NULL, str); + LOG_INFO("nv_shader", "shader_debug: %s\n", str); + free(str); + } + } + } + return 0; +} + +GLES2RendererMaterial::shaderProgram::shaderProgram() : + modelMatrixUniform(-1), + viewMatrixUniform(-1), + projMatrixUniform(-1), + modelViewMatrixUniform(-1), + boneMatricesUniform(-1), + modelViewProjMatrixUniform(-1), + positionAttr(-1), + colorAttr(-1), + normalAttr(-1), + tangentAttr(-1), + boneIndexAttr(-1), + boneWeightAttr(-1), + vsUniformsTotal(0), + psUniformsTotal(0), + vsUniformsVec4(NULL), + vsUniformsVec4Location(-1), + vsUniformsVec4Size(0), + psUniformsVec4(NULL), + psUniformsVec4Location(-1), + psUniformsVec4Size(0), + vertexMojoResult(NULL), + fragmentMojoResult(NULL) +{ +} + +GLES2RendererMaterial::shaderProgram::~shaderProgram() +{ + for(int i = 0; i < NUM_PASSES; ++i) + glDeleteProgram(program); + DELETESINGLE(vertexMojoResult); + DELETESINGLE(fragmentMojoResult); + DELETEARRAY(vsUniformsVec4); + DELETEARRAY(psUniformsVec4); +} + + +GLES2RendererMaterial::GLES2RendererMaterial(GLES2Renderer &renderer, const RendererMaterialDesc &desc) : + RendererMaterial(desc, false), + m_renderer(renderer) +{ + m_glAlphaTestFunc = GL_ALWAYS; + + AlphaTestFunc alphaTestFunc = getAlphaTestFunc(); + switch(alphaTestFunc) + { + case ALPHA_TEST_ALWAYS: m_glAlphaTestFunc = GL_ALWAYS; break; + case ALPHA_TEST_EQUAL: m_glAlphaTestFunc = GL_EQUAL; break; + case ALPHA_TEST_NOT_EQUAL: m_glAlphaTestFunc = GL_NOTEQUAL; break; + case ALPHA_TEST_LESS: m_glAlphaTestFunc = GL_LESS; break; + case ALPHA_TEST_LESS_EQUAL: m_glAlphaTestFunc = GL_LEQUAL; break; + case ALPHA_TEST_GREATER: m_glAlphaTestFunc = GL_GREATER; break; + case ALPHA_TEST_GREATER_EQUAL: m_glAlphaTestFunc = GL_GEQUAL; break; + default: + RENDERER_ASSERT(0, "Unknown Alpha Test Func."); + } + + std::string vertexShaderPath(desc.vertexShaderPath); + std::string fragmentShaderPath(desc.fragmentShaderPath); + std::string vertexSource, fragmentSource; + + for(int i = 0; i < NUM_PASSES; ++i) + { + if(vertexShaderPath.substr(vertexShaderPath.size() - 3, 3) == ".cg") + { + m_program[i].vertexMojoResult = static_cast<mojoResult*>(SampleFramework::SamplePlatform::platform()-> + compileProgram(NULL, m_renderer.getAssetDir(), desc.vertexShaderPath, 0, getPassName(static_cast<Pass>(i)), "vmain", NULL)); + vertexSource = m_program[i].vertexMojoResult->parseResult.source; + LOGI("Vertex source is: \n %s \n", vertexSource.c_str()); + } + else + { + vertexSource = load_file(desc.vertexShaderPath); + } + if(fragmentShaderPath.substr(fragmentShaderPath.size() - 3, 3) == ".cg") + { + m_program[i].fragmentMojoResult = static_cast<mojoResult*>(SampleFramework::SamplePlatform::platform()-> + compileProgram(NULL, m_renderer.getAssetDir(), desc.fragmentShaderPath, 0, getPassName(static_cast<Pass>(i)), "fmain", NULL)); + fragmentSource = m_program[i].fragmentMojoResult->parseResult.source; + LOGI("Fragment source is: \n %s \n", fragmentSource.c_str()); + } + else + { + fragmentSource = load_file(desc.fragmentShaderPath); + } + + m_program[i].program = glCreateProgram(); + if(!m_program[i].program) + LOGI("GLES2RenderMaterial", "Failed to create program"); + m_program[i].vertexShader = glCreateShader(GL_VERTEX_SHADER); + if(!m_program[i].vertexShader) + LOGI("GLES2RenderMaterial", "Failed to create vertex shader"); + m_program[i].fragmentShader = glCreateShader(GL_FRAGMENT_SHADER); + if(!m_program[i].fragmentShader) + LOGI("GLES2RenderMaterial", "Failed to create vertex shader"); + + glAttachShader(m_program[i].program, m_program[i].vertexShader); + glAttachShader(m_program[i].program, m_program[i].fragmentShader); + + int size = (int)vertexSource.size(); + const char* vertexShaderCstr = vertexSource.c_str(); + glShaderSource(m_program[i].vertexShader, 1, &vertexShaderCstr, &size); + glCompileShader(m_program[i].vertexShader); + // __android_log_print(ANDROID_LOG_DEBUG, "GLES2RendererMaterial", "Compiling:\n_______________________________\n%s\n_______________________________\n", vertexSource.c_str()); + LOGI("Vertex shader compile status:"); + glsl_log(m_program[i].vertexShader, GL_COMPILE_STATUS); + + size = (int)fragmentSource.size(); + const char* fragmentShaderCstr = fragmentSource.c_str(); + glShaderSource(m_program[i].fragmentShader, 1, &fragmentShaderCstr, &size); + glCompileShader(m_program[i].fragmentShader); + // __android_log_print(ANDROID_LOG_DEBUG, "GLES2RendererMaterial", "Compiling:\n_______________________________\n%s\n_______________________________\n", fragmentSource.c_str()); + LOGI("Fragment shader compile status:"); + glsl_log(m_program[i].fragmentShader, GL_COMPILE_STATUS); + + glLinkProgram(m_program[i].program); + GLint link_status; + glsl_log(m_program[i].program, GL_LINK_STATUS); + glGetProgramiv(m_program[i].program, GL_LINK_STATUS, &link_status); + if(link_status == GL_FALSE) + { + LOGI("Failed to link program"); + GLint error = glGetError(); + if(error == GL_INVALID_VALUE) + LOGI("GL_INVALID_VALUE"); + else if(error == GL_INVALID_OPERATION) + LOGI("GL_INVALID_OPERATION"); + } + loadCustomConstants(static_cast<Pass>(i)); + } + LOGI(""); +} + +GLES2RendererMaterial::~GLES2RendererMaterial() +{ +} + +GLES2RendererMaterial *g_hackCurrentMat = NULL; +RendererMaterialInstance *g_hackCurrentMatInstance = NULL; + +void GLES2RendererMaterial::bind(RendererMaterial::Pass pass, RendererMaterialInstance *materialInstance, bool instanced) const +{ + g_hackCurrentMat = const_cast<GLES2RendererMaterial*>(this); + g_hackCurrentMatInstance = materialInstance; + m_currentPass = pass; + glUseProgram(m_program[m_currentPass].program); + m_renderer.setCommonRendererParameters(); + RendererMaterial::bind(m_currentPass, materialInstance, instanced); +} + +void GLES2RendererMaterial::bindMeshState(bool instanced) const +{ +} + +void GLES2RendererMaterial::unbind(void) const +{ +} + +static void bindSampler(const RendererMaterial::Variable &variable, const void *data, RendererMaterial::Pass pass) +{ + GLESVariable &var = (GLESVariable&) variable; + data = *(void**)data; + RENDERER_ASSERT(data, "NULL Sampler."); + if(data) + { + GLES2RendererTexture2D *tex = const_cast<GLES2RendererTexture2D*>(static_cast<const GLES2RendererTexture2D*>(data)); + glUniform1i(var.m_location[pass], var.m_sampler[pass]); + tex->bind(var.m_sampler[pass]); + } +} + +void GLES2RendererMaterial::submitUniforms() +{ + /* When all variables were fetched, we send this uniform array and clear collected variables. + At this point, if some variables will be binded after all variables already were supplied, + this will cause these variables not binded at all, until all other variables collected again. */ + Pass pass = g_hackCurrentMat->m_currentPass; + if(m_program[pass].vsUniformsTotal > 0 && m_program[pass].vsUniformsCollected.size() == m_program[pass].vsUniformsTotal) + { + const GLfloat* ptr = const_cast<const GLfloat*>(reinterpret_cast<GLfloat*>(m_program[pass].vsUniformsVec4)); + //LOGI("VERTEX: Setting uniform at %d of size %d from %x", m_program[pass].vsUniformsVec4Location, m_program[pass].vsUniformsVec4Size, ptr); + glUniform4fv(m_program[pass].vsUniformsVec4Location, (int)m_program[pass].vsUniformsVec4Size, ptr); + m_program[pass].vsUniformsCollected.clear(); + } + /* When all variables were fetched, we send this uniform array and clear collected variables. + At this point, if some variables will be binded after all variables already were supplied, + this will cause these variables not binded at all, until all other variables collected again. */ + if(m_program[pass].psUniformsTotal > 0 && m_program[pass].psUniformsCollected.size() == m_program[pass].psUniformsTotal) + { + const GLfloat* ptr = const_cast<const GLfloat*>(reinterpret_cast<GLfloat*>(m_program[pass].psUniformsVec4)); + // LOGI("FRAGMENT: Setting uniform at %d of size %d from %x", m_program[pass].psUniformsVec4Location, m_program[pass].psUniformsVec4Size, ptr); + glUniform4fv(m_program[pass].psUniformsVec4Location, (int)m_program[pass].psUniformsVec4Size, ptr); + m_program[pass].psUniformsCollected.clear(); + } +} + +void GLES2RendererMaterial::bindVariable(Pass pass, const Variable &variable, const void *data) const +{ + GLESVariable &var = (GLESVariable&) variable; + if(m_program[pass].vertexMojoResult || m_program[pass].fragmentMojoResult) + { + mojoResult::relocationType::iterator it = m_program[pass].vertexMojoResult->relocation.find(variable.getName()); + if(it != m_program[pass].vertexMojoResult->relocation.end()) + { + if(it->second.name == vertexUniformArrayName) + { + mojoResult::shaderUniformRelocation& relocation = it->second; + // Mojo could truncate unused parts of the original variable, so in the D3D assembly it'll have type which is bigger then needed in the translated shader. + // This is to prevent buffer overruns in such cases. + //relocation.size = (relocation.index + relocation.size) > m_program[pass].vsUniformsVec4SizeInBytes ? (m_program[pass].vsUniformsVec4SizeInBytes - relocation.index) : relocation.size; + //LOGI("Found variable '%s' for %s (%x)", variable.getName(), getPassName(pass), this); + //LOGI("VERTEX: Copying %d bytes from %x to %x+%d for %s (%s) -- %p", relocation.size, data, m_program[pass].vsUniformsVec4, relocation.index, variable.getName(), getPassName(pass), this); + memcpy(m_program[pass].vsUniformsVec4 + relocation.index, data, relocation.size); + m_program[pass].vsUniformsCollected.insert(variable.getName()); + } + else + { + bindSampler(variable, data, pass); + } + } + else if((it = m_program[pass].fragmentMojoResult->relocation.find(variable.getName())) != m_program[pass].fragmentMojoResult->relocation.end()) + { + if(it->second.name == pixelUniformArrayName) + { + mojoResult::shaderUniformRelocation& relocation = it->second; + // Mojo could truncate unused parts of the original variable, so in the D3D assembly it'll have type which is bigger then needed in the translated shader. + // This is to prevent buffer overruns in such cases. + //relocation.size = (relocation.index + relocation.size) > m_program[pass].psUniformsVec4SizeInBytes ? (m_program[pass].psUniformsVec4SizeInBytes - relocation.index) : relocation.size; + //LOGI("FRAGMENT: Copying %d bytes from %x to %x+%d for %s (%s) -- %p", relocation.size, data, m_program[pass].psUniformsVec4, relocation.index, variable.getName(), getPassName(pass), this); + memcpy(m_program[pass].psUniformsVec4 + relocation.index, data, relocation.size); + m_program[pass].psUniformsCollected.insert(variable.getName()); + } + else + { + bindSampler(variable, data, pass); + } + } + } + else + { + switch(var.getType()) + { + case VARIABLE_FLOAT: + { + float f = *(const float*)data; + //LOGI("GLES2RendererMaterial: VARIABLE_FLOAT"); + glUniform1f(var.m_location[pass], f); + break; + } + case VARIABLE_FLOAT2: + { + //LOGI("GLES2RendererMaterial: VARIABLE_FLOAT2"); + glUniform2fv(var.m_location[pass], 1, (const GLfloat*)data); + break; + } + case VARIABLE_FLOAT3: + { + //LOGI("GLES2RendererMaterial: VARIABLE_FLOAT3"); + glUniform3fv(var.m_location[pass], 1, (const GLfloat*)data); + break; + } + case VARIABLE_FLOAT4: + { + //LOGI("GLES2RendererMaterial: VARIABLE_FLOAT4"); + glUniform4fv(var.m_location[pass], 1, (const GLfloat*)data); + break; + } + case VARIABLE_FLOAT4x4: + { + //LOGI("GLES2RendererMaterial: VARIABLE_FLOAT4x4"); + glUniformMatrix4fv(var.m_location[pass], 1, GL_FALSE, (const GLfloat*)data); + break; + } + case VARIABLE_SAMPLER2D: + { + bindSampler(variable, data, pass); + break; + } + default: + break; + } + } +} + +RendererMaterial::VariableType GLES2RendererMaterial::GLTypetoVariableType(GLenum type) +{ + switch (type) + { + case GL_SAMPLER_2D: return VARIABLE_SAMPLER2D; + case GL_FLOAT: return VARIABLE_FLOAT; + case GL_FLOAT_VEC2: return VARIABLE_FLOAT2; + case GL_FLOAT_VEC3: return VARIABLE_FLOAT3; + case GL_FLOAT_VEC4: return VARIABLE_FLOAT4; + case GL_FLOAT_MAT4: return VARIABLE_FLOAT4x4; + default: return NUM_VARIABLE_TYPES; + } +} + +static std::string variableTypeToString(RendererMaterial::VariableType type) +{ + switch (type) + { + case RendererMaterial::VARIABLE_SAMPLER2D: return "VARIABLE_SAMPLER2D"; + case RendererMaterial::VARIABLE_FLOAT: return "VARIABLE_FLOAT"; + case RendererMaterial::VARIABLE_FLOAT2: return "VARIABLE_FLOAT2"; + case RendererMaterial::VARIABLE_FLOAT3: return "VARIABLE_FLOAT3"; + case RendererMaterial::VARIABLE_FLOAT4: return "VARIABLE_FLOAT4"; + case RendererMaterial::VARIABLE_FLOAT4x4: return "VARIABLE_FLOAT4x4"; + default: return "VARIABLE_UNKNOWN"; + } +} + +GLint GLES2RendererMaterial::getAttribLocation(size_t usage, size_t index, Pass pass) +{ + GLint result = -1; + if(m_program[pass].vertexMojoResult->parseResult.attributes.find(usage) != m_program[pass].vertexMojoResult->parseResult.attributes.end() && + m_program[pass].vertexMojoResult->parseResult.attributes[usage].size() > index) + return glGetAttribLocation(m_program[pass].program, m_program[pass].vertexMojoResult->parseResult.attributes[usage][index].c_str()); + return result; +} + +std::string GLES2RendererMaterial::mojoSampleNameToOriginal(Pass pass, const std::string& name) +{ + for(mojoResult::relocationType::const_iterator it = m_program[pass].vertexMojoResult->relocation.begin(); + it != m_program[pass].vertexMojoResult->relocation.end(); ++it) + { + if(it->second.name == name) return it->first; + } + for(mojoResult::relocationType::const_iterator it = m_program[pass].fragmentMojoResult->relocation.begin(); + it != m_program[pass].fragmentMojoResult->relocation.end(); ++it) + { + if(it->second.name == name) return it->first; + } + return std::string(); +} + +void GLES2RendererMaterial::loadCustomConstants(Pass pass) +{ + /* Find samplers locations */ + std::vector<std::string> uniformArrayName; + uniformArrayName.push_back("vs_uniforms_vec4"); + uniformArrayName.push_back("ps_uniforms_vec4"); + int sampler = 0; + GLint count; + glGetProgramiv(m_program[pass].program, GL_ACTIVE_UNIFORMS, &count); + + if (count == 0) + { + LOGI("No active uniforms!"); + } + + for (int i = 0; i < count; i++) + { + char name[512]; + GLsizei length; + GLint size; + GLenum type; + glGetActiveUniform(m_program[pass].program, i, 512, &length, &size, &type, name); + + assert(m_program[pass].vertexMojoResult && m_program[pass].fragmentMojoResult); + + RendererMaterial::VariableType vtype = GLTypetoVariableType(type); + if (strncmp(name, "g_", 2) && (vtype != NUM_VARIABLE_TYPES)) + { + if(m_program[pass].vertexMojoResult || m_program[pass].fragmentMojoResult) + { + if (vtype == VARIABLE_SAMPLER2D) + { + // find existing variable... + GLESVariable *var = NULL; + bool varFound = false; + const char* varName = mojoSampleNameToOriginal(pass, name).c_str(); + PxU32 numVariables = (PxU32)m_variables.size(); + for(PxU32 j=0; j<numVariables; j++) + { + if(!strcmp(m_variables[j]->getName(), varName)) + { + var = static_cast<GLESVariable*>(m_variables[j]); + varFound = true; + break; + } + } + + if(!varFound) + var = new GLESVariable(varName, vtype, m_variableBufferSize); + + var->m_location[pass] = glGetUniformLocation(m_program[pass].program, name); + var->m_sampler[pass] = sampler++; + if(!varFound) + { + m_variables.push_back(var); + m_variableBufferSize += var->getDataSize(); + LOGI("Uniform '%s' -> location %d, size %d", var->getName(), var->m_location[pass], var->getDataSize()); + } + else + { + LOGI("Uniform '%s' was updated -> location %d, m_sampler %d", var->getName(), var->m_location[pass], var->m_sampler[pass]); + } + } + else if(uniformArrayName[0].compare(0, uniformArrayName[0].size(), name, uniformArrayName[0].size()) == 0) + { + m_program[pass].vsUniformsVec4Size = size; + m_program[pass].vsUniformsVec4SizeInBytes = m_program[pass].vsUniformsVec4Size * sizeof(float) * 4; + m_program[pass].vsUniformsVec4 = new char[m_program[pass].vsUniformsVec4SizeInBytes]; + LOGI("Allocated %d bytes at %x for vsUniformsVec4", m_program[pass].vsUniformsVec4SizeInBytes, size_t(m_program[pass].vsUniformsVec4)); + m_program[pass].vsUniformsVec4Location = glGetUniformLocation(m_program[pass].program, name); + LOGI("Hidden uniform '%s' -> location %d, size %d x vec4", name, m_program[pass].vsUniformsVec4Location, m_program[pass].vsUniformsVec4Size); + } + else if(uniformArrayName[1].compare(0, uniformArrayName[1].size(), name, uniformArrayName[1].size()) == 0) + { + m_program[pass].psUniformsVec4Size = size; + m_program[pass].psUniformsVec4SizeInBytes = m_program[pass].psUniformsVec4Size * sizeof(float) * 4; + m_program[pass].psUniformsVec4 = new char[m_program[pass].psUniformsVec4SizeInBytes]; + LOGI("Allocated %d bytes at %x for psUniformsVec4", m_program[pass].psUniformsVec4SizeInBytes, size_t(m_program[pass].psUniformsVec4)); + m_program[pass].psUniformsVec4Location = glGetUniformLocation(m_program[pass].program, name); + LOGI("Hidden uniform '%s' -> location %d, size %d x vec4", name, m_program[pass].psUniformsVec4Location, m_program[pass].psUniformsVec4Size); + } + else + { + LOGI("Couldn't find uniform!"); + } + } + else + { + GLESVariable *var = new GLESVariable(name, vtype, m_variableBufferSize); + var->m_location[pass] = glGetUniformLocation(m_program[pass].program, name); + if (vtype == VARIABLE_SAMPLER2D) + var->m_sampler[pass] = sampler++; + LOGI("Uniform '%s' -> location %d, size %d", name, var->m_location[pass], var->getDataSize()); + m_variables.push_back(var); + m_variableBufferSize += var->getDataSize(); + } + } + } + /* Use attributes info received from the AndroidSamplePlatform layer */ + if(m_program[pass].vertexMojoResult || m_program[pass].fragmentMojoResult) + { + /* Find attributes locations */ + m_program[pass].positionAttr = getAttribLocation(MOJOSHADER_USAGE_POSITION, 0, pass); + m_program[pass].colorAttr = getAttribLocation(MOJOSHADER_USAGE_COLOR, 0, pass); + m_program[pass].normalAttr = getAttribLocation(MOJOSHADER_USAGE_NORMAL, 0, pass); + m_program[pass].tangentAttr = getAttribLocation(MOJOSHADER_USAGE_TANGENT, 0, pass); + m_program[pass].boneIndexAttr = -1; + m_program[pass].boneWeightAttr = -1; + memset(m_program[pass].texcoordAttr, -1, sizeof(m_program[pass].texcoordAttr)); + LOGI("Attributes:"); + if(m_program[pass].vertexMojoResult->parseResult.attributes.find(MOJOSHADER_USAGE_TEXCOORD) != m_program[pass].vertexMojoResult->parseResult.attributes.end()) + { + for(int i = 0; i < m_program[pass].vertexMojoResult->parseResult.attributes[MOJOSHADER_USAGE_TEXCOORD].size(); ++i) + { + m_program[pass].texcoordAttr[i] = glGetAttribLocation(m_program[pass].program, m_program[pass].vertexMojoResult->parseResult.attributes[MOJOSHADER_USAGE_TEXCOORD][i].c_str()); + LOGI("\t TEXCOORD%d: %d", i, m_program[pass].texcoordAttr[i]); + } + /* If shader contains more than 4 texture coords inputs, then next one/two should be: bone indices input, bone weights input */ + if(m_program[pass].vertexMojoResult->parseResult.attributes[MOJOSHADER_USAGE_TEXCOORD].size() > 4) + { + m_program[pass].boneIndexAttr = glGetAttribLocation(m_program[pass].program, m_program[pass].vertexMojoResult->parseResult.attributes[MOJOSHADER_USAGE_TEXCOORD][4].c_str()); + } + if(m_program[pass].vertexMojoResult->parseResult.attributes[MOJOSHADER_USAGE_TEXCOORD].size() > 5) + { + m_program[pass].boneWeightAttr = glGetAttribLocation(m_program[pass].program, m_program[pass].vertexMojoResult->parseResult.attributes[MOJOSHADER_USAGE_TEXCOORD][5].c_str()); + } + } + + LOGI("\t POSITION: %d", m_program[pass].positionAttr); + LOGI("\t COLOR: %d", m_program[pass].colorAttr); + LOGI("\t NORMAL: %d", m_program[pass].normalAttr); + LOGI("\t TANGENT: %d", m_program[pass].tangentAttr); + LOGI("\t BONE INDEX: %d", m_program[pass].boneIndexAttr); + LOGI("\t BONE WEIGHT: %d", m_program[pass].boneWeightAttr); + + /* Expose variables that were in the original shader, but are now inside one vec4 array */ + std::vector<mojoResult*> mojoResults; + mojoResults.push_back(m_program[pass].vertexMojoResult); + mojoResults.push_back(m_program[pass].fragmentMojoResult); + for(int i = 0; i < mojoResults.size(); ++i) + { + for(mojoResult::relocationType::const_iterator it = mojoResults[i]->relocation.begin(); + it != mojoResults[i]->relocation.end(); ++it) + { + if(it->second.name == uniformArrayName[i]) { + // find existing variable... + GLESVariable *var = NULL; + bool varFound = false; + PxU32 numVariables = (PxU32)m_variables.size(); + for(PxU32 j=0; j<numVariables; j++) + { + if(!strcmp(m_variables[j]->getName(), it->first.c_str())) + { + var = static_cast<GLESVariable*>(m_variables[j]); + varFound = true; + break; + } + } + if(!varFound) + var = new GLESVariable(it->first.c_str(), GLTypetoVariableType(it->second.type), m_variableBufferSize); + + var->setSize(it->second.size); + var->m_location[pass] = glGetAttribLocation(m_program[pass].program, it->second.name.c_str()); + + /* Count total variables inside an array */ + /* Inside vertex uniform array ... */ + if(i == 0) m_program[pass].vsUniformsTotal++; + /* or fragment uniform array */ + else m_program[pass].psUniformsTotal++; + + if(!varFound) + { + m_variables.push_back(var); + m_variableBufferSize += it->second.size; + } + if(varFound) + LOGI("Variable is found and updated with m_location for %s", getPassName(static_cast<Pass>(pass))); + LOGI("Uniform '%s' -> location %d, size %d of type %s", var->getName(), var->m_location[pass], it->second.size, variableTypeToString(var->getType()).c_str()); + } + } + } + LOGI("Variables inside vertex uniform array - %d", m_program[pass].vsUniformsTotal); + LOGI("Variables inside fragment uniform array - %d", m_program[pass].psUniformsTotal); + } + else + { + m_program[pass].modelViewProjMatrixUniform = glGetUniformLocation(m_program[pass].program, "g_MVP"); + m_program[pass].modelMatrixUniform = glGetUniformLocation(m_program[pass].program, "g_modelMatrix"); + m_program[pass].viewMatrixUniform = glGetUniformLocation(m_program[pass].program, "g_viewMatrix"); + m_program[pass].projMatrixUniform = glGetUniformLocation(m_program[pass].program, "g_projMatrix"); + m_program[pass].modelViewMatrixUniform = glGetUniformLocation(m_program[pass].program, "g_modelViewMatrix"); + m_program[pass].boneMatricesUniform = glGetUniformLocation(m_program[pass].program, "g_boneMatrices"); + + m_program[pass].positionAttr = glGetAttribLocation(m_program[pass].program, "position_attr"); + m_program[pass].colorAttr = glGetAttribLocation(m_program[pass].program, "color_attr"); + m_program[pass].normalAttr = glGetAttribLocation(m_program[pass].program, "normal_attr"); + m_program[pass].tangentAttr = glGetAttribLocation(m_program[pass].program, "tangent_attr"); + m_program[pass].boneIndexAttr = glGetAttribLocation(m_program[pass].program, "boneIndex_attr"); + m_program[pass].boneWeightAttr = glGetAttribLocation(m_program[pass].program, "boneWeight_attr"); + + for(PxU32 i=0; i<8; i++) + { + char attr[32]; + sprintf(attr, "texcoord%d_attr", i); + m_program[pass].texcoordAttr[i] = glGetAttribLocation(m_program[pass].program, attr); + } + } + + LOGI("That was %p", this); +} + +} +#endif // #if defined(RENDERER_ENABLE_GLES2) diff --git a/PhysX_3.4/Samples/SampleFramework/renderer/src/gles2/GLES2RendererMaterial.h b/PhysX_3.4/Samples/SampleFramework/renderer/src/gles2/GLES2RendererMaterial.h new file mode 100644 index 00000000..b278f5e3 --- /dev/null +++ b/PhysX_3.4/Samples/SampleFramework/renderer/src/gles2/GLES2RendererMaterial.h @@ -0,0 +1,139 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved. + + +#ifndef GLES2_RENDERER_MATERIAL_H +#define GLES2_RENDERER_MATERIAL_H + +#include <RendererConfig.h> + +#if defined(RENDERER_ENABLE_GLES2) + +#include <RendererMaterial.h> +#include "GLES2Renderer.h" + +#if defined(RENDERER_ANDROID) +#include "android/AndroidSamplePlatform.h" +#elif defined(RENDERER_IOS) +#include "ios/IosSamplePlatform.h" +#endif + +#include <set> + +#include <set> + +namespace SampleRenderer +{ + +class GLES2RendererMaterial : public RendererMaterial +{ + public: + GLES2RendererMaterial(GLES2Renderer &renderer, const RendererMaterialDesc &desc); + virtual ~GLES2RendererMaterial(void); + virtual void setModelMatrix(const float *matrix) + { + PX_UNUSED(matrix); + PX_ALWAYS_ASSERT(); + } + virtual const Renderer& getRenderer() const { return m_renderer; } + + /* Actually executes glUniform* and submits data saved in the m_program[m_currentPass].vsUniformsVec4/psUniformsVec4 */ + void submitUniforms(); + + private: + virtual void bind(RendererMaterial::Pass pass, RendererMaterialInstance *materialInstance, bool instanced) const; + virtual void bindMeshState(bool instanced) const; + virtual void unbind(void) const; + virtual void bindVariable(Pass pass, const Variable &variable, const void *data) const; + + VariableType GLTypetoVariableType(GLenum type); + GLint getAttribLocation(size_t usage, size_t index, Pass pass); + std::string mojoSampleNameToOriginal(Pass pass, const std::string& name); + + private: + GLES2RendererMaterial &operator=(const GLES2RendererMaterial&) { return *this; } + + private: + void loadCustomConstants(Pass pass); + + friend class GLES2Renderer; + friend class GLES2RendererVertexBuffer; + friend class GLES2RendererDirectionalLight; + GLES2Renderer &m_renderer; + + GLenum m_glAlphaTestFunc; + + mutable struct shaderProgram { + GLuint vertexShader; + GLuint fragmentShader; + GLuint program; + + GLint modelMatrixUniform; + GLint viewMatrixUniform; + GLint projMatrixUniform; + GLint modelViewMatrixUniform; + GLint boneMatricesUniform; + GLint modelViewProjMatrixUniform; + + GLint positionAttr; + GLint colorAttr; + GLint normalAttr; + GLint tangentAttr; + GLint boneIndexAttr; + GLint boneWeightAttr; + + GLint texcoordAttr[8]; + + mutable std::set<std::string> vsUniformsCollected; + mutable std::set<std::string> psUniformsCollected; + + size_t vsUniformsTotal; + size_t psUniformsTotal; + + char* vsUniformsVec4; + GLuint vsUniformsVec4Location; + size_t vsUniformsVec4Size; + size_t vsUniformsVec4SizeInBytes; + char* psUniformsVec4; + GLuint psUniformsVec4Location; + size_t psUniformsVec4Size; + size_t psUniformsVec4SizeInBytes; + + mojoResult* vertexMojoResult; + mojoResult* fragmentMojoResult; + + shaderProgram(); + ~shaderProgram(); + } m_program[NUM_PASSES]; + + mutable Pass m_currentPass; +}; + +} + +#endif // #if defined(RENDERER_ENABLE_GLES2) +#endif diff --git a/PhysX_3.4/Samples/SampleFramework/renderer/src/gles2/GLES2RendererMesh.cpp b/PhysX_3.4/Samples/SampleFramework/renderer/src/gles2/GLES2RendererMesh.cpp new file mode 100644 index 00000000..b5a0ff2c --- /dev/null +++ b/PhysX_3.4/Samples/SampleFramework/renderer/src/gles2/GLES2RendererMesh.cpp @@ -0,0 +1,103 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved. + + +#include "GLES2RendererMesh.h" + +#if defined(RENDERER_ENABLE_GLES2) +namespace SampleRenderer +{ + +static GLenum getGLPrimitive(RendererMesh::Primitive primitive) +{ + GLenum glprim = ~(GLenum)0; + switch(primitive) + { + case RendererMesh::PRIMITIVE_POINTS: glprim = GL_POINTS; break; + case RendererMesh::PRIMITIVE_LINES: glprim = GL_LINES; break; + case RendererMesh::PRIMITIVE_LINE_STRIP: glprim = GL_LINE_STRIP; break; + case RendererMesh::PRIMITIVE_TRIANGLES: glprim = GL_TRIANGLES; break; + case RendererMesh::PRIMITIVE_TRIANGLE_STRIP: glprim = GL_TRIANGLE_STRIP; break; + case RendererMesh::PRIMITIVE_POINT_SPRITES: glprim = GL_POINTS; break; + default: break; + } + RENDERER_ASSERT(glprim != ~(GLenum)0, "Unable to find GL Primitive type."); + return glprim; +} + +static GLenum getGLIndexType(RendererIndexBuffer::Format format) +{ + GLenum gltype = 0; + switch(format) + { + case RendererIndexBuffer::FORMAT_UINT16: gltype = GL_UNSIGNED_SHORT; break; + case RendererIndexBuffer::FORMAT_UINT32: gltype = GL_UNSIGNED_INT; break; + default: break; + } + RENDERER_ASSERT(gltype, "Unable to convert to GL Index Type."); + return gltype; +} + +GLES2RendererMesh::GLES2RendererMesh(GLES2Renderer& renderer, const RendererMeshDesc &desc) : + RendererMesh(desc), m_renderer(renderer) +{ + +} + +GLES2RendererMesh::~GLES2RendererMesh(void) +{ + +} + +void GLES2RendererMesh::renderIndices(PxU32 numVertices, PxU32 firstIndex, PxU32 numIndices, RendererIndexBuffer::Format indexFormat, RendererMaterial *material) const +{ + const PxU32 indexSize = RendererIndexBuffer::getFormatByteSize(indexFormat); + void *buffer = ((PxU8*) 0)+indexSize*firstIndex; + glDrawElements(getGLPrimitive(getPrimitives()), numIndices, getGLIndexType(indexFormat), buffer); +} + +void GLES2RendererMesh::renderVertices(PxU32 numVertices, RendererMaterial *material) const +{ + RendererMesh::Primitive primitive = getPrimitives(); + if(primitive == RendererMesh::PRIMITIVE_POINT_SPRITES) glDepthMask(false); + glDrawArrays(getGLPrimitive(primitive), 0, numVertices); + if(primitive == RendererMesh::PRIMITIVE_POINT_SPRITES) glDepthMask(true); + } + +void GLES2RendererMesh::renderIndicesInstanced(PxU32 numVertices, PxU32 firstIndex, PxU32 numIndices, RendererIndexBuffer::Format indexFormat, RendererMaterial *material) const +{ + RENDERER_ASSERT(0, "TODO") +} + +void GLES2RendererMesh::renderVerticesInstanced(PxU32 numVertices, RendererMaterial *material) const +{ + RENDERER_ASSERT(0, "TODO") +} + +} +#endif // #if defined(RENDERER_ENABLE_GLES2) + diff --git a/PhysX_3.4/Samples/SampleFramework/renderer/src/gles2/GLES2RendererMesh.h b/PhysX_3.4/Samples/SampleFramework/renderer/src/gles2/GLES2RendererMesh.h new file mode 100644 index 00000000..b24dd778 --- /dev/null +++ b/PhysX_3.4/Samples/SampleFramework/renderer/src/gles2/GLES2RendererMesh.h @@ -0,0 +1,62 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved. + + +#ifndef GLES2_RENDERER_MESH_H +#define GLES2_RENDERER_MESH_H + +#include <RendererConfig.h> + +#if defined(RENDERER_ENABLE_GLES2) + +#include <RendererMesh.h> + +#include "GLES2Renderer.h" + +namespace SampleRenderer +{ +class GLES2RendererMesh : public RendererMesh +{ + public: + GLES2RendererMesh(GLES2Renderer& renderer, const RendererMeshDesc &desc); + virtual ~GLES2RendererMesh(void); + + public: + virtual void renderIndices(PxU32 numVertices, PxU32 firstIndex, PxU32 numIndices, RendererIndexBuffer::Format indexFormat, RendererMaterial *material) const; + virtual void renderVertices(PxU32 numVertices, RendererMaterial *material) const; + + virtual void renderIndicesInstanced(PxU32 numVertices, PxU32 firstIndex, PxU32 numIndices, RendererIndexBuffer::Format indexFormat, RendererMaterial *material) const; + virtual void renderVerticesInstanced(PxU32 numVertices, RendererMaterial *material) const; + + protected: + Renderer& renderer() { return m_renderer; } + + GLES2Renderer& m_renderer; +}; +} +#endif // #if defined(RENDERER_ENABLE_OPENGL) +#endif diff --git a/PhysX_3.4/Samples/SampleFramework/renderer/src/gles2/GLES2RendererTexture2D.cpp b/PhysX_3.4/Samples/SampleFramework/renderer/src/gles2/GLES2RendererTexture2D.cpp new file mode 100644 index 00000000..fab87c05 --- /dev/null +++ b/PhysX_3.4/Samples/SampleFramework/renderer/src/gles2/GLES2RendererTexture2D.cpp @@ -0,0 +1,273 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved. + + +#include "GLES2RendererTexture2D.h" + +#if defined(RENDERER_ENABLE_GLES2) + +namespace SampleRenderer +{ + +static GLuint getGLPixelFormat(RendererTexture2D::Format format) +{ + GLuint glformat = 0; + switch(format) + { +#if !defined(RENDERER_IOS) + case RendererTexture2D::FORMAT_B8G8R8A8: glformat = GL_RGBA8; break; +#else + case RendererTexture2D::FORMAT_B8G8R8A8: glformat = GL_BGRA8; break; +#endif + case RendererTexture2D::FORMAT_R32F: glformat = GL_LUMINANCE; break; + case RendererTexture2D::FORMAT_D16: glformat = GL_DEPTH_COMPONENT; break; + case RendererTexture2D::FORMAT_D24S8: glformat = GL_DEPTH_COMPONENT; break; + default: break; + } + return glformat; +} + +static GLuint getGLPixelInternalFormat(RendererTexture2D::Format format) +{ + GLuint glinternalformat = 0; + switch(format) + { + case RendererTexture2D::FORMAT_B8G8R8A8: + //apparently APPLE's current GLES2 implementation doesn't really support BGRA as an internal texture format + glinternalformat = GL_RGBA8; + break; + case RendererTexture2D::FORMAT_DXT1: + glinternalformat = GL_COMPRESSED_RGBA_S3TC_DXT1_EXT; + break; + case RendererTexture2D::FORMAT_DXT3: + glinternalformat = GL_COMPRESSED_RGBA_S3TC_DXT3_EXT; + break; + case RendererTexture2D::FORMAT_DXT5: + glinternalformat = GL_COMPRESSED_RGBA_S3TC_DXT5_EXT; + break; + case RendererTexture2D::FORMAT_PVR_2BPP: + glinternalformat = GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG; + break; + case RendererTexture2D::FORMAT_PVR_4BPP: + glinternalformat = GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG; + break; + default: + break; + } + RENDERER_ASSERT(glinternalformat, "Unable to compute GL Internal Format."); + return glinternalformat; +} + +static GLuint getGLPixelType(RendererTexture2D::Format format) +{ + GLuint gltype = 0; + switch(format) + { + case RendererTexture2D::FORMAT_B8G8R8A8: + gltype = GL_UNSIGNED_BYTE; + break; + case RendererTexture2D::FORMAT_R32F: + gltype = GL_FLOAT; + break; + case RendererTexture2D::FORMAT_D16: + gltype = GL_UNSIGNED_SHORT; + break; + case RendererTexture2D::FORMAT_D24S8: + gltype = GL_UNSIGNED_INT; + break; + default: + break; + } + return gltype; +} + +static GLint getGLTextureFilter(RendererTexture2D::Filter filter, bool mipmap) +{ + GLint glfilter = 0; + switch(filter) + { + case RendererTexture2D::FILTER_NEAREST: glfilter = mipmap ? GL_NEAREST_MIPMAP_NEAREST : GL_NEAREST; break; + case RendererTexture2D::FILTER_LINEAR: glfilter = mipmap ? GL_LINEAR_MIPMAP_LINEAR : GL_LINEAR; break; + case RendererTexture2D::FILTER_ANISOTROPIC: glfilter = mipmap ? GL_LINEAR_MIPMAP_LINEAR : GL_LINEAR; break; + default: break; + } + RENDERER_ASSERT(glfilter, "Unable to convert to OpenGL Filter mode."); + return glfilter; +} + +static GLint getGLTextureAddressing(RendererTexture2D::Addressing addressing) +{ + GLint glwrap = 0; + switch(addressing) + { + case RendererTexture2D::ADDRESSING_WRAP: glwrap = GL_REPEAT; break; + case RendererTexture2D::ADDRESSING_CLAMP: glwrap = GL_CLAMP; break; + case RendererTexture2D::ADDRESSING_MIRROR: glwrap = GL_MIRRORED_REPEAT; break; + default: break; + + } + RENDERER_ASSERT(glwrap, "Unable to convert to OpenGL Addressing mode."); + return glwrap; +} + +GLES2RendererTexture2D::GLES2RendererTexture2D(const RendererTextureDesc &desc) : + RendererTexture2D(desc) +{ + m_textureid = 0; + m_glformat = 0; + m_glinternalformat = 0; + m_gltype = 0; + m_numLevels = 0; + m_data = 0; + + m_glformat = getGLPixelFormat(desc.format); + m_glinternalformat = getGLPixelInternalFormat(desc.format); + m_gltype = getGLPixelType(desc.format); + + glGenTextures(1, &m_textureid); + RENDERER_ASSERT(m_textureid, "Failed to create OpenGL Texture."); + if(m_textureid) + { + m_width = desc.width; + m_height = desc.height; + m_numLevels = desc.numLevels; + m_data = new PxU8*[m_numLevels]; + memset(m_data, 0, sizeof(PxU8*)*m_numLevels); + + glBindTexture(GL_TEXTURE_2D, m_textureid); + if(isCompressedFormat(desc.format)) + { + for(PxU32 i=0; i<desc.numLevels; i++) + { + PxU32 w = getLevelDimension(m_width, i); + PxU32 h = getLevelDimension(m_height, i); + PxU32 levelSize = computeImageByteSize(w, h, 1, desc.format); + m_data[i] = new PxU8[levelSize]; + memset(m_data[i], 0, levelSize); + glCompressedTexImage2D(GL_TEXTURE_2D, (GLint)i, m_glinternalformat, w, h, 0, levelSize, m_data[i]); + } + } + else + { + RENDERER_ASSERT(m_glformat, "Unknown OpenGL Format!"); + for(PxU32 i=0; i<desc.numLevels; i++) + { + PxU32 w = getLevelDimension(m_width, i); + PxU32 h = getLevelDimension(m_height, i); + PxU32 levelSize = computeImageByteSize(w, h, 1, desc.format); + m_data[i] = new PxU8[levelSize]; + memset(m_data[i], 0, levelSize); + glTexImage2D(GL_TEXTURE_2D, (GLint)i, m_glinternalformat, w, h, 0, m_glformat, m_gltype, m_data[i]); + } + } + + + // set filtering mode... + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, getGLTextureFilter(desc.filter, m_numLevels > 1)); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, getGLTextureFilter(desc.filter, false)); + if(desc.filter == FILTER_ANISOTROPIC) + { + GLfloat maxAnisotropy = 1.0f; + glGetFloatv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &maxAnisotropy); + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, maxAnisotropy); + } + + // set addressing modes... + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, getGLTextureAddressing(desc.addressingU)); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, getGLTextureAddressing(desc.addressingV)); + + glBindTexture(GL_TEXTURE_2D, 0); + } +} + +GLES2RendererTexture2D::~GLES2RendererTexture2D(void) +{ + if(m_textureid) + { + glDeleteTextures(1, &m_textureid); + } + if(m_data) + { + for(PxU32 i=0; i<m_numLevels; i++) + { + delete [] m_data[i]; + } + delete [] m_data; + } +} + +void *GLES2RendererTexture2D::lockLevel(PxU32 level, PxU32 &pitch) +{ + void *buffer = 0; + RENDERER_ASSERT(level < m_numLevels, "Level out of range!"); + if(level < m_numLevels) + { + buffer = m_data[level]; + pitch = getFormatNumBlocks(getWidth()>>level, getFormat()) * getBlockSize(); + } + return buffer; +} + + +void GLES2RendererTexture2D::select(PxU32 stageIndex) +{ + bind(stageIndex); +} + +void GLES2RendererTexture2D::unlockLevel(PxU32 level) +{ + RENDERER_ASSERT(level < m_numLevels, "Level out of range!"); + if(m_textureid && level < m_numLevels) + { + PxU32 w = getLevelDimension(getWidth(), level); + PxU32 h = getLevelDimension(getHeight(), level); + glBindTexture(GL_TEXTURE_2D, m_textureid); + if(isCompressedFormat(getFormat())) + { + PxU32 levelSize = computeImageByteSize(w, h, 1, getFormat()); + glCompressedTexSubImage2D(GL_TEXTURE_2D, (GLint)level, 0, 0, w, h, m_glinternalformat, levelSize, m_data[level]); + } + else + { + glTexImage2D(GL_TEXTURE_2D, (GLint)level, m_glinternalformat, w, h, 0, m_glformat, m_gltype, m_data[level]); + } + glBindTexture(GL_TEXTURE_2D, 0); + } +} + +void GLES2RendererTexture2D::bind(PxU32 textureUnit) +{ + if(m_textureid) + { + glActiveTextureARB(GL_TEXTURE0_ARB + textureUnit); + glClientActiveTextureARB(GL_TEXTURE0_ARB + textureUnit); + glBindTexture(GL_TEXTURE_2D, m_textureid); + } +} + +} +#endif // #if defined(RENDERER_ENABLE_GLES2) diff --git a/PhysX_3.4/Samples/SampleFramework/renderer/src/gles2/GLES2RendererTexture2D.h b/PhysX_3.4/Samples/SampleFramework/renderer/src/gles2/GLES2RendererTexture2D.h new file mode 100644 index 00000000..9c9a2010 --- /dev/null +++ b/PhysX_3.4/Samples/SampleFramework/renderer/src/gles2/GLES2RendererTexture2D.h @@ -0,0 +1,72 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved. + + +#ifndef GLES2_RENDERER_TEXTURE_2D_H +#define GLES2_RENDERER_TEXTURE_2D_H + +#include <RendererConfig.h> + +#if defined(RENDERER_ENABLE_GLES2) + +#include <RendererTexture2D.h> +#include <RendererTexture2DDesc.h> +#include "GLES2Renderer.h" + +namespace SampleRenderer +{ +class RendererTextureDesc; + +class GLES2RendererTexture2D : public RendererTexture2D +{ + public: + GLES2RendererTexture2D(const RendererTextureDesc &desc); + virtual ~GLES2RendererTexture2D(void); + + public: + virtual void *lockLevel(PxU32 level, PxU32 &pitch); + virtual void unlockLevel(PxU32 level); + + void bind(PxU32 textureUnit); + void select(PxU32 stageIndex); + + private: + GLuint m_textureid; + GLuint m_glformat; + GLuint m_glinternalformat; + GLuint m_gltype; + + PxU32 m_width; + PxU32 m_height; + + PxU32 m_numLevels; + + PxU8 **m_data; +}; +} +#endif // #if defined(RENDERER_ENABLE_GLES2) +#endif diff --git a/PhysX_3.4/Samples/SampleFramework/renderer/src/gles2/GLES2RendererVertexBuffer.cpp b/PhysX_3.4/Samples/SampleFramework/renderer/src/gles2/GLES2RendererVertexBuffer.cpp new file mode 100644 index 00000000..e9a0ec75 --- /dev/null +++ b/PhysX_3.4/Samples/SampleFramework/renderer/src/gles2/GLES2RendererVertexBuffer.cpp @@ -0,0 +1,332 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved. + + +#include "GLES2RendererVertexBuffer.h" +#include "GLES2RendererMaterial.h" + +#if defined(RENDERER_ENABLE_GLES2) + +#include <RendererVertexBufferDesc.h> + +namespace SampleRenderer +{ + +extern GLES2RendererMaterial *g_hackCurrentMat; + +GLES2RendererVertexBuffer::GLES2RendererVertexBuffer(const RendererVertexBufferDesc &desc) : + RendererVertexBuffer(desc) +{ + m_vbo = 0; + + RENDERER_ASSERT(GLEW_ARB_vertex_buffer_object, "Vertex Buffer Objects not supported on this machine!"); + if(GLEW_ARB_vertex_buffer_object) + { + GLenum usage = GL_STATIC_DRAW_ARB; + if(getHint() == HINT_DYNAMIC) + { + usage = GL_DYNAMIC_DRAW_ARB; + } + + RENDERER_ASSERT(m_stride && desc.maxVertices, "Unable to create Vertex Buffer of zero size."); + if(m_stride && desc.maxVertices) + { + glGenBuffersARB(1, &m_vbo); + RENDERER_ASSERT(m_vbo, "Failed to create Vertex Buffer Object."); + } + if(m_vbo) + { + m_maxVertices = desc.maxVertices; + PxU32 bufferSize = m_stride * m_maxVertices; + glBindBufferARB(GL_ARRAY_BUFFER_ARB, m_vbo); + glBufferDataARB(GL_ARRAY_BUFFER_ARB, bufferSize, 0, usage); + glBindBufferARB(GL_ARRAY_BUFFER_ARB, 0); + } + } +} + +GLES2RendererVertexBuffer::~GLES2RendererVertexBuffer(void) +{ + if(m_vbo) + { + glDeleteBuffersARB(1, &m_vbo); + } +} + +void GLES2RendererVertexBuffer::swizzleColor(void *colors, PxU32 stride, PxU32 numColors, RendererVertexBuffer::Format inFormat) +{ + if (inFormat == RendererVertexBuffer::FORMAT_COLOR_RGBA) + { + const void *end = ((PxU8*)colors)+(stride*numColors); + for(PxU8* iterator = (PxU8*)colors; iterator < end; iterator+=stride) + { + std::swap(((PxU8*)iterator)[0], ((PxU8*)iterator)[2]); + } + } +} + +PxU32 GLES2RendererVertexBuffer::convertColor(const RendererColor& color) +{ + return color.a << 24 | color.b << 16 | color.g << 8 | color.r; +} + +void *GLES2RendererVertexBuffer::lock(void) +{ + void *buffer = 0; + if(m_vbo) + { + glBindBufferARB(GL_ARRAY_BUFFER_ARB, m_vbo); + buffer = glMapBufferOES(GL_ARRAY_BUFFER, GL_WRITE_ONLY); + glBindBufferARB(GL_ARRAY_BUFFER_ARB, 0); + } + return buffer; +} + +void GLES2RendererVertexBuffer::unlock(void) +{ + if(m_vbo) + { + /* TODO: print out if format is USHORT4 */ + glBindBufferARB(GL_ARRAY_BUFFER_ARB, m_vbo); + glUnmapBufferOES(GL_ARRAY_BUFFER); + glBindBufferARB(GL_ARRAY_BUFFER_ARB, 0); + } +} + +static GLuint getGLFormatSize(RendererVertexBuffer::Format format) +{ + PxU32 size = 0; + switch(format) + { + case RendererVertexBuffer::FORMAT_FLOAT1: size = 1; break; + case RendererVertexBuffer::FORMAT_FLOAT2: size = 2; break; + case RendererVertexBuffer::FORMAT_FLOAT3: size = 3; break; + case RendererVertexBuffer::FORMAT_FLOAT4: size = 4; break; + case RendererVertexBuffer::FORMAT_UBYTE4: size = 4; break; + case RendererVertexBuffer::FORMAT_USHORT4: size = 4; break; + case RendererVertexBuffer::FORMAT_COLOR_BGRA: size = 4; break; + case RendererVertexBuffer::FORMAT_COLOR_RGBA: size = 4; break; + case RendererVertexBuffer::FORMAT_COLOR_NATIVE: size = 4; break; + default: break; + } + RENDERER_ASSERT(size, "Unable to compute number of Vertex Buffer elements."); + return size; +} + +static GLenum getGLFormatType(RendererVertexBuffer::Format format) +{ + GLenum type = 0; + switch(format) + { + case RendererVertexBuffer::FORMAT_FLOAT1: + case RendererVertexBuffer::FORMAT_FLOAT2: + case RendererVertexBuffer::FORMAT_FLOAT3: + case RendererVertexBuffer::FORMAT_FLOAT4: + type = GL_FLOAT; + break; + case RendererVertexBuffer::FORMAT_UBYTE4: + type = GL_BYTE; + break; + case RendererVertexBuffer::FORMAT_USHORT4: + type = GL_SHORT; + break; + case RendererVertexBuffer::FORMAT_COLOR_BGRA: + case RendererVertexBuffer::FORMAT_COLOR_RGBA: + case RendererVertexBuffer::FORMAT_COLOR_NATIVE: + type = GL_UNSIGNED_BYTE; + break; + default: + break; + } + RENDERER_ASSERT(type, "Unable to compute GLType for Vertex Buffer Format."); + return type; +} + +#if !defined(RENDERER_ANDROID) && !defined(RENDERER_IOS) +static GLenum getGLSemantic(RendererVertexBuffer::Semantic semantic) +{ + GLenum glsemantic = 0; + switch(semantic) + { + case RendererVertexBuffer::SEMANTIC_POSITION: glsemantic = GL_VERTEX_ARRAY; break; + case RendererVertexBuffer::SEMANTIC_COLOR: glsemantic = GL_COLOR_ARRAY; break; + case RendererVertexBuffer::SEMANTIC_NORMAL: glsemantic = GL_NORMAL_ARRAY; break; + case RendererVertexBuffer::SEMANTIC_TANGENT: glsemantic = GL_TEXTURE_COORD_ARRAY; break; + + case RendererVertexBuffer::SEMANTIC_TEXCOORD0: + case RendererVertexBuffer::SEMANTIC_TEXCOORD1: + case RendererVertexBuffer::SEMANTIC_TEXCOORD2: + case RendererVertexBuffer::SEMANTIC_TEXCOORD3: + case RendererVertexBuffer::SEMANTIC_TEXCOORD3: + case RendererVertexBuffer::SEMANTIC_BONEINDEX: + case RendererVertexBuffer::SEMANTIC_BONEWEIGHT: + glsemantic = GL_TEXTURE_COORD_ARRAY; + break; + } + RENDERER_ASSERT(glsemantic, "Unable to compute the GL Semantic for Vertex Buffer Semantic."); + return glsemantic; +} +#endif + +void GLES2RendererVertexBuffer::bindGL(GLint position, const SemanticDesc &sm, PxU8 *buffer) +{ + if (position == -1) + return; + + glEnableVertexAttribArray(position); + GLenum type = getGLFormatType(sm.format); + glVertexAttribPointer(position, getGLFormatSize(sm.format), type, type == GL_UNSIGNED_BYTE, m_stride, buffer+sm.offset); +} + +void GLES2RendererVertexBuffer::unbindGL(GLint pos) +{ + if (pos != -1) + glDisableVertexAttribArray(pos); +} + +void GLES2RendererVertexBuffer::bind(PxU32 streamID, PxU32 firstVertex) +{ + prepareForRender(); + GLES2RendererMaterial *mat = g_hackCurrentMat; + PxU8 *buffer = ((PxU8*)0) + firstVertex*m_stride; + if(m_vbo) + { + glBindBufferARB(GL_ARRAY_BUFFER_ARB, m_vbo); + for(PxU32 i=0; i<NUM_SEMANTICS; i++) + { + Semantic semantic = (Semantic)i; + const SemanticDesc &sm = m_semanticDescs[semantic]; + if(sm.format < NUM_FORMATS) + { + switch(semantic) + { + case SEMANTIC_POSITION: + RENDERER_ASSERT(sm.format >= FORMAT_FLOAT1 && sm.format <= FORMAT_FLOAT4, "Unsupported Vertex Buffer Format for POSITION semantic."); + if(sm.format >= FORMAT_FLOAT1 && sm.format <= FORMAT_FLOAT4) + { + bindGL(mat->m_program[mat->m_currentPass].positionAttr, sm, buffer); + } + break; + case SEMANTIC_COLOR: + RENDERER_ASSERT(sm.format == FORMAT_COLOR_BGRA || sm.format == FORMAT_COLOR_RGBA || sm.format == FORMAT_COLOR_NATIVE || sm.format == FORMAT_FLOAT4, "Unsupported Vertex Buffer Format for COLOR semantic."); + if(sm.format == FORMAT_COLOR_BGRA || sm.format == FORMAT_COLOR_RGBA || sm.format == FORMAT_COLOR_NATIVE || sm.format == FORMAT_FLOAT4) + { + bindGL(mat->m_program[mat->m_currentPass].colorAttr, sm, buffer); + } + break; + case SEMANTIC_NORMAL: + RENDERER_ASSERT(sm.format == FORMAT_FLOAT3 || sm.format == FORMAT_FLOAT4, "Unsupported Vertex Buffer Format for NORMAL semantic."); + if(sm.format == FORMAT_FLOAT3 || sm.format == FORMAT_FLOAT4) + { + bindGL(mat->m_program[mat->m_currentPass].normalAttr, sm, buffer); + } + break; + case SEMANTIC_TANGENT: + RENDERER_ASSERT(sm.format == FORMAT_FLOAT3 || sm.format == FORMAT_FLOAT4, "Unsupported Vertex Buffer Format for TANGENT semantic."); + if(sm.format == FORMAT_FLOAT3 || sm.format == FORMAT_FLOAT4) + { + bindGL(mat->m_program[mat->m_currentPass].tangentAttr, sm, buffer); + } + break; + case SEMANTIC_TEXCOORD0: + case SEMANTIC_TEXCOORD1: + case SEMANTIC_TEXCOORD2: + case SEMANTIC_TEXCOORD3: + { + const PxU32 channel = semantic - SEMANTIC_TEXCOORD0; + glActiveTextureARB((GLenum)(GL_TEXTURE0_ARB + channel)); + glClientActiveTextureARB((GLenum)(GL_TEXTURE0_ARB + channel)); + + bindGL(mat->m_program[mat->m_currentPass].texcoordAttr[channel], sm, buffer); + + break; + } + case SEMANTIC_BONEINDEX: + { + glActiveTextureARB((GLenum)(GL_TEXTURE0_ARB + RENDERER_BONEINDEX_CHANNEL)); + glClientActiveTextureARB((GLenum)(GL_TEXTURE0_ARB + RENDERER_BONEINDEX_CHANNEL)); + bindGL(mat->m_program[mat->m_currentPass].boneIndexAttr, sm, buffer); + break; + } + case SEMANTIC_BONEWEIGHT: + { + glActiveTextureARB((GLenum)(GL_TEXTURE0_ARB + RENDERER_BONEWEIGHT_CHANNEL)); + glClientActiveTextureARB((GLenum)(GL_TEXTURE0_ARB + RENDERER_BONEWEIGHT_CHANNEL)); + bindGL(mat->m_program[mat->m_currentPass].boneWeightAttr, sm, buffer); + break; + } + default: + /* + __android_log_print(ANDROID_LOG_DEBUG, "GLES2RendererVertexBuffer", "semantic: %d", i); + RENDERER_ASSERT(0, "Unable to bind Vertex Buffer Semantic."); + */ + break; + } + } + } + glBindBufferARB(GL_ARRAY_BUFFER_ARB, 0); + } +} + +void GLES2RendererVertexBuffer::unbind(PxU32 streamID) +{ + GLES2RendererMaterial *mat = g_hackCurrentMat; + + for(PxU32 i=0; i<NUM_SEMANTICS; i++) + { + Semantic semantic = (Semantic)i; + const SemanticDesc &sm = m_semanticDescs[semantic]; + if(sm.format < NUM_FORMATS) + { + switch (semantic) + { + case SEMANTIC_POSITION: unbindGL(mat->m_program[mat->m_currentPass].positionAttr); break; + case SEMANTIC_COLOR: unbindGL(mat->m_program[mat->m_currentPass].positionAttr); break; + case SEMANTIC_NORMAL: unbindGL(mat->m_program[mat->m_currentPass].normalAttr); break; + case SEMANTIC_TANGENT: unbindGL(mat->m_program[mat->m_currentPass].tangentAttr); break; + case SEMANTIC_BONEINDEX: unbindGL(mat->m_program[mat->m_currentPass].boneIndexAttr); break; + case SEMANTIC_BONEWEIGHT: unbindGL(mat->m_program[mat->m_currentPass].boneWeightAttr); break; + default: + /* + __android_log_print(ANDROID_LOG_DEBUG, "GLES2RendererVertexBuffer", "semantic: %d", i); + RENDERER_ASSERT(0, "Unable to unbind Vertex Buffer Semantic."); + */ + break; + } + } + } + for(PxU32 i=0; i<8; i++) + { + glActiveTextureARB((GLenum)(GL_TEXTURE0_ARB + i)); + glClientActiveTextureARB((GLenum)(GL_TEXTURE0_ARB + i)); + + unbindGL(mat->m_program[mat->m_currentPass].texcoordAttr[i]); + } +} + +} +#endif // #if defined(RENDERER_ENABLE_GLES2) diff --git a/PhysX_3.4/Samples/SampleFramework/renderer/src/gles2/GLES2RendererVertexBuffer.h b/PhysX_3.4/Samples/SampleFramework/renderer/src/gles2/GLES2RendererVertexBuffer.h new file mode 100644 index 00000000..29009f90 --- /dev/null +++ b/PhysX_3.4/Samples/SampleFramework/renderer/src/gles2/GLES2RendererVertexBuffer.h @@ -0,0 +1,67 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved. + + +#ifndef GLES2_RENDERER_VERTEXBUFFER_H +#define GLES2_RENDERER_VERTEXBUFFER_H + +#include <RendererConfig.h> + +#if defined(RENDERER_ENABLE_GLES2) + +#include <RendererVertexBuffer.h> +#include "GLES2Renderer.h" + +namespace SampleRenderer +{ + +class GLES2RendererVertexBuffer : public RendererVertexBuffer +{ + public: + GLES2RendererVertexBuffer(const RendererVertexBufferDesc &desc); + virtual ~GLES2RendererVertexBuffer(void); + static PxU32 convertColor(const RendererColor& color); + + protected: + virtual void swizzleColor(void *colors, PxU32 stride, PxU32 numColors, RendererVertexBuffer::Format inFormat); + virtual void *lock(void); + virtual void unlock(void); + + virtual void bind(PxU32 streamID, PxU32 firstVertex); + virtual void unbind(PxU32 streamID); + + virtual void bindGL(GLint position, const SemanticDesc &sm, PxU8 *buffer); + virtual void unbindGL(GLint attr); + private: + + GLuint m_vbo; +}; + +} + +#endif // #if defined(RENDERER_ENABLE_GLES2) +#endif diff --git a/PhysX_3.4/Samples/SampleFramework/renderer/src/null/NULLRenderer.cpp b/PhysX_3.4/Samples/SampleFramework/renderer/src/null/NULLRenderer.cpp new file mode 100644 index 00000000..323bde15 --- /dev/null +++ b/PhysX_3.4/Samples/SampleFramework/renderer/src/null/NULLRenderer.cpp @@ -0,0 +1,292 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved. + +#include <RendererConfig.h> +#include "NULLRenderer.h" + +#include <RendererDesc.h> + +#include "NULLRendererDirectionalLight.h" +#include "NULLRendererIndexBuffer.h" +#include "NULLRendererInstanceBuffer.h" +#include "NULLRendererMaterial.h" +#include "NULLRendererMesh.h" +#include "NULLRendererSpotLight.h" +#include "NULLRendererTexture2D.h" +#include "NULLRendererVertexBuffer.h" + +#include "RendererVertexBufferDesc.h" +#include "RendererIndexBufferDesc.h" +#include "RendererInstanceBufferDesc.h" +#include "RendererTexture2DDesc.h" +#include "RendererMaterialDesc.h" +#include "RendererDirectionalLightDesc.h" +#include "RendererSpotLightDesc.h" +#include "RendererMeshDesc.h" + +using namespace SampleRenderer; + +NullRenderer::NullRenderer(const RendererDesc &desc, const char* assetDir) : +Renderer(DRIVER_NULL, desc.errorCallback, assetDir) +{ + +} + +NullRenderer::~NullRenderer(void) +{ +} + +void NullRenderer::finishRendering() +{ +} + +bool NullRenderer::captureScreen(const char* filename) +{ + return false; +} + +// clears the offscreen buffers. +void NullRenderer::clearBuffers(void) +{ +} + +// presents the current color buffer to the screen. +// returns true on device reset and if buffers need to be rewritten. +bool NullRenderer::swapBuffers(void) +{ + return false; +} + +RendererVertexBuffer *NullRenderer::createVertexBuffer(const RendererVertexBufferDesc &desc) +{ + NullRendererVertexBuffer *vb = 0; + RENDERER_ASSERT(desc.isValid(), "Invalid Vertex Buffer Descriptor."); + if(desc.isValid()) + { + vb = new NullRendererVertexBuffer(desc); + } + return vb; +} + +RendererIndexBuffer *NullRenderer::createIndexBuffer(const RendererIndexBufferDesc &desc) +{ + NullRendererIndexBuffer *ib = 0; + RENDERER_ASSERT(desc.isValid(), "Invalid Index Buffer Descriptor."); + if(desc.isValid()) + { + ib = new NullRendererIndexBuffer(desc); + } + return ib; +} + +void* NullRenderer::getDevice() +{ + return NULL; +} + +void NullRenderer::getWindowSize(PxU32 &width, PxU32 &height) const +{ + width = 640; + height = 480; +} + +void NullRenderer::renderLines2D(const void* vertices, PxU32 nbVerts) +{ + +} + +RendererInstanceBuffer *NullRenderer::createInstanceBuffer(const RendererInstanceBufferDesc &desc) +{ + NullRendererInstanceBuffer *ib = 0; + RENDERER_ASSERT(desc.isValid(), "Invalid Instance Buffer Descriptor."); + if(desc.isValid()) + { + ib = new NullRendererInstanceBuffer(desc); + } + return ib; +} + +RendererTexture2D *NullRenderer::createTexture2D(const RendererTexture2DDesc &desc) +{ + RendererTexture2D *texture = 0; + RENDERER_ASSERT(desc.isValid(), "Invalid Texture 2D Descriptor."); + if(desc.isValid()) + { + texture = new NullRendererTexture2D(desc); + } + return texture; +} + +RendererTexture3D *NullRenderer::createTexture3D(const RendererTexture3DDesc &desc) +{ + RendererTexture3D *texture = 0; + RENDERER_ASSERT(desc.isValid(), "Invalid Texture 3D Descriptor."); + if(desc.isValid()) + { + // TODO: implement + texture = NULL; + } + return texture; +} + +RendererTarget *NullRenderer::createTarget(const RendererTargetDesc &desc) +{ + RENDERER_ASSERT(0, "Not Implemented."); + return 0; +} + +RendererMaterial *NullRenderer::createMaterial(const RendererMaterialDesc &desc) +{ + NullRendererMaterial *mat = 0; + RENDERER_ASSERT(desc.isValid(), "Invalid Material Descriptor."); + if(desc.isValid()) + { + mat = new NullRendererMaterial(*this, desc); + } + return mat; +} + +RendererMesh *NullRenderer::createMesh(const RendererMeshDesc &desc) +{ + NullRendererMesh *mesh = 0; + RENDERER_ASSERT(desc.isValid(), "Invalid Mesh Descriptor."); + if(desc.isValid()) + { + mesh = new NullRendererMesh(*this,desc); + } + return mesh; +} + +RendererLight *NullRenderer::createLight(const RendererLightDesc &desc) +{ + RendererLight *light = 0; + RENDERER_ASSERT(desc.isValid(), "Invalid Light Descriptor."); + if(desc.isValid()) + { + switch(desc.type) + { + case RendererLight::TYPE_DIRECTIONAL: + light = new NullRendererDirectionalLight(*static_cast<const RendererDirectionalLightDesc*>(&desc)); + break; + case RendererLight::TYPE_SPOT: + { + light = new NullRendererSpotLight(*static_cast<const RendererSpotLightDesc*>(&desc)); + } + break; + default: + break; + } + + } + return light; +} + +void NullRenderer::bindViewProj(const physx::PxMat44 &eye, const RendererProjection &proj) +{ + +} + +void NullRenderer::bindFogState(const RendererColor &fogColor, float fogDistance) +{ +} + +void NullRenderer::bindAmbientState(const RendererColor &ambientColor) +{ + +} + +void NullRenderer::bindDeferredState(void) +{ + RENDERER_ASSERT(0, "Not implemented!"); +} + +void NullRenderer::bindMeshContext(const RendererMeshContext &context) +{ + +} + +void NullRenderer::beginMultiPass(void) +{ +} + +void NullRenderer::endMultiPass(void) +{ +} + +void NullRenderer::renderDeferredLight(const RendererLight &/*light*/) +{ + RENDERER_ASSERT(0, "Not implemented!"); +} + +PxU32 NullRenderer::convertColor(const RendererColor& color) const +{ + return color.a << 24 | color.b << 16 | color.g << 8 | color.r; +} + + +bool NullRenderer::isOk(void) const +{ + return true; +} + +/////////////////////////////////////////////////////////////////////////////// + +void NullRenderer::setupTextRenderStates() +{ +} + +void NullRenderer::resetTextRenderStates() +{ + +} + +bool NullRenderer::initTexter() +{ + + return true; +} + +void NullRenderer::renderTextBuffer(const void* verts, PxU32 nbVerts, const PxU16* indices, PxU32 nbIndices, RendererMaterial* material) +{ + +} + +void NullRenderer::renderLines2D(const void* vertices, PxU32 nbPassedVerts, RendererMaterial* material) +{ + +} + +void NullRenderer::setupScreenquadRenderStates() +{ + +} + +void NullRenderer::resetScreenquadRenderStates() +{ + +} + diff --git a/PhysX_3.4/Samples/SampleFramework/renderer/src/null/NULLRenderer.h b/PhysX_3.4/Samples/SampleFramework/renderer/src/null/NULLRenderer.h new file mode 100644 index 00000000..9ca77a08 --- /dev/null +++ b/PhysX_3.4/Samples/SampleFramework/renderer/src/null/NULLRenderer.h @@ -0,0 +1,102 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved. +#ifndef NULL_RENDERER_H +#define NULL_RENDERER_H + +#include <RendererConfig.h> + +#include <Renderer.h> + +namespace SampleRenderer +{ + + class NullRenderer : public Renderer + { + public: + NullRenderer(const RendererDesc &desc, const char* assetDir); + virtual ~NullRenderer(void); + + public: + // clears the offscreen buffers. + virtual void clearBuffers(void); + + // presents the current color buffer to the screen. + // returns true on device reset and if buffers need to be rewritten. + virtual bool swapBuffers(void); + + // get the device pointer (void * abstraction) + virtual void *getDevice(); + + virtual void finishRendering(); + + virtual void getWindowSize(PxU32 &width, PxU32 &height) const; + + virtual RendererVertexBuffer *createVertexBuffer( const RendererVertexBufferDesc &desc); + virtual RendererIndexBuffer *createIndexBuffer( const RendererIndexBufferDesc &desc); + virtual RendererInstanceBuffer *createInstanceBuffer(const RendererInstanceBufferDesc &desc); + virtual RendererTexture2D *createTexture2D( const RendererTexture2DDesc &desc); + virtual RendererTexture3D *createTexture3D( const RendererTexture3DDesc &desc); + virtual RendererTarget *createTarget( const RendererTargetDesc &desc); + virtual RendererMaterial *createMaterial( const RendererMaterialDesc &desc); + virtual RendererMesh *createMesh( const RendererMeshDesc &desc); + virtual RendererLight *createLight( const RendererLightDesc &desc); + + virtual bool captureScreen(const char* filename); + + virtual void renderLines2D(const void* vertices, PxU32 nbVerts); + + private: + virtual void bindViewProj(const physx::PxMat44 &eye, const RendererProjection &proj); + virtual void bindAmbientState(const RendererColor &ambientColor); + virtual void bindFogState(const RendererColor &fogColor, float fogDistance); + virtual void bindDeferredState(void); + virtual void bindMeshContext(const RendererMeshContext &context); + virtual void beginMultiPass(void); + virtual void endMultiPass(void); + virtual void renderDeferredLight(const RendererLight &light); + virtual PxU32 convertColor(const RendererColor& color) const; + virtual void beginTransparentMultiPass(void) {} + virtual void endTransparentMultiPass(void) {} + virtual void setVsync(bool on) {} + virtual bool captureScreen(PxU32 &width, PxU32& height, PxU32& sizeInBytes, const void*& screenshotData) { return false; } + + virtual bool isOk(void) const; + + virtual void setupTextRenderStates(); + virtual void resetTextRenderStates(); + virtual void renderTextBuffer(const void* vertices, PxU32 nbVerts, const PxU16* indices, PxU32 nbIndices, RendererMaterial* material); + virtual void renderLines2D(const void* vertices, PxU32 nbVerts, RendererMaterial* material); + virtual void setupScreenquadRenderStates(); + virtual void resetScreenquadRenderStates(); + virtual bool initTexter(); + + private: + }; + +} // namespace SampleRenderer + +#endif diff --git a/PhysX_3.4/Samples/SampleFramework/renderer/src/null/NULLRendererDirectionalLight.cpp b/PhysX_3.4/Samples/SampleFramework/renderer/src/null/NULLRendererDirectionalLight.cpp new file mode 100644 index 00000000..d5ff3852 --- /dev/null +++ b/PhysX_3.4/Samples/SampleFramework/renderer/src/null/NULLRendererDirectionalLight.cpp @@ -0,0 +1,48 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved. + +#include <RendererConfig.h> + + + +#include "NULLRendererDirectionalLight.h" + +using namespace SampleRenderer; + +NullRendererDirectionalLight::NullRendererDirectionalLight(const RendererDirectionalLightDesc &desc) : + RendererDirectionalLight(desc) +{ +} + +NullRendererDirectionalLight::~NullRendererDirectionalLight(void) +{ +} + +void NullRendererDirectionalLight::bind(void) const +{ +} + diff --git a/PhysX_3.4/Samples/SampleFramework/renderer/src/null/NULLRendererDirectionalLight.h b/PhysX_3.4/Samples/SampleFramework/renderer/src/null/NULLRendererDirectionalLight.h new file mode 100644 index 00000000..ba38aeb9 --- /dev/null +++ b/PhysX_3.4/Samples/SampleFramework/renderer/src/null/NULLRendererDirectionalLight.h @@ -0,0 +1,54 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved. +#ifndef NULL_RENDERER_DIRECTIONAL_LIGHT_H +#define NULL_RENDERER_DIRECTIONAL_LIGHT_H + +#include <RendererConfig.h> + + +#include <RendererDirectionalLight.h> + +namespace SampleRenderer +{ + + class RendererDirectionalLightDesc; + + class NullRendererDirectionalLight : public RendererDirectionalLight + { + public: + NullRendererDirectionalLight(const RendererDirectionalLightDesc &desc); + virtual ~NullRendererDirectionalLight(void); + + virtual void bind(void) const; + + private: + + }; + +} // namespace SampleRenderer + +#endif diff --git a/PhysX_3.4/Samples/SampleFramework/renderer/src/null/NULLRendererIndexBuffer.cpp b/PhysX_3.4/Samples/SampleFramework/renderer/src/null/NULLRendererIndexBuffer.cpp new file mode 100644 index 00000000..b57108a6 --- /dev/null +++ b/PhysX_3.4/Samples/SampleFramework/renderer/src/null/NULLRendererIndexBuffer.cpp @@ -0,0 +1,74 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved. + +#include <RendererConfig.h> + + +#include "NULLRendererIndexBuffer.h" +#include <RendererIndexBufferDesc.h> + +using namespace SampleRenderer; + +NullRendererIndexBuffer::NullRendererIndexBuffer(const RendererIndexBufferDesc &desc) : + RendererIndexBuffer(desc), m_Buffer(0) +{ + PxU32 indexSize = getFormatByteSize(getFormat()); + + RENDERER_ASSERT(desc.maxIndices > 0 && desc.maxIndices > 0, "Cannot create zero size Index Buffer."); + if(indexSize && desc.maxIndices > 0) + { + m_Buffer = new PxU8[indexSize*desc.maxIndices]; + m_maxIndices = desc.maxIndices; + } + +} + +NullRendererIndexBuffer::~NullRendererIndexBuffer(void) +{ + if(m_Buffer) + { + delete [] m_Buffer; + m_Buffer = NULL; + } +} + +void *NullRendererIndexBuffer::lock(void) +{ + return m_Buffer; +} + +void NullRendererIndexBuffer::unlock(void) +{ +} + +void NullRendererIndexBuffer::bind(void) const +{ +} + +void NullRendererIndexBuffer::unbind(void) const +{ +} diff --git a/PhysX_3.4/Samples/SampleFramework/renderer/src/null/NULLRendererIndexBuffer.h b/PhysX_3.4/Samples/SampleFramework/renderer/src/null/NULLRendererIndexBuffer.h new file mode 100644 index 00000000..07551449 --- /dev/null +++ b/PhysX_3.4/Samples/SampleFramework/renderer/src/null/NULLRendererIndexBuffer.h @@ -0,0 +1,57 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved. +#ifndef NULL_RENDERER_INDEXBUFFER_H +#define NULL_RENDERER_INDEXBUFFER_H + +#include <RendererConfig.h> + +#include <RendererIndexBuffer.h> + +namespace SampleRenderer +{ + + class NullRendererIndexBuffer : public RendererIndexBuffer + { + public: + NullRendererIndexBuffer(const RendererIndexBufferDesc &desc); + virtual ~NullRendererIndexBuffer(void); + + public: + virtual void *lock(void); + virtual void unlock(void); + + private: + virtual void bind(void) const; + virtual void unbind(void) const; + + private: + PxU8* m_Buffer; + }; + +} // namespace SampleRenderer + +#endif diff --git a/PhysX_3.4/Samples/SampleFramework/renderer/src/null/NULLRendererInstanceBuffer.cpp b/PhysX_3.4/Samples/SampleFramework/renderer/src/null/NULLRendererInstanceBuffer.cpp new file mode 100644 index 00000000..bc5244c7 --- /dev/null +++ b/PhysX_3.4/Samples/SampleFramework/renderer/src/null/NULLRendererInstanceBuffer.cpp @@ -0,0 +1,74 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved. + +#include <RendererConfig.h> + +#include "NULLRendererInstanceBuffer.h" +#include <RendererInstanceBufferDesc.h> + +using namespace SampleRenderer; + +NullRendererInstanceBuffer::NullRendererInstanceBuffer(const RendererInstanceBufferDesc &desc) : + RendererInstanceBuffer(desc) +{ + m_bufferSize = (PxU32)(desc.maxInstances * m_stride); + m_buffer = new PxU8[m_bufferSize]; + + RENDERER_ASSERT(m_buffer, "Failed to create Vertex Buffer Object."); + + m_maxInstances = desc.maxInstances; +} + +NullRendererInstanceBuffer::~NullRendererInstanceBuffer(void) +{ + if(m_buffer) + { + delete [] m_buffer; + m_buffer = NULL; + } +} + + +void *NullRendererInstanceBuffer::lock(void) +{ + return m_buffer; +} + +void NullRendererInstanceBuffer::unlock(void) +{ + +} + +void NullRendererInstanceBuffer::bind(PxU32 streamID, PxU32 firstInstance) const +{ +} + +void NullRendererInstanceBuffer::unbind(PxU32 streamID) const +{ + +} + diff --git a/PhysX_3.4/Samples/SampleFramework/renderer/src/null/NULLRendererInstanceBuffer.h b/PhysX_3.4/Samples/SampleFramework/renderer/src/null/NULLRendererInstanceBuffer.h new file mode 100644 index 00000000..68d9178e --- /dev/null +++ b/PhysX_3.4/Samples/SampleFramework/renderer/src/null/NULLRendererInstanceBuffer.h @@ -0,0 +1,58 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved. +#ifndef NULL_RENDERER_INSTANCEBUFFER_H +#define NULL_RENDERER_INSTANCEBUFFER_H + +#include <RendererConfig.h> + +#include <RendererInstanceBuffer.h> + +namespace SampleRenderer +{ + + class NullRendererInstanceBuffer : public RendererInstanceBuffer + { + public: + NullRendererInstanceBuffer(const RendererInstanceBufferDesc &desc); + virtual ~NullRendererInstanceBuffer(void); + + public: + + virtual void *lock(void); + virtual void unlock(void); + + virtual void bind(PxU32 streamID, PxU32 firstInstance) const; + virtual void unbind(PxU32 streamID) const; + + private: + PxU8 *m_buffer; + PxU32 m_bufferSize; + }; + +} // namespace SampleRenderer + +#endif diff --git a/PhysX_3.4/Samples/SampleFramework/renderer/src/null/NULLRendererMaterial.cpp b/PhysX_3.4/Samples/SampleFramework/renderer/src/null/NULLRendererMaterial.cpp new file mode 100644 index 00000000..89540069 --- /dev/null +++ b/PhysX_3.4/Samples/SampleFramework/renderer/src/null/NULLRendererMaterial.cpp @@ -0,0 +1,78 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved. + +#include "RendererConfig.h" + +#include "NULLRendererMaterial.h" + +#include <RendererMaterialDesc.h> + +#include <SamplePlatform.h> + +// for PsString.h +namespace physx +{ + namespace string + {} +} +#include <PsString.h> +#include <PxTkFile.h> + +using namespace SampleRenderer; + +NullRendererMaterial::NullRendererMaterial(NullRenderer &renderer, const RendererMaterialDesc &desc) : + RendererMaterial(desc, renderer.getEnableMaterialCaching()), + m_renderer(renderer) +{ +} + +NullRendererMaterial::~NullRendererMaterial(void) +{ +} + + +void NullRendererMaterial::bind(RendererMaterial::Pass pass, RendererMaterialInstance *materialInstance, bool instanced) const +{ + RendererMaterial::bind(pass, materialInstance, instanced); +} + +void NullRendererMaterial::bindMeshState(bool instanced) const +{ + +} + +void NullRendererMaterial::unbind(void) const +{ + +} + + +void NullRendererMaterial::bindVariable(Pass pass, const Variable &variable, const void *data) const +{ +} + + diff --git a/PhysX_3.4/Samples/SampleFramework/renderer/src/null/NULLRendererMaterial.h b/PhysX_3.4/Samples/SampleFramework/renderer/src/null/NULLRendererMaterial.h new file mode 100644 index 00000000..88674136 --- /dev/null +++ b/PhysX_3.4/Samples/SampleFramework/renderer/src/null/NULLRendererMaterial.h @@ -0,0 +1,66 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved. +#ifndef NULL_RENDERER_MATERIAL_H +#define NULL_RENDERER_MATERIAL_H + +#include <RendererConfig.h> + +#include <RendererMaterial.h> + +#include "NULLRenderer.h" + +namespace SampleRenderer +{ + + class NullRendererMaterial : public RendererMaterial + { + public: + NullRendererMaterial(NullRenderer &renderer, const RendererMaterialDesc &desc); + virtual ~NullRendererMaterial(void); + virtual void setModelMatrix(const float *matrix) + { + PX_UNUSED(matrix); + PX_ALWAYS_ASSERT(); + } + + private: + virtual const Renderer& getRenderer() const { return m_renderer; } + virtual void bind(RendererMaterial::Pass pass, RendererMaterialInstance *materialInstance, bool instanced) const; + virtual void bindMeshState(bool instanced) const; + virtual void unbind(void) const; + virtual void bindVariable(Pass pass, const Variable &variable, const void *data) const; + + private: + NullRendererMaterial &operator=(const NullRendererMaterial&) { return *this; } + + private: + NullRenderer & m_renderer; + }; + +} // namespace SampleRenderer + +#endif diff --git a/PhysX_3.4/Samples/SampleFramework/renderer/src/null/NULLRendererMesh.cpp b/PhysX_3.4/Samples/SampleFramework/renderer/src/null/NULLRendererMesh.cpp new file mode 100644 index 00000000..6d2a7e20 --- /dev/null +++ b/PhysX_3.4/Samples/SampleFramework/renderer/src/null/NULLRendererMesh.cpp @@ -0,0 +1,72 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved. + +#include <RendererConfig.h> + +#include "NULLRendererMesh.h" + +using namespace SampleRenderer; + + +NullRendererMesh::NullRendererMesh(NullRenderer &renderer, const RendererMeshDesc &desc) : +RendererMesh(desc), +mRenderer(renderer) +{ +} + +NullRendererMesh::~NullRendererMesh(void) +{ + + + +} + +void NullRendererMesh::renderIndices(PxU32 numVertices, PxU32 firstIndex, PxU32 numIndices, RendererIndexBuffer::Format indexFormat, RendererMaterial *material) const +{ + +} + +bool NullRendererMesh::willRender() const +{ + return true; + +} + +void NullRendererMesh::renderVertices(PxU32 numVertices, RendererMaterial *material) const +{ + +} + +void NullRendererMesh::renderIndicesInstanced(PxU32 numVertices, PxU32 firstIndex, PxU32 numIndices, RendererIndexBuffer::Format indexFormat,RendererMaterial *material) const +{ +} + +void NullRendererMesh::renderVerticesInstanced(PxU32 numVertices,RendererMaterial *material) const +{ +} + + diff --git a/PhysX_3.4/Samples/SampleFramework/renderer/src/null/NULLRendererMesh.h b/PhysX_3.4/Samples/SampleFramework/renderer/src/null/NULLRendererMesh.h new file mode 100644 index 00000000..b0b87ba0 --- /dev/null +++ b/PhysX_3.4/Samples/SampleFramework/renderer/src/null/NULLRendererMesh.h @@ -0,0 +1,62 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved. +#ifndef NULL_RENDERER_MESH_H +#define NULL_RENDERER_MESH_H + +#include <RendererConfig.h> +#include <RendererMesh.h> +#include "NULLRenderer.h" + +namespace SampleRenderer +{ + + class NullRendererMesh : public RendererMesh + { + public: + NullRendererMesh(NullRenderer &renderer, const RendererMeshDesc &desc); + virtual ~NullRendererMesh(void); + + virtual bool willRender() const; + + public: + virtual void renderIndices(PxU32 numVertices, PxU32 firstIndex, PxU32 numIndices, RendererIndexBuffer::Format indexFormat, RendererMaterial *material) const; + virtual void renderVertices(PxU32 numVertices, RendererMaterial *material) const; + + virtual void renderIndicesInstanced(PxU32 numVertices, PxU32 firstIndex, PxU32 numIndices, RendererIndexBuffer::Format indexFormat,RendererMaterial *material) const; + virtual void renderVerticesInstanced(PxU32 numVertices,RendererMaterial *material) const; + + protected: + void operator=(const NullRendererMesh &){} + Renderer& renderer() { return mRenderer; } + + private: + NullRenderer& mRenderer; + }; + +} // namespace SampleRenderer + +#endif diff --git a/PhysX_3.4/Samples/SampleFramework/renderer/src/null/NULLRendererSpotLight.cpp b/PhysX_3.4/Samples/SampleFramework/renderer/src/null/NULLRendererSpotLight.cpp new file mode 100644 index 00000000..22a3d032 --- /dev/null +++ b/PhysX_3.4/Samples/SampleFramework/renderer/src/null/NULLRendererSpotLight.cpp @@ -0,0 +1,46 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved. +#include <RendererConfig.h> + +#include "NULLRendererSpotLight.h" + +using namespace SampleRenderer; + +NullRendererSpotLight::NullRendererSpotLight(const RendererSpotLightDesc &desc) : + RendererSpotLight(desc) +{ + +} + +NullRendererSpotLight::~NullRendererSpotLight(void) +{ + +} + +void NullRendererSpotLight::bind(void) const +{ +} diff --git a/PhysX_3.4/Samples/SampleFramework/renderer/src/null/NULLRendererSpotLight.h b/PhysX_3.4/Samples/SampleFramework/renderer/src/null/NULLRendererSpotLight.h new file mode 100644 index 00000000..f349e98e --- /dev/null +++ b/PhysX_3.4/Samples/SampleFramework/renderer/src/null/NULLRendererSpotLight.h @@ -0,0 +1,51 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved. + +#ifndef NULL_RENDERER_SPOT_LIGHT_H +#define NULL_RENDERER_SPOT_LIGHT_H + +#include <RendererConfig.h> +#include <RendererSpotLight.h> + + +namespace SampleRenderer +{ + + class NullRendererSpotLight : public RendererSpotLight + { + public: + NullRendererSpotLight (const RendererSpotLightDesc &desc); + virtual ~NullRendererSpotLight (void); + + virtual void bind(void) const; + + private: + }; + +} // namespace SampleRenderer + +#endif diff --git a/PhysX_3.4/Samples/SampleFramework/renderer/src/null/NULLRendererTexture2D.cpp b/PhysX_3.4/Samples/SampleFramework/renderer/src/null/NULLRendererTexture2D.cpp new file mode 100644 index 00000000..d0a19ac1 --- /dev/null +++ b/PhysX_3.4/Samples/SampleFramework/renderer/src/null/NULLRendererTexture2D.cpp @@ -0,0 +1,100 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved. + +#include <RendererConfig.h> + +#include "NULLRendererTexture2D.h" +#include <RendererTexture2DDesc.h> + +using namespace SampleRenderer; + +NullRendererTexture2D::NullRendererTexture2D(const RendererTexture2DDesc &desc) : +RendererTexture2D(desc) +{ + PxU32 width = desc.width; + PxU32 height = desc.height; + + m_numLevels = desc.numLevels; + m_data = new PxU8*[m_numLevels]; + m_width = new PxU32[m_numLevels]; + memset(m_data, 0, sizeof(PxU8*)*m_numLevels); + + for(PxU32 i=0; i<desc.numLevels; i++) + { + PxU32 w = getLevelDimension(width, i); + m_width[i] = w; + PxU32 h = getLevelDimension(height, i); + PxU32 levelSize = computeImageByteSize(w, h, 1, desc.format); + + // allocate memory + m_data[i] = new PxU8[levelSize]; + + memset(m_data[i], 0, levelSize); + } +} + +NullRendererTexture2D::~NullRendererTexture2D(void) +{ + for(PxU32 i=0; i<m_numLevels; i++) + { + delete [] m_data[i]; + } + + if(m_data) + { + delete [] m_data; + } + + if(m_width) + { + delete [] m_width; + } +} + +void *NullRendererTexture2D::lockLevel(PxU32 level, PxU32 &pitch) +{ + void *buffer = 0; + pitch = 0; + RENDERER_ASSERT(level < m_numLevels, "Level out of range!"); + if(level < m_numLevels) + { + buffer = m_data[level]; + PxU32 w = SampleRenderer::RendererTexture2D::getFormatNumBlocks(m_width[level], getFormat()); + pitch = w * getBlockSize(); + } + return buffer; +} + +void NullRendererTexture2D::unlockLevel(PxU32 level) +{ + RENDERER_ASSERT(level < m_numLevels, "Level out of range!"); +} + +void NullRendererTexture2D::bind(PxU32 textureUnit) +{ +} + diff --git a/PhysX_3.4/Samples/SampleFramework/renderer/src/null/NULLRendererTexture2D.h b/PhysX_3.4/Samples/SampleFramework/renderer/src/null/NULLRendererTexture2D.h new file mode 100644 index 00000000..e4fa175b --- /dev/null +++ b/PhysX_3.4/Samples/SampleFramework/renderer/src/null/NULLRendererTexture2D.h @@ -0,0 +1,63 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved. +#ifndef NULL_RENDERER_TEXTURE_2D_H +#define NULL_RENDERER_TEXTURE_2D_H + +#include <RendererConfig.h> + +#include <RendererTexture2D.h> + +namespace SampleRenderer +{ + + class NullRendererTexture2D : public RendererTexture2D + { + public: + NullRendererTexture2D(const RendererTexture2DDesc &desc); + virtual ~NullRendererTexture2D(void); + + public: + virtual void *lockLevel(PxU32 level, PxU32 &pitch); + virtual void unlockLevel(PxU32 level); + + void bind(PxU32 textureUnit); + + virtual void select(PxU32 stageIndex) + { + bind(stageIndex); + } + + private: + PxU8** m_data; + PxU32 m_numLevels; + PxU32* m_width; + + }; + +} // namespace SampleRenderer + +#endif diff --git a/PhysX_3.4/Samples/SampleFramework/renderer/src/null/NULLRendererVertexBuffer.cpp b/PhysX_3.4/Samples/SampleFramework/renderer/src/null/NULLRendererVertexBuffer.cpp new file mode 100644 index 00000000..a7a73e3c --- /dev/null +++ b/PhysX_3.4/Samples/SampleFramework/renderer/src/null/NULLRendererVertexBuffer.cpp @@ -0,0 +1,82 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved. + +#include "RendererConfig.h" +#include <SamplePlatform.h> + +#include "NULLRendererVertexBuffer.h" + +#include <RendererVertexBufferDesc.h> + + +using namespace SampleRenderer; + +NullRendererVertexBuffer::NullRendererVertexBuffer(const RendererVertexBufferDesc &desc) + :RendererVertexBuffer(desc),m_buffer(0) +{ + RENDERER_ASSERT(m_stride && desc.maxVertices, "Unable to create Vertex Buffer of zero size."); + if(m_stride && desc.maxVertices) + { + m_buffer = new PxU8[m_stride * desc.maxVertices]; + + RENDERER_ASSERT(m_buffer, "Failed to create Vertex Buffer Object."); + + m_maxVertices = desc.maxVertices; + } +} + +NullRendererVertexBuffer::~NullRendererVertexBuffer(void) +{ + if(m_buffer) + { + delete [] m_buffer; + m_buffer = NULL; + } +} + +void NullRendererVertexBuffer::swizzleColor(void *colors, PxU32 stride, PxU32 numColors, RendererVertexBuffer::Format inFormat) +{ +} + +void *NullRendererVertexBuffer::lock(void) +{ + return m_buffer; +} + +void NullRendererVertexBuffer::unlock(void) +{ +} + + +void NullRendererVertexBuffer::bind(PxU32 streamID, PxU32 firstVertex) +{ +} + +void NullRendererVertexBuffer::unbind(PxU32 streamID) +{ +} + diff --git a/PhysX_3.4/Samples/SampleFramework/renderer/src/null/NULLRendererVertexBuffer.h b/PhysX_3.4/Samples/SampleFramework/renderer/src/null/NULLRendererVertexBuffer.h new file mode 100644 index 00000000..5a27c512 --- /dev/null +++ b/PhysX_3.4/Samples/SampleFramework/renderer/src/null/NULLRendererVertexBuffer.h @@ -0,0 +1,58 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved. +#ifndef NULL_RENDERER_VERTEXBUFFER_H +#define NULL_RENDERER_VERTEXBUFFER_H + +#include <RendererConfig.h> + +#include <RendererVertexBuffer.h> + +namespace SampleRenderer +{ + + class NullRendererVertexBuffer : public RendererVertexBuffer + { + public: + NullRendererVertexBuffer(const RendererVertexBufferDesc &desc); + virtual ~NullRendererVertexBuffer(void); + + protected: + virtual void swizzleColor(void *colors, PxU32 stride, PxU32 numColors, RendererVertexBuffer::Format inFormat); + + virtual void *lock(void); + virtual void unlock(void); + + virtual void bind(PxU32 streamID, PxU32 firstVertex); + virtual void unbind(PxU32 streamID); + + private: + PxU8* m_buffer; + }; + +} // namespace SampleRenderer + +#endif diff --git a/PhysX_3.4/Samples/SampleFramework/renderer/src/ogl/OGLRenderer.cpp b/PhysX_3.4/Samples/SampleFramework/renderer/src/ogl/OGLRenderer.cpp new file mode 100644 index 00000000..0d536f1d --- /dev/null +++ b/PhysX_3.4/Samples/SampleFramework/renderer/src/ogl/OGLRenderer.cpp @@ -0,0 +1,873 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved. + +#include <RendererConfig.h> + +#if defined(RENDERER_ENABLE_OPENGL) + +#include "OGLRenderer.h" + +#include <RendererDesc.h> + +#include <RendererVertexBufferDesc.h> +#include "OGLRendererVertexBuffer.h" + +#include <RendererIndexBufferDesc.h> +#include "OGLRendererIndexBuffer.h" + +#include <RendererInstanceBufferDesc.h> +#include "OGLRendererInstanceBuffer.h" + +#include <RendererMeshDesc.h> +#include <RendererMeshContext.h> +#include "OGLRendererMesh.h" + +#include <RendererMaterialDesc.h> +#include <RendererMaterialInstance.h> +#include "OGLRendererMaterial.h" + +#include <RendererLightDesc.h> +#include <RendererDirectionalLightDesc.h> +#include "OGLRendererDirectionalLight.h" +#include <RendererSpotLightDesc.h> +#include "OGLRendererSpotLight.h" + +#include <RendererTexture2DDesc.h> +#include "OGLRendererTexture2D.h" + +#include <RendererProjection.h> + +#include <SamplePlatform.h> + +#include "PxTkFile.h" +#include "PsString.h" + +namespace Ps = physx::shdfnd; + +using namespace SampleRenderer; + +#if defined(RENDERER_ENABLE_CG) + void SampleRenderer::setColorParameter(CGparameter param, const RendererColor &color) + { + const float inv255 = 1.0f / 255.0f; + const float fcolor[3] = { color.r*inv255, color.g*inv255, color.b*inv255 }; + cgSetParameter3fv(param, fcolor); + } + + void SampleRenderer::setFloat4Parameter(CGparameter param, float* values) + { + cgSetParameter4fv(param, values); + } + +#endif + +#if defined(RENDERER_ENABLE_CG) + +#if !defined(RENDERER_PS3) + static void CGENTRY onCgError(CGcontext cgContext, CGerror err, void * data) + { + const char *errstr = cgGetErrorString(err); + if(cgContext) + { + errstr = cgGetLastListing(cgContext); + } + static_cast<SampleFramework::SamplePlatform*>(data)->showMessage("Cg error", errstr); + } +#endif + + OGLRenderer::CGEnvironment::CGEnvironment(void) + { + memset(this, 0, sizeof(*this)); + } + + OGLRenderer::CGEnvironment::CGEnvironment(CGcontext cgContext) + { + modelMatrix = cgCreateParameter(cgContext, CG_FLOAT4x4); + viewMatrix = cgCreateParameter(cgContext, CG_FLOAT4x4); + projMatrix = cgCreateParameter(cgContext, CG_FLOAT4x4); + modelViewMatrix = cgCreateParameter(cgContext, CG_FLOAT4x4); + modelViewProjMatrix = cgCreateParameter(cgContext, CG_FLOAT4x4); + + boneMatrices = cgCreateParameterArray(cgContext, CG_FLOAT4x4, RENDERER_MAX_BONES); + + fogColorAndDistance = cgCreateParameter(cgContext, CG_FLOAT4); + + eyePosition = cgCreateParameter(cgContext, CG_FLOAT3); + eyeDirection = cgCreateParameter(cgContext, CG_FLOAT3); + + ambientColor = cgCreateParameter(cgContext, CG_FLOAT3); + + lightColor = cgCreateParameter(cgContext, CG_FLOAT3); + lightIntensity = cgCreateParameter(cgContext, CG_FLOAT); + lightDirection = cgCreateParameter(cgContext, CG_FLOAT3); + lightPosition = cgCreateParameter(cgContext, CG_FLOAT3); + lightInnerRadius = cgCreateParameter(cgContext, CG_FLOAT); + lightOuterRadius = cgCreateParameter(cgContext, CG_FLOAT); + lightInnerCone = cgCreateParameter(cgContext, CG_FLOAT); + lightOuterCone = cgCreateParameter(cgContext, CG_FLOAT); + } +#endif + + void SampleRenderer::PxToGL(GLfloat *gl44, const physx::PxMat44 &mat44) + { + memcpy(gl44, mat44.front(), 4 * 4 * sizeof (GLfloat)); + } + + void SampleRenderer::RenToGL(GLfloat *gl44, const RendererProjection &proj) + { + proj.getColumnMajor44(gl44); + } + + OGLRenderer::OGLRenderer(const RendererDesc &desc, const char* assetDir) : + Renderer(DRIVER_OPENGL, desc.errorCallback, assetDir), m_platform(SampleFramework::SamplePlatform::platform()) + { + m_useShadersForTextRendering = false; + m_displayWidth = 0; + m_displayHeight = 0; + m_currMaterial = 0; + m_viewMatrix = PxMat44(PxIdentity); + + m_platform->initializeOGLDisplay(desc, m_displayWidth, m_displayHeight); + m_platform->postInitializeOGLDisplay(); + + //added this to avoid garbage being displayed during initialization + RendererColor savedColor = getClearColor(); + setClearColor(RendererColor(0U)); + clearBuffers(); + swapBuffers(); + setClearColor(savedColor); + + checkResize(); + +#if defined(RENDERER_ENABLE_CG) + m_cgContext = cgCreateContext(); + RENDERER_ASSERT(m_cgContext, "Unable to obtain Cg Context."); + + m_platform->initializeCGRuntimeCompiler(); + + if(m_cgContext) + { + m_cgEnv = CGEnvironment(m_cgContext); + +#if !defined(RENDERER_PS3) + cgSetErrorHandler(onCgError, m_platform); + cgSetParameterSettingMode(m_cgContext, CG_DEFERRED_PARAMETER_SETTING); +#endif +#if defined(RENDERER_DEBUG) + cgGLSetDebugMode(CG_TRUE); +#else + cgGLSetDebugMode(CG_FALSE); +#endif + } +#endif + + Ps::strlcpy(m_deviceName, sizeof(m_deviceName), (const char*)glGetString(GL_RENDERER)); + for(char *c=m_deviceName; *c; c++) + { + if(*c == '/') + { + *c = 0; + break; + } + } + + RendererColor& clearColor = getClearColor(); + glClearColor(clearColor.r/255.0f, clearColor.g/255.0f, clearColor.b/255.0f, clearColor.a/255.0f); + glEnable(GL_CULL_FACE); + glCullFace(GL_BACK); + glFrontFace(GL_CW); + glEnable(GL_DEPTH_TEST); + } + + OGLRenderer::~OGLRenderer(void) + { + // avoid displaying garbage on screen + setClearColor(RendererColor(0U)); + clearBuffers(); + swapBuffers(); + releaseAllMaterials(); + +#if defined(RENDERER_ENABLE_CG) + if(m_cgContext) + { + cgDestroyContext(m_cgContext); + } +#endif + + m_platform->freeDisplay(); + } + + bool OGLRenderer::begin(void) + { + bool ok = false; + ok = m_platform->makeContextCurrent(); + return ok; + } + + void OGLRenderer::end(void) + { + GLenum error = glGetError(); + //RENDERER_ASSERT(GL_NO_ERROR == error, "An OpenGL error has occured"); + + if (GL_NO_ERROR != error) + { + const char* errorString = "unknown"; + +#define CASE(MESSAGE) case MESSAGE: errorString = #MESSAGE; break; + switch(error) + { + CASE(GL_INVALID_ENUM) + CASE(GL_INVALID_VALUE) + CASE(GL_INVALID_OPERATION) + CASE(GL_STACK_OVERFLOW) + CASE(GL_STACK_UNDERFLOW) + CASE(GL_OUT_OF_MEMORY) +#if !defined(RENDERER_PS3) + CASE(GL_INVALID_FRAMEBUFFER_OPERATION) +#endif + + }; + +#undef CASE + + char buf[128]; + Ps::snprintf(buf, 128, "GL error %x occurred (%s)\n", error, errorString); + if (m_errorCallback) + m_errorCallback->reportError(PxErrorCode::eINTERNAL_ERROR, buf, __FILE__, __LINE__); + } + } + + void OGLRenderer::checkResize(void) + { + PxU32 width = m_displayWidth; + PxU32 height = m_displayHeight; + m_platform->getWindowSize(width, height); + if(width != m_displayWidth || height != m_displayHeight) + { + m_displayWidth = width; + m_displayHeight = height; + glViewport(0, 0, (GLsizei)m_displayWidth, (GLsizei)m_displayHeight); + glScissor( 0, 0, (GLsizei)m_displayWidth, (GLsizei)m_displayHeight); + } + } + + // clears the offscreen buffers. + void OGLRenderer::clearBuffers(void) + { + if(begin()) + { + GLbitfield glbuf = GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT; + glDepthMask(1); + + RendererColor& clearColor = getClearColor(); + glClearColor(clearColor.r/255.0f, clearColor.g/255.0f, clearColor.b/255.0f, clearColor.a/255.0f); + glClear(glbuf); + } + end(); + } + + // presents the current color buffer to the screen. + // returns true on device reset and if buffers need to be rewritten. + bool OGLRenderer::swapBuffers(void) + { + PX_PROFILE_ZONE("OGLRendererSwapBuffers",0); + if(begin()) + { + m_platform->swapBuffers(); + checkResize(); + } + end(); + return false; + } + + void OGLRenderer::getWindowSize(PxU32 &width, PxU32 &height) const + { + RENDERER_ASSERT(m_displayHeight * m_displayWidth > 0, "variables not initialized properly"); + width = m_displayWidth; + height = m_displayHeight; + } + + RendererVertexBuffer *OGLRenderer::createVertexBuffer(const RendererVertexBufferDesc &desc) + { + PX_PROFILE_ZONE("OGLRenderer_createVertexBuffer",0); + OGLRendererVertexBuffer *vb = 0; + RENDERER_ASSERT(desc.isValid(), "Invalid Vertex Buffer Descriptor."); + if(desc.isValid()) + { + vb = new OGLRendererVertexBuffer(desc); + } + return vb; + } + + RendererIndexBuffer *OGLRenderer::createIndexBuffer(const RendererIndexBufferDesc &desc) + { + PX_PROFILE_ZONE("OGLRenderer_createIndexBuffer",0); + OGLRendererIndexBuffer *ib = 0; + RENDERER_ASSERT(desc.isValid(), "Invalid Index Buffer Descriptor."); + if(desc.isValid()) + { + ib = new OGLRendererIndexBuffer(desc); + } + return ib; + } + + RendererInstanceBuffer *OGLRenderer::createInstanceBuffer(const RendererInstanceBufferDesc &desc) + { + PX_PROFILE_ZONE("OGLRenderer_createInstanceBuffer",0); + OGLRendererInstanceBuffer *ib = 0; + RENDERER_ASSERT(desc.isValid(), "Invalid Instance Buffer Descriptor."); + if(desc.isValid()) + { + ib = new OGLRendererInstanceBuffer(desc); + } + return ib; + } + + RendererTexture2D *OGLRenderer::createTexture2D(const RendererTexture2DDesc &desc) + { + PX_PROFILE_ZONE("OGLRenderer_createTexture2D",0); + OGLRendererTexture2D *texture = 0; + RENDERER_ASSERT(desc.isValid(), "Invalid Texture 2D Descriptor."); + if(desc.isValid()) + { + texture = new OGLRendererTexture2D(desc); + } + return texture; + } + + RendererTexture3D *OGLRenderer::createTexture3D(const RendererTexture3DDesc &desc) + { + // TODO: Implement + return 0; + } + + RendererTarget *OGLRenderer::createTarget(const RendererTargetDesc &desc) + { + PX_PROFILE_ZONE("OGLRenderer_createTarget",0); + RENDERER_ASSERT(0, "Not Implemented."); + return 0; + } + + RendererMaterial *OGLRenderer::createMaterial(const RendererMaterialDesc &desc) + { + RendererMaterial *mat = hasMaterialAlready(desc); + RENDERER_ASSERT(desc.isValid(), "Invalid Material Descriptor."); + if(!mat && desc.isValid()) + { + PX_PROFILE_ZONE("OGLRenderer_createMaterial",0); + mat = new OGLRendererMaterial(*this, desc); + + registerMaterial(desc, mat); + } + return mat; + } + + RendererMesh *OGLRenderer::createMesh(const RendererMeshDesc &desc) + { + PX_PROFILE_ZONE("OGLRenderer_createMesh",0); + OGLRendererMesh *mesh = 0; + RENDERER_ASSERT(desc.isValid(), "Invalid Mesh Descriptor."); + if(desc.isValid()) + { + mesh = new OGLRendererMesh(*this, desc); + } + return mesh; + } + + RendererLight *OGLRenderer::createLight(const RendererLightDesc &desc) + { + PX_PROFILE_ZONE("OGLRenderer_createLight",0); + RendererLight *light = 0; + RENDERER_ASSERT(desc.isValid(), "Invalid Light Descriptor."); + if(desc.isValid()) + { + switch(desc.type) + { + case RendererLight::TYPE_DIRECTIONAL: + light = new OGLRendererDirectionalLight(*static_cast<const RendererDirectionalLightDesc*>(&desc), *this); + break; + case RendererLight::TYPE_SPOT: + light = new OGLRendererSpotLight(*static_cast<const RendererSpotLightDesc*>(&desc), *this); + break; + default: + RENDERER_ASSERT(0, "OGLRenderer does not support this light type"); + break; + } + } + return light; + } + + void OGLRenderer::setVsync(bool on) + { + m_platform->setOGLVsync(on); + } + + void OGLRenderer::bindViewProj(const physx::PxMat44 &eye, const RendererProjection &proj) + { + PxMat44 inveye = eye.inverseRT(); + + // load the projection matrix... + const GLfloat* glproj = &proj.getPxMat44().column0.x; + + // load the view matrix... + m_viewMatrix = inveye; + +#if defined(RENDERER_ENABLE_CG) + GLfloat glview[16]; + PxToGL(glview, inveye); + const PxVec3 &eyePosition = eye.getPosition(); + const PxVec3 eyeDirection = -eye.getBasis(2); + if(m_cgEnv.viewMatrix) cgGLSetMatrixParameterfc(m_cgEnv.viewMatrix, glview); + if(m_cgEnv.projMatrix) cgGLSetMatrixParameterfc(m_cgEnv.projMatrix, glproj); + if(m_cgEnv.eyePosition) cgGLSetParameter3fv( m_cgEnv.eyePosition, &eyePosition.x); + if(m_cgEnv.eyeDirection) cgGLSetParameter3fv( m_cgEnv.eyeDirection, &eyeDirection.x); +#endif + } + + void OGLRenderer::bindFogState(const RendererColor &fogColor, float fogDistance) + { +#if defined(RENDERER_ENABLE_CG) + const float inv255 = 1.0f / 255.0f; + + float values[4]; + values[0] = fogColor.r*inv255; + values[1] = fogColor.g*inv255; + values[2] = fogColor.b*inv255; + values[3] = fogDistance; + + setFloat4Parameter(m_cgEnv.fogColorAndDistance, values); +#endif + } + + void OGLRenderer::bindAmbientState(const RendererColor &ambientColor) + { +#if defined(RENDERER_ENABLE_CG) + setColorParameter(m_cgEnv.ambientColor, ambientColor); +#endif + } + + void OGLRenderer::bindDeferredState(void) + { + RENDERER_ASSERT(0, "Not implemented!"); + } + + void OGLRenderer::bindMeshContext(const RendererMeshContext &context) + { + PX_PROFILE_ZONE("OGLRendererBindMeshContext",0); + physx::PxMat44 model; + physx::PxMat44 modelView; + + if(context.transform) model = *context.transform; + else model = PxMat44(PxIdentity); + modelView = m_viewMatrix * model; + + GLfloat glmodelview[16]; + PxToGL(glmodelview, modelView); + glLoadMatrixf(glmodelview); + + RendererMeshContext::CullMode cullMode = context.cullMode; + if (!blendingCull() && NULL != context.material && context.material->getBlending()) + cullMode = RendererMeshContext::NONE; + + switch(cullMode) + { + case RendererMeshContext::CLOCKWISE: + glFrontFace( GL_CW ); + glCullFace( GL_BACK ); + glEnable( GL_CULL_FACE ); + break; + case RendererMeshContext::COUNTER_CLOCKWISE: + glFrontFace( GL_CCW ); + glCullFace( GL_BACK ); + glEnable( GL_CULL_FACE ); + break; + case RendererMeshContext::NONE: + glDisable( GL_CULL_FACE ); + break; + default: + RENDERER_ASSERT(0, "Invalid Cull Mode"); + } + + switch(context.fillMode) + { + case RendererMeshContext::SOLID: + glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); + break; + case RendererMeshContext::LINE: + glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); + break; + case RendererMeshContext::POINT: + glPolygonMode(GL_FRONT_AND_BACK, GL_POINT); + break; + } + + +#if defined(RENDERER_ENABLE_CG) + GLfloat glmodel[16]; + PxToGL(glmodel, model); + if(m_cgEnv.modelMatrix) cgGLSetMatrixParameterfc(m_cgEnv.modelMatrix, glmodel); + if(m_cgEnv.modelViewMatrix) cgGLSetMatrixParameterfc(m_cgEnv.modelViewMatrix, glmodelview); + + RENDERER_ASSERT(context.numBones <= RENDERER_MAX_BONES, "Too many bones."); + if(context.boneMatrices && context.numBones>0 && context.numBones <= RENDERER_MAX_BONES) + { +#if 0 + for(PxU32 i=0; i<context.numBones; i++) + { + GLfloat glbonematrix[16]; + PxToGL(glbonematrix, context.boneMatrices[i]); + cgSetMatrixParameterfc(cgGetArrayParameter(m_cgEnv.boneMatrices, i), glbonematrix); + } +#else + GLfloat glbonematrix[16*RENDERER_MAX_BONES]; + for(PxU32 i=0; i<context.numBones; i++) + { + PxToGL(glbonematrix+(16*i), context.boneMatrices[i]); + } + +#if defined(RENDERER_PS3) + OGLRendererMaterial* pMaterial = (OGLRendererMaterial*)context.material; + if( pMaterial ) + { + CGprogram program = pMaterial->GetVertexProgramPS3(); + cgGLSetMatrixParameterArrayfc(cgGetNamedParameter(program, "g_" "boneMatrices"), + 0, context.numBones, glbonematrix); + } +#else + { + PX_PROFILE_ZONE("cgGLSetMatrixParameter",0); + cgGLSetMatrixParameterArrayfc(m_cgEnv.boneMatrices, 0, context.numBones, glbonematrix); + } +#endif +#endif + } + +#endif + } + + void OGLRenderer::beginMultiPass(void) + { + glEnable(GL_BLEND); + glBlendFunc(GL_ONE, GL_ONE); + glDepthFunc(GL_EQUAL); + } + + void OGLRenderer::endMultiPass(void) + { + glDisable(GL_BLEND); + glDepthFunc(GL_LESS); + } + + void OGLRenderer::beginTransparentMultiPass(void) + { + setEnableBlendingOverride(true); + glEnable(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA, GL_ONE); + glDepthFunc(GL_LEQUAL); + glDepthMask(false); + } + + void OGLRenderer::endTransparentMultiPass(void) + { + setEnableBlendingOverride(false); + glDisable(GL_BLEND); + glDepthFunc(GL_LESS); + glDepthMask(true); + } + + void OGLRenderer::renderDeferredLight(const RendererLight &/*light*/) + { + RENDERER_ASSERT(0, "Not implemented!"); + } + + PxU32 OGLRenderer::convertColor(const RendererColor& color) const + { + return OGLRendererVertexBuffer::convertColor(color); + } + + + bool OGLRenderer::isOk(void) const + { + bool ok = true; + ok = m_platform->isContextValid(); + return ok; + } + + /////////////////////////////////////////////////////////////////////////////// + + /*static DWORD gCullMode; + static DWORD gAlphaBlendEnable; + static DWORD gSrcBlend; + static DWORD gDstBlend; + static DWORD gFillMode; + static DWORD gZWrite; + static DWORD gLighting; + */ + + void OGLRenderer::setupTextRenderStates() + { + /* // PT: save render states. Let's just hope this isn't a pure device, else the Get method won't work + m_d3dDevice->GetRenderState(D3DRS_CULLMODE, &gCullMode); + m_d3dDevice->GetRenderState(D3DRS_ALPHABLENDENABLE, &gAlphaBlendEnable); + m_d3dDevice->GetRenderState(D3DRS_SRCBLEND, &gSrcBlend); + m_d3dDevice->GetRenderState(D3DRS_DESTBLEND, &gDstBlend); + m_d3dDevice->GetRenderState(D3DRS_FILLMODE, &gFillMode); + m_d3dDevice->GetRenderState(D3DRS_ZWRITEENABLE, &gZWrite); + m_d3dDevice->GetRenderState(D3DRS_LIGHTING, &gLighting); + + // PT: setup render states for text rendering + m_d3dDevice->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE); + m_d3dDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE); + m_d3dDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA); + m_d3dDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA); + m_d3dDevice->SetRenderState(D3DRS_FILLMODE, D3DFILL_SOLID); + m_d3dDevice->SetRenderState(D3DRS_ZWRITEENABLE, FALSE); + m_d3dDevice->SetRenderState(D3DRS_LIGHTING, FALSE);*/ + + glDisable(GL_CULL_FACE); + glEnable(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); + glDepthMask(false); + glDisable(GL_LIGHTING); + glEnable(GL_TEXTURE_2D); + glDisable(GL_DEPTH_TEST); + } + + void OGLRenderer::resetTextRenderStates() + { + glEnable(GL_CULL_FACE); + glDisable(GL_BLEND); + // glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); + glDepthMask(true); + glEnable(GL_LIGHTING); + glDisable(GL_TEXTURE_2D); + glEnable(GL_DEPTH_TEST); + } + + void OGLRenderer::renderTextBuffer(const void* verts, PxU32 nbVerts, const PxU16* indices, PxU32 nbIndices, RendererMaterial* material) + { + const int stride = sizeof(TextVertex); + char* data = (char*)verts; + + glEnableClientState(GL_VERTEX_ARRAY); + glDisableClientState(GL_NORMAL_ARRAY); + glEnableClientState(GL_COLOR_ARRAY); + glEnableClientState(GL_TEXTURE_COORD_ARRAY); + + // pos + glVertexPointer(3, GL_FLOAT, stride, data); + data += 3*sizeof(float); + + // rhw + PxU32 width, height; + getWindowSize(width, height); + + glMatrixMode(GL_PROJECTION); + glPushMatrix(); + glLoadIdentity(); + glOrtho(0, width, height, 0, -1, 1); + glMatrixMode(GL_MODELVIEW); + glPushMatrix(); + glLoadIdentity(); + data += sizeof(float); + + // Diffuse color + glColorPointer(4, GL_UNSIGNED_BYTE, stride, data); + data += sizeof(int); + + // Texture coordinates + glTexCoordPointer(2, GL_FLOAT, stride, data); + data += 2*sizeof(float); + + glDrawRangeElements(GL_TRIANGLES, 0, nbVerts, nbIndices, GL_UNSIGNED_SHORT, indices); + + glPopMatrix(); + glMatrixMode(GL_PROJECTION); + glPopMatrix(); + glMatrixMode(GL_MODELVIEW); + + glDisableClientState(GL_VERTEX_ARRAY); + glDisableClientState(GL_COLOR_ARRAY); + glDisableClientState(GL_TEXTURE_COORD_ARRAY); + } + + void OGLRenderer::renderLines2D(const void* vertices, PxU32 nbVerts) + { + const int stride = sizeof(TextVertex); + char* data = (char*)vertices; + + glEnableClientState(GL_VERTEX_ARRAY); + glDisableClientState(GL_NORMAL_ARRAY); + glEnableClientState(GL_COLOR_ARRAY); + glEnableClientState(GL_TEXTURE_COORD_ARRAY); + + // pos + glVertexPointer(3, GL_FLOAT, stride, data); + data += 3*sizeof(float); + + // rhw + PxU32 width, height; + getWindowSize(width, height); + + glMatrixMode(GL_PROJECTION); + glPushMatrix(); + glLoadIdentity(); + glOrtho(0, width, height, 0, -1, 1); + glMatrixMode(GL_MODELVIEW); + glPushMatrix(); + glLoadIdentity(); + data += sizeof(float); + + // Diffuse color + glColorPointer(4, GL_UNSIGNED_BYTE, stride, data); + data += sizeof(int); + + // Texture coordinates + glTexCoordPointer(2, GL_FLOAT, stride, data); + data += 2*sizeof(float); + + glDrawArrays(GL_LINE_STRIP, 0, nbVerts); + + glPopMatrix(); + glMatrixMode(GL_PROJECTION); + glPopMatrix(); + glMatrixMode(GL_MODELVIEW); + + glDisableClientState(GL_VERTEX_ARRAY); + glDisableClientState(GL_COLOR_ARRAY); + glDisableClientState(GL_TEXTURE_COORD_ARRAY); + } + + void OGLRenderer::setupScreenquadRenderStates() + { + glDisable(GL_CULL_FACE); + glEnable(GL_BLEND); + glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); + glDepthMask(false); + glDisable(GL_LIGHTING); + } + + void OGLRenderer::resetScreenquadRenderStates() + { + glEnable(GL_CULL_FACE); + glDisable(GL_BLEND); + glDepthMask(true); + glEnable(GL_LIGHTING); + } + +#pragma pack(push,2) + typedef struct + { + unsigned short bfType; + unsigned int bfSize; + unsigned short bfReserved1; + unsigned short bfReserved2; + unsigned int bfOffBits; + } PXT_BITMAPFILEHEADER; +#pragma pack(pop) + typedef struct _tagBITMAPINFO + { + struct + { + GLuint biSize; + GLuint biWidth; + GLuint biHeight; + GLushort biPlanes; + GLushort biBitCount; + GLuint biCompression; + GLuint biSizeImage; + GLuint biXPelsPerMeter; + GLuint biYPelsPerMeter; + GLuint biClrUsed; + GLuint biClrImportant; + } bmiHeader; + unsigned int bmiColors[1]; + } PXT_BITMAPINFO; + + static inline PxU32 screenshotDataOffset() + { + return sizeof(PXT_BITMAPFILEHEADER) + sizeof(PXT_BITMAPINFO); + } + static inline PxU32 screenshotSize(PxU32 width, PxU32 height) + { + return width * height * 4 *sizeof(GLubyte) + screenshotDataOffset(); + } + + bool OGLRenderer::captureScreen(PxU32 &width, PxU32& height, PxU32& sizeInBytes, const void*& screenshotData) + { + // Target buffer size + const PxU32 newBufferSize = screenshotSize(m_displayWidth, m_displayHeight); + + // Resize of necessary + if (newBufferSize != (PxU32)m_displayData.size()) + m_displayData.resize(newBufferSize); + + // Quit if resize failed + if (newBufferSize != (PxU32)m_displayData.size()) + return false; + + // Write the screen data into the buffer + glPixelStorei(GL_UNPACK_ALIGNMENT, 4); + glReadPixels(0, 0, m_displayWidth, m_displayHeight, GL_RGBA, GL_UNSIGNED_BYTE, &m_displayData[screenshotDataOffset()]); + if (GL_NO_ERROR != glGetError()) + return false; + + // Write the header data into the buffer + PXT_BITMAPFILEHEADER bitmapFileHeader; + PXT_BITMAPINFO bitmapInfoHeader; + + bitmapFileHeader.bfType = 0x4D42; //"BM" + bitmapFileHeader.bfReserved1 = 0; + bitmapFileHeader.bfReserved2 = 0; + bitmapFileHeader.bfOffBits = sizeof(PXT_BITMAPFILEHEADER) + sizeof(bitmapInfoHeader.bmiHeader); + bitmapFileHeader.bfSize = m_displayWidth * m_displayHeight * 4 + bitmapFileHeader.bfOffBits; + + bitmapInfoHeader.bmiHeader.biSize = sizeof(bitmapInfoHeader.bmiHeader); + bitmapInfoHeader.bmiHeader.biWidth = m_displayWidth; + bitmapInfoHeader.bmiHeader.biHeight = m_displayHeight; + bitmapInfoHeader.bmiHeader.biPlanes = 1; + bitmapInfoHeader.bmiHeader.biBitCount = 32; + bitmapInfoHeader.bmiHeader.biCompression = 0 /*BI_RGB*/; + bitmapInfoHeader.bmiHeader.biSizeImage = 0; + bitmapInfoHeader.bmiHeader.biXPelsPerMeter = 0; + bitmapInfoHeader.bmiHeader.biYPelsPerMeter = 0; + bitmapInfoHeader.bmiHeader.biClrUsed = 0; + bitmapInfoHeader.bmiHeader.biClrImportant = 0; + + memcpy(&m_displayData[0], &bitmapFileHeader, sizeof(bitmapFileHeader)); + memcpy(&m_displayData[sizeof(bitmapFileHeader)], &bitmapInfoHeader.bmiHeader, sizeof(bitmapInfoHeader.bmiHeader)); + + // Output the result + getWindowSize(width, height); + sizeInBytes = (PxU32)m_displayData.size(); + screenshotData = &m_displayData[0]; + + return true; + } + +#endif // #if defined(RENDERER_ENABLE_OPENGL) diff --git a/PhysX_3.4/Samples/SampleFramework/renderer/src/ogl/OGLRenderer.h b/PhysX_3.4/Samples/SampleFramework/renderer/src/ogl/OGLRenderer.h new file mode 100644 index 00000000..afd18693 --- /dev/null +++ b/PhysX_3.4/Samples/SampleFramework/renderer/src/ogl/OGLRenderer.h @@ -0,0 +1,189 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved. +#ifndef OGL_RENDERER_H +#define OGL_RENDERER_H + +#include <RendererConfig.h> + +#if defined(RENDERER_ENABLE_OPENGL) +#include <GLIncludes.h> + +#if defined(RENDERER_ENABLE_CG) + #include <Cg/cg.h> + #include <Cg/cgGL.h> +#endif + +#include <Renderer.h> + +namespace SampleFramework { + class SamplePlatform; +} + +namespace SampleRenderer +{ + +#if defined(RENDERER_ENABLE_CG) + void setColorParameter(CGparameter param, const RendererColor &color); + void setFloat4Parameter(CGparameter param, float* values); +#endif + + class OGLRendererMaterial; + + + void PxToGL(GLfloat *gl44, const physx::PxMat44 &mat); + void RenToGL(GLfloat *gl44, const RendererProjection &proj); + + class OGLRenderer : public Renderer + { + public: + OGLRenderer(const RendererDesc &desc, const char* assetDir); + virtual ~OGLRenderer(void); + +#if defined(RENDERER_ENABLE_CG) + class CGEnvironment + { + public: + CGparameter modelMatrix; + CGparameter viewMatrix; + CGparameter projMatrix; + CGparameter modelViewMatrix; + CGparameter modelViewProjMatrix; + + CGparameter boneMatrices; + + CGparameter fogColorAndDistance; + + CGparameter eyePosition; + CGparameter eyeDirection; + + CGparameter ambientColor; + + CGparameter lightColor; + CGparameter lightIntensity; + CGparameter lightDirection; + CGparameter lightPosition; + CGparameter lightInnerRadius; + CGparameter lightOuterRadius; + CGparameter lightInnerCone; + CGparameter lightOuterCone; + + public: + CGEnvironment(void); + CGEnvironment(CGcontext cgContext); + }; + + CGcontext getCGContext(void) { return m_cgContext; } + CGEnvironment &getCGEnvironment(void) { return m_cgEnv; } + const CGEnvironment &getCGEnvironment(void) const { return m_cgEnv; } +#endif + + const physx::PxMat44 &getViewMatrix(void) const { return m_viewMatrix; } + + void setCurrentMaterial(const OGLRendererMaterial *cm) { m_currMaterial = cm; } + const OGLRendererMaterial *getCurrentMaterial(void) { return m_currMaterial; } + + private: + bool begin(void); + void end(void); + void checkResize(void); + + public: + // clears the offscreen buffers. + virtual void clearBuffers(void); + + // presents the current color buffer to the screen. + // returns true on device reset and if buffers need to be rewritten. + virtual bool swapBuffers(void); + + // get the device pointer (void * abstraction) + virtual void *getDevice() { return static_cast<void*>(getCGContext()); } + + virtual bool captureScreen(const char* ) { PX_ASSERT("not supported"); return false; } + + // gets a handle to the current frame's data, in bitmap format + // note: subsequent calls will invalidate any previously returned data + // return true on successful screenshot capture + virtual bool captureScreen(PxU32 &width, PxU32& height, PxU32& sizeInBytes, const void*& screenshotData); + + // get the window size + void getWindowSize(PxU32 &width, PxU32 &height) const; + + virtual RendererVertexBuffer *createVertexBuffer( const RendererVertexBufferDesc &desc); + virtual RendererIndexBuffer *createIndexBuffer( const RendererIndexBufferDesc &desc); + virtual RendererInstanceBuffer *createInstanceBuffer(const RendererInstanceBufferDesc &desc); + virtual RendererTexture2D *createTexture2D( const RendererTexture2DDesc &desc); + virtual RendererTexture3D *createTexture3D( const RendererTexture3DDesc &desc); + virtual RendererTarget *createTarget( const RendererTargetDesc &desc); + virtual RendererMaterial *createMaterial( const RendererMaterialDesc &desc); + virtual RendererMesh *createMesh( const RendererMeshDesc &desc); + virtual RendererLight *createLight( const RendererLightDesc &desc); + + virtual void setVsync(bool on); + + private: + virtual void bindViewProj(const physx::PxMat44 &inveye, const RendererProjection &proj); + virtual void bindAmbientState(const RendererColor &ambientColor); + virtual void bindFogState(const RendererColor &fogColor, float fogDistance); + virtual void bindDeferredState(void); + virtual void bindMeshContext(const RendererMeshContext &context); + virtual void beginMultiPass(void); + virtual void endMultiPass(void); + virtual void beginTransparentMultiPass(void); + virtual void endTransparentMultiPass(void); + virtual void renderDeferredLight(const RendererLight &light); + virtual PxU32 convertColor(const RendererColor& color) const; + + virtual bool isOk(void) const; + + virtual void setupTextRenderStates(); + virtual void resetTextRenderStates(); + virtual void renderTextBuffer(const void* vertices, PxU32 nbVerts, const PxU16* indices, PxU32 nbIndices, RendererMaterial* material); + virtual void renderLines2D(const void* vertices, PxU32 nbVerts); + virtual void setupScreenquadRenderStates(); + virtual void resetScreenquadRenderStates(); + + private: + SampleFramework::SamplePlatform* m_platform; +#if defined(RENDERER_ENABLE_CG) + CGcontext m_cgContext; + CGEnvironment m_cgEnv; +#endif + + const OGLRendererMaterial *m_currMaterial; + + PxU32 m_displayWidth; + PxU32 m_displayHeight; + + std::vector<GLubyte> m_displayData; + + physx::PxMat44 m_viewMatrix; + }; + +} // namespace SampleRenderer + +#endif // #if defined(RENDERER_ENABLE_OPENGL) +#endif diff --git a/PhysX_3.4/Samples/SampleFramework/renderer/src/ogl/OGLRendererDirectionalLight.cpp b/PhysX_3.4/Samples/SampleFramework/renderer/src/ogl/OGLRendererDirectionalLight.cpp new file mode 100644 index 00000000..4301033d --- /dev/null +++ b/PhysX_3.4/Samples/SampleFramework/renderer/src/ogl/OGLRendererDirectionalLight.cpp @@ -0,0 +1,58 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved. + +#include <RendererConfig.h> + +#if defined(RENDERER_ENABLE_OPENGL) + +#include "OGLRendererDirectionalLight.h" + +using namespace SampleRenderer; + +OGLRendererDirectionalLight::OGLRendererDirectionalLight(const RendererDirectionalLightDesc &desc, OGLRenderer &renderer) +: RendererDirectionalLight(desc) +#if defined(RENDERER_ENABLE_CG) +, m_cgenv(renderer.getCGEnvironment()) +#endif + +{ +} + +OGLRendererDirectionalLight::~OGLRendererDirectionalLight(void) +{ +} + +void OGLRendererDirectionalLight::bind(void) const +{ +#if defined(RENDERER_ENABLE_CG) + setColorParameter(m_cgenv.lightColor, m_color); + cgSetParameter1f( m_cgenv.lightIntensity, m_intensity); + cgSetParameter3fv(m_cgenv.lightDirection, &m_direction.x); +#endif +} + +#endif // #if defined(RENDERER_ENABLE_OPENGL) diff --git a/PhysX_3.4/Samples/SampleFramework/renderer/src/ogl/OGLRendererDirectionalLight.h b/PhysX_3.4/Samples/SampleFramework/renderer/src/ogl/OGLRendererDirectionalLight.h new file mode 100644 index 00000000..cefad68f --- /dev/null +++ b/PhysX_3.4/Samples/SampleFramework/renderer/src/ogl/OGLRendererDirectionalLight.h @@ -0,0 +1,60 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved. +#ifndef OGL_RENDERER_DIRECTIONAL_LIGHT_H +#define OGL_RENDERER_DIRECTIONAL_LIGHT_H + +#include <RendererConfig.h> + +#if defined(RENDERER_ENABLE_OPENGL) + +#include <RendererDirectionalLight.h> + +#include "OGLRenderer.h" + +namespace SampleRenderer +{ + + class RendererDirectionalLightDesc; + + class OGLRendererDirectionalLight : public RendererDirectionalLight + { + public: + OGLRendererDirectionalLight(const RendererDirectionalLightDesc &desc, OGLRenderer &renderer); + virtual ~OGLRendererDirectionalLight(void); + + virtual void bind(void) const; + + private: +#if defined(RENDERER_ENABLE_CG) + const OGLRenderer::CGEnvironment &m_cgenv; +#endif + }; + +} // namespace SampleRenderer + +#endif // #if defined(RENDERER_ENABLE_OPENGL) +#endif diff --git a/PhysX_3.4/Samples/SampleFramework/renderer/src/ogl/OGLRendererIndexBuffer.cpp b/PhysX_3.4/Samples/SampleFramework/renderer/src/ogl/OGLRendererIndexBuffer.cpp new file mode 100644 index 00000000..4dda7229 --- /dev/null +++ b/PhysX_3.4/Samples/SampleFramework/renderer/src/ogl/OGLRendererIndexBuffer.cpp @@ -0,0 +1,138 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved. + +#include <RendererConfig.h> + +#if defined(RENDERER_ENABLE_OPENGL) + +#include "OGLRendererIndexBuffer.h" +#include <RendererIndexBufferDesc.h> + +#if PX_WINDOWS +#include "cudamanager/PxCudaContextManager.h" +#endif + +using namespace SampleRenderer; + +OGLRendererIndexBuffer::OGLRendererIndexBuffer(const RendererIndexBufferDesc &desc) : + RendererIndexBuffer(desc) +{ + m_indexSize = getFormatByteSize(getFormat()); + + RENDERER_ASSERT(GLEW_ARB_vertex_buffer_object, "Vertex Buffer Objects not supported on this machine!"); + if(GLEW_ARB_vertex_buffer_object) + { + RENDERER_ASSERT(desc.maxIndices > 0, "Cannot create zero size Index Buffer."); + if(desc.maxIndices > 0) + { + GLenum usage = GL_STATIC_DRAW_ARB; + if(getHint() == HINT_DYNAMIC) + { + usage = GL_DYNAMIC_DRAW_ARB; + } + + glGenBuffersARB(1, &m_ibo); + RENDERER_ASSERT(m_ibo, "Failed to create Index Buffer."); + if(m_ibo) + { + m_maxIndices = desc.maxIndices; + const PxU32 bufferSize = m_indexSize * m_maxIndices; + + glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, m_ibo); + glBufferDataARB(GL_ELEMENT_ARRAY_BUFFER_ARB, bufferSize, 0, usage); + glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, 0); + +#if PX_WINDOWS + if(m_interopContext && m_mustBeRegisteredInCUDA) + { + m_registeredInCUDA = m_interopContext->registerResourceInCudaGL(m_InteropHandle, (PxU32) m_ibo); + } +#endif + } + } + } +} + +OGLRendererIndexBuffer::~OGLRendererIndexBuffer(void) +{ + if(m_ibo) + { +#if PX_WINDOWS + if(m_registeredInCUDA) + { + m_interopContext->unregisterResourceInCuda(m_InteropHandle); + } +#endif + glDeleteBuffersARB(1, &m_ibo); + } +} + +void *OGLRendererIndexBuffer::lock(void) +{ + void *buffer = 0; + if(m_ibo) + { + glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, m_ibo); + buffer = glMapBuffer(GL_ELEMENT_ARRAY_BUFFER_ARB, GL_READ_WRITE); + glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, 0); + } + return buffer; +} + +void OGLRendererIndexBuffer::unlock(void) +{ + if(m_ibo) + { + glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, m_ibo); + glUnmapBuffer(GL_ELEMENT_ARRAY_BUFFER_ARB); + glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, 0); + } +} + +void OGLRendererIndexBuffer::bind(void) const +{ + if(m_ibo) + { +#if !defined(RENDERER_PS3) + glEnableClientState(GL_INDEX_ARRAY); +#endif + glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, m_ibo); + } +} + +void OGLRendererIndexBuffer::unbind(void) const +{ + if(m_ibo) + { + glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, 0); +#if !defined(RENDERER_PS3) + glDisableClientState(GL_INDEX_ARRAY); +#endif + } +} + +#endif // #if defined(RENDERER_ENABLE_OPENGL) diff --git a/PhysX_3.4/Samples/SampleFramework/renderer/src/ogl/OGLRendererIndexBuffer.h b/PhysX_3.4/Samples/SampleFramework/renderer/src/ogl/OGLRendererIndexBuffer.h new file mode 100644 index 00000000..84e24b15 --- /dev/null +++ b/PhysX_3.4/Samples/SampleFramework/renderer/src/ogl/OGLRendererIndexBuffer.h @@ -0,0 +1,62 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved. +#ifndef OGL_RENDERER_INDEXBUFFER_H +#define OGL_RENDERER_INDEXBUFFER_H + +#include <RendererConfig.h> + +#if defined(RENDERER_ENABLE_OPENGL) + +#include <RendererIndexBuffer.h> +#include "OGLRenderer.h" + +namespace SampleRenderer +{ + + class OGLRendererIndexBuffer : public RendererIndexBuffer + { + public: + OGLRendererIndexBuffer(const RendererIndexBufferDesc &desc); + virtual ~OGLRendererIndexBuffer(void); + + public: + virtual void *lock(void); + virtual void unlock(void); + + private: + virtual void bind(void) const; + virtual void unbind(void) const; + + private: + GLuint m_ibo; + PxU32 m_indexSize; + }; + +} // namespace SampleRenderer + +#endif // #if defined(RENDERER_ENABLE_OPENGL) +#endif diff --git a/PhysX_3.4/Samples/SampleFramework/renderer/src/ogl/OGLRendererInstanceBuffer.cpp b/PhysX_3.4/Samples/SampleFramework/renderer/src/ogl/OGLRendererInstanceBuffer.cpp new file mode 100644 index 00000000..738a439c --- /dev/null +++ b/PhysX_3.4/Samples/SampleFramework/renderer/src/ogl/OGLRendererInstanceBuffer.cpp @@ -0,0 +1,92 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved. + +#include <RendererConfig.h> + +#if defined(RENDERER_ENABLE_OPENGL) + +#include "OGLRendererInstanceBuffer.h" +#include <RendererInstanceBufferDesc.h> + +using namespace SampleRenderer; + +OGLRendererInstanceBuffer::OGLRendererInstanceBuffer(const RendererInstanceBufferDesc &desc) : + RendererInstanceBuffer(desc) +{ + m_bufferSize = (PxU32)(desc.maxInstances * m_stride); + m_buffer = malloc(m_bufferSize);//PX_ALLOC(m_bufferSize); + m_maxInstances = desc.maxInstances; +} + +OGLRendererInstanceBuffer::~OGLRendererInstanceBuffer(void) +{ + if(m_buffer) free(m_buffer);//PX_FREE(m_buffer); +} + +physx::PxMat44 OGLRendererInstanceBuffer::getModelMatrix(PxU32 index) const +{ + physx::PxMat44 model = PxMat44(PxIdentity); + if(index < m_maxInstances) + { + const void *instance = ((PxU8*)m_buffer)+(m_stride*index); + PxVec3 column0 = getInstanceColumn(instance, m_semanticDescs[SEMANTIC_NORMALX]); + PxVec3 column1 = getInstanceColumn(instance, m_semanticDescs[SEMANTIC_NORMALY]); + PxVec3 column2 = getInstanceColumn(instance, m_semanticDescs[SEMANTIC_NORMALZ]); + PxVec3 column3 = getInstanceColumn(instance, m_semanticDescs[SEMANTIC_POSITION]); + + model = PxMat44(column0, column1, column2, column3); + } + return model; +} + +PxVec3 OGLRendererInstanceBuffer::getInstanceColumn(const void *instance, const OGLRendererInstanceBuffer::SemanticDesc &sd) const +{ + PxVec3 col = *(PxVec3*)(((PxU8*)instance)+sd.offset); + return col; +} + +void *OGLRendererInstanceBuffer::lock(void) +{ + return m_buffer; +} + +void OGLRendererInstanceBuffer::unlock(void) +{ + +} + +void OGLRendererInstanceBuffer::bind(PxU32 streamID, PxU32 firstInstance) const +{ + +} + +void OGLRendererInstanceBuffer::unbind(PxU32 streamID) const +{ + +} + +#endif // #if defined(RENDERER_ENABLE_OPENGL) diff --git a/PhysX_3.4/Samples/SampleFramework/renderer/src/ogl/OGLRendererInstanceBuffer.h b/PhysX_3.4/Samples/SampleFramework/renderer/src/ogl/OGLRendererInstanceBuffer.h new file mode 100644 index 00000000..f6ac259b --- /dev/null +++ b/PhysX_3.4/Samples/SampleFramework/renderer/src/ogl/OGLRendererInstanceBuffer.h @@ -0,0 +1,67 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved. +#ifndef OGL_RENDERER_INSTANCEBUFFER_H +#define OGL_RENDERER_INSTANCEBUFFER_H + +#include <RendererConfig.h> + +#if defined(RENDERER_ENABLE_OPENGL) + +#include <RendererInstanceBuffer.h> +#include "OGLRenderer.h" + +namespace SampleRenderer +{ + + class OGLRendererInstanceBuffer : public RendererInstanceBuffer + { + public: + OGLRendererInstanceBuffer(const RendererInstanceBufferDesc &desc); + virtual ~OGLRendererInstanceBuffer(void); + + physx::PxMat44 getModelMatrix(PxU32 index) const; + + private: + PxVec3 getInstanceColumn(const void *instance, const OGLRendererInstanceBuffer::SemanticDesc &sd) const; + + public: + + virtual void *lock(void); + virtual void unlock(void); + + virtual void bind(PxU32 streamID, PxU32 firstInstance) const; + virtual void unbind(PxU32 streamID) const; + + private: + PxU32 m_bufferSize; + void *m_buffer; + }; + +} // namespace SampleRenderer + +#endif // #if defined(RENDERER_ENABLE_OPENGL) +#endif diff --git a/PhysX_3.4/Samples/SampleFramework/renderer/src/ogl/OGLRendererMaterial.cpp b/PhysX_3.4/Samples/SampleFramework/renderer/src/ogl/OGLRendererMaterial.cpp new file mode 100644 index 00000000..fa84492c --- /dev/null +++ b/PhysX_3.4/Samples/SampleFramework/renderer/src/ogl/OGLRendererMaterial.cpp @@ -0,0 +1,518 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved. + +#include "RendererConfig.h" + +#if defined(RENDERER_ENABLE_OPENGL) + +#include "OGLRendererMaterial.h" +#include "OGLRendererTexture2D.h" + +#include <RendererMaterialDesc.h> + +#include <SamplePlatform.h> + +#include <stdio.h> + +// for PsString.h +namespace physx +{ + namespace string + {} +} +#include <PsString.h> +#include <PxTkFile.h> +namespace Ps = physx::shdfnd; + +using namespace SampleRenderer; + +#if defined(RENDERER_ENABLE_CG) + +static RendererMaterial::VariableType getVariableType(CGtype cgt) +{ + RendererMaterial::VariableType vt = RendererMaterial::NUM_VARIABLE_TYPES; + switch(cgt) + { + case CG_INT: vt = RendererMaterial::VARIABLE_INT; break; + case CG_FLOAT: vt = RendererMaterial::VARIABLE_FLOAT; break; + case CG_FLOAT2: vt = RendererMaterial::VARIABLE_FLOAT2; break; + case CG_FLOAT3: vt = RendererMaterial::VARIABLE_FLOAT3; break; + case CG_FLOAT4: vt = RendererMaterial::VARIABLE_FLOAT4; break; + case CG_FLOAT4x4: vt = RendererMaterial::VARIABLE_FLOAT4x4; break; + case CG_SAMPLER2D: vt = RendererMaterial::VARIABLE_SAMPLER2D; break; + case CG_SAMPLER3D: vt = RendererMaterial::VARIABLE_SAMPLER3D; break; + default: break; + } + RENDERER_ASSERT(vt < RendererMaterial::NUM_VARIABLE_TYPES, "Unable to convert shader parameter type."); + return vt; +} + +static GLuint getGLBlendFunc(RendererMaterial::BlendFunc func) +{ + GLuint glfunc = 0; + switch(func) + { + case RendererMaterial::BLEND_ZERO: glfunc = GL_ZERO; break; + case RendererMaterial::BLEND_ONE: glfunc = GL_ONE; break; + case RendererMaterial::BLEND_SRC_COLOR: glfunc = GL_SRC_COLOR; break; + case RendererMaterial::BLEND_ONE_MINUS_SRC_COLOR: glfunc = GL_ONE_MINUS_SRC_COLOR; break; + case RendererMaterial::BLEND_SRC_ALPHA: glfunc = GL_SRC_ALPHA; break; + case RendererMaterial::BLEND_ONE_MINUS_SRC_ALPHA: glfunc = GL_ONE_MINUS_SRC_ALPHA; break; + case RendererMaterial::BLEND_DST_ALPHA: glfunc = GL_DST_COLOR; break; + case RendererMaterial::BLEND_ONE_MINUS_DST_ALPHA: glfunc = GL_ONE_MINUS_DST_ALPHA; break; + case RendererMaterial::BLEND_DST_COLOR: glfunc = GL_DST_COLOR; break; + case RendererMaterial::BLEND_ONE_MINUS_DST_COLOR: glfunc = GL_ONE_MINUS_DST_COLOR; break; + case RendererMaterial::BLEND_SRC_ALPHA_SATURATE: glfunc = GL_SRC_ALPHA_SATURATE; break; + default: break; + } + RENDERER_ASSERT(glfunc, "Unable to convert Material Blend Func."); + return glfunc; +} + +static void connectParameters(CGparameter from, CGparameter to) +{ + if(from && to) cgConnectParameter(from, to); +} + +static void connectEnvParameters(const OGLRenderer::CGEnvironment &cgEnv, CGprogram program) +{ + connectParameters(cgEnv.modelMatrix, cgGetNamedParameter(program, "g_" "modelMatrix")); + connectParameters(cgEnv.viewMatrix, cgGetNamedParameter(program, "g_" "viewMatrix")); + connectParameters(cgEnv.projMatrix, cgGetNamedParameter(program, "g_" "projMatrix")); + connectParameters(cgEnv.modelViewMatrix, cgGetNamedParameter(program, "g_" "modelViewMatrix")); + connectParameters(cgEnv.modelViewProjMatrix, cgGetNamedParameter(program, "g_" "modelViewProjMatrix")); + + +#if !defined(RENDERER_PS3) + connectParameters(cgEnv.boneMatrices, cgGetNamedParameter(program, "g_" "boneMatrices")); +#endif + connectParameters(cgEnv.eyePosition, cgGetNamedParameter(program, "g_" "eyePosition")); + connectParameters(cgEnv.eyeDirection, cgGetNamedParameter(program, "g_" "eyeDirection")); + + connectParameters(cgEnv.fogColorAndDistance, cgGetNamedParameter(program, "g_" "fogColorAndDistance")); + + connectParameters(cgEnv.ambientColor, cgGetNamedParameter(program, "g_" "ambientColor")); + + connectParameters(cgEnv.lightColor, cgGetNamedParameter(program, "g_" "lightColor")); + connectParameters(cgEnv.lightIntensity, cgGetNamedParameter(program, "g_" "lightIntensity")); + connectParameters(cgEnv.lightDirection, cgGetNamedParameter(program, "g_" "lightDirection")); + connectParameters(cgEnv.lightPosition, cgGetNamedParameter(program, "g_" "lightPosition")); + connectParameters(cgEnv.lightInnerRadius, cgGetNamedParameter(program, "g_" "lightInnerRadius")); + connectParameters(cgEnv.lightOuterRadius, cgGetNamedParameter(program, "g_" "lightOuterRadius")); + connectParameters(cgEnv.lightInnerCone, cgGetNamedParameter(program, "g_" "lightInnerCone")); + connectParameters(cgEnv.lightOuterCone, cgGetNamedParameter(program, "g_" "lightOuterCone")); +} + +OGLRendererMaterial::CGVariable::CGVariable(const char *name, VariableType type, PxU32 offset) : + Variable(name, type, offset) +{ + m_vertexHandle = 0; + memset(m_fragmentHandles, 0, sizeof(m_fragmentHandles)); +} + +OGLRendererMaterial::CGVariable::~CGVariable(void) +{ + +} + +void OGLRendererMaterial::CGVariable::addVertexHandle(CGparameter handle) +{ + m_vertexHandle = handle; +} + +void OGLRendererMaterial::CGVariable::addFragmentHandle(CGparameter handle, Pass pass) +{ + m_fragmentHandles[pass] = handle; +} + +#endif + +OGLRendererMaterial::OGLRendererMaterial(OGLRenderer &renderer, const RendererMaterialDesc &desc) : + RendererMaterial(desc, renderer.getEnableMaterialCaching()), + m_renderer(renderer) +{ + m_glAlphaTestFunc = GL_ALWAYS; + + AlphaTestFunc alphaTestFunc = getAlphaTestFunc(); + switch(alphaTestFunc) + { + case ALPHA_TEST_ALWAYS: m_glAlphaTestFunc = GL_ALWAYS; break; + case ALPHA_TEST_EQUAL: m_glAlphaTestFunc = GL_EQUAL; break; + case ALPHA_TEST_NOT_EQUAL: m_glAlphaTestFunc = GL_NOTEQUAL; break; + case ALPHA_TEST_LESS: m_glAlphaTestFunc = GL_LESS; break; + case ALPHA_TEST_LESS_EQUAL: m_glAlphaTestFunc = GL_LEQUAL; break; + case ALPHA_TEST_GREATER: m_glAlphaTestFunc = GL_GREATER; break; + case ALPHA_TEST_GREATER_EQUAL: m_glAlphaTestFunc = GL_GEQUAL; break; + default: + RENDERER_ASSERT(0, "Unknown Alpha Test Func."); + } + +#if defined(RENDERER_ENABLE_CG) + m_vertexProgram = 0; +#if defined(RENDERER_PS3) + m_vertexProfile = getVertexProfile(); + m_fragmentProfile = getFragmentProfile(); +#else +#define NO_SUPPORT_DDX_DDY +#if 0 + // JD: CG_PROFILE_GPU_VP FAILS SO BAD! + m_vertexProfile = CG_PROFILE_ARBVP1; + m_fragmentProfile = CG_PROFILE_ARBVP1; +#else + // PH: Seems to work fine nowadays + m_vertexProfile = cgGLGetLatestProfile(CG_GL_VERTEX); + m_fragmentProfile = cgGLGetLatestProfile(CG_GL_FRAGMENT); +#endif +#endif + memset(m_fragmentPrograms, 0, sizeof(m_fragmentPrograms)); + + CGcontext cgContext = m_renderer.getCGContext(); + const OGLRenderer::CGEnvironment &cgEnv = m_renderer.getCGEnvironment(); + if(cgContext && m_vertexProfile && m_fragmentProfile) + { + char fullPath[1024] = "-I"; + Ps::strlcat(fullPath, 1024, m_renderer.getAssetDir()); + Ps::strlcat(fullPath, 1024, "shaders/include"); + const char *vertexEntry = "vmain"; + const char *vertexArgs[] = + { + fullPath, + "-DRENDERER_VERTEX", +#ifdef RENDERER_PS3 + "-DRENDERER_PS3", + "-melf", +#endif + 0, 0, + }; + + cgGLSetOptimalOptions(m_vertexProfile); + if(1) + { + PX_PROFILE_ZONE("OGLRendererMaterial_compile_vertexProgram",0); + m_vertexProgram = static_cast<CGprogram>(SampleFramework::SamplePlatform::platform()->compileProgram(cgContext, m_renderer.getAssetDir(), desc.vertexShaderPath, m_vertexProfile, 0, vertexEntry, vertexArgs)); + } + RENDERER_ASSERT(m_vertexProgram, "Failed to compile Vertex Shader."); + if(m_vertexProgram) + { + PX_PROFILE_ZONE("OGLRendererMaterial_load_vertexProgram",0); + connectEnvParameters(cgEnv, m_vertexProgram); + cgGLLoadProgram(m_vertexProgram); + loadCustomConstants(m_vertexProgram, NUM_PASSES); + } + else + { + char msg[1024]; + Ps::snprintf(msg, sizeof(msg), "Could not find shader file: <%s> in path: <%sshaders/>", desc.vertexShaderPath, m_renderer.getAssetDir()); + RENDERER_OUTPUT_MESSAGE(&m_renderer, msg); + } + + const char *fragmentEntry = "fmain"; + for(PxU32 i=0; i<NUM_PASSES; i++) + { + char passDefine[64] = {0}; + Ps::snprintf(passDefine, 63, "-D%s", getPassName((Pass)i)); + + char fvaceDefine[20] = "-DENABLE_VFACE=0"; +#if PX_WINDOWS + // Aparently the FACE semantic is only supported with fp40 + if (cgGLIsProfileSupported(CG_PROFILE_FP40)) + { + fvaceDefine[15] = '1'; + } +#endif + const char *fragmentArgs[] = + { + fullPath, + "-DRENDERER_FRAGMENT", + fvaceDefine, // used for double sided rendering (as done in D3D anyways) + "-DVFACE=FACE", // rename VFACE to FACE semantic, the first is only known to HLSL shaders... +#ifdef RENDERER_PS3 + "-DRENDERER_PS3", + "-melf", + "-DENABLE_VFACE", +#endif +#ifdef NO_SUPPORT_DDX_DDY + "-DNO_SUPPORT_DDX_DDY", +#endif + passDefine, + 0, 0, + }; + cgGLSetOptimalOptions(m_fragmentProfile); + CGprogram fp = 0; + if(1) + { + PX_PROFILE_ZONE("OGLRendererMaterial_compile_fragmentProgram",0); + fp = static_cast<CGprogram>(SampleFramework::SamplePlatform::platform()->compileProgram(cgContext, m_renderer.getAssetDir(), desc.fragmentShaderPath, m_fragmentProfile, getPassName((Pass)i), fragmentEntry, fragmentArgs)); + } + RENDERER_ASSERT(fp, "Failed to compile Fragment Shader."); + if(fp) + { + PX_PROFILE_ZONE("OGLRendererMaterial_load_fragmentProgram",0); + connectEnvParameters(cgEnv, fp); + cgGLLoadProgram(fp); + m_fragmentPrograms[i] = fp; + loadCustomConstants(fp, (Pass)i); + } + } + } +#endif +} + +OGLRendererMaterial::~OGLRendererMaterial(void) +{ +#if defined(RENDERER_ENABLE_CG) + if(m_vertexProgram) + { + cgDestroyProgram(m_vertexProgram); + } + for(PxU32 i=0; i<NUM_PASSES; i++) + { + CGprogram fp = m_fragmentPrograms[i]; + if(fp) + { + cgDestroyProgram(fp); + } + } +#endif +} + +void OGLRendererMaterial::bind(RendererMaterial::Pass pass, RendererMaterialInstance *materialInstance, bool instanced) const +{ + m_renderer.setCurrentMaterial(this); + + if(m_glAlphaTestFunc == GL_ALWAYS) + { + glDisable(GL_ALPHA_TEST); + } + else + { + glEnable(GL_ALPHA_TEST); + glAlphaFunc(m_glAlphaTestFunc, PxClamp(getAlphaTestRef(), 0.0f, 1.0f)); + } + + if(getBlending()) + { + glBlendFunc(getGLBlendFunc(getSrcBlendFunc()), getGLBlendFunc(getDstBlendFunc())); + glEnable(GL_BLEND); + glDepthMask(0); + } + +#if defined(RENDERER_ENABLE_CG) + if(m_vertexProgram) + { + cgGLEnableProfile(m_vertexProfile); + cgGLBindProgram(m_vertexProgram); +#if !defined(RENDERER_PS3) + cgUpdateProgramParameters(m_vertexProgram); +#endif + } + if(pass < NUM_PASSES && m_fragmentPrograms[pass]) + { + cgGLEnableProfile(m_fragmentProfile); + cgGLBindProgram(m_fragmentPrograms[pass]); + + RendererMaterial::bind(pass, materialInstance, instanced); + //this is a kludge to make the particles work. I see no way to set env's through this interface + glEnable(GL_POINT_SPRITE_ARB); + glTexEnvf(GL_POINT_SPRITE_ARB, GL_COORD_REPLACE_ARB, GL_TRUE); + glEnable(GL_VERTEX_PROGRAM_POINT_SIZE_ARB); + +#if !defined(RENDERER_PS3) + cgUpdateProgramParameters(m_fragmentPrograms[pass]); +#endif + } +#endif +} + +void OGLRendererMaterial::bindMeshState(bool instanced) const +{ +#if defined(RENDERER_ENABLE_CG) + if(m_vertexProgram) + { +#if defined(RENDERER_PS3) + cgGLBindProgram(m_vertexProgram); +#else + cgUpdateProgramParameters(m_vertexProgram); +#endif + } +#endif +} + +void OGLRendererMaterial::unbind(void) const +{ +#if defined(RENDERER_ENABLE_CG) + glTexEnvf(GL_POINT_SPRITE_ARB, GL_COORD_REPLACE_ARB, GL_FALSE); + glDisable(GL_POINT_SPRITE_ARB); + glDisable(GL_VERTEX_PROGRAM_POINT_SIZE_ARB); + + if(m_vertexProfile) + { + cgGLUnbindProgram(m_vertexProfile); + cgGLDisableProfile(m_vertexProfile); + } + if(m_fragmentProfile) + { + cgGLUnbindProgram(m_fragmentProfile); + cgGLDisableProfile(m_fragmentProfile); + } +#endif + + if(getBlending()) + { + glDisable(GL_BLEND); + glDepthMask(1); + } + + m_renderer.setCurrentMaterial(0); +} + +#if defined(RENDERER_ENABLE_CG) +template<class TextureType> +static void bindSamplerVariable(CGparameter param, RendererTexture2D &texture) +{ + TextureType &tex = *static_cast<TextureType*>(&texture); + if(param) + { + CGresource resource = cgGetParameterResource(param); + RENDERER_ASSERT(resource >= CG_TEXUNIT0 && resource <= CG_TEXUNIT15, "Invalid Texture Resource Location."); + if(resource >= CG_TEXUNIT0 && resource <= CG_TEXUNIT15) + { + tex.bind(resource-CG_TEXUNIT0); + } + } +} +#endif + +void OGLRendererMaterial::bindVariable(Pass pass, const Variable &variable, const void *data) const +{ +#if defined(RENDERER_ENABLE_CG) + CGVariable &var = *(CGVariable*)&variable; + switch(var.getType()) + { + case VARIABLE_FLOAT: + { + float f = *(const float*)data; + if(var.m_vertexHandle) cgGLSetParameter1f(var.m_vertexHandle, f); + if(var.m_fragmentHandles[pass]) cgGLSetParameter1f(var.m_fragmentHandles[pass], f); + break; + } + case VARIABLE_FLOAT2: + { + const float *f = (const float*)data; + if(var.m_vertexHandle) cgGLSetParameter2fv(var.m_vertexHandle, f); + if(var.m_fragmentHandles[pass]) cgGLSetParameter2fv(var.m_fragmentHandles[pass], f); + break; + } + case VARIABLE_FLOAT3: + { + const float *f = (const float*)data; + if(var.m_vertexHandle) cgGLSetParameter3fv(var.m_vertexHandle, f); + if(var.m_fragmentHandles[pass]) cgGLSetParameter3fv(var.m_fragmentHandles[pass], f); + break; + } + case VARIABLE_FLOAT4: + { + const float *f = (const float*)data; + if(var.m_vertexHandle) cgGLSetParameter4fv(var.m_vertexHandle, f); + if(var.m_fragmentHandles[pass]) cgGLSetParameter4fv(var.m_fragmentHandles[pass], f); + break; + } + case VARIABLE_SAMPLER2D: + data = *(void**)data; + RENDERER_ASSERT(data, "NULL Sampler."); + if(data) + { + bindSamplerVariable<OGLRendererTexture2D>(var.m_vertexHandle, *(RendererTexture2D*)data); + bindSamplerVariable<OGLRendererTexture2D>(var.m_fragmentHandles[pass], *(RendererTexture2D*)data); + } + break; + case VARIABLE_SAMPLER3D: + RENDERER_ASSERT(0, "3D GL Textures Not Implemented."); + /* + data = *(void**)data; + RENDERER_ASSERT(data, "NULL Sampler."); + if(data) + { + bindSamplerVariable<OGLRendererTexture3D>(var.m_vertexHandle, *(RendererTexture2D*)data); + bindSamplerVariable<OGLRendererTexture3D>(var.m_fragmentHandles[pass], *(RendererTexture2D*)data); + } + */ + break; + default: + RENDERER_ASSERT(0, "Cannot bind variable of this type."); + break; + } +#endif +} + +#if defined(RENDERER_ENABLE_CG) +void OGLRendererMaterial::loadCustomConstants(CGprogram program, Pass pass) +{ + for(CGparameter param = cgGetFirstParameter(program, CG_GLOBAL); param; param=cgGetNextParameter(param)) + { + const char *name = cgGetParameterName(param); + CGtype cgtype = cgGetParameterType(param); + VariableType type = cgtype != CG_STRUCT && cgtype != CG_ARRAY ? getVariableType(cgtype) : NUM_VARIABLE_TYPES; + if(type < NUM_VARIABLE_TYPES && cgIsParameter(param) && cgIsParameterReferenced(param) && strncmp(name, "g_", 2)) + { + CGVariable *var = 0; + // find existing variable... + PxU32 numVariables = (PxU32)m_variables.size(); + for(PxU32 i=0; i<numVariables; i++) + { + if(!strcmp(m_variables[i]->getName(), name)) + { + var = static_cast<CGVariable*>(m_variables[i]); + break; + } + } + // check to see if the variable is of the same type. + if(var) + { + RENDERER_ASSERT(var->getType() == type, "Variable changes type!"); + } + // if the variable was not found, add it. + if(!var) + { + var = new CGVariable(name, type, m_variableBufferSize); + m_variables.push_back(var); + m_variableBufferSize += var->getDataSize(); + } + if(pass < NUM_PASSES) + { + var->addFragmentHandle(param, pass); + } + else + { + var->addVertexHandle(param); + } + } + } +} +#endif + +#endif // #if defined(RENDERER_ENABLE_OPENGL) diff --git a/PhysX_3.4/Samples/SampleFramework/renderer/src/ogl/OGLRendererMaterial.h b/PhysX_3.4/Samples/SampleFramework/renderer/src/ogl/OGLRendererMaterial.h new file mode 100644 index 00000000..f415e3a6 --- /dev/null +++ b/PhysX_3.4/Samples/SampleFramework/renderer/src/ogl/OGLRendererMaterial.h @@ -0,0 +1,106 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved. +#ifndef OGL_RENDERER_MATERIAL_H +#define OGL_RENDERER_MATERIAL_H + +#include <RendererConfig.h> + +#if defined(RENDERER_ENABLE_OPENGL) + +#include <RendererMaterial.h> + +#include "OGLRenderer.h" + +namespace SampleRenderer +{ + + class OGLRendererMaterial : public RendererMaterial + { + friend class OGLRendererMesh; + public: + OGLRendererMaterial(OGLRenderer &renderer, const RendererMaterialDesc &desc); + virtual ~OGLRendererMaterial(void); + virtual void setModelMatrix(const float *matrix) + { + PX_UNUSED(matrix); + PX_ALWAYS_ASSERT(); + } + + private: + virtual const Renderer& getRenderer() const { return m_renderer; } + virtual void bind(RendererMaterial::Pass pass, RendererMaterialInstance *materialInstance, bool instanced) const; + virtual void bindMeshState(bool instanced) const; + virtual void unbind(void) const; + virtual void bindVariable(Pass pass, const Variable &variable, const void *data) const; + +#if defined(RENDERER_ENABLE_CG) + void loadCustomConstants(CGprogram program, Pass pass); +#endif + + private: +#if defined(RENDERER_ENABLE_CG) + class CGVariable : public Variable + { + friend class OGLRendererMaterial; + public: + CGVariable(const char *name, VariableType type, PxU32 offset); + virtual ~CGVariable(void); + + void addVertexHandle(CGparameter handle); + void addFragmentHandle(CGparameter handle, Pass pass); + + private: + CGparameter m_vertexHandle; + CGparameter m_fragmentHandles[NUM_PASSES]; + }; +#endif + + private: + OGLRendererMaterial &operator=(const OGLRendererMaterial&) { return *this; } + + private: + OGLRenderer &m_renderer; + + GLenum m_glAlphaTestFunc; + +#if defined(RENDERER_ENABLE_CG) + CGprofile m_vertexProfile; + CGprogram m_vertexProgram; + + CGprofile m_fragmentProfile; + CGprogram m_fragmentPrograms[NUM_PASSES]; +#if defined(RENDERER_PS3) + public: + CGprogram GetVertexProgramPS3(){ return m_vertexProgram;} +#endif +#endif + }; + +} // namespace SampleRenderer + +#endif // #if defined(RENDERER_ENABLE_OPENGL) +#endif diff --git a/PhysX_3.4/Samples/SampleFramework/renderer/src/ogl/OGLRendererMesh.cpp b/PhysX_3.4/Samples/SampleFramework/renderer/src/ogl/OGLRendererMesh.cpp new file mode 100644 index 00000000..cd25df2b --- /dev/null +++ b/PhysX_3.4/Samples/SampleFramework/renderer/src/ogl/OGLRendererMesh.cpp @@ -0,0 +1,171 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved. + +#include <RendererConfig.h> + +#if defined(RENDERER_ENABLE_OPENGL) + +#include "OGLRendererMesh.h" + +#include "OGLRendererInstanceBuffer.h" +#include "OGLRendererMaterial.h" + +using namespace SampleRenderer; + +static GLenum getGLPrimitive(RendererMesh::Primitive primitive) +{ + GLenum glprim = ~(GLenum)0; + switch(primitive) + { + case RendererMesh::PRIMITIVE_POINTS: glprim = GL_POINTS; break; + case RendererMesh::PRIMITIVE_LINES: glprim = GL_LINES; break; + case RendererMesh::PRIMITIVE_LINE_STRIP: glprim = GL_LINE_STRIP; break; + case RendererMesh::PRIMITIVE_TRIANGLES: glprim = GL_TRIANGLES; break; + case RendererMesh::PRIMITIVE_TRIANGLE_STRIP: glprim = GL_TRIANGLE_STRIP; break; + case RendererMesh::PRIMITIVE_POINT_SPRITES: glprim = GL_POINTS; break; + default: break; + } + RENDERER_ASSERT(glprim != ~(GLenum)0, "Unable to find GL Primitive type."); + return glprim; +} + +static GLenum getGLIndexType(RendererIndexBuffer::Format format) +{ + GLenum gltype = 0; + switch(format) + { + case RendererIndexBuffer::FORMAT_UINT16: gltype = GL_UNSIGNED_SHORT; break; + case RendererIndexBuffer::FORMAT_UINT32: gltype = GL_UNSIGNED_INT; break; + default: break; + } + RENDERER_ASSERT(gltype, "Unable to convert to GL Index Type."); + return gltype; +} + +OGLRendererMesh::OGLRendererMesh(OGLRenderer &renderer, const RendererMeshDesc &desc) +: RendererMesh(desc) +, m_renderer(renderer) +{ + +} + +OGLRendererMesh::~OGLRendererMesh(void) +{ + +} + +void OGLRendererMesh::renderIndices(PxU32 numVertices, PxU32 firstIndex, PxU32 numIndices, RendererIndexBuffer::Format indexFormat, RendererMaterial *material) const +{ + const PxU32 indexSize = RendererIndexBuffer::getFormatByteSize(indexFormat); + void *buffer = ((PxU8*)0)+indexSize*firstIndex; + glDrawElements(getGLPrimitive(getPrimitives()), numIndices, getGLIndexType(indexFormat), buffer); +} + +void OGLRendererMesh::renderVertices(PxU32 numVertices, RendererMaterial *material) const +{ + RendererMesh::Primitive primitive = getPrimitives(); + glDrawArrays(getGLPrimitive(primitive), 0, numVertices); +} + +void OGLRendererMesh::renderIndicesInstanced(PxU32 numVertices, PxU32 firstIndex, PxU32 numIndices, RendererIndexBuffer::Format indexFormat, RendererMaterial *material) const +{ + const OGLRendererInstanceBuffer *ib = static_cast<const OGLRendererInstanceBuffer*>(getInstanceBuffer()); + if(ib) + { + const PxU32 firstInstance = m_firstInstance; + const PxU32 numInstances = getNumInstances(); + + const OGLRendererMaterial *currentMaterial = m_renderer.getCurrentMaterial(); + + CGparameter modelMatrixParam = m_renderer.getCGEnvironment().modelMatrix; + CGparameter modelViewMatrixParam = m_renderer.getCGEnvironment().modelViewMatrix; + + if(currentMaterial && modelMatrixParam && modelViewMatrixParam) + { + for(PxU32 i=0; i<numInstances; i++) + { +#if defined(RENDERER_ENABLE_CG) + const physx::PxMat44 &model = ib->getModelMatrix(firstInstance+i); + GLfloat glmodel[16]; + PxToGL(glmodel, model); + + physx::PxMat44 modelView = m_renderer.getViewMatrix() * model; + GLfloat glmodelview[16]; + PxToGL(glmodelview, modelView); + + cgGLSetMatrixParameterfc(modelMatrixParam, glmodel); + cgGLSetMatrixParameterfc(modelViewMatrixParam, glmodelview); +#endif + + currentMaterial->bindMeshState(false); + + renderIndices(numVertices, firstIndex, numIndices, indexFormat, material); + } + } + } +} + +void OGLRendererMesh::renderVerticesInstanced(PxU32 numVertices, RendererMaterial *material) const +{ + const OGLRendererInstanceBuffer *ib = static_cast<const OGLRendererInstanceBuffer*>(getInstanceBuffer()); + if(ib) + { + const PxU32 firstInstance = m_firstInstance; + const PxU32 numInstances = getNumInstances(); + + const OGLRendererMaterial *currentMaterial = m_renderer.getCurrentMaterial(); + + CGparameter modelMatrixParam = m_renderer.getCGEnvironment().modelMatrix; + CGparameter modelViewMatrixParam = m_renderer.getCGEnvironment().modelViewMatrix; + + if(currentMaterial && modelMatrixParam && modelViewMatrixParam) + { + for(PxU32 i=0; i<numInstances; i++) + { +#if defined(RENDERER_ENABLE_CG) + const physx::PxMat44 &model = ib->getModelMatrix(firstInstance+i); + GLfloat glmodel[16]; + PxToGL(glmodel, model); + + physx::PxMat44 modelView = m_renderer.getViewMatrix() * model; + GLfloat glmodelview[16]; + PxToGL(glmodelview, modelView); + + cgGLSetMatrixParameterfc(modelMatrixParam, glmodel); + cgGLSetMatrixParameterfc(modelViewMatrixParam, glmodelview); +#endif + + currentMaterial->bindMeshState(false); + + renderVertices(numVertices, material); + } + } + } +} + +#endif // #if defined(RENDERER_ENABLE_OPENGL) + diff --git a/PhysX_3.4/Samples/SampleFramework/renderer/src/ogl/OGLRendererMesh.h b/PhysX_3.4/Samples/SampleFramework/renderer/src/ogl/OGLRendererMesh.h new file mode 100644 index 00000000..95281bbd --- /dev/null +++ b/PhysX_3.4/Samples/SampleFramework/renderer/src/ogl/OGLRendererMesh.h @@ -0,0 +1,66 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved. +#ifndef OGL_RENDERER_MESH_H +#define OGL_RENDERER_MESH_H + +#include <RendererConfig.h> + +#if defined(RENDERER_ENABLE_OPENGL) + +#include <RendererMesh.h> + +#include "OGLRenderer.h" + +namespace SampleRenderer +{ + + class OGLRendererMesh : public RendererMesh + { + public: + OGLRendererMesh(OGLRenderer &renderer, const RendererMeshDesc &desc); + virtual ~OGLRendererMesh(void); + + public: + virtual void renderIndices(PxU32 numVertices, PxU32 firstIndex, PxU32 numIndices, RendererIndexBuffer::Format indexFormat,RendererMaterial *material) const; + virtual void renderVertices(PxU32 numVertices,RendererMaterial *material) const; + + virtual void renderIndicesInstanced(PxU32 numVertices, PxU32 firstIndex, PxU32 numIndices, RendererIndexBuffer::Format indexFormat,RendererMaterial *material) const; + virtual void renderVerticesInstanced(PxU32 numVertices,RendererMaterial *material) const; + + protected: + void operator=(const OGLRendererMesh &){} + + Renderer& renderer() { return m_renderer; } + + private: + OGLRenderer &m_renderer; + }; + +} // namespace SampleRenderer + +#endif // #if defined(RENDERER_ENABLE_OPENGL) +#endif diff --git a/PhysX_3.4/Samples/SampleFramework/renderer/src/ogl/OGLRendererSpotLight.cpp b/PhysX_3.4/Samples/SampleFramework/renderer/src/ogl/OGLRendererSpotLight.cpp new file mode 100644 index 00000000..9a44b99d --- /dev/null +++ b/PhysX_3.4/Samples/SampleFramework/renderer/src/ogl/OGLRendererSpotLight.cpp @@ -0,0 +1,63 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved. +#include <RendererConfig.h> + +#if defined(RENDERER_ENABLE_OPENGL) + +#include "OGLRendererSpotLight.h" + +using namespace SampleRenderer; + +OGLRendererSpotLight::OGLRendererSpotLight(const RendererSpotLightDesc &desc, OGLRenderer &renderer) +: RendererSpotLight(desc) +#if defined(RENDERER_ENABLE_CG) +, m_cgenv(renderer.getCGEnvironment()) +#endif +{ + +} + +OGLRendererSpotLight::~OGLRendererSpotLight(void) +{ + +} + +void OGLRendererSpotLight::bind(void) const +{ +#if defined(RENDERER_ENABLE_CG) + setColorParameter(m_cgenv.lightColor, m_color); + cgSetParameter1f( m_cgenv.lightIntensity, m_intensity); + cgSetParameter3fv(m_cgenv.lightDirection, &m_direction.x); + cgSetParameter3fv(m_cgenv.lightPosition, &m_position.x); + cgSetParameter1f( m_cgenv.lightInnerRadius, m_innerRadius); + cgSetParameter1f( m_cgenv.lightOuterRadius, m_outerRadius); + cgSetParameter1f( m_cgenv.lightInnerCone, m_innerCone); + cgSetParameter1f( m_cgenv.lightOuterCone, m_outerCone); +#endif +} + +#endif diff --git a/PhysX_3.4/Samples/SampleFramework/renderer/src/ogl/OGLRendererSpotLight.h b/PhysX_3.4/Samples/SampleFramework/renderer/src/ogl/OGLRendererSpotLight.h new file mode 100644 index 00000000..c6828849 --- /dev/null +++ b/PhysX_3.4/Samples/SampleFramework/renderer/src/ogl/OGLRendererSpotLight.h @@ -0,0 +1,58 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved. +#ifndef OGL_RENDERER_SPOT_LIGHT_H +#define OGL_RENDERER_SPOT_LIGHT_H + +#include <RendererConfig.h> + +#if defined(RENDERER_ENABLE_OPENGL) + +#include <RendererSpotLight.h> + +#include "OGLRenderer.h" + +namespace SampleRenderer +{ + + class OGLRendererSpotLight : public RendererSpotLight + { + public: + OGLRendererSpotLight(const RendererSpotLightDesc &desc, OGLRenderer &renderer); + virtual ~OGLRendererSpotLight(void); + + virtual void bind(void) const; + + private: +#if defined(RENDERER_ENABLE_CG) + const OGLRenderer::CGEnvironment &m_cgenv; +#endif + }; + +} // namespace SampleRenderer + +#endif // #if defined(RENDERER_ENABLE_DIRECT3D9) +#endif diff --git a/PhysX_3.4/Samples/SampleFramework/renderer/src/ogl/OGLRendererTexture2D.cpp b/PhysX_3.4/Samples/SampleFramework/renderer/src/ogl/OGLRendererTexture2D.cpp new file mode 100644 index 00000000..a0d99b8b --- /dev/null +++ b/PhysX_3.4/Samples/SampleFramework/renderer/src/ogl/OGLRendererTexture2D.cpp @@ -0,0 +1,299 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved. + +#include <RendererConfig.h> + +#if defined(RENDERER_ENABLE_OPENGL) + +#include "OGLRendererTexture2D.h" +#include <RendererTexture2DDesc.h> + +using namespace SampleRenderer; + +static GLuint getGLPixelFormat(RendererTexture2D::Format format) +{ + GLuint glformat = 0; + switch(format) + { + case RendererTexture2D::FORMAT_B8G8R8A8: glformat = GL_BGRA; break; + case RendererTexture2D::FORMAT_R8G8B8A8: glformat = GL_RGBA; break; + case RendererTexture2D::FORMAT_A8: glformat = GL_ALPHA; break; + case RendererTexture2D::FORMAT_R32F: glformat = GL_LUMINANCE; break; + case RendererTexture2D::FORMAT_D16: glformat = GL_DEPTH_COMPONENT; break; + case RendererTexture2D::FORMAT_D24S8: glformat = GL_DEPTH_COMPONENT; break; + default: + // The pixel type need not be defined (in the case of compressed formats) + break; + } + return glformat; +} + +static GLuint getGLPixelInternalFormat(RendererTexture2D::Format format) +{ + GLuint glinternalformat = 0; + switch(format) + { + case RendererTexture2D::FORMAT_B8G8R8A8: + glinternalformat = GL_RGBA8; + break; + case RendererTexture2D::FORMAT_R8G8B8A8: + glinternalformat = GL_RGBA8; + break; + case RendererTexture2D::FORMAT_A8: + glinternalformat = GL_ALPHA8; + break; +#if !defined(RENDERER_PS3) + case RendererTexture2D::FORMAT_R32F: + if(GLEW_ARB_texture_float) glinternalformat = GL_LUMINANCE32F_ARB; + else if(GLEW_ATI_texture_float) glinternalformat = GL_LUMINANCE_FLOAT32_ATI; + break; +#endif + case RendererTexture2D::FORMAT_DXT1: + glinternalformat = GL_COMPRESSED_RGBA_S3TC_DXT1_EXT; + break; + case RendererTexture2D::FORMAT_DXT3: + glinternalformat = GL_COMPRESSED_RGBA_S3TC_DXT3_EXT; + break; + case RendererTexture2D::FORMAT_DXT5: + glinternalformat = GL_COMPRESSED_RGBA_S3TC_DXT5_EXT; + break; +#if !defined(RENDERER_PS3) + case RendererTexture2D::FORMAT_D16: + glinternalformat = GL_DEPTH_COMPONENT16_ARB; + break; + case RendererTexture2D::FORMAT_D24S8: + glinternalformat = GL_DEPTH_COMPONENT24_ARB; + break; +#endif + default: RENDERER_ASSERT(0, "Unsupported GL pixel internal format."); break; + } + RENDERER_ASSERT(glinternalformat, "Unable to compute GL Internal Format."); + return glinternalformat; +} + +static GLuint getGLPixelType(RendererTexture2D::Format format) +{ + GLuint gltype = 0; + switch(format) + { + case RendererTexture2D::FORMAT_B8G8R8A8: + case RendererTexture2D::FORMAT_R8G8B8A8: + gltype = GL_UNSIGNED_BYTE; + break; + case RendererTexture2D::FORMAT_A8: + gltype = GL_UNSIGNED_BYTE; + break; + case RendererTexture2D::FORMAT_R32F: + gltype = GL_FLOAT; + break; + case RendererTexture2D::FORMAT_D16: + gltype = GL_UNSIGNED_SHORT; + break; + case RendererTexture2D::FORMAT_D24S8: + gltype = GL_UNSIGNED_INT; + break; + default: + // The pixel type need not be defined (in the case of compressed formats) + break; + } + return gltype; +} + +static GLint getGLTextureFilter(RendererTexture2D::Filter filter, bool mipmap) +{ + GLint glfilter = 0; + switch(filter) + { + case RendererTexture2D::FILTER_NEAREST: glfilter = mipmap ? GL_NEAREST_MIPMAP_NEAREST : GL_NEAREST; break; + case RendererTexture2D::FILTER_LINEAR: glfilter = mipmap ? GL_LINEAR_MIPMAP_LINEAR : GL_LINEAR; break; + case RendererTexture2D::FILTER_ANISOTROPIC: glfilter = mipmap ? GL_LINEAR_MIPMAP_LINEAR : GL_LINEAR; break; + default: break; + } + RENDERER_ASSERT(glfilter, "Unable to convert to OpenGL Filter mode."); + return glfilter; +} + +static GLint getGLTextureAddressing(RendererTexture2D::Addressing addressing) +{ + GLint glwrap = 0; + switch(addressing) + { + case RendererTexture2D::ADDRESSING_WRAP: glwrap = GL_REPEAT; break; + case RendererTexture2D::ADDRESSING_CLAMP: glwrap = GL_CLAMP; break; + case RendererTexture2D::ADDRESSING_MIRROR: glwrap = GL_MIRRORED_REPEAT; break; + default: break; + } + RENDERER_ASSERT(glwrap, "Unable to convert to OpenGL Addressing mode."); + return glwrap; +} + +OGLRendererTexture2D::OGLRendererTexture2D(const RendererTexture2DDesc &desc) : +RendererTexture2D(desc) +{ + RENDERER_ASSERT(desc.depth == 1, "Invalid depth for 3D Texture!"); + + m_textureid = 0; + m_glformat = 0; + m_glinternalformat = 0; + m_gltype = 0; + m_numLevels = 0; + m_data = 0; + + m_glformat = getGLPixelFormat(desc.format); + m_glinternalformat = getGLPixelInternalFormat(desc.format); + m_gltype = getGLPixelType(desc.format); + + glGenTextures(1, &m_textureid); + RENDERER_ASSERT(m_textureid, "Failed to create OpenGL Texture."); + if(m_textureid) + { + m_width = desc.width; + m_height = desc.height; + m_numLevels = desc.numLevels; + m_data = new PxU8*[m_numLevels]; + memset(m_data, 0, sizeof(PxU8*)*m_numLevels); + + glBindTexture(GL_TEXTURE_2D, m_textureid); + if(isDepthStencilFormat(desc.format)) + { + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE_ARB, GL_COMPARE_R_TO_TEXTURE_ARB); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_FUNC_ARB, GL_LEQUAL); + glTexParameteri(GL_TEXTURE_2D, GL_DEPTH_TEXTURE_MODE_ARB, GL_INTENSITY); + } + if(isCompressedFormat(desc.format)) + { + for(PxU32 i=0; i<desc.numLevels; i++) + { + PxU32 w = getLevelDimension(m_width, i); + PxU32 h = getLevelDimension(m_height, i); + PxU32 levelSize = computeImageByteSize(w, h, 1, desc.format); + m_data[i] = new PxU8[levelSize]; + memset(m_data[i], 0, levelSize); + + // limit the maximum level used for mip mapping (we don't update levels < 4 pixels wide) + if (w >= 4 && h >= 4) + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_LOD, float(i)); + + glCompressedTexImage2D(GL_TEXTURE_2D, (GLint)i, m_glinternalformat, w, h, 0, levelSize, m_data[i]); + } + } + else + { + RENDERER_ASSERT(m_glformat, "Unknown OpenGL Format!"); + for(PxU32 i=0; i<desc.numLevels; i++) + { + PxU32 w = getLevelDimension(m_width, i); + PxU32 h = getLevelDimension(m_height, i); + PxU32 levelSize = computeImageByteSize(w, h, 1, desc.format); + m_data[i] = new PxU8[levelSize]; + memset(m_data[i], 0, levelSize); + glTexImage2D(GL_TEXTURE_2D, (GLint)i, m_glinternalformat, w, h, 0, m_glformat, m_gltype, m_data[i]); + } + } + + + // set filtering mode... + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, getGLTextureFilter(desc.filter, m_numLevels > 1)); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, getGLTextureFilter(desc.filter, false)); + if(desc.filter == FILTER_ANISOTROPIC) + { + GLfloat maxAnisotropy = 1.0f; + glGetFloatv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &maxAnisotropy); + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, maxAnisotropy); + } + + // set addressing modes... + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, getGLTextureAddressing(desc.addressingU)); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, getGLTextureAddressing(desc.addressingV)); + + glBindTexture(GL_TEXTURE_2D, 0); + } +} + +OGLRendererTexture2D::~OGLRendererTexture2D(void) +{ + if(m_textureid) + { + glDeleteTextures(1, &m_textureid); + } + if(m_data) + { + for(PxU32 i=0; i<m_numLevels; i++) + { + delete [] m_data[i]; + } + delete [] m_data; + } +} + +void *OGLRendererTexture2D::lockLevel(PxU32 level, PxU32 &pitch) +{ + void *buffer = 0; + RENDERER_ASSERT(level < m_numLevels, "Level out of range!"); + if(level < m_numLevels) + { + buffer = m_data[level]; + pitch = getFormatNumBlocks(getWidth()>>level, getFormat()) * getBlockSize(); + } + return buffer; +} + +void OGLRendererTexture2D::unlockLevel(PxU32 level) +{ + RENDERER_ASSERT(level < m_numLevels, "Level out of range!"); + if(m_textureid && level < m_numLevels) + { + PxU32 w = getLevelDimension(getWidth(), level); + PxU32 h = getLevelDimension(getHeight(), level); + glBindTexture(GL_TEXTURE_2D, m_textureid); + if(isCompressedFormat(getFormat())) + { + PxU32 levelSize = computeImageByteSize(w, h, 1, getFormat()); + + // Some platforms don't like smaller than 4x4 compressed textures + if (w >= 4 && h >= 4) + glCompressedTexSubImage2D(GL_TEXTURE_2D, (GLint)level, 0, 0, w, h, m_glinternalformat, levelSize, m_data[level]); + } + else + { + glTexImage2D(GL_TEXTURE_2D, (GLint)level, m_glinternalformat, w, h, 0, m_glformat, m_gltype, m_data[level]); + } + glBindTexture(GL_TEXTURE_2D, 0); + } +} + +void OGLRendererTexture2D::bind(PxU32 textureUnit) +{ + if(m_textureid) + { + glActiveTextureARB(GL_TEXTURE0_ARB + textureUnit); + glClientActiveTextureARB(GL_TEXTURE0_ARB + textureUnit); + glBindTexture(GL_TEXTURE_2D, m_textureid); + } +} + +#endif // #if defined(RENDERER_ENABLE_OPENGL) diff --git a/PhysX_3.4/Samples/SampleFramework/renderer/src/ogl/OGLRendererTexture2D.h b/PhysX_3.4/Samples/SampleFramework/renderer/src/ogl/OGLRendererTexture2D.h new file mode 100644 index 00000000..de894347 --- /dev/null +++ b/PhysX_3.4/Samples/SampleFramework/renderer/src/ogl/OGLRendererTexture2D.h @@ -0,0 +1,75 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved. +#ifndef OGL_RENDERER_TEXTURE_2D_H +#define OGL_RENDERER_TEXTURE_2D_H + +#include <RendererConfig.h> + +#if defined(RENDERER_ENABLE_OPENGL) + +#include <RendererTexture2D.h> +#include "OGLRenderer.h" + +namespace SampleRenderer +{ + + class OGLRendererTexture2D : public RendererTexture2D + { + public: + OGLRendererTexture2D(const RendererTexture2DDesc &desc); + virtual ~OGLRendererTexture2D(void); + + public: + virtual void *lockLevel(PxU32 level, PxU32 &pitch); + virtual void unlockLevel(PxU32 level); + + void bind(PxU32 textureUnit); + + virtual void select(PxU32 stageIndex) + { + bind(stageIndex); + } + + private: + + GLuint m_textureid; + GLuint m_glformat; + GLuint m_glinternalformat; + GLuint m_gltype; + + PxU32 m_width; + PxU32 m_height; + + PxU32 m_numLevels; + + PxU8 **m_data; + }; + +} // namespace SampleRenderer + +#endif // #if defined(RENDERER_ENABLE_OPENGL) +#endif diff --git a/PhysX_3.4/Samples/SampleFramework/renderer/src/ogl/OGLRendererVertexBuffer.cpp b/PhysX_3.4/Samples/SampleFramework/renderer/src/ogl/OGLRendererVertexBuffer.cpp new file mode 100644 index 00000000..6ca1c52c --- /dev/null +++ b/PhysX_3.4/Samples/SampleFramework/renderer/src/ogl/OGLRendererVertexBuffer.cpp @@ -0,0 +1,342 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved. + +#include "RendererConfig.h" +#include <SamplePlatform.h> + +#if defined(RENDERER_ENABLE_OPENGL) + +#include "OGLRendererVertexBuffer.h" + +#include <RendererVertexBufferDesc.h> + +#if PX_WINDOWS +#include "cudamanager/PxCudaContextManager.h" +#endif + +using namespace SampleRenderer; + +OGLRendererVertexBuffer::OGLRendererVertexBuffer(const RendererVertexBufferDesc &desc) : + RendererVertexBuffer(desc) +, m_vbo(0) +, m_access(0) +{ + RENDERER_ASSERT(GLEW_ARB_vertex_buffer_object, "Vertex Buffer Objects not supported on this machine!"); + if(GLEW_ARB_vertex_buffer_object) + { + GLenum usage = GL_STATIC_DRAW_ARB; + m_access = GL_READ_WRITE; + if(getHint() == HINT_DYNAMIC) + { + usage = GL_DYNAMIC_DRAW_ARB; + m_access = GL_WRITE_ONLY; + } + + RENDERER_ASSERT(m_stride && desc.maxVertices, "Unable to create Vertex Buffer of zero size."); + if(m_stride && desc.maxVertices) + { + glGenBuffersARB(1, &m_vbo); + RENDERER_ASSERT(m_vbo, "Failed to create Vertex Buffer Object."); + } + if(m_vbo) + { + m_maxVertices = desc.maxVertices; + PxU32 bufferSize = m_stride * m_maxVertices; + glBindBufferARB(GL_ARRAY_BUFFER_ARB, m_vbo); + glBufferDataARB(GL_ARRAY_BUFFER_ARB, bufferSize, 0, usage); + glBindBufferARB(GL_ARRAY_BUFFER_ARB, 0); + +#if PX_WINDOWS + if(m_interopContext && m_mustBeRegisteredInCUDA) + { + RENDERER_ASSERT(m_deferredUnlock == false, "Deferred VB Unlock must be disabled when CUDA Interop is in use.") + m_registeredInCUDA = m_interopContext->registerResourceInCudaGL(m_InteropHandle, (PxU32) m_vbo); + } +#endif + } + } +} + +OGLRendererVertexBuffer::~OGLRendererVertexBuffer(void) +{ + if(m_vbo) + { +#if PX_WINDOWS + if(m_registeredInCUDA) + { + m_interopContext->unregisterResourceInCuda(m_InteropHandle); + } +#endif + glDeleteBuffersARB(1, &m_vbo); + } +} + +PxU32 OGLRendererVertexBuffer::convertColor(const RendererColor& color) +{ +#if defined(RENDERER_WINDOWS) + return color.a << 24 | color.b << 16 | color.g << 8 | color.r; +#elif defined (RENDERER_PS3) + return (PxU32&)color; +#elif defined (RENDERER_MACOSX) + return color.a << 24 | color.b << 16 | color.g << 8 | color.r; // TODO: JPB: Check if this is the right order +#elif defined(RENDERER_LINUX) + return color.a << 24 | color.b << 16 | color.g << 8 | color.r; +#else + PX_ASSERT(!"Platform not implemented"); + return (PxU32&)color; +#endif +} + +void OGLRendererVertexBuffer::swizzleColor(void *colors, PxU32 stride, PxU32 numColors, RendererVertexBuffer::Format inFormat) +{ +#if !defined(RENDERER_PS3) + if (inFormat == RendererVertexBuffer::FORMAT_COLOR_BGRA) + { + const void *end = ((PxU8*)colors)+(stride*numColors); + for(PxU8* iterator = (PxU8*)colors; iterator < end; iterator+=stride) + { + // swizzle red and blue + std::swap(((PxU8*)iterator)[0], ((PxU8*)iterator)[2]); + } + } +#endif +} + +void *OGLRendererVertexBuffer::lock(void) +{ + PX_PROFILE_ZONE("OGLRendererVertexBufferLock",0); + void *buffer = 0; + if(m_vbo) + { + glBindBufferARB(GL_ARRAY_BUFFER_ARB, m_vbo); + buffer = glMapBuffer(GL_ARRAY_BUFFER, m_access); + glBindBufferARB(GL_ARRAY_BUFFER_ARB, 0); + } + return buffer; +} + +void OGLRendererVertexBuffer::unlock(void) +{ + if(m_vbo) + { + glBindBufferARB(GL_ARRAY_BUFFER_ARB, m_vbo); + glUnmapBuffer(GL_ARRAY_BUFFER); + glBindBufferARB(GL_ARRAY_BUFFER_ARB, 0); + } +} + +static GLuint getGLFormatSize(RendererVertexBuffer::Format format) +{ + PxU32 size = 0; + switch(format) + { + case RendererVertexBuffer::FORMAT_FLOAT1: size = 1; break; + case RendererVertexBuffer::FORMAT_FLOAT2: size = 2; break; + case RendererVertexBuffer::FORMAT_FLOAT3: size = 3; break; + case RendererVertexBuffer::FORMAT_FLOAT4: size = 4; break; + case RendererVertexBuffer::FORMAT_UBYTE4: size = 4; break; + case RendererVertexBuffer::FORMAT_USHORT4: size = 4; break; + case RendererVertexBuffer::FORMAT_COLOR_BGRA: size = 4; break; + case RendererVertexBuffer::FORMAT_COLOR_RGBA: size = 4; break; + case RendererVertexBuffer::FORMAT_COLOR_NATIVE: size = 4; break; + default: break; + } + RENDERER_ASSERT(size, "Unable to compute number of Vertex Buffer elements."); + return size; +} + +static GLenum getGLFormatType(RendererVertexBuffer::Format format) +{ + GLenum type = 0; + switch(format) + { + case RendererVertexBuffer::FORMAT_FLOAT1: + case RendererVertexBuffer::FORMAT_FLOAT2: + case RendererVertexBuffer::FORMAT_FLOAT3: + case RendererVertexBuffer::FORMAT_FLOAT4: + type = GL_FLOAT; + break; + case RendererVertexBuffer::FORMAT_UBYTE4: + type = GL_BYTE; + break; + case RendererVertexBuffer::FORMAT_USHORT4: + type = GL_SHORT; + break; + case RendererVertexBuffer::FORMAT_COLOR_BGRA: + case RendererVertexBuffer::FORMAT_COLOR_RGBA: + case RendererVertexBuffer::FORMAT_COLOR_NATIVE: + type = GL_UNSIGNED_BYTE; + break; + default: break; + } + RENDERER_ASSERT(type, "Unable to compute GLType for Vertex Buffer Format."); + return type; +} + +static GLenum getGLSemantic(RendererVertexBuffer::Semantic semantic) +{ + GLenum glsemantic = 0; + switch(semantic) + { + case RendererVertexBuffer::SEMANTIC_POSITION: glsemantic = GL_VERTEX_ARRAY; break; + case RendererVertexBuffer::SEMANTIC_COLOR: glsemantic = GL_COLOR_ARRAY; break; + case RendererVertexBuffer::SEMANTIC_NORMAL: glsemantic = GL_NORMAL_ARRAY; break; + case RendererVertexBuffer::SEMANTIC_TANGENT: glsemantic = GL_TEXTURE_COORD_ARRAY; break; + + case RendererVertexBuffer::SEMANTIC_TEXCOORD0: + case RendererVertexBuffer::SEMANTIC_TEXCOORD1: + case RendererVertexBuffer::SEMANTIC_TEXCOORD2: + case RendererVertexBuffer::SEMANTIC_TEXCOORD3: + case RendererVertexBuffer::SEMANTIC_BONEINDEX: + case RendererVertexBuffer::SEMANTIC_BONEWEIGHT: + glsemantic = GL_TEXTURE_COORD_ARRAY; + break; + default: + break; + } + // There is no reason why certain semantics can go unsupported by OpenGL + //RENDERER_ASSERT(glsemantic, "Unable to compute the GL Semantic for Vertex Buffer Semantic."); + return glsemantic; +} + +void OGLRendererVertexBuffer::bind(PxU32 streamID, PxU32 firstVertex) +{ + PX_PROFILE_ZONE("OGLRendererVertexBufferBind",0); + prepareForRender(); + const PxU8 *buffer = ((PxU8*)0) + firstVertex*m_stride; + if(m_vbo) + { + glBindBufferARB(GL_ARRAY_BUFFER_ARB, m_vbo); + for(PxU32 i=0; i<NUM_SEMANTICS; i++) + { + Semantic semantic = (Semantic)i; + const SemanticDesc &sm = m_semanticDescs[semantic]; + if(sm.format < NUM_FORMATS) + { + switch(semantic) + { + case SEMANTIC_POSITION: + RENDERER_ASSERT(sm.format >= FORMAT_FLOAT1 && sm.format <= FORMAT_FLOAT4, "Unsupported Vertex Buffer Format for POSITION semantic."); + if(sm.format >= FORMAT_FLOAT1 && sm.format <= FORMAT_FLOAT4) + { + glVertexPointer(getGLFormatSize(sm.format), getGLFormatType(sm.format), m_stride, buffer+sm.offset); + } + break; + case SEMANTIC_COLOR: + // swizzling was already handled in unlock() + RENDERER_ASSERT((sm.format == FORMAT_COLOR_BGRA || sm.format == FORMAT_COLOR_RGBA || sm.format == FORMAT_COLOR_NATIVE), "Unsupported Vertex Buffer Format for COLOR semantic."); + if(sm.format == FORMAT_COLOR_BGRA || sm.format == FORMAT_COLOR_RGBA || sm.format == FORMAT_COLOR_NATIVE) + { + glColorPointer(getGLFormatSize(sm.format), getGLFormatType(sm.format), m_stride, buffer+sm.offset); + } + break; + case SEMANTIC_NORMAL: + RENDERER_ASSERT((sm.format == FORMAT_FLOAT3 || sm.format == FORMAT_FLOAT4), "Unsupported Vertex Buffer Format for NORMAL semantic."); + if(sm.format == FORMAT_FLOAT3 || sm.format == FORMAT_FLOAT4) + { + glNormalPointer(getGLFormatType(sm.format), m_stride, buffer+sm.offset); + } + break; + case SEMANTIC_TANGENT: + RENDERER_ASSERT((sm.format == FORMAT_FLOAT3 || sm.format == FORMAT_FLOAT4), "Unsupported Vertex Buffer Format for TANGENT semantic."); + if(sm.format == FORMAT_FLOAT3 || sm.format == FORMAT_FLOAT4) + { + const PxU32 channel = RENDERER_TANGENT_CHANNEL; + glActiveTextureARB((GLenum)(GL_TEXTURE0_ARB + channel)); + glClientActiveTextureARB((GLenum)(GL_TEXTURE0_ARB + channel)); + glTexCoordPointer(getGLFormatSize(sm.format), getGLFormatType(sm.format), m_stride, buffer+sm.offset); + } + break; + case SEMANTIC_TEXCOORD0: + case SEMANTIC_TEXCOORD1: + case SEMANTIC_TEXCOORD2: + case SEMANTIC_TEXCOORD3: + { + const PxU32 channel = semantic - SEMANTIC_TEXCOORD0; + glActiveTextureARB((GLenum)(GL_TEXTURE0_ARB + channel)); + glClientActiveTextureARB((GLenum)(GL_TEXTURE0_ARB + channel)); + glTexCoordPointer(getGLFormatSize(sm.format), getGLFormatType(sm.format), m_stride, buffer+sm.offset); + break; + } + case SEMANTIC_BONEINDEX: + { + const PxU32 channel = RENDERER_BONEINDEX_CHANNEL; + glActiveTextureARB((GLenum)(GL_TEXTURE0_ARB + channel)); + glClientActiveTextureARB((GLenum)(GL_TEXTURE0_ARB + channel)); + glTexCoordPointer(getGLFormatSize(sm.format), getGLFormatType(sm.format), m_stride, buffer+sm.offset); + break; + } + case SEMANTIC_BONEWEIGHT: + { + const PxU32 channel = RENDERER_BONEWEIGHT_CHANNEL; + glActiveTextureARB((GLenum)(GL_TEXTURE0_ARB + channel)); + glClientActiveTextureARB((GLenum)(GL_TEXTURE0_ARB + channel)); + glTexCoordPointer(getGLFormatSize(sm.format), getGLFormatType(sm.format), m_stride, buffer+sm.offset); + break; + } + case SEMANTIC_DISPLACEMENT_TEXCOORD: + case SEMANTIC_DISPLACEMENT_FLAGS: + break; + default: + RENDERER_ASSERT(0, "Unable to bind Vertex Buffer Semantic."); + } + + GLenum glsemantic = getGLSemantic(semantic); + if(glsemantic) + { + glEnableClientState(getGLSemantic(semantic)); + } + } + } + glBindBufferARB(GL_ARRAY_BUFFER_ARB, 0); + } +} + +void OGLRendererVertexBuffer::unbind(PxU32 streamID) +{ + for(PxU32 i=0; i<NUM_SEMANTICS; i++) + { + Semantic semantic = (Semantic)i; + const SemanticDesc &sm = m_semanticDescs[semantic]; + if(sm.format < NUM_FORMATS) + { + GLenum glsemantic = getGLSemantic(semantic); + if(glsemantic != GL_TEXTURE_COORD_ARRAY) + { + glDisableClientState(glsemantic); + } + } + } + for(PxU32 i=0; i<8; i++) + { + glActiveTextureARB((GLenum)(GL_TEXTURE0_ARB + i)); + glClientActiveTextureARB((GLenum)(GL_TEXTURE0_ARB + i)); + glDisableClientState(GL_TEXTURE_COORD_ARRAY); + } +} + +#endif // #if defined(RENDERER_ENABLE_OPENGL) diff --git a/PhysX_3.4/Samples/SampleFramework/renderer/src/ogl/OGLRendererVertexBuffer.h b/PhysX_3.4/Samples/SampleFramework/renderer/src/ogl/OGLRendererVertexBuffer.h new file mode 100644 index 00000000..bca28184 --- /dev/null +++ b/PhysX_3.4/Samples/SampleFramework/renderer/src/ogl/OGLRendererVertexBuffer.h @@ -0,0 +1,65 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved. +#ifndef OGL_RENDERER_VERTEXBUFFER_H +#define OGL_RENDERER_VERTEXBUFFER_H + +#include <RendererConfig.h> + +#if defined(RENDERER_ENABLE_OPENGL) + +#include <RendererVertexBuffer.h> +#include "OGLRenderer.h" + +namespace SampleRenderer +{ + + class OGLRendererVertexBuffer : public RendererVertexBuffer + { + public: + OGLRendererVertexBuffer(const RendererVertexBufferDesc &desc); + virtual ~OGLRendererVertexBuffer(void); + + static PxU32 convertColor(const RendererColor& color); + + protected: + virtual void swizzleColor(void *colors, PxU32 stride, PxU32 numColors, RendererVertexBuffer::Format inFormat); + + virtual void *lock(void); + virtual void unlock(void); + + virtual void bind(PxU32 streamID, PxU32 firstVertex); + virtual void unbind(PxU32 streamID); + + private: + GLuint m_vbo; + GLenum m_access; + }; + +} // namespace SampleRenderer + +#endif // #if defined(RENDERER_ENABLE_OPENGL) +#endif |