コード例 #1
0
ファイル: D3D10EffectPass.cs プロジェクト: chuz/tesla-engine
        /// <summary>
        /// Creates a new instance of <see cref="D3D10EffectPass"/>.
        /// </summary>
        /// <param name="renderer">The D3D10 renderer.</param>
        /// <param name="pass">The D3D10 pass.</param>
        /// <param name="map">The input layout map to share between passes that have the same effect origin.</param>
        internal D3D10EffectPass(D3D10Renderer renderer, D3D.EffectPass pass, InputLayoutMap map)
        {
            _pass     = pass;
            _renderer = renderer;

            D3D.EffectPassDescription desc = pass.Description;
            _name      = desc.Name;
            _layoutMap = map;

            //Fetch annotations
            int annoCount = desc.AnnotationCount;

            _annotations = new D3D10EffectAnnotationCollection();
            for (int i = 0; i < annoCount; i++)
            {
                D3D.EffectVariable            anno     = _pass.GetAnnotationByIndex(i);
                D3D.EffectVariableDescription annoDesc = anno.Description;
                D3D.EffectVariable            annoVar  = anno.AsString();
                if (annoVar != null)
                {
                    _annotations.Add(new D3D10EffectAnnotation(annoVar, annoDesc.Name, annoDesc.Semantic, EffectParameterClass.Object, EffectParameterType.String));
                }
                annoVar = anno.AsScalar();
                if (annoVar != null)
                {
                    //Need to find a way to get the param type...
                    _annotations.Add(new D3D10EffectAnnotation(annoVar, annoDesc.Name, annoDesc.Semantic, EffectParameterClass.Scalar, EffectParameterType.Unknown));
                }
                annoVar = anno.AsMatrix();
                if (annoVar != null)
                {
                    _annotations.Add(new D3D10EffectAnnotation(annoVar, annoDesc.Name, annoDesc.Semantic, EffectParameterClass.Matrix, EffectParameterType.Single));
                }
            }
        }
コード例 #2
0
        /// <summary>
        /// Creates a new instance of <see cref="D3D10RenderSystemProvider"/> using the adapter index.
        /// </summary>
        /// <param name="adapterIndex">Index of the adapter to use when creating the underlying device</param>
        public D3D10RenderSystemProvider(int adapterIndex)
        {
            //Create the DXGI Factory
            DXGI.Factory factory = new DXGI.Factory();

            //Create the device
            DXGI.Adapter adapter = factory.GetAdapter(adapterIndex);
            D3D.Device   device  = new D3D.Device(adapter, D3D.DriverType.Hardware, D3D.DeviceCreationFlags.None);

            //Enumerate adapters
            List <IGraphicsAdapter> adapterList = new List <IGraphicsAdapter>();
            int adapterCount = factory.GetAdapterCount();

            for (int i = 0; i < adapterCount; i++)
            {
                adapterList.Add(new D3D10GraphicsAdapter(device, factory, i));
            }
            _adapters = new ReadOnlyList <IGraphicsAdapter>(adapterList);

            //Create the renderer
            _renderer = new D3D10Renderer(factory, device, (D3D10GraphicsAdapter)adapterList[adapterIndex]);

            //Create default content manager
            _content = new ContentManager(new EmbeddedResourceLocator(Tesla.Direct3D10.DefaultContent.ResourceManager));
            _content.UseDefaultContent = false;
        }
コード例 #3
0
 /// <summary>
 /// Creates a new instance of <see cref="D3D10TextureCollection"/>.
 /// </summary>
 /// <param name="renderer">The D3D10 renderer.</param>
 /// <param name="maxTextures">The max textures count.</param>
 /// <param name="vertexTextures">True if this is meant for vertex shader textures, false for pixel shader textures.</param>
 internal D3D10TextureCollection(D3D10Renderer renderer, int maxTextures, bool vertexTextures)
 {
     _renderer           = renderer;
     _graphicsDevice     = renderer.GraphicsDevice;
     _vertexTex          = vertexTextures;
     _maxTextures        = maxTextures;
     _textures           = new Texture[_maxTextures];
     _dirtyMark          = new bool[_maxTextures];
     _shortCircuitUpdate = false;
 }
コード例 #4
0
 /// <summary>
 /// Creates a new instance of <see cref="D3D10SamplerStateCollection"/>.
 /// </summary>
 /// <param name="renderer">The D3D10 renderer.</param>
 /// <param name="maxSamplers">The max sampler count.</param>
 /// <param name="vertexSamplers">True if this is meant for vertex shader samplers, false for pixel shader samplers.</param>
 internal D3D10SamplerStateCollection(D3D10Renderer renderer, int maxSamplers, bool vertexSamplers)
 {
     _renderer           = renderer;
     _graphicsDevice     = renderer.GraphicsDevice;
     _maxSamplers        = maxSamplers;
     _vertexSamplers     = vertexSamplers;
     _samplers           = new SamplerState[maxSamplers];
     _dirtyMark          = new bool[maxSamplers];
     _shortCircuitUpdate = false;
 }
