• Advertisement

wh1sp3rik

Member
  • Content count

    111
  • Joined

  • Last visited

Community Reputation

249 Neutral

About wh1sp3rik

  • Rank
    Member

Personal Information

  • Interests
    Programming
  1. DX12 Descriptors and heaps

    Thanks for answers, so, when i load a model with its textures, I should make a heap for model textures, which is not visible to a shader. When I am going to render my model, I have to copy my descriptors to the main heap, and actually "append" them after existing descriptors in the main heap. Then, i have to pass ,where my descriptors starts to the model shader. if I hit the end of the main heap, I will start from begining and rewrite existing ones. Am I correct ?
  2. DX12 Descriptors and heaps

    So let's say, I can make a huge heap of 2000 SRV descriptors. If I load a texture after initial, can I just call "CreateShaderResourceView" on free handle ? How fast is that ? Also it seems, this command will run on CPU timeline, can I use it even GPU is using that heap but not using the descriptor ? Can I call "CreateShaderResourceView" on handle that already exists ? ( and GPU is not using that descriptor ) ? Thanks !
  3. Hi, I am moving from DX11 to DX12 and I started fighting with texture resources. I provide only an simplified example. Let's say, I have this root parameters: CD3DX12_DESCRIPTOR_RANGE diffuseTextureTable; diffuseTextureTable.Init(D3D12_DESCRIPTOR_RANGE_TYPE_SRV, 16, 0, 0); CD3DX12_ROOT_PARAMETER signatureParameters[3]; signatureParameters[0].InitAsConstantBufferView(0); // Per draw signatureParameters[1].InitAsConstantBufferView(1); // Per frame signatureParameters[2].InitAsDescriptorTable(1, &diffuseTextureTable, D3D12_SHADER_VISIBILITY_PIXEL); // 16 My shader has one per draw constant buffer, one per frame buffer and table of 16 SRVs. Every model can have up to 16 diffuse textures. Well, the question is, how can I set textures for a model before rendering ? I read that changing heaps is costly. That's the only thing I thought that's the way. Do i have to really load all textures into memory in initial time ? What If i can want to load some textures after initial time ? Is it possible to copy new texture descriptors into heap cheaply ? Thank you very much :-)
  4. Hi, thanks for answer. Yes, I mean calling SAME heap twice. I was just not sure, if heap can change its address in one RUN. So, heap has ALWAYS same address in an application live, am I correct ?
  5. Hi, I have a question about this function in DX12 to get a HANDLE for descriptor. I am curious if this function returns ALWAYS same address for specific descriptor, or address can change overtime ? Same for GPU version of function. Thank you very much !
  6. Hello,   I have a question about updaing contant buffer performance. I would like to know how it works when I bind a constant buffer to let's say all shaders. ( it's VS, HS, DS, GS, PS, CS ).   Let's say, I will upload some per frame data and I am curious what steps it will do if I call UpdateSubresource function.   Microsoft says that UpdateSubresource does two copies. First copy goes to temporary storage and it's copied by CPU and second copy goes to non mappable memory and it's copied async by GPU. If I bind contant buffers to more shaders, does it mean, it will copy it multiple times for every shader ?   thank you very much.  
  7. Map texture for reading problem

    Yeah, I realized it now. Padding ...   Thank you, let's try it.
  8. Making a texture render to itself

    In this situation, I think it's better to create two textures. One for SRV and one for RTV. After you render into RTV, you can copy RTV to SRV with copyresource. It's should be fast as it's GPU to GPU. Also SRV and RTV should be set to default, so no CPU writing/reading.
  9. Hello,   I have a strange problem with mapping texture for reading. My texture is R32_SINT format. When mapping, I obtained pData, RowPitch and DepthPitch. My texture is 800 x 600 in size. Graphics debugger says, It's 800x600 and its size is 1920000. That's correct. Unfortunately, RowPitch is 3328 ( which is about 128 more then it should be ) and DepthPitch is 1996800 ( and it should be 1920000 ).   Creating texture code ZeroMemory(&textureDesc, sizeof(D3D11_TEXTURE2D_DESC)); textureDesc.BindFlags = 0; textureDesc.CPUAccessFlags = D3D11_CPU_ACCESS_READ; textureDesc.Width = width; textureDesc.Height = height; textureDesc.Format = dxformat; textureDesc.Usage = D3D11_USAGE_STAGING; textureDesc.SampleDesc.Quality = 0; textureDesc.SampleDesc.Count = 1; textureDesc.ArraySize = 1; textureDesc.MipLevels = 1; _device->CreateTexture2D(&textureDesc, 0, &resource->_resourceRead); where width = 800, height = 600, dxformat = DXGI_FORMAT_R32_SINT.   Why it happend ? What's going on ?   Thank you very much for answers.
  10. [DXSHOW] Get webcam bitmap

    I just got an answer on StackOverflow.   I set up SampleGrabber filter too late. I should set it up before connecting and that was the problem.
  11. Hello,   Trying to figure out, how to get a bitmap from webcam output. The problem is in colours. it seems a webcam output is YUV color space and i am not sure, how to display it right as most other examples are not care about that. using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; using DirectShowLib; using System.Runtime.InteropServices; using System.Drawing.Imaging; namespace WindowsFormsApplication3 { public partial class Form1 : Form { [DllImport("kernel32.dll", EntryPoint = "CopyMemory", SetLastError = false)] public static extern void CopyMemory(IntPtr dest, IntPtr src, uint count); public IGraphBuilder gb; public ICaptureGraphBuilder2 cgb; public IBaseFilter filter; static SampleGrabberCallback cb; VideoInfoHeader header; static Form1 thisform; public class SampleGrabberCallback : ISampleGrabberCB { int ISampleGrabberCB.SampleCB(Double SampleTime, IMediaSample sample) { return 0; } int ISampleGrabberCB.BufferCB( Double SampleTime, IntPtr dataPtr, Int32 BufferLen ) { Bitmap bitmap = new Bitmap(640, 480, 640*3, PixelFormat.Format24bbp, dataPtr); Graphics g = thisform.panel1.CreateGraphics(); g.DrawImageUnscaled(bitmap, 0, 0, 640, 480); return 0; } } public Form1() { InitializeComponent(); thisform = this; DsDevice[] videoInputDevices = DsDevice.GetDevicesOfCat(FilterCategory.VideoInputDevice); object obj = null; Guid iid = typeof(IBaseFilter).GUID; videoInputDevices[1].Mon.BindToObject(null, null, ref iid, out obj); filter = (IBaseFilter)obj; ISampleGrabber grabberFilter = (ISampleGrabber)new SampleGrabber(); IBaseFilter baseGrabber = (IBaseFilter)grabberFilter; ((IAMCameraControl)filter).Set(CameraControlProperty.Exposure, 0, CameraControlFlags.Auto); gb = (IGraphBuilder) new FilterGraph(); cgb = (ICaptureGraphBuilder2) new CaptureGraphBuilder2(); cgb.SetFiltergraph(gb); IEnumPins pins; IPin [] inputPin = { null }; IPin [] outputPin = { null }; filter.EnumPins(out pins); pins.Next(1, outputPin, IntPtr.Zero); baseGrabber.EnumPins(out pins); pins.Next(1, inputPin, IntPtr.Zero); gb.AddFilter(filter, "First Filter"); gb.AddFilter(baseGrabber, "Grabber Filter"); gb.Connect(outputPin[0], inputPin[0]); grabberFilter.SetBufferSamples(true); AMMediaType media = new AMMediaType(); media.majorType = MediaType.Video; media.subType = MediaSubType.RGB24; media.formatType = FormatType.VideoInfo; grabberFilter.SetMediaType(media); grabberFilter.GetConnectedMediaType(media); header = (VideoInfoHeader)Marshal.PtrToStructure(media.formatPtr, typeof(VideoInfoHeader)); cb = new SampleGrabberCallback(); grabberFilter.SetCallback(cb, 1); cgb.RenderStream(PinCategory.Preview, MediaType.Video, filter, null, null); ((IVideoWindow)gb).put_Owner(this.panel1.Handle); ((IVideoWindow)gb).put_WindowStyle(WindowStyle.Child | WindowStyle.ClipChildren); ((IVideoWindow)gb).put_Visible(OABool.True); ((IVideoWindow)gb).SetWindowPosition(0, 0, this.panel1.Width, this.panel1.Height); ((IMediaControl)gb).Run(); } private void OnResize(object sender, EventArgs e) { ((IVideoWindow)gb).SetWindowPosition(0, 0, this.panel1.Width, this.panel1.Height); } } } This is my code, it enumerate video devices ( my default device is number 1, you should use 0, if you have only one device ), SampleGrabber calls callback function and i can get a buffer there.   I tried most formats Format24bbp, Format16bpp565 .. and .. ok, if it's YUV, i should convert it, but i though i can just specify type in mediatype as examples are doing it.   I also attached full source with directshownet library. if someone has a time to check, i will be very happy as i am trying to figure it out whole a day, reading tutorials, samples ...   Thank you very much
  12. Writing to R16G16_UINT

    Hello,   you are right. Also, there is not R16G16B16_UINT format, it has a reason :) These memory aligments are pain. Thank you, I am on the good way now.
  13. Hello,   I have a little problem :) I would like to write data into buffer with format : {"POSITION", 0, DXGI_FORMAT_R16G16_UINT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0}, {"TPOSITION", 0, DXGI_FORMAT_R16G16_UINT, 1, 0, D3D11_INPUT_PER_INSTANCE_DATA, 1 }, {"LODID", 0, DXGI_FORMAT_R16_UINT, 1, 4, D3D11_INPUT_PER_INSTANCE_DATA, 1 }, First stream has 4 bytes, second stream has 6 bytes. So, i created buffers with that sized and i copied USHORT data into buffer.   When rendering, it says D3D11 ERROR: ID3D11DeviceContext::DrawIndexedInstanced: Vertex Buffer Stride (6) at the input vertex slot 1 is not aligned properly. The current Input Layout imposes an alignment of (4) because of the Formats used with this slot. [ EXECUTION ERROR #367: DEVICE_DRAW_VERTEX_STRIDE_UNALIGNED] Shader layout: struct VIn { uint2 position : POSITION0; uint2 instance : TPOSITION; uint lodid : LODID; }; when i use 32bits , it's working fine. I also tried to use uint only and unpack two ushorts ( uints in hlsl ). It's a pity, there are no ushorts in hlsl ;-)   thank you
  14. Sampling depth buffer in shader

    that's great, i did not know that .. is it working for any resource ?
  15. Constant struct arrays

    Pink Horror:   let's say, i have lot of layouts and i thought it's a great idea to be able to access them by index. :-)
  • Advertisement