private Expression GetWriteColorOutputExpression(int location, Expression colorParam) { var framebuffer = (SoftwareFramebuffer)m_context.m_RenderPassBeginInfo.framebuffer; var imgView = framebuffer.m_createInfo.pAttachments[m_context.m_CurrentSubpass.pColorAttachments[location].attachment]; Expression fragCoord = IntrospectionUtil.GetExpressionFor(() => internal_FragCoord); Expression call = IntrospectionUtil.GetMethodCallExpression(imgView, "SetPixel", fragCoord, colorParam); return(call); }
private Expression GetReadVertexBufferExpression(FieldInfo fieldInfo, int location) { Type returnType = fieldInfo.FieldType; string debugFieldName = string.Format("{0}.{1}", fieldInfo.DeclaringType.Name, fieldInfo.Name); foreach (var attributeDesc in m_context.m_GraphicsPipeline.m_graphicsPipelineCreateInfo.pVertexInputState.pVertexAttributeDescriptions) { if (location == attributeDesc.location) { bool found = false; VkVertexInputBindingDescription inputBindingDesc = new VkVertexInputBindingDescription(); foreach (var item in m_context.m_GraphicsPipeline.m_graphicsPipelineCreateInfo.pVertexInputState.pVertexBindingDescriptions) { if (item.binding == attributeDesc.binding) { inputBindingDesc = item; found = true; break; } } if (!found) { // Binding not found DebugMsg(string.Format( "ERROR: vertex buffer binding={0} not found for location={1} for field {2}", attributeDesc.binding, location, debugFieldName )); return(null); } var vb = m_context.m_CommandBuffer.m_context.m_VertexBuffers[attributeDesc.binding]; var mem = vb.m_deviceMemory; int stride = inputBindingDesc.stride; int offset = attributeDesc.offset; byte[] memory = mem.m_bytes; if (vb.m_VertexBufferCache != null) { // Use vertex buffer cache Expression indexExpression = IntrospectionUtil.GetExpressionFor(() => this.gl_VertexIndex); return(vb.m_VertexBufferCache.GetReadExpression(returnType, offset, stride, indexExpression)); } else { // Read from raw return(IntrospectionUtil.GetGenericMethodCallExpression( this, nameof(ReadVertexBuffer), new Type[] { returnType }, Expression.Constant(memory), Expression.Constant(offset), Expression.Constant(stride))); } } } DebugMsg(string.Format( "ERROR: vertex buffer location={0} not found for field {1}", location, debugFieldName )); return(null); }