/// <summary> /// Constructs a new GraphicsDeviceOptions for a device with no main Swapchain. /// </summary> /// <param name="debug">Indicates whether the GraphicsDevice will support debug features, provided they are supported by /// the host system.</param> public GraphicsDeviceOptions(bool debug) { Debug = debug; HasMainSwapchain = false; SwapchainDepthFormat = null; SyncToVerticalBlank = false; ResourceBindingModel = ResourceBindingModel.Default; }
/// <summary> /// Constructs a new GraphicsDeviceOptions for a device with a main Swapchain. /// </summary> /// <param name="debug">Indicates whether the GraphicsDevice will enable debug features, provided they are supported by /// the host system.</param> /// <param name="swapchainDepthFormat">An optional <see cref="PixelFormat"/> to be used for the depth buffer of the /// swapchain. If this value is null, then no depth buffer will be present on the swapchain.</param> /// <param name="syncToVerticalBlank">Indicates whether the main Swapchain will be synchronized to the window system's /// vertical refresh rate.</param> public GraphicsDeviceOptions(bool debug, PixelFormat?swapchainDepthFormat, bool syncToVerticalBlank) { Debug = debug; HasMainSwapchain = true; SwapchainDepthFormat = swapchainDepthFormat; SyncToVerticalBlank = syncToVerticalBlank; ResourceBindingModel = ResourceBindingModel.Default; }
/// <summary> /// Constructs a new GraphicsDeviceOptions for a device with a main Swapchain. /// </summary> /// <param name="debug">Indicates whether the GraphicsDevice will enable debug features, provided they are supported by /// the host system.</param> /// <param name="swapchainDepthFormat">An optional <see cref="PixelFormat"/> to be used for the depth buffer of the /// swapchain. If this value is null, then no depth buffer will be present on the swapchain.</param> /// <param name="syncToVerticalBlank">Indicates whether the main Swapchain will be synchronized to the window system's /// vertical refresh rate.</param> public GraphicsDeviceOptions(bool debug, PixelFormat?swapchainDepthFormat, bool syncToVerticalBlank) { Debug = debug; HasMainSwapchain = true; SwapchainDepthFormat = swapchainDepthFormat; SyncToVerticalBlank = syncToVerticalBlank; ResourceBindingModel = ResourceBindingModel.Default; PreferDepthRangeZeroToOne = false; PreferStandardClipSpaceYDirection = false; }
public IActionResult AddResource(int id) { var model = new ResourceBindingModel() { LectureId = id, ResourceTypes = this.GetResourceTypes() }; return(View(model)); }
/// <summary> /// Constructs a new GraphicsDeviceOptions for a device with no main Swapchain. /// </summary> /// <param name="debug">Indicates whether the GraphicsDevice will support debug features, provided they are supported by /// the host system.</param> public GraphicsDeviceOptions(bool debug) { Debug = debug; HasMainSwapchain = false; SwapchainDepthFormat = null; SyncToVerticalBlank = false; ResourceBindingModel = ResourceBindingModel.Default; PreferDepthRangeZeroToOne = false; PreferStandardClipSpaceYDirection = false; SwapchainSrgbFormat = false; }
/// <summary> /// Constructs a new GraphicsDeviceOptions for a device with a main Swapchain. /// </summary> /// <param name="debug">Indicates whether the GraphicsDevice will enable debug features, provided they are supported by /// the host system.</param> /// <param name="swapchainDepthFormat">An optional <see cref="PixelFormat"/> to be used for the depth buffer of the /// swapchain. If this value is null, then no depth buffer will be present on the swapchain.</param> /// <param name="syncToVerticalBlank">Indicates whether the main Swapchain will be synchronized to the window system's /// vertical refresh rate.</param> /// <param name="resourceBindingModel">Specifies which model the rendering backend should use for binding resources.</param> public GraphicsDeviceOptions( bool debug, PixelFormat?swapchainDepthFormat, bool syncToVerticalBlank, ResourceBindingModel resourceBindingModel) { Debug = debug; HasMainSwapchain = true; SwapchainDepthFormat = swapchainDepthFormat; SyncToVerticalBlank = syncToVerticalBlank; ResourceBindingModel = resourceBindingModel; PreferDepthRangeZeroToOne = false; }
public void AddElement(ResourceBindingModel model) { Resource element = context.Resources.FirstOrDefault(rec => rec.resourceName == model.resourceName); if (element != null) { throw new Exception("Уже есть компонент с таким названием"); } context.Resources.Add(new Resource { resourceName = model.resourceName, price = model.price }); context.SaveChanges(); }
public IActionResult AddResource(ResourceBindingModel model) { if (!this.ModelState.IsValid) { return(this.View(model)); } var resource = this.mapper.Map <Resource>(model); this.db.Resources.Add(resource); this.db.SaveChanges(); return(Redirect(string.Format(this.ReturnUrl, model.LectureId))); }
public void UpdElement(ResourceBindingModel model) { Resource element = context.Resources.FirstOrDefault(rec => rec.resourceName == model.resourceName && rec.id != model.id); if (element != null) { throw new Exception("Уже есть компонент с таким названием"); } element = context.Resources.FirstOrDefault(rec => rec.id == model.id); if (element == null) { throw new Exception("Элемент не найден"); } element.resourceName = model.resourceName; context.SaveChanges(); }
/// <summary> /// Constructs a new GraphicsDeviceOptions for a device with a main Swapchain. /// </summary> /// <param name="debug">Indicates whether the GraphicsDevice will enable debug features, provided they are supported by /// the host system.</param> /// <param name="swapchainDepthFormat">An optional <see cref="PixelFormat"/> to be used for the depth buffer of the /// swapchain. If this value is null, then no depth buffer will be present on the swapchain.</param> /// <param name="syncToVerticalBlank">Indicates whether the main Swapchain will be synchronized to the window system's /// vertical refresh rate.</param> /// <param name="resourceBindingModel">Specifies which model the rendering backend should use for binding resources.</param> /// <param name="preferDepthRangeZeroToOne">Indicates whether a 0-to-1 depth range mapping is preferred. For OpenGL, /// this is not the default, and is not available on all systems.</param> /// <param name="preferStandardClipSpaceYDirection">Indicates whether a bottom-to-top-increasing clip space Y direction /// is preferred. For Vulkan, this is not the default, and is not available on all systems.</param> /// <param name="swapchainSrgbFormat">Indicates whether the main Swapchain should use an sRGB format. This value is only /// used in cases where the properties of the main SwapChain are not explicitly specified with a /// <see cref="SwapchainDescription"/>. If they are, then the value of <see cref="SwapchainDescription.ColorSrgb"/> will /// supercede the value specified here.</param> public GraphicsDeviceOptions( bool debug, PixelFormat?swapchainDepthFormat, bool syncToVerticalBlank, ResourceBindingModel resourceBindingModel, bool preferDepthRangeZeroToOne, bool preferStandardClipSpaceYDirection, bool swapchainSrgbFormat) { Debug = debug; HasMainSwapchain = true; SwapchainDepthFormat = swapchainDepthFormat; SyncToVerticalBlank = syncToVerticalBlank; ResourceBindingModel = resourceBindingModel; PreferDepthRangeZeroToOne = preferDepthRangeZeroToOne; PreferStandardClipSpaceYDirection = preferStandardClipSpaceYDirection; SwapchainSrgbFormat = swapchainSrgbFormat; }
/// <summary> /// Constructs a new <see cref="GraphicsPipelineDescription"/>. /// </summary> /// <param name="blendState">A description of the blend state, which controls how color values are blended into each /// color target.</param> /// <param name="depthStencilStateDescription">A description of the depth stencil state, which controls depth tests, /// writing, and comparisons.</param> /// <param name="rasterizerState">A description of the rasterizer state, which controls culling, clipping, scissor, and /// polygon-fill behavior.</param> /// <param name="primitiveTopology">The <see cref="PrimitiveTopology"/> to use, which controls how a series of input /// vertices is interpreted by the <see cref="Pipeline"/>.</param> /// <param name="shaderSet">A description of the shader set to be used.</param> /// <param name="resourceLayouts">An array of <see cref="ResourceLayout"/>, which controls the layout of shader resoruces /// in the <see cref="Pipeline"/>.</param> /// <param name="outputs">A description of the output attachments used by the <see cref="Pipeline"/>.</param> /// <param name="resourceBindingModel">The <see cref="ResourceBindingModel"/> to use for this pipeline. Overrides /// the value specified in <see cref="GraphicsDeviceOptions"/>.</param> public GraphicsPipelineDescription( BlendStateDescription blendState, DepthStencilStateDescription depthStencilStateDescription, RasterizerStateDescription rasterizerState, PrimitiveTopology primitiveTopology, ShaderSetDescription shaderSet, ResourceLayout[] resourceLayouts, OutputDescription outputs, ResourceBindingModel resourceBindingModel) { BlendState = blendState; DepthStencilState = depthStencilStateDescription; RasterizerState = rasterizerState; PrimitiveTopology = primitiveTopology; ShaderSet = shaderSet; ResourceLayouts = resourceLayouts; Outputs = outputs; ResourceBindingModel = resourceBindingModel; }
public void AddElement(ResourceBindingModel model) { int maxId = 0; for (int i = 0; i < source.Resources.Count; ++i) { if (source.Resources[i].Id > maxId) { maxId = source.Resources[i].Id; } if (source.Resources[i].ResourceName == model.ResourceName) { throw new Exception("Уже есть склад с таким названием"); } } source.Resources.Add(new Resource { Id = maxId + 1, ResourceName = model.ResourceName }); }
public void UpdElement(ResourceBindingModel model) { int index = -1; for (int i = 0; i < source.Resources.Count; ++i) { if (source.Resources[i].Id == model.Id) { index = i; } if (source.Resources[i].ResourceName == model.ResourceName && source.Resources[i].Id != model.Id) { throw new Exception("Уже есть склад с таким названием"); } } if (index == -1) { throw new Exception("Элемент не найден"); } source.Resources[index].ResourceName = model.ResourceName; }
public IActionResult EditResource(ResourceBindingModel model) { if (!this.ModelState.IsValid) { return(this.View(model)); } var resource = this.db.Resources.FirstOrDefault(r => r.Id == model.ResourceId && r.IsDeleted == false); if (resource == null) { return(NotFound()); } resource.Title = model.Title; resource.ResourceUrl = model.ResourceUrl; resource.ResourceTypeId = model.ResourceTypeId; this.db.SaveChanges(); return(Redirect(string.Format(this.ReturnUrl, model.LectureId))); }
public MTLGraphicsDevice( GraphicsDeviceOptions options, SwapchainDescription?swapchainDesc) { _device = MTLDevice.MTLCreateSystemDefaultDevice(); MetalFeatures = new MTLFeatureSupport(_device); Features = new GraphicsDeviceFeatures( computeShader: true, geometryShader: false, tessellationShaders: false, multipleViewports: MetalFeatures.IsSupported(MTLFeatureSet.macOS_GPUFamily1_v3), samplerLodBias: false, drawBaseVertex: true, drawBaseInstance: true, drawIndirect: true, drawIndirectBaseInstance: true, fillModeWireframe: true, samplerAnisotropy: true, depthClipDisable: true, texture1D: true, // TODO: Should be macOS 10.11+ and iOS 11.0+. independentBlend: true, structuredBuffer: true, subsetTextureView: true, commandListDebugMarkers: true, bufferRangeBinding: true); ResourceBindingModel = options.ResourceBindingModel; _libSystem = new NativeLibrary("libSystem.dylib"); _concreteGlobalBlock = _libSystem.LoadFunction <IntPtr>("_NSConcreteGlobalBlock"); if (MetalFeatures.IsMacOS) { _completionHandler = OnCommandBufferCompleted; } else { _completionHandler = OnCommandBufferCompleted_Static; } _completionHandlerFuncPtr = Marshal.GetFunctionPointerForDelegate <MTLCommandBufferHandler>(_completionHandler); _completionBlockDescriptor = Marshal.AllocHGlobal(Unsafe.SizeOf <BlockDescriptor>()); BlockDescriptor *descriptorPtr = (BlockDescriptor *)_completionBlockDescriptor; descriptorPtr->reserved = 0; descriptorPtr->Block_size = (ulong)Unsafe.SizeOf <BlockDescriptor>(); _completionBlockLiteral = Marshal.AllocHGlobal(Unsafe.SizeOf <BlockLiteral>()); BlockLiteral *blockPtr = (BlockLiteral *)_completionBlockLiteral; blockPtr->isa = _concreteGlobalBlock; blockPtr->flags = 1 << 28 | 1 << 29; blockPtr->invoke = _completionHandlerFuncPtr; blockPtr->descriptor = descriptorPtr; if (!MetalFeatures.IsMacOS) { lock (s_aotRegisteredBlocks) { s_aotRegisteredBlocks.Add(_completionBlockLiteral, this); } } ResourceFactory = new MTLResourceFactory(this); _commandQueue = _device.newCommandQueue(); TextureSampleCount[] allSampleCounts = (TextureSampleCount[])Enum.GetValues(typeof(TextureSampleCount)); _supportedSampleCounts = new bool[allSampleCounts.Length]; for (int i = 0; i < allSampleCounts.Length; i++) { TextureSampleCount count = allSampleCounts[i]; uint uintValue = FormatHelpers.GetSampleCountUInt32(count); if (_device.supportsTextureSampleCount((UIntPtr)uintValue)) { _supportedSampleCounts[i] = true; } } if (swapchainDesc != null) { SwapchainDescription desc = swapchainDesc.Value; _mainSwapchain = new MTLSwapchain(this, ref desc); } PostDeviceCreated(); }