コード例 #5
0
ファイル: InputLayoutMap.cs プロジェクト: chuz/tesla-engine
 public InputLayoutMap(D3D10Renderer renderer, D3DC.ShaderSignature shaderSignature)
 {
     _device             = renderer.GraphicsDevice;
     _sig                = shaderSignature;
     _layoutMap          = new Dictionary <int, D3D.InputLayout>();
     _semanticIndexCount = new int[Enum.GetValues(typeof(VertexSemantic)).Length];
     _isDisposed         = false;
     renderer.Disposing += new EventHandler(delegate(object o, EventArgs args) {
         Dispose();
     });
 }
コード例 #6
0
 /// <summary>
 /// Creates a new render target manager.
 /// </summary>
 /// <param name="renderer">D3D10 renderer</param>
 /// <param name="maxTargets">Max targets</param>
 public RenderTargetManager(D3D10Renderer renderer, int maxTargets)
 {
     _renderer                 = renderer;
     _graphicsDevice           = renderer.GraphicsDevice;
     _views                    = new D3D.RenderTargetView[maxTargets];
     _currentRenderTargets     = new RenderTargetBinding[maxTargets];
     _targetsToMipMap          = new RenderTargetBinding[maxTargets];
     _activeBackBuffer         = null;
     _currentRenderTargetCount = 0;
     _targetsToMipMapCount     = 0;
 }
コード例 #7
0
ファイル: D3D10EffectPass.cs プロジェクト: chuz/tesla-engine
        /// <summary>
        /// Creates a new instance of <see cref="D3D10EffectPass"/>.
        /// </summary>
        /// <param name="parent">The implementation parent.</param>
        /// <param name="effect">The D3D10 effect so we can query for variables.</param>
        /// <param name="pass">The D3D10 pass.</param>
        internal D3D10EffectPass(D3D10EffectImplementation parent, D3D.Effect effect, D3D.EffectPass pass)
        {
            _pass     = pass;
            _renderer = parent.Renderer;

            D3D.EffectPassDescription desc = pass.Description;
            _name      = desc.Name;
            _layoutMap = new InputLayoutMap(_renderer, desc.Signature);

            //Fetch annotations
            int annoCount = desc.AnnotationCount;

            _annotations = new D3D10EffectAnnotationCollection();
            for (int i = 0; i < annoCount; i++)
            {
                D3D.EffectVariable            anno     = _pass.GetAnnotationByIndex(i);
                D3D.EffectVariableDescription annoDesc = anno.Description;
                D3D.EffectVariable            annoVar  = anno.AsString();
                if (annoVar != null)
                {
                    _annotations.Add(new D3D10EffectAnnotation(annoVar, annoDesc.Name, annoDesc.Semantic, EffectParameterClass.Object, EffectParameterType.String));
                    continue;
                }
                annoVar = anno.AsScalar();
                if (annoVar != null)
                {
                    _annotations.Add(new D3D10EffectAnnotation(annoVar, annoDesc.Name, annoDesc.Semantic, EffectParameterClass.Scalar, EffectParameterType.Unknown));
                    continue;
                }
                annoVar = anno.AsMatrix();
                if (annoVar != null)
                {
                    _annotations.Add(new D3D10EffectAnnotation(annoVar, annoDesc.Name, annoDesc.Semantic, EffectParameterClass.Matrix, EffectParameterType.Unknown));
                    continue;
                }
                annoVar = anno.AsVector();
                if (annoVar != null)
                {
                    _annotations.Add(new D3D10EffectAnnotation(annoVar, annoDesc.Name, annoDesc.Semantic, EffectParameterClass.Vector, EffectParameterType.Unknown));
                }
            }

            //Now to reflect the parameters and start adding them to the shader
            D3D.EffectPassShaderDescription vertexShaderDesc = pass.VertexShaderDescription;
            D3D.EffectShaderVariable        vertexShaderVar  = vertexShaderDesc.Variable;
            ParseShader(parent, effect, vertexShaderVar);
            ParseShader(parent, effect, pass.PixelShaderDescription.Variable);

            //And the standard input layout
            CreateInputLayout(vertexShaderVar, vertexShaderDesc.Index);
        }
コード例 #8
0
 public ResourceTracker(D3D10Renderer renderer)
 {
     _parent     = renderer;
     _syncObject = new Object();
     _resources  = new Dictionary <IntPtr, ResourceData>();
 }