hlsl

DirectX 11 - Compute shader: Writing to an output resource

守給你的承諾、 提交于 2019-12-03 01:32:52
I've just started using the Compute shader stage in DirectX 11 and encountered some unwanted behaviour when writing to an output resource in the Compute shader. I seem to get only zeroes as output which, to my understanding, means that out-of-bound reads has been performed in the Compute shader. (Out-of-bound writes results in no-ops) Creating the Compute shader components Input resources First I create an ID3D11Buffer* for input data. This is passed as a resource when creating the SRV used for input to the Compute shader stage. If the input data never changes then we could release the

How to pass textures to DirectX 9 pixel shader?

戏子无情 提交于 2019-12-02 18:48:00
问题 I have pixel shader // fxc.exe tiles.fs /T ps_3_0 /Fotiles.fsc /Fctiles.fsl struct PSInput { float4 Pos : TEXCOORD0; float3 Normal : TEXCOORD1; float2 TexcoordUV : TEXCOORD2; float2 TexcoordST : TEXCOORD3; }; sampler2D sampler0; //uniform sampler2D sampler1; //uniform sampler2D sampler2; //uniform sampler2D sampler3; //uniform sampler2D alphamap1;//uniform sampler2D alphamap2;//uniform sampler2D alphamap3;//uniform uniform int tex_count = 0; uniform float4 color_ambient = float4(0.75, 0.75, 0

When does the transition from clip space to screen coordinates happen?

穿精又带淫゛_ 提交于 2019-12-02 14:30:57
I was studying the rendering pipeline and when I got to the clipping stage it was explained that from the view (eye or camera) space we have to pass to the clip space , also called normalized device space (NDC), that is a cubic space from -1 to 1. However, now I don't understand when the passage from this space to the screen coordinates space happens: Right after clipping and before rasterization? After rasterization and before scissor and z-test? At the end just before writing on the frame buffer? No, clip space and NDC space are not the same thing. Clip space is actually one step away from

HLSL: Index to unaligned/packed floats

心已入冬 提交于 2019-12-02 10:49:35
问题 I have a vertex shader (2.0) doing some instancing - each vertex specifies an index into an array. If I have an array like this: float instanceData[100]; The compiler allocates it 100 constant registers. Each constant register is a float4 , so it's allocating 4 times as much space as is needed. I need a way to make it allocate just 25 constant registers and store four values in each of them. Ideally I'd like a method where it still looks like a float[] on both the CPU and GPU (Right now I am

swift can not save .m3u8 file to gallery

血红的双手。 提交于 2019-12-02 06:07:17
Im using this below method to download and save my video to gallery, with .mp4 it's work normally, but when change to .m3u8 it's always fail. func downloadVideoLinkAndCreateAsset(_ videoLink: String,_ fileName : String) { // use guard to make sure you have a valid url guard let videoURL = URL(string: videoLink) else { return } guard let documentsDirectoryURL = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask).first else { return } let fileNameToSave = "CiviX_HistoryVideo_\(fileName)" // check if the file already exist at the destination folder if you don't want to download

HLSL: Index to unaligned/packed floats

僤鯓⒐⒋嵵緔 提交于 2019-12-02 03:30:57
I have a vertex shader (2.0) doing some instancing - each vertex specifies an index into an array. If I have an array like this: float instanceData[100]; The compiler allocates it 100 constant registers. Each constant register is a float4 , so it's allocating 4 times as much space as is needed. I need a way to make it allocate just 25 constant registers and store four values in each of them. Ideally I'd like a method where it still looks like a float[] on both the CPU and GPU (Right now I am calling EffectParamter.SetValue(Single[]) , I'm using XNA). But manually packing and unpacking a float4

DirectX 11 Pixel Shader What Is SV_POSITION?

痞子三分冷 提交于 2019-12-01 22:24:38
问题 I am learning HLSL for DirectX 11, and I was wondering what exactly is the SV_POSITION that is the output for a Vertex Shader, and the input for a Pixel Shader. 1: Is this x,y,z of every pixel on your screen, or of the object? 2: Why is it 4 32bit floats? 3: Do you need this System Variable for the vertex output? Thank you! 回答1: The vertex shader stage only has one required output: the position of the vertex. This value is then used by the fixed-function rasterizer to compute which pixels are

HLSL 3 Can a Pixel Shader be declared alone?

江枫思渺然 提交于 2019-12-01 21:11:25
I've been asked to split the question below into multiple questions: HLSL and Pix number of questions This is asking the first question, can I in HLSL 3 run a pixel shader without a vertex shader. In HLSL 2 I notice you can but I can't seem to find a way in 3? The shader will compile fine, I will then however get this error from Visual Studio when calling SpriteBatch Draw(). "Cannot mix shader model 3.0 with earlier shader models. If either the vertex shader or pixel shader is compiled as 3.0, they must both be." I don't believe I've defined anything in the shader to use anything earlier then

DirectX 11 Pixel Shader What Is SV_POSITION?

扶醉桌前 提交于 2019-12-01 20:53:52
I am learning HLSL for DirectX 11, and I was wondering what exactly is the SV_POSITION that is the output for a Vertex Shader, and the input for a Pixel Shader. 1: Is this x,y,z of every pixel on your screen, or of the object? 2: Why is it 4 32bit floats? 3: Do you need this System Variable for the vertex output? Thank you! The vertex shader stage only has one required output: the position of the vertex. This value is then used by the fixed-function rasterizer to compute which pixels are being drawn and invoke the pixel shader for each one. That's what the system value semantic SV_Position

How can I compile asm shader to fxo file?

旧城冷巷雨未停 提交于 2019-12-01 17:52:49
问题 I have a compiled fxo shader which I'm trying to edit slightly (just adjusting some constants). Using fxdis (https://code.google.com/archive/p/fxdis-d3d1x/) I can disassemble this shader, this is the output: # DXBC chunk 0: RDEF offset 52 size 972 # DXBC chunk 1: ISGN offset 1032 size 80 # DXBC chunk 2: OSGN offset 1120 size 44 # DXBC chunk 3: SHEX offset 1172 size 1592 # DXBC chunk 4: STAT offset 2772 size 148 ps_5_0 dcl_global_flags refactoringAllowed dcl_constant_buffer cb0[30].xyzw